diff --git a/AMDiS/lib/mtl4/CMakeLists.txt b/AMDiS/lib/mtl4/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..0beb66966a464e36cc21711125e03abc3f2d9638 --- /dev/null +++ b/AMDiS/lib/mtl4/CMakeLists.txt @@ -0,0 +1,80 @@ +project (mtl4) # GPU version + +cmake_minimum_required(VERSION 2.8) +option(ENABLE_GCOV "enable gnu coverage flags for gnu compiler" OFF) +option(ENABLE_WARNINGS "Enable gnu specific warnings" ON) +option(ENABLE_DEVELOPMENT "enable program parts under development" OFF) + +# adding the Path of our own Modules +SET(CMAKE_MODULE_PATH $ENV{CMAKE_MODULE_PATH}) +SET(MTL4_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +#SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${MTL4_ROOT_PATH}/Cmake_Module) +SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${MTL4_ROOT_PATH}) + +#look for mtl4, use THIS directory as mtl dir +find_package(MTL REQUIRED HINTS ${CMAKE_CURRENT_SOURCE_DIR}) +include_directories(${MTL_INCLUDE_DIRS}) +add_definitions(${MTL_CXX_DEFINITIONS}) + + + +#REMAINING PART USES MTL4 +include(CheckCXXCompilerFlag) + +#let cmake look for the svn-version, only needed for packages? +if (NOT MSVC) + find_package(Subversion) + if(Subversion_FOUND) + Subversion_WC_INFO(${CMAKE_CURRENT_SOURCE_DIR} mtlSubinfo) + set(CurrentRevision ${mtlSubinfo_WC_REVISION}) +# message("current revision: ${mtlSubinfo_WC_REVISION}") + else(Subversion_FOUND) + set(CurrentRevision "0") + endif(Subversion_FOUND) +endif (NOT MSVC) + +# if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") +# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lstdc++") +# endif() + +configure_file(boost/numeric/mtl/version.hpp.in boost/numeric/mtl/version.hpp @ONLY) + + +#look for compiler specific settings +if (MSVC) + # to quiet DevStudio 2005 secure code warnings + add_definitions(/D_SCL_SECURE_NO_WARNINGS) + add_definitions(/D_CRT_SECURE_NO_WARNINGS) + add_definitions(/DMTL_ASSERT_FOR_THROW /D_CRT_SECURE_NO_DEPRECATE /DNOMINMAX /D_CONSOLE /D"_HAS_ITERATOR_DEBUGGING=0" /D"_SECURE_SCL=0" ) + # specialty flags such as the C++ language exception model etc. come from the init flags determined by CMAKE + # you may override them, but I have not found it necessary + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG_INIT} /wd4018 /wd4099 /wd4522 /wd4996 /wd4355 /wd4244 /Z7") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE_INIT} /wd4018 /wd4099 /wd4522 /wd4996 /wd4355 /wd4244 /Z7") +endif (MSVC) + +if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND ENABLE_WARNINGS) + add_definitions("-Wall -Wextra -Wpointer-arith -Wcast-align -Wcast-qual -Wwrite-strings") + foreach(FLAG "-Wno-long-long") # "-Wno-unused-local-typedefs") + # message(STATUS "Check flag ${FLAG}") + mtl_check_cxx_compiler_flag(${FLAG} FLAG_OKAY) + if(FLAG_OKAY) + message(STATUS "Add ${FLAG}") + add_definitions("${FLAG}") + endif() + endforeach() +endif() + +if (ENABLE_DEVELOPMENT) + add_definitions("-DMTL_WITH_DEVELOPMENT") +endif() + +if (ENABLE_SHORT_ELE_PROD) + add_definitions("-DMTL_WITH_SHORT_ELE_PROD") +endif() + +set(BUILDNAME "${TESTBUILDNAME}") +enable_testing() +include(CTest) + +set(MTL_IS_CONFIGURED True) # impede double double configuration in libs +add_subdirectory(libs) diff --git a/AMDiS/lib/mtl4/CTestConfig.cmake b/AMDiS/lib/mtl4/CTestConfig.cmake new file mode 100644 index 0000000000000000000000000000000000000000..976ddd35b1adf24cba41405a08575afeca75d886 --- /dev/null +++ b/AMDiS/lib/mtl4/CTestConfig.cmake @@ -0,0 +1,26 @@ +## This file should be placed in the root directory of your project. +## Then modify the CMakeLists.txt file in the root directory of your +## project to incorporate the testing dashboard. +## # The following are required to uses Dart and the Cdash dashboard +## ENABLE_TESTING() +## INCLUDE(CTest) +set(CTEST_PROJECT_NAME "mtl4") +set(CTEST_NIGHTLY_START_TIME "00:00:00 CEST") + +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "simunova.zih.tu-dresden.de") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=mtl4") +set(CTEST_DROP_SITE_CDASH TRUE) +# set(CTEST_CURL_OPTIONS "CURLOPT_SSL_VERIFYPEER_OFF") + +# build in parallel if not on Windows +# if (NOT MSVC) +# message("now with make -j4") +# set(CTEST_BUILD_FLAGS -j4) +# endif() + +while (${CTEST_ELAPSED_TIME} LESS 36) + set (START_TIME ${CTEST_ELAPSED_TIME}) + ctest_start (Continuous) + ctest_sleep( ${START_TIME} 3 ${CTEST_ELAPSED_TIME}) +endwhile() diff --git a/AMDiS/lib/mtl4/Doxyfile b/AMDiS/lib/mtl4/Doxyfile new file mode 100644 index 0000000000000000000000000000000000000000..fdc37d46a51a942ddfa1721a34b2a662b63ebd9a --- /dev/null +++ b/AMDiS/lib/mtl4/Doxyfile @@ -0,0 +1,1614 @@ +# Doxyfile 1.6.3 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = "MTL 4" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = "" + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = libs/numeric/mtl/doc + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = NO + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = /Volumes/Doxygen/ + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 8 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it parses. +# With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this tag. +# The format is ext=language, where ext is a file extension, and language is one of +# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP, +# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat +# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C. Note that for custom extensions you also need to set +# FILE_PATTERNS otherwise the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen to replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penality. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will rougly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols + +SYMBOL_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespace are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = YES + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = YES + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = NO + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen +# will list include files with double quotes in the documentation +# rather than with sharp brackets. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen +# will sort the (brief and detailed) documentation of class members so that +# constructors and destructors are listed first. If set to NO (the default) +# the constructors will appear in the respective orders defined by +# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. +# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO +# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = NO + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command <command> <input-file>, where <command> is the value of +# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by +# doxygen. The layout file controls the global structure of the generated output files +# in an output format independent way. The create the layout file that represents +# doxygen's defaults, run doxygen with the -l option. You can optionally specify a +# file name after the option, if omitted DoxygenLayout.xml will be used as the name +# of the layout file. + +LAYOUT_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = . + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 + +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.d \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.idl \ + *.odl \ + *.cs \ + *.php \ + *.php3 \ + *.inc \ + *.m \ + *.mm \ + *.dox \ + *.py \ + *.C \ + *.CC \ + *.C++ \ + *.II \ + *.I++ \ + *.H \ + *.HH \ + *.H++ \ + *.CS \ + *.PHP \ + *.PHP3 \ + *.M \ + *.MM \ + *.PY + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = libs/numeric/mtl/doc/* \ + libs/numeric/mtl/doc-complete/* \ + packages + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = .svn + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = libs/numeric/mtl/examples \ + boost/numeric/itl/krylov \ + libs/numeric/mtl/experimental + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = *.*pp + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = libs/numeric/mtl/examples/images + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command <filter> <input-file>, where <filter> +# is the value of the INPUT_FILTER tag, and <input-file> is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# is applied to all files. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = YES + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = YES + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = libs/numeric/mtl/examples/doxygen_header.html + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = libs/numeric/mtl/examples/doxygen_footer.html + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting +# this to NO can help when comparing the output of multiple runs. + +HTML_TIMESTAMP = YES + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = NO + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER +# are set, an additional index file will be generated that can be used as input for +# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated +# HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add. +# For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see +# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">Qt Help Project / Custom Filters</a>. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's +# filter section matches. +# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">Qt Help Project / Filter Attributes</a>. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files +# will be generated, which together with the HTML files, form an Eclipse help +# plugin. To install this plugin and make it available under the help contents +# menu in Eclipse, the contents of the directory containing the HTML and XML +# files needs to be copied into the plugins directory of eclipse. The name of +# the directory within the plugins directory should be the same as +# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before +# the help appears. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have +# this name. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. + +ENUM_VALUES_PER_LINE = 4 + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to YES, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). +# Windows users are probably better off using the HTML help feature. + +GENERATE_TREEVIEW = NO + +# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, +# and Class Hierarchy pages using a tree view instead of an ordered list. + +USE_INLINE_TREES = NO + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box +# for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that when using +# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets +# (GENERATE_DOCSET) there is already a search function so this one should +# typically be disabled. For large projects the javascript based search engine +# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. + +SEARCHENGINE = NO + +# When the SERVER_BASED_SEARCH tag is enabled the search engine will be +# implemented using a PHP enabled web server instead of at the web client +# using Javascript. Doxygen will generate the search PHP script and index +# file to put on the web server. The advantage of the server +# based approach is that it scales better to large projects and allows +# full text search. The disadvances is that it is more difficult to setup +# and does not have live searching capabilities. + +SERVER_BASED_SEARCH = NO + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = YES + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. +# Note that when enabling USE_PDFLATEX this option is only used for +# generating bitmaps for formulas in the HTML output, but not in the +# Makefile that is written to the output directory. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = letter + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = NO + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = NO + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings +# such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. This is useful +# if you want to understand what is going on. On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# in the INCLUDE_PATH (see below) will be search if a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = MTL_HAS_UMFPACK MTL_HAS_VPT + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse +# the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option is superseded by the HAVE_DOT option below. This is only a +# fallback. It is recommended to install and use dot, since it yields more +# powerful graphs. + +CLASS_DIAGRAMS = YES + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = YES + +# By default doxygen will write a font called FreeSans.ttf to the output +# directory and reference it in all dot files that doxygen generates. This +# font does not include all possible unicode characters however, so when you need +# these (or just want a differently looking font) you can specify the font name +# using DOT_FONTNAME. You need need to make sure dot is able to find the font, +# which can be done by putting it in a standard location or by setting the +# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory +# containing the font. + +DOT_FONTNAME = FreeSans + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the output directory to look for the +# FreeSans.ttf font (which doxygen will put there itself). If you specify a +# different font using DOT_FONTNAME you can set the path where dot +# can find it using this tag. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are png, jpg, or gif +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = /Volumes/Doxygen/Doxygen.app/Contents/Resources/ + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 1000 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES diff --git a/AMDiS/lib/mtl4/INSTALL b/AMDiS/lib/mtl4/INSTALL new file mode 100644 index 0000000000000000000000000000000000000000..63a39d2e461554e42a96ac0e8ff4ee8a65601979 --- /dev/null +++ b/AMDiS/lib/mtl4/INSTALL @@ -0,0 +1,23 @@ +-*- text -*- + +Software License for MTL + +Copyright (c) 2007-2008 The Trustees of Indiana University. + 2008 Dresden University of Technology and the Trustees of Indiana University. + 2010 SimuNova UG, www.simunova.com. +All rights reserved. +Authors: Peter Gottschling and Andrew Lumsdaine + +This file is part of the Matrix Template Library + +See also tools/license/license.mtl.txt in the distribution. +--------------------------------------------------------------- + + The Matrix Template Library + Version 4 + + +I. Installation +=============== + +see http://www.simunova.com/node/189 diff --git a/AMDiS/lib/mtl4/MTLConfig.cmake b/AMDiS/lib/mtl4/MTLConfig.cmake new file mode 100644 index 0000000000000000000000000000000000000000..8b44981d969e8c5574029ec3da1af4fd63c92806 --- /dev/null +++ b/AMDiS/lib/mtl4/MTLConfig.cmake @@ -0,0 +1,6 @@ +set(MTL_COMMON_CONFIG "${MTL_DIR}/tools/cmake/MTLCommon.cmake") +if( EXISTS ${MTL_COMMON_CONFIG}) + include(${MTL_COMMON_CONFIG}) +else() + message(ERROR "could not find the common mtl configuration. this is possibly a wrong installation of mtl.") +endif() diff --git a/AMDiS/lib/mtl4/README b/AMDiS/lib/mtl4/README new file mode 100644 index 0000000000000000000000000000000000000000..c59d60859af99d22e7e8c23dcd86164afeeb8066 --- /dev/null +++ b/AMDiS/lib/mtl4/README @@ -0,0 +1,117 @@ +-*- text -*- + +Software License for MTL + +Copyright (c) 2007-2008 The Trustees of Indiana University. All rights reserved. +Authors: Peter Gottschling and Andrew Lumsdaine + +This file is part of the Matrix Template Library + +See also license.mtl.txt in the distribution. +--------------------------------------------------------------- + + The Matrix Template Library + Version 4 + +I. Introduction +=============== + +The Matrix Template Library is a C++ class library for basic linear +algebra. The MTL is designed for high-performance while at the same +time taking advantage of the generic programming paradigm (ala the +STL) to allow much greater flexibility and breadth of +functionality. Many new and advanced programming techniques were used +in the construction of this library. + +The MTL is a low level library in the sense that the user must be +conscious of the matrix type being used, and that all computationally +expensive operations are explicit. The MTL is not a C++ Matlab or +Mathematica. Nevertheless, the interface is designed to be simple and easy +to use. + +The matrix types provided include compressed sparse row/column, +traditional row- and column-major dense, Morton-order, and block-recursive +matrices. All matrix types share a common and easy to use interface. + +The algorithms consist of the traditional basic linear algebra +routines (from the BLAS level-1 to 3) which includes matrix and vector +arithmetic. + + +II. Compilers +============= + +The Matrix Template Library is written in compliance with the C++ standard +and should be compilable with every compiler compliant with the standard. +It has been tested (and passed) with the following compilers and architectures: + +Linux & MacOS +------------- + clang++ 3.0 (32 bit) + g++ 4.1.3 (32 and 64 bit) + g++ 4.2.4 (64bit) + g++ 4.3.4 (32 and 64 bit) + g++ 4.4.3 (32 and 64 bit) + g++ 4.5.1 (64 bit) + g++ 4.6.0 (64 bit) + g++ 4.6.1 (64 bit) + icc 9.1 (32 and 64 bit) + icc 10.0 (32 and 64 bit) + icc 10.1 (32 and 64 bit) + icc 11.0 (32 and 64 bit) + icc 11.1 (32 and 64 bit) + +Windows +------- + VC 8.0 from Visual Studio 2005 (32 bit) + VC 9.0 from Visual Studio 2008 (32 bit) + VC 10.0 from Visual Studio 2010 (32 bit) + +Compilers that are not standard-compliant (e.g. VC 6.0 from VS 2003) are not subject to support. + + +III. Documentation +================== + +The documentation can be generated with doxygen in the main directory and +is found in the /libs/numeric/mtl/doc. You +can also view the documentation at our web site: +http://www.simunova.com/node/184 +At the moment, the documentation illustrates the basic operations and +partially provides a reference manual of some classes and functions. +A detailed description of more features, especially tuning opportunities, +is in the works. + +There are also a large number of examples in the /libs/numeric/mtl/examples +directory. + + +IV. Installation Procedure +========================== + +See the file INSTALL in this directory. + + + +V. Contact Information +======================= + +The Matrix Template Library is available at the main distribution site: + + http://www.mtl4.org + +This distribution includes: + + - Source code for the MTL (all header files /boost/numeric/mtl) + - Some completing sources (header files /boost/numeric/meta_math) + - A test suite (/libs/numeric/mtl/test) + - Some example code (/libs/numeric/mtl/examples) + +Bug reports should be sent to mtl4@osl.iu.edu. + +Questions, comments, suggestions, and requests for additional +information should also be directed to mtl4@osl.iu.edu. + +Subscribe at: + + http://www.osl.iu.edu/mailman/listinfo.cgi/mtl4 diff --git a/AMDiS/lib/mtl4/SConstruct b/AMDiS/lib/mtl4/SConstruct new file mode 100644 index 0000000000000000000000000000000000000000..e547d4590592601eae3a4460052a49219260b20d --- /dev/null +++ b/AMDiS/lib/mtl4/SConstruct @@ -0,0 +1,411 @@ +import getopt, sys, os, os.path, re, string + +###################### +# Helper functions +###################### + +# platform-dependent preprocessor definitions +def macro_flag(env, flag): + if sys.platform == 'win32' and conf.env['CC'] == 'cl': + return '/D' + flag + else: + return '-D' + flag + +# add debugging flags to environment +def add_debug(env): + if sys.platform == 'win32' and conf.env['CC'] == 'cl': + env.Append(CCFLAGS = '/Z7') + env.Append(CCFLAGS = '/MDd') + else: + env.Append(CCFLAGS = '-g') + #print macro_flag(env, 'MTL_ASSERT_FOR_THROW') + env.Append(CCFLAGS = macro_flag(env, 'MTL_ASSERT_FOR_THROW')) + + +def check_g5(): + print "platform ", sys.platform + if sys.platform == "darwin" : + + system("/usr/bin/system_profiler SPHardwareDataType") + profile = os.popen("system_profiler SPHardwareDataType").read() + print profile + if profile.find("Mac G5") != -1: + print "is G5" + return 1 + print "isn't G5" + return None + + +def add_platform_flags(env): + if env['CC'] == 'cl': + # Turn off some warnings: 1. for problems with CRTP 2. with VC's own headers + # 3. alleged ambiguos assignment + # I hope we find a cleaner way to get rid of this warning + wd = ' /wd4355 /wd4996 /wd4522' + env.Append(CCFLAGS = '/EHa /D_CONSOLE /D_CRT_SECURE_NO_DEPRECATE /DNOMINMAX' + + ' /D_SECURE_SCL=0' + wd) + + # The following two if shouldn't be necessary + # Note that INCLUDE must be split and LIB must not :-P + if os.environ.has_key('INCLUDE') : + for p in os.environ['INCLUDE'].split(';'): + env.Append(CPPPATH = p) + if os.environ.has_key('LIB') : + env.Append(LIBPATH = os.environ['LIB']) + + +# add optimization flags to environment +# normal optimization for opt=1, for opt=2 high optimization +# at the moment additional flags are added in this function +# -> this needs to be cleaned up! +def add_opt(env, opt): + if int(opt): + env.Append(CCFLAGS = macro_flag(env, 'NDEBUG')) + if sys.platform == 'win32' and conf.env['CC'] == 'cl': + if int(opt) == 1: + env.Append(CCFLAGS = '/O2 /Ot /Ob2') + elif int(opt) == 2: + env.Append(CCFLAGS = '/Ox') + env.Append(CCFLAGS = '/MD') + else: + if int(opt) == 2: + env.Append(CCFLAGS = '-O3') + if conf.env['CC'] == 'gcc': + env.Append(CCFLAGS = '-ffast-math') + #check_g5() + # env.Append(CCFLAGS = '-pg') # for profiling + # env.Append(LINKFLAGS = '-pg') # for profiling + elif int(opt) == 1: + env.Append(CCFLAGS = '-O2') + # env.Append(CCFLAGS = '-pg') # for profiling + # env.Append(LINKFLAGS = '-pg') # for profiling + + if env['CC'] != 'cl': + env.Append(CXXFLAGS = conf.env['CCFLAGS']) + + +def check_no_long_double(conf): + cc = conf.env['CC'] + if cc == 'gcc': + # conf.env.Append(CXXFLAGS = '-Werror -Wreorder -pedantic -Wpointer-arith -Wcast-align -Wcast-qual -Wwrite-strings') + output = os.popen(cc + " --version").read() + st = output.split('\n')[0] + tmatch = re.search(".* \(GCC\) (\d\.\d)", st) + if tmatch and string.atof(tmatch.group(1)) == 4.0: + conf.env.Append(CCFLAGS = '-Wno-long-double') + # conf.env.Append(CXXFLAGS = '-Wno-long-double') + + +def add_user_opt(env, add_optflag): + env.Append(CCFLAGS = add_optflag) + env.Append(CXXFLAGS = add_optflag) + +############################### +# check for installed blas ... +# search different libraries +############################### +def detected_blas(env): # blas library found + env.Append(CPPDEFINES = 'MTL_HAS_BLAS') + +def check_for_blas(env): + # symbolname + symname = 'dgemm_' + found_blas = 0 + + # get command line blas path + blas_path = ARGUMENTS.get('blas_path', '') + if blas_path: + print 'adding ' + blas_path + ' to LIBPATH.' + env.Append(LIBPATH = [ blas_path, blas_path + '/lib/' ]) + + # extra linker flags for blas + blas_ldflags = ARGUMENTS.get('blas_ldflags', '') + if blas_ldflags: + env.Append(_LIBFLAGS=blas_ldflags.split()) + + # get command line blas lib + blas_lib = ARGUMENTS.get('blas_lib', '') + if blas_lib: + myenv = env.Copy() + conf = Configure(myenv) + # check supplied lib + print "Checking for lib " + blas_lib + "..." + if conf.CheckLib(blas_lib, symname): + myenv = conf.Finish() + detected_blas(myenv) + myenv.Append(LIBS=[blas_lib]) + return myenv + else: + print "Autodetecting BLAS support. See config.log for details!" + + ######################## + # check for acml + myenv = env.Copy() + # new configure object + conf = Configure(myenv) + # additional libs needed for acml + myenv.Append(LIBS=['m', 'g2c']) + if conf.CheckLib('acml', symname): + detected_blas(myenv) + found_blas = 1 + myenv = conf.Finish() + if(found_blas == 1): + return myenv + + ######################## + # check for goto + myenv = env.Copy() + # new configure object + conf = Configure(myenv) + # additional libs needed for goto + myenv.Append(LIBS=['pthread']) + # extra linker flags for libgoto + # myenv.Append(_LIBFLAGS=['libs/numeric/mtl/build/xerbla.c']) + myenv.Append(_LIBFLAGS=['libs/numeric/mtl/build/xerbla.o']) # not portable !!! + # myenv.Library('build/xerbla', 'build/xerbla.c') + # myenv.Append(LIBS=['xerbla']) + # myenv.Append(LIBPATH=['build']) + + if conf.CheckLib('goto', symname) or conf.CheckLib('goto_opteron-64', symname) or \ + conf.CheckLib('goto_coppermine-32', symname) or conf.CheckLib('goto_opteron-32', symname) or \ + conf.CheckLib('goto_itanium2-64', symname) or conf.CheckLib('goto_katmai-32', symname) or \ + conf.CheckLib('goto_northwood-32', symname) or conf.CheckLib('goto_prescott-32', symname) or \ + conf.CheckLib('goto_prescott-64', symname): + detected_blas(myenv) + found_blas = 1 + myenv = conf.Finish() + if(found_blas == 1): + return myenv + + ######################## + # check for ATLAS + myenv = env.Copy() + # new configure object + conf = Configure(myenv) + # additional libs needed for goto + myenv.Append(LIBS=['f77blas', 'g2c']) + if conf.CheckLib('atlas', symname): + detected_blas(myenv) + found_blas = 1 + myenv = conf.Finish() + if(found_blas == 1): + return myenv + + return env + + + +################################### +# Add UMFPACK (extremely simplistic) +################################### + +def detected_umfpack(env): # umfpack library found + env.Append(CPPDEFINES = 'MTL_HAS_UMFPACK') + +def check_for_umfpack(env): + ufconfig_path = ARGUMENTS.get('ufconfig_path', '') + if ufconfig_path: + env.Prepend(CPPPATH = [ ufconfig_path ]) + else: + print "UMFPACK only works with the UFconfig library." + print "Provide ufconfig_path." + print "Building continued without UMFPACK." + return env + + amd_path = ARGUMENTS.get('amd_path', '') + if amd_path: + # print 'adding ' + amd_path + '/Lib to LIBPATH.' + env.Append(LIBPATH = [ amd_path + '/Lib' ]) + #print 'adding ' + amd_path + '/Include to CPPPATH.' + env.Prepend(CPPPATH = [ amd_path + '/Include' ]) + env.Prepend(LIBS=['amd']) + # print "nachher: ", env['CPPPATH'] + else: + print "UMFPACK only works with the AMD library." + print "Provide amd_path." + print "Building continued without UMFPACK." + return env + + # get command line umfpack path + umfpack_path = ARGUMENTS.get('umfpack_path', '') + if umfpack_path: + # print 'adding ' + umfpack_path + '/Lib to LIBPATH.' + env.Prepend(LIBPATH = [ umfpack_path + '/Lib' ]) + env.Prepend(LIBS=['umfpack']) + # print 'adding ' + umfpack_path + '/Include to CPPPATH.' + env.Append(CPPPATH = [ umfpack_path + '/Include' ]) + detected_umfpack(env) + return env + + + + +###################### +# Start setting up env +###################### + + +SourceSignatures('timestamp') + +env = Environment() +# env.Decider('timestamp-newer') + +conf = Configure(env) +check_no_long_double(conf) +env = conf.Finish() + +# Search only for BLAS when explicitly asked for +with_blas = ARGUMENTS.get('with_blas', 0) +if int(with_blas): + env = check_for_blas(env) + +# Search only for UMFPACK when explicitly asked for +with_umfpack = ARGUMENTS.get('with_umfpack', 0) +if int(with_umfpack): + env = check_for_umfpack(env) + + + + +###################### +# Include paths +###################### + + +my_cpppath = [] +if os.environ.has_key('MTL_BOOST_ROOT') : + mtlp = os.environ['MTL_BOOST_ROOT'] + my_cpppath.append(mtlp) +if os.environ.has_key('BOOST_ROOT') : + my_cpppath.append(os.environ['BOOST_ROOT']) + +# In branches, the current directory is prepended +pwd = os.getcwd() +if not os.environ.has_key('MTL_BOOST_ROOT') \ +or not hasattr(os.path, 'samefile') or not os.path.samefile(pwd, mtlp): + my_cpppath = [pwd] + my_cpppath + +# Add directory of extern libraries if exist +# Not needed currently +#if os.path.exists('extern'): +# my_cpppath.append(os.path.abspath('extern')) + +env.Append(CPPPATH = my_cpppath) + +# Hack to select compiler explicitly +# env['CXX'] = 'g++-4.1' + + +###################### +# Opt. and debug flags +###################### + + +opts = Options() +opts.Add('opt', 'Set to 1 for normal optimization, 2 for high optimization', 0) +opts.Add('debug', 'Set to 1 for debugging', 0) +opts.Add('check', 'Set to 1 if test programs shall be ran', 0) +opts.Add('with_concepts', 'Set to 1 if test programs shall be compiled with conceptg++ (must be in ~/bin)', 0) +opts.Add('full_warnings', 'Set to 1 to turn on all possible warnings and transform into errors (currently only gcc)', 0) + + +opts.Add('add_ccflag', 'Add extra CC compiler flags that aren\'t automatically set', '') +opts.Add('add_cxxflag', 'Add extra CXX compiler flags that aren\'t automatically set', '') +opts.Add('add_optflag', 'Add extra optimization flags that aren\'t automatically set', '') + +############ +# BLAS flags +############ + +opts.Add('with_blas', 'Link with BLAS (have to given each time :-( until we can save configurations)', 0) +opts.Add('blas_path', 'Add path of blas library', '') +opts.Add('blas_lib', 'Add name of blas library', '') +opts.Add('blas_ldflags', 'Add LDFLAGS for blas library', '') + +############ +# UMFPACK flags +############ +opts.Add('with_umfpack', 'Use UMFPACK. Needs umfpack_path and amd_path.', 0) +opts.Add('umfpack_path', 'Add path of UMFPACK library', '') +opts.Add('amd_path', 'Add path of AMD library', '') +opts.Add('ufconfig_path', 'Add path of AMD library', '') + + +Help(opts.GenerateHelpText(env)) + +#env.Append(CCFLAGS = ARGUMENTS.get('debug', '')) +# Hack, for test only +# env.Replace(CXX = '/san/intel/cc/9.0/bin/icc') + +# To test with conceptg++ +# requires +if int(ARGUMENTS.get('with_concepts', 0)): + env['CXX'] = '~/bin/conceptg++' + env.Append(CCFLAGS = macro_flag(env, 'CONCEPTS_WITHOUT_OVERLOADED_REQUIREMENTS')) + + +# Full warnings and treat as errors +if int(ARGUMENTS.get('full_warnings', 0)): + if env['CXX'] == 'g++': + env.Append(CXXFLAGS = '-Werror -Wall -Wreorder -pedantic -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings') +full_warnings = ARGUMENTS.get('full_warnings', 0) + + +# add user-defined CC flags +add_ccflag = ARGUMENTS.get('add_ccflag', '') +if add_ccflag: + env.Append(CCFLAGS = add_ccflag) + +# add user-defined CXX flags +add_cxxflag = ARGUMENTS.get('add_cxxflag', '') +if add_cxxflag: + env.Append(CXXFLAGS = add_cxxflag) + +add_platform_flags(env) + +#create alternative environments +debug_env = env.Copy() +opt_env = env.Copy() +high_opt_env = env.Copy() + +# add debugging flags to appropriate environment +debug = ARGUMENTS.get('debug', 0) +if int(debug): + add_debug(env) +add_debug(debug_env) + + +# add optimization flags to appropriate environment +opt = ARGUMENTS.get('opt', 0) + +# Add optimization flags and then copy C flags into C++ flags +add_opt(debug_env, 0) +add_opt(env, int(opt)) +add_opt(opt_env, 1) +add_opt(high_opt_env, 2) + +# add user-defined optimization flags +add_optflag = ARGUMENTS.get('add_optflag', '') +if add_optflag: + add_user_opt(env, add_optflag) + add_user_opt(opt_env, add_optflag) + add_user_opt(high_opt_env, add_optflag) + +# whether test programs should be ran +check = ARGUMENTS.get('check', 0) + +##################### +# Sub-directories +##################### + +Export('env debug_env opt_env high_opt_env check full_warnings') + +SConscript(['libs/numeric/mtl/build/SConscript', + 'libs/numeric/mtl/test/SConscript', + 'libs/numeric/mtl/test_with_optimization/SConscript', + 'libs/numeric/mtl/examples/SConscript', + 'libs/numeric/mtl/experimental/SConscript', + 'libs/numeric/mtl/timing/SConscript', + 'libs/numeric/linear_algebra/test/SConscript', + 'libs/numeric/itl/test/SConscript']) + diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/iteration/basic_iteration.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/iteration/basic_iteration.hpp new file mode 100644 index 0000000000000000000000000000000000000000..369995fdaa481d91f65b13dd97009ba26cd13636 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/iteration/basic_iteration.hpp @@ -0,0 +1,151 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef ITL_BASIC_ITERATION_INCLUDE +#define ITL_BASIC_ITERATION_INCLUDE + +#include <iostream> +#include <complex> +#include <string> + +namespace itl { + + +template <class Real> +class basic_iteration +{ + public: + typedef basic_iteration self; + typedef Real real; + + template <class Vector> + basic_iteration(const Vector& r0, int max_iter_, Real t, Real a = Real(0)) + : error(0), i(0), norm_r0(std::abs(two_norm(r0))), + max_iter(max_iter_), rtol_(t), atol_(a), is_finished(false), my_quite(false), my_suppress(false) { } + + basic_iteration(Real nb, int max_iter_, Real t, Real a = Real(0)) + : error(0), i(0), norm_r0(nb), max_iter(max_iter_), rtol_(t), atol_(a), is_finished(false), + my_quite(false), my_suppress(false) {} + + virtual ~basic_iteration() {} + + bool check_max() + { + if (i >= max_iter) + error= 1, is_finished= true, err_msg= "Too many iterations."; + return is_finished; + } + + template <class Vector> + bool finished(const Vector& r) + { + if (converged(two_norm(r))) + return is_finished= true; + return check_max(); + } + + bool finished(const Real& r) + { + if (converged(r)) + return is_finished= true; + return check_max(); + } + + template <typename T> + bool finished(const std::complex<T>& r) + { + if (converged(std::abs(r))) + return is_finished= true; + return check_max(); + } + + bool finished() const { return is_finished; } + + template <class T> + int terminate(const T& r) { finished(r); return error; } + + bool converged(const Real& r) { resid_= r; return converged(); } + + bool converged() const + { + if (norm_r0 == 0) + return resid_ <= atol_; // ignore relative tolerance if |r0| is zero + return resid_ <= rtol_ * norm_r0 || resid_ <= atol_; + } + + self& operator++() { ++i; return *this; } + + self& operator+=(int n) { i+= n; return *this; } + + bool first() const { return i <= 1; } + + virtual operator int() const { return error; } + + virtual int error_code() const { return error; } + + bool is_converged() const { return is_finished && error == 0; } + + int iterations() const { return i; } + + int max_iterations() const { return max_iter; } + + void set_max_iterations(int m) { max_iter= m; } + + Real resid() const { return resid_; } + + Real relresid() const { return resid_ / norm_r0; } + + Real normb() const { return norm_r0; } + + Real tol() const { return rtol_; } + Real atol() const { return atol_; } + + int fail(int err_code) { error = err_code; return error_code(); } + + int fail(int err_code, const std::string& msg) + { error = err_code; err_msg = msg; return error_code(); } + + void set(Real v) { norm_r0 = v; } + + void set_quite(bool q) { my_quite= q; } + + bool is_quite() const { return my_quite; } + + void suppress_resume(bool s) { my_suppress= s; } + + bool resume_suppressed() const { return my_suppress; } + + void update_progress(const basic_iteration& that) + { + i= that.i; + resid_= that.resid_; + if (that.error > 1) { // copy error except too many iterations + error= that.error; + err_msg= that.err_msg; + is_finished= true; + } else + finished(resid_); + } + + protected: + int error, i; + Real norm_r0; + int max_iter; + Real rtol_, atol_, resid_; + std::string err_msg; + bool is_finished, my_quite, my_suppress; +}; + + +} // namespace itl + +#endif // ITL_BASIC_ITERATION_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/iteration/cyclic_iteration.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/iteration/cyclic_iteration.hpp new file mode 100644 index 0000000000000000000000000000000000000000..a488a19ee1a56920c837018b854886e84b34e8c5 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/iteration/cyclic_iteration.hpp @@ -0,0 +1,96 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library2 +// +// See also license.mtl.txt in the distribution. + +#ifndef ITL_CYCLIC_ITERATION_INCLUDE +#define ITL_CYCLIC_ITERATION_INCLUDE + +#include <iostream> +#include <boost/numeric/itl/iteration/basic_iteration.hpp> + +namespace itl { + + /// Class for iteration control that cyclically prints residual + template <class Real, class OStream = std::ostream> + class cyclic_iteration : public basic_iteration<Real> + { + typedef basic_iteration<Real> super; + typedef cyclic_iteration self; + + void print_resid() + { + if (!this->my_quite && this->i % cycle == 0) + if (multi_print || this->i != last_print) { // Avoid multiple print-outs in same iteration + out << "iteration " << this->i << ": resid " << this->resid() + // << " / " << this->norm_r0 << " = " << this->resid() / this->norm_r0 << " (rel. error)" + << std::endl; + last_print= this->i; + } + } + + public: + + template <class Vector> + cyclic_iteration(const Vector& r0, int max_iter_, Real tol_, Real atol_ = Real(0), int cycle_ = 100, + OStream& out = std::cout) + : super(r0, max_iter_, tol_, atol_), cycle(cycle_), last_print(-1), multi_print(false), out(out) + {} + + cyclic_iteration(Real r0, int max_iter_, Real tol_, Real atol_ = Real(0), int cycle_ = 100, + OStream& out = std::cout) + : super(r0, max_iter_, tol_, atol_), cycle(cycle_), last_print(-1), multi_print(false), out(out) + {} + + + bool finished() { return super::finished(); } + + template <typename T> + bool finished(const T& r) + { + bool ret= super::finished(r); + print_resid(); + return ret; + } + + inline self& operator++() { ++this->i; return *this; } + + inline self& operator+=(int n) { this->i+= n; return *this; } + + operator int() const { return error_code(); } + + /// Whether the residual is printed multiple times in iteration + bool is_multi_print() const { return multi_print; } + + /// Set whether the residual is printed multiple times in iteration + void set_multi_print(bool m) { multi_print= m; } + + int error_code() const + { + if (!this->my_suppress) + out << "finished! error code = " << this->error << '\n' + << this->iterations() << " iterations\n" + << this->resid() << " is actual final residual. \n" + << this->relresid() << " is actual relative tolerance achieved. \n" + << "Relative tol: " << this->rtol_ << " Absolute tol: " << this->atol_ << '\n' + << "Convergence: " << pow(this->relresid(), 1.0 / double(this->iterations())) << std::endl; + return this->error; + } + protected: + int cycle, last_print; + bool multi_print; + OStream& out; + }; + + + +} // namespace itl + +#endif // ITL_CYCLIC_ITERATION_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/iteration/noisy_iteration.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/iteration/noisy_iteration.hpp new file mode 100644 index 0000000000000000000000000000000000000000..73acbdf99dc4f971c3e23d1d4dd92c04d037f7b7 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/iteration/noisy_iteration.hpp @@ -0,0 +1,34 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef ITL_NOISY_ITERATION_INCLUDE +#define ITL_NOISY_ITERATION_INCLUDE + +#include <iostream> +#include <boost/numeric/itl/iteration/cyclic_iteration.hpp> + +namespace itl { + + template <class Real, class OStream = std::ostream> + class noisy_iteration : public cyclic_iteration<Real, OStream> + { + public: + template <class Vector> + noisy_iteration(const Vector& r0, int max_iter_, Real tol_, Real atol_ = Real(0), + OStream& out = std::cout) + : cyclic_iteration<Real, OStream>(r0, max_iter_, tol_, atol_, 1, out) + {} + }; + +} // namespace itl + +#endif // ITL_NOISY_ITERATION_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/itl.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/itl.hpp new file mode 100644 index 0000000000000000000000000000000000000000..d802660d34666b8509fefadaaee32bfa9c4c3c79 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/itl.hpp @@ -0,0 +1,62 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef ITL_ITL_INCLUDE +#define ITL_ITL_INCLUDE + + +#include <boost/numeric/itl/iteration/basic_iteration.hpp> +#include <boost/numeric/itl/iteration/cyclic_iteration.hpp> +#include <boost/numeric/itl/iteration/noisy_iteration.hpp> + +#include <boost/numeric/itl/krylov/cg.hpp> +#include <boost/numeric/itl/krylov/cgs.hpp> +#include <boost/numeric/itl/krylov/bicg.hpp> +#include <boost/numeric/itl/krylov/bicgstab.hpp> +#include <boost/numeric/itl/krylov/bicgstab_2.hpp> +#include <boost/numeric/itl/krylov/bicgstab_ell.hpp> +#include <boost/numeric/itl/krylov/fsm.hpp> +#include <boost/numeric/itl/krylov/idr_s.hpp> +#include <boost/numeric/itl/krylov/gmres.hpp> +#include <boost/numeric/itl/krylov/tfqmr.hpp> +#include <boost/numeric/itl/krylov/qmr.hpp> + +#include <boost/numeric/itl/krylov/repeating_solver.hpp> + +#include <boost/numeric/itl/minimization/quasi_newton.hpp> + +#include <boost/numeric/itl/pc/identity.hpp> +#include <boost/numeric/itl/pc/is_identity.hpp> +#include <boost/numeric/itl/pc/diagonal.hpp> +#include <boost/numeric/itl/pc/ilu.hpp> +#include <boost/numeric/itl/pc/ilu_0.hpp> +#include <boost/numeric/itl/pc/ilut.hpp> +#include <boost/numeric/itl/pc/ic_0.hpp> + +#include <boost/numeric/itl/pc/imf_preconditioner.hpp> +#include <boost/numeric/itl/pc/imf_algorithms.hpp> + +#include <boost/numeric/itl/pc/sub_matrix_pc.hpp> +#include <boost/numeric/itl/pc/concat.hpp> + +#include <boost/numeric/itl/smoother/gauss_seidel.hpp> + +#include <boost/numeric/itl/stepper/armijo.hpp> +#include <boost/numeric/itl/stepper/wolf.hpp> + +#include <boost/numeric/itl/updater/bfgs.hpp> +#include <boost/numeric/itl/updater/broyden.hpp> +#include <boost/numeric/itl/updater/dfp.hpp> +#include <boost/numeric/itl/updater/psb.hpp> +#include <boost/numeric/itl/updater/sr1.hpp> + +#endif // ITL_ITL_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/itl_fwd.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/itl_fwd.hpp new file mode 100644 index 0000000000000000000000000000000000000000..15ddadbd2c5af1c16a356b3f0ef7518daffefd4a --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/itl_fwd.hpp @@ -0,0 +1,90 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef ITL_ITL_FWD_INCLUDE +#define ITL_ITL_FWD_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> + +namespace itl { + + template <class Real> class basic_iteration; + template <class Real, class OStream> class cyclic_iteration; + template <class Real, class OStream> class noisy_iteration; + + template <typename Solver, typename VectorIn, bool trans> class solver_proxy; + + namespace pc { + + template <typename PC, typename Vector, bool> struct solver; + template <typename Matrix, typename Value> class identity; + // template <typename Matrix, typename Value, typename Vector> Vector solve(const identity<Matrix>&, const Vector& x); + // template <typename Matrix, typename Vector> Vector adjoint_solve(const identity<Matrix>&, const Vector& x); + + template <typename Matrix, typename Value> class diagonal; + // template <typename Matrix, typename Vector> Vector solve(const diagonal<Matrix>& P, const Vector& x); + // template <typename Matrix, typename Vector> Vector adjoint_solve(const diagonal<Matrix>& P, const Vector& x); + + template <typename Matrix, typename Factorizer, typename Value> class ilu; + template <typename Matrix, typename Value> class ilu_0; // Maybe we should declare the default here??? + template <typename Matrix, typename Value> class ilut; // Maybe we should declare the default here??? + // template <typename Matrix, typename Vector> Vector solve(const ilu_0<Matrix>& P, const Vector& x); + // template <typename Matrix, typename Vector> Vector adjoint_solve(const ilu_0<Matrix>& P, const Vector& x); + + template <typename Matrix, typename Value> class ic_0; // Maybe we should declare the default here??? + // template <typename Matrix, typename Vector> Vector solve(const ic_0<Matrix>& P, const Vector& x); + // template <typename Matrix, typename Value, typename Vector> Vector adjoint_solve(const ic_0<Matrix, Value>& P, const Vector& x); + + } // namespace pc + + template < typename LinearOperator, typename HilbertSpaceX, typename HilbertSpaceB, + typename Preconditioner, typename Iteration > + int cg(const LinearOperator& A, HilbertSpaceX& x, const HilbertSpaceB& b, + const Preconditioner& M, Iteration& iter); + + template < typename LinearOperator, typename Preconditioner= pc::identity<LinearOperator, double>, + typename RightPreconditioner= pc::identity<LinearOperator, double> > + class cg_solver; + + + template < typename LinearOperator, typename Vector, + typename Preconditioner, typename Iteration > + int bicg(const LinearOperator &A, Vector &x, const Vector &b, + const Preconditioner &M, Iteration& iter); + + template < class LinearOperator, class HilbertSpaceX, class HilbertSpaceB, + class Preconditioner, class Iteration > + int bicgstab(const LinearOperator& A, HilbertSpaceX& x, const HilbertSpaceB& b, + const Preconditioner& M, Iteration& iter); + + template < class LinearOperator, class HilbertSpaceX, class HilbertSpaceB, + class Preconditioner, class Iteration > + int bicgstab_2(const LinearOperator& A, HilbertSpaceX& x, const HilbertSpaceB& b, + const Preconditioner& M, Iteration& iter); + + template < typename LinearOperator, typename Vector, + typename LeftPreconditioner, typename RightPreconditioner, + typename Iteration > + int bicgstab_ell(const LinearOperator &A, Vector &x, const Vector &b, + const LeftPreconditioner &L, const RightPreconditioner &R, + Iteration& iter, size_t l); + + template < typename LinearOperator, typename Preconditioner= pc::identity<LinearOperator, double>, + typename RightPreconditioner= pc::identity<LinearOperator, double> > + class bicgstab_ell_solver; + + template <typename Solver, unsigned N, bool Stored= false> + class repeating_solver; + +} // namespace itl + +#endif // ITL_ITL_FWD_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/krylov/bicg.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/krylov/bicg.hpp new file mode 100644 index 0000000000000000000000000000000000000000..9dde56bc35f9e5253be85625b0346c4cfd4f97ce --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/krylov/bicg.hpp @@ -0,0 +1,115 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef ITL_BICG_INCLUDE +#define ITL_BICG_INCLUDE + +#include <complex> +#include <boost/numeric/itl/itl_fwd.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/operation/conj.hpp> +#include <boost/numeric/mtl/operation/resource.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace itl { + +/// Bi-Conjugate Gradient +template < typename LinearOperator, typename Vector, + typename Preconditioner, typename Iteration > +int bicg(const LinearOperator &A, Vector &x, const Vector &b, + const Preconditioner &M, Iteration& iter) +{ + mtl::vampir_trace<7003> tracer; + using mtl::conj; + typedef typename mtl::Collection<Vector>::value_type Scalar; + Scalar rho_1(0), rho_2(0), alpha(0), beta(0); + Vector r(b - A * x), z(resource(x)), p(resource(x)), q(resource(x)), + r_tilde(r), z_tilde(resource(x)), p_tilde(resource(x)), q_tilde(resource(x)); + + while ( ! iter.finished(r)) { + ++iter; + z= solve(M, r); + z_tilde= adjoint_solve(M, r_tilde); + rho_1= dot(z_tilde, z); + + if (rho_1 == 0.) return iter.fail(2, "bicg breakdown"); + if (iter.first()) { + p= z; + p_tilde= z_tilde; + } else { + beta= rho_1 / rho_2; + p= z + beta * p; + p_tilde= z_tilde + conj(beta) * p_tilde; + } + + q= A * p; + q_tilde= adjoint(A) * p_tilde; + alpha= rho_1 / dot(p_tilde, q); + + x+= alpha * p; + r-= alpha * q; + r_tilde-= conj(alpha) * q_tilde; + + rho_2= rho_1; + } + return iter; +} + +/// Solver class for BiCG method; right preconditioner ignored (prints warning if not identity) +template < typename LinearOperator, typename Preconditioner= pc::identity<LinearOperator>, + typename RightPreconditioner= pc::identity<LinearOperator> > +class bicg_solver +{ + public: + /// Construct solver from a linear operator; generate (left) preconditioner from it + explicit bicg_solver(const LinearOperator& A) : A(A), L(A) + { + if (!pc::static_is_identity<RightPreconditioner>::value) + std::cerr << "Right Preconditioner ignored!" << std::endl; + } + + /// Construct solver from a linear operator and (left) preconditioner + bicg_solver(const LinearOperator& A, const Preconditioner& L) : A(A), L(L) + { + if (!pc::static_is_identity<RightPreconditioner>::value) + std::cerr << "Right Preconditioner ignored!" << std::endl; + } + + /// Solve linear system approximately as specified by \p iter + template < typename HilbertSpaceB, typename HilbertSpaceX, typename Iteration > + int solve(const HilbertSpaceB& b, HilbertSpaceX& x, Iteration& iter) const + { + return bicg(A, x, b, L, iter); + } + + /// Perform one bicg iteration on linear system + template < typename HilbertSpaceB, typename HilbertSpaceX > + int solve(const HilbertSpaceB& b, HilbertSpaceX& x) const + { + itl::basic_iteration<double> iter(x, 1, 0, 0); + return bicg(A, x, b, L, iter); + } + + private: + const LinearOperator& A; + Preconditioner L; +}; + +} // namespace itl + +#endif // ITL_BICG_INCLUDE + + + + + + diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/krylov/bicgstab.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/krylov/bicgstab.hpp new file mode 100644 index 0000000000000000000000000000000000000000..c61d487464ed77795b9dc15762f2ac9f6cf8ed6a --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/krylov/bicgstab.hpp @@ -0,0 +1,120 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef ITL_BICGSTAB_INCLUDE +#define ITL_BICGSTAB_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/itl/utility/exception.hpp> +#include <boost/numeric/mtl/operation/resource.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace itl { + +/// Bi-Conjugate Gradient Stabilized +template < class LinearOperator, class HilbertSpaceX, class HilbertSpaceB, + class Preconditioner, class Iteration > +int bicgstab(const LinearOperator& A, HilbertSpaceX& x, const HilbertSpaceB& b, + const Preconditioner& M, Iteration& iter) +{ + typedef typename mtl::Collection<HilbertSpaceX>::value_type Scalar; + typedef HilbertSpaceX Vector; + mtl::vampir_trace<7004> tracer; + + Scalar rho_1(0), rho_2(0), alpha(0), beta(0), gamma, omega(0); + Vector p(resource(x)), phat(resource(x)), s(resource(x)), shat(resource(x)), + t(resource(x)), v(resource(x)), r(resource(x)), rtilde(resource(x)); + + r = b - A * x; + rtilde = r; + + while (! iter.finished(r)) { + ++iter; + rho_1 = dot(rtilde, r); + MTL_THROW_IF(rho_1 == 0.0, unexpected_orthogonality()); + + if (iter.first()) + p = r; + else { + MTL_THROW_IF(omega == 0.0, unexpected_orthogonality()); + beta = (rho_1 / rho_2) * (alpha / omega); + p = r + beta * (p - omega * v); + } + phat = solve(M, p); + v = A * phat; + + gamma = dot(rtilde, v); + MTL_THROW_IF(gamma == 0.0, unexpected_orthogonality()); + + alpha = rho_1 / gamma; + s = r - alpha * v; + + if (iter.finished(s)) { + x += alpha * phat; + break; + } + shat = solve(M, s); + t = A * shat; + omega = dot(t, s) / dot(t, t); + + x += omega * shat + alpha * phat; + r = s - omega * t; + + rho_2 = rho_1; + } + return iter; +} + +/// Solver class for BiCGStab method; right preconditioner ignored (prints warning if not identity) +template < typename LinearOperator, typename Preconditioner= pc::identity<LinearOperator>, + typename RightPreconditioner= pc::identity<LinearOperator> > +class bicgstab_solver +{ + public: + /// Construct solver from a linear operator; generate (left) preconditioner from it + explicit bicgstab_solver(const LinearOperator& A) : A(A), L(A) + { + if (!pc::static_is_identity<RightPreconditioner>::value) + std::cerr << "Right Preconditioner ignored!" << std::endl; + } + + /// Construct solver from a linear operator and (left) preconditioner + bicgstab_solver(const LinearOperator& A, const Preconditioner& L) : A(A), L(L) + { + if (!pc::static_is_identity<RightPreconditioner>::value) + std::cerr << "Right Preconditioner ignored!" << std::endl; + } + + /// Solve linear system approximately as specified by \p iter + template < typename HilbertSpaceB, typename HilbertSpaceX, typename Iteration > + int solve(const HilbertSpaceB& b, HilbertSpaceX& x, Iteration& iter) const + { + return bicgstab(A, x, b, L, iter); + } + + /// Perform one BiCGStab iteration on linear system + template < typename HilbertSpaceB, typename HilbertSpaceX > + int solve(const HilbertSpaceB& b, HilbertSpaceX& x) const + { + itl::basic_iteration<double> iter(x, 1, 0, 0); + return solve(b, x, iter); + } + + private: + const LinearOperator& A; + Preconditioner L; +}; + +} // namespace itl + +#endif // ITL_BICGSTAB_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/krylov/bicgstab_2.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/krylov/bicgstab_2.hpp new file mode 100644 index 0000000000000000000000000000000000000000..013379700470ba2f73f2375f262e6d1642f83167 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/krylov/bicgstab_2.hpp @@ -0,0 +1,182 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef ITL_BICGSTAB_2_INCLUDE +#define ITL_BICGSTAB_2_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/linear_algebra/identity.hpp> +#include <boost/numeric/mtl/operation/resource.hpp> +#include <boost/numeric/mtl/operation/size.hpp> +#include <boost/numeric/itl/pc/identity.hpp> +#include <boost/numeric/mtl/vector/dense_vector.hpp> +#include <boost/numeric/mtl/matrix/strict_upper.hpp> +#include <boost/numeric/mtl/matrix/dense2D.hpp> +#include <boost/numeric/mtl/utility/irange.hpp> +#include <boost/numeric/mtl/operation/orth.hpp> +#include <boost/numeric/mtl/operation/lazy.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace itl { + +/// Bi-Conjugate Gradient Stabilized(2) +template < typename LinearOperator, typename Vector, + typename Preconditioner, typename Iteration > +int bicgstab_2(const LinearOperator &A, Vector &x, const Vector &b, + const Preconditioner &L, Iteration& iter) +{ + mtl::vampir_trace<7005> tracer; + using mtl::size; using mtl::irange; using mtl::imax; using mtl::matrix::strict_upper; using mtl::lazy; + typedef typename mtl::Collection<Vector>::value_type Scalar; + typedef typename mtl::Collection<Vector>::size_type Size; + + if (size(b) == 0) throw mtl::logic_error("empty rhs vector"); + + const size_t l= 2; + const Scalar zero= math::zero(Scalar()), one= math::one(Scalar()); + Vector x0(resource(x)), y(resource(x)); + mtl::vector::dense_vector<Vector> r_hat(l+1,Vector(resource(x))), u_hat(l+1,Vector(resource(x))); + + // shift problem + x0= zero; + r_hat[0]= b; + if (two_norm(x) != zero) { + r_hat[0]-= A * x; + x0= x; + x= zero; + } + + Vector r0_tilde(r_hat[0]/two_norm(r_hat[0])); + y= solve(L, r_hat[0]); + r_hat[0]= y; + u_hat[0]= zero; + + Scalar rho_0(one), rho_1(zero), alpha(zero), Gamma(zero), beta(zero), omega(one); + mtl::matrix::dense2D<Scalar> tau(l+1, l+1); + mtl::vector::dense_vector<Scalar> sigma(l+1), gamma(l+1), gamma_a(l+1), gamma_aa(l+1); + + while (! iter.finished(r_hat[0])) { + ++iter; + rho_0= -omega * rho_0; + + for (Size j= 0; j < 2; ++j) { + rho_1= dot(r0_tilde, r_hat[j]); + beta= alpha * rho_1/rho_0; rho_0= rho_1; + + for (Size i= 0; i <= j; ++i) + u_hat[i]= r_hat[i] - beta * u_hat[i]; + + y= A * u_hat[j]; + u_hat[j+1]= solve(L, y); + Gamma= dot(r0_tilde, u_hat[j+1]); + alpha= rho_0 / Gamma; + + for (Size i= 0; i <= j; ++i) + r_hat[i]-= alpha * u_hat[i+1]; + + if (iter.finished(r_hat[j])) { + x+= x0; + return iter; + } + + y= A * r_hat[j]; + r_hat[j+1]= solve(L, y); + x+= alpha * u_hat[0]; + } + + // mod GS (MR part) + irange i1m(1, imax); + mtl::vector::dense_vector<Vector> r_hat_tail(r_hat[i1m]); + tau[i1m][i1m]= orthogonalize_factors(r_hat_tail); + for (Size j= 1; j <= l; ++j) + gamma_a[j]= dot(r_hat[j], r_hat[0]) / tau[j][j]; + + gamma[l]= gamma_a[l]; omega= gamma[l]; + if (omega == zero) return iter.fail(3, "bicg breakdown #2"); + + // is this something like a tri-solve? + for (Size j= l-1; j > 0; --j) { + Scalar sum= zero; + for (Size i=j+1;i<=l;++i) + sum += tau[j][i] * gamma[i]; + gamma[j] = gamma_a[j] - sum; + } + + gamma_aa[irange(1, l)]= strict_upper(tau[irange(1, l)][irange(1, l)]) * gamma[irange(2, l+1)] + gamma[irange(2, l+1)]; + + x+= gamma[1] * r_hat[0]; + r_hat[0]-= gamma_a[l] * r_hat[l]; + u_hat[0]-= gamma[l] * u_hat[l]; + for (Size j=1; j < l; ++j) { + u_hat[0] -= gamma[j] * u_hat[j]; + x+= gamma_aa[j] * r_hat[j]; + r_hat[0] -= gamma_a[j] * r_hat[j]; + } + } + x+= x0; // convert to real solution and undo shift + return iter; +} + + + +/// Solver class for BiCGStab(2) method; right preconditioner ignored (prints warning if not identity) +template < typename LinearOperator, typename Preconditioner= pc::identity<LinearOperator>, + typename RightPreconditioner= pc::identity<LinearOperator> > +class bicgstab_2_solver +{ + public: + /// Construct solver from a linear operator; generate (left) preconditioner from it + explicit bicgstab_2_solver(const LinearOperator& A) : A(A), L(A) + { + if (!pc::static_is_identity<RightPreconditioner>::value) + std::cerr << "Right Preconditioner ignored!" << std::endl; + } + + /// Construct solver from a linear operator and (left) preconditioner + bicgstab_2_solver(const LinearOperator& A, const Preconditioner& L) : A(A), L(L) + { + if (!pc::static_is_identity<RightPreconditioner>::value) + std::cerr << "Right Preconditioner ignored!" << std::endl; + } + + /// Solve linear system approximately as specified by \p iter + template < typename HilbertSpaceB, typename HilbertSpaceX, typename Iteration > + int solve(const HilbertSpaceB& b, HilbertSpaceX& x, Iteration& iter) const + { + return bicgstab_2(A, x, b, L, iter); + } + + /// Perform one BiCGStab(2) iteration on linear system + template < typename HilbertSpaceB, typename HilbertSpaceX > + int solve(const HilbertSpaceB& b, HilbertSpaceX& x) const + { + itl::basic_iteration<double> iter(x, 1, 0, 0); + return bicgstab_2(A, x, b, L, iter); + } + + private: + const LinearOperator& A; + Preconditioner L; +}; + + + +} // namespace itl + +#endif // ITL_BICGSTAB_2_INCLUDE + + + + + + diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/krylov/bicgstab_ell.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/krylov/bicgstab_ell.hpp new file mode 100644 index 0000000000000000000000000000000000000000..450eb5cc477c4aa6e7a0492f3a35f23e7f159130 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/krylov/bicgstab_ell.hpp @@ -0,0 +1,177 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +// Written by Jan Bos +// Edited by Peter Gottschling + +#ifndef ITL_BICGSTAB_ELL_INCLUDE +#define ITL_BICGSTAB_ELL_INCLUDE + +#include <boost/numeric/itl/itl_fwd.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/vector/dense_vector.hpp> +#include <boost/numeric/mtl/matrix/strict_upper.hpp> +#include <boost/numeric/mtl/matrix/dense2D.hpp> +#include <boost/numeric/mtl/utility/irange.hpp> +#include <boost/numeric/mtl/operation/orth.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/linear_algebra/identity.hpp> +#include <boost/numeric/mtl/operation/resource.hpp> +#include <boost/numeric/mtl/operation/size.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace itl { + +/// Bi-Conjugate Gradient Stabilized(ell) +template < typename LinearOperator, typename Vector, + typename LeftPreconditioner, typename RightPreconditioner, + typename Iteration > +int bicgstab_ell(const LinearOperator &A, Vector &x, const Vector &b, + const LeftPreconditioner &L, const RightPreconditioner &R, + Iteration& iter, size_t l) +{ + mtl::vampir_trace<7006> tracer; + using mtl::size; using mtl::irange; using mtl::imax; using mtl::matrix::strict_upper; + typedef typename mtl::Collection<Vector>::value_type Scalar; + typedef typename mtl::Collection<Vector>::size_type Size; + + if (size(b) == 0) throw mtl::logic_error("empty rhs vector"); + + const Scalar zero= math::zero(Scalar()), one= math::one(Scalar()); + Vector x0(resource(x)), y(resource(x)); + mtl::vector::dense_vector<Vector> r_hat(l+1,Vector(resource(x))), u_hat(l+1,Vector(resource(x))); + + // shift problem + x0= zero; + r_hat[0]= b; + if (two_norm(x) != zero) { + r_hat[0]-= A * x; + x0= x; + x= zero; + } + + Vector r0_tilde(r_hat[0]/two_norm(r_hat[0])); + y= solve(L, r_hat[0]); + r_hat[0]= y; + u_hat[0]= zero; + + Scalar rho_0(one), rho_1(zero), alpha(zero), Gamma(zero), beta(zero), omega(one); + mtl::matrix::dense2D<Scalar> tau(l+1, l+1); + mtl::vector::dense_vector<Scalar> sigma(l+1), gamma(l+1), gamma_a(l+1), gamma_aa(l+1); + + while (! iter.finished(r_hat[0])) { + ++iter; + rho_0= -omega * rho_0; + + for (Size j= 0; j < l; ++j) { + rho_1= dot(r0_tilde, r_hat[j]); + beta= alpha * rho_1/rho_0; rho_0= rho_1; + + for (Size i= 0; i <= j; ++i) + u_hat[i]= r_hat[i] - beta * u_hat[i]; + + y= A * Vector(solve(R, u_hat[j])); + u_hat[j+1]= solve(L, y); + Gamma= dot(r0_tilde, u_hat[j+1]); + alpha= rho_0 / Gamma; + + for (Size i= 0; i <= j; ++i) + r_hat[i]-= alpha * u_hat[i+1]; + + if (iter.finished(r_hat[j])) { + x= solve(R, x); + x+= x0; + return iter; + } + + r_hat[j+1]= solve(R, r_hat[j]); + y= A * r_hat[j+1]; + r_hat[j+1]= solve(L, y); + x+= alpha * u_hat[0]; + } + + // mod GS (MR part) + irange i1m(1, imax); + mtl::vector::dense_vector<Vector> r_hat_tail(r_hat[i1m]); + tau[i1m][i1m]= orthogonalize_factors(r_hat_tail); + for (Size j= 1; j <= l; ++j) + gamma_a[j]= dot(r_hat[j], r_hat[0]) / tau[j][j]; + + gamma[l]= gamma_a[l]; omega= gamma[l]; + if (omega == zero) return iter.fail(3, "bicg breakdown #2"); + + // is this something like a tri-solve? + for (Size j= l-1; j > 0; --j) { + Scalar sum= zero; + for (Size i=j+1;i<=l;++i) + sum += tau[j][i] * gamma[i]; + gamma[j] = gamma_a[j] - sum; + } + + gamma_aa[irange(1, l)]= strict_upper(tau[irange(1, l)][irange(1, l)]) * gamma[irange(2, l+1)] + gamma[irange(2, l+1)]; + + x+= gamma[1] * r_hat[0]; + r_hat[0]-= gamma_a[l] * r_hat[l]; + u_hat[0]-= gamma[l] * u_hat[l]; + for (Size j=1; j < l; ++j) { + u_hat[0] -= gamma[j] * u_hat[j]; + x+= gamma_aa[j] * r_hat[j]; + r_hat[0] -= gamma_a[j] * r_hat[j]; + } + } + x= solve(R, x); x+= x0; // convert to real solution and undo shift + return iter; +} + + +/// Solver class for BiCGStab(ell) method; right preconditioner ignored (prints warning if not identity) +template < typename LinearOperator, typename Preconditioner, + typename RightPreconditioner> +class bicgstab_ell_solver +{ + public: + /// Construct solver from a linear operator; generate (left) preconditioner from it + explicit bicgstab_ell_solver(const LinearOperator& A, size_t l= 8) : A(A), l(l), L(A), R(A) {} + + /// Construct solver from a linear operator and left preconditioner + bicgstab_ell_solver(const LinearOperator& A, size_t l, const Preconditioner& L) : A(A), l(l), L(L), R(A) {} + + /// Construct solver from a linear operator and left preconditioner + bicgstab_ell_solver(const LinearOperator& A, size_t l, const Preconditioner& L, const RightPreconditioner& R) + : A(A), l(l), L(L), R(R) {} + + /// Solve linear system approximately as specified by \p iter + template < typename HilbertSpaceB, typename HilbertSpaceX, typename Iteration > + int solve(const HilbertSpaceB& b, HilbertSpaceX& x, Iteration& iter) const + { + return bicgstab_ell(A, x, b, L, R, iter, l); + } + + /// Perform one BiCGStab(ell) iteration on linear system + template < typename HilbertSpaceB, typename HilbertSpaceX > + int solve(const HilbertSpaceB& b, HilbertSpaceX& x) const + { + itl::basic_iteration<double> iter(x, 1, 0, 0); + return solve(b, x, iter); + } + + private: + const LinearOperator& A; + size_t l; + Preconditioner L; + RightPreconditioner R; +}; + + +} // namespace itl + +#endif // ITL_BICGSTAB_ELL_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/krylov/cg.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/krylov/cg.hpp new file mode 100644 index 0000000000000000000000000000000000000000..f1f2eeedbee8ecbaa8fe07b69b14c32d72d79019 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/krylov/cg.hpp @@ -0,0 +1,163 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef ITL_CG_INCLUDE +#define ITL_CG_INCLUDE + +#include <cmath> +#include <cassert> +#include <iostream> +#include <boost/mpl/bool.hpp> + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/itl/itl_fwd.hpp> +#include <boost/numeric/itl/iteration/basic_iteration.hpp> +#include <boost/numeric/itl/pc/identity.hpp> +#include <boost/numeric/itl/pc/is_identity.hpp> +#include <boost/numeric/mtl/operation/dot.hpp> +#include <boost/numeric/mtl/operation/unary_dot.hpp> +#include <boost/numeric/mtl/operation/conj.hpp> +#include <boost/numeric/mtl/operation/resource.hpp> +#include <boost/numeric/mtl/operation/lazy.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace itl { + +/// Conjugate Gradients without preconditioning +template < typename LinearOperator, typename HilbertSpaceX, typename HilbertSpaceB, + typename Iteration > +int cg(const LinearOperator& A, HilbertSpaceX& x, const HilbertSpaceB& b, + Iteration& iter) +{ + mtl::vampir_trace<7001> tracer; + using std::abs; using mtl::conj; using mtl::lazy; + typedef HilbertSpaceX Vector; + typedef typename mtl::Collection<HilbertSpaceX>::value_type Scalar; + typedef typename Iteration::real Real; + + Scalar rho(0), rho_1(0), alpha(0), alpha_1(0); + Vector p(resource(x)), q(resource(x)), r(resource(x)), z(resource(x)); + + r = b - A*x; + rho = dot(r, r); + while (! iter.finished(Real(sqrt(abs(rho))))) { + ++iter; + if (iter.first()) + p = r; + else + p = r + (rho / rho_1) * p; + + // q = A * p; alpha = rho / dot(p, q); + (lazy(q)= A * p) || (lazy(alpha_1)= lazy_dot(p, q)); + alpha= rho / alpha_1; + + x += alpha * p; + rho_1 = rho; + (lazy(r) -= alpha * q) || (lazy(rho) = lazy_unary_dot(r)); + } + + return iter; +} + +/// Conjugate Gradients +template < typename LinearOperator, typename HilbertSpaceX, typename HilbertSpaceB, + typename Preconditioner, typename Iteration > +int cg(const LinearOperator& A, HilbertSpaceX& x, const HilbertSpaceB& b, + const Preconditioner& L, Iteration& iter) +{ + using pc::is_identity; + if (is_identity(L)) + return cg(A, x, b, iter); + + mtl::vampir_trace<7002> tracer; + using std::abs; using mtl::conj; using mtl::lazy; + typedef HilbertSpaceX Vector; + typedef typename mtl::Collection<HilbertSpaceX>::value_type Scalar; + typedef typename Iteration::real Real; + + Scalar rho(0), rho_1(0), rr, alpha(0), alpha_1; + Vector p(resource(x)), q(resource(x)), r(resource(x)), z(resource(x)); + + r = b - A*x; + rr = dot(r, r); + while (! iter.finished(Real(sqrt(abs(rr))))) { + ++iter; + (lazy(z)= solve(L, r)) || (lazy(rho)= lazy_dot(r, z)); + + if (iter.first()) + p = z; + else + p = z + (rho / rho_1) * p; + + (lazy(q)= A * p) || (lazy(alpha_1)= lazy_dot(p, q)); + alpha= rho / alpha_1; + + x += alpha * p; + rho_1 = rho; + (lazy(r) -= alpha * q) || (lazy(rr) = lazy_unary_dot(r)); + } + return iter; +} + +/// Conjugate Gradients with ignored right preconditioner to unify interface +template < typename LinearOperator, typename HilbertSpaceX, typename HilbertSpaceB, + typename Preconditioner, typename RightPreconditioner, typename Iteration > +int cg(const LinearOperator& A, HilbertSpaceX& x, const HilbertSpaceB& b, + const Preconditioner& L, const RightPreconditioner&, Iteration& iter) +{ + return cg(A, x, b, L, iter); +} + +/// Solver class for CG method; right preconditioner ignored (prints warning if not identity) +template < typename LinearOperator, typename Preconditioner, + typename RightPreconditioner> +class cg_solver +{ + public: + /// Construct solver from a linear operator; generate (left) preconditioner from it + explicit cg_solver(const LinearOperator& A) : A(A), L(A) + { + if (!pc::static_is_identity<RightPreconditioner>::value) + std::cerr << "Right Preconditioner ignored!" << std::endl; + } + + /// Construct solver from a linear operator and (left) preconditioner + cg_solver(const LinearOperator& A, const Preconditioner& L) : A(A), L(L) + { + if (!pc::static_is_identity<RightPreconditioner>::value) + std::cerr << "Right Preconditioner ignored!" << std::endl; + } + + /// Solve linear system approximately as specified by \p iter + template < typename HilbertSpaceB, typename HilbertSpaceX, typename Iteration > + int solve(const HilbertSpaceB& b, HilbertSpaceX& x, Iteration& iter) const + { + return cg(A, x, b, L, iter); + } + + /// Perform one CG iteration on linear system + template < typename HilbertSpaceB, typename HilbertSpaceX > + int solve(const HilbertSpaceB& b, HilbertSpaceX& x) const + { + itl::basic_iteration<double> iter(x, 1, 0, 0); + return solve(b, x, iter); + } + + private: + const LinearOperator& A; + Preconditioner L; +}; + + +} // namespace itl + +#endif // ITL_CG_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/krylov/cgs.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/krylov/cgs.hpp new file mode 100644 index 0000000000000000000000000000000000000000..0fc0705bbb62048fbacd3f81d9ce78f1dfd51ef9 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/krylov/cgs.hpp @@ -0,0 +1,110 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef ITL_CGS_INCLUDE +#define ITL_CGS_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/operation/resource.hpp> +#include <boost/numeric/mtl/operation/dot.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace itl { + +/// Conjugate Gradient Squared +template < typename LinearOperator, typename Vector, + typename Preconditioner, typename Iteration > +int cgs(const LinearOperator &A, Vector &x, const Vector &b, + const Preconditioner &M, Iteration& iter) +{ + mtl::vampir_trace<7007> tracer; + typedef typename mtl::Collection<Vector>::value_type Scalar; + Scalar rho_1(0), rho_2(0), alpha(0), beta(0); + Vector p(resource(x)), phat(resource(x)), q(resource(x)), qhat(resource(x)), vhat(resource(x)), + u(resource(x)), uhat(resource(x)), r(b - A * x), rtilde= r; + + while (! iter.finished(r)) { + ++iter; + rho_1= dot(rtilde, r); + + if (rho_1 == 0.) iter.fail(2, "cgs breakdown"); + + if (iter.first()) + p= u= r; + else { + beta = rho_1 / rho_2; + u= r + beta * q; + p= u + beta * (q + beta * p); + } + + vhat= A * Vector(solve(M, p)); + alpha = rho_1 / dot(rtilde, vhat); + q= u - alpha * vhat; + + u+= q; + uhat= solve(M, u); + + x+= alpha * uhat; + qhat= A * uhat; + r-= alpha * qhat; + + rho_2= rho_1; + } + return iter; +} + +/// Solver class for CGS method; right preconditioner ignored (prints warning if not identity) +template < typename LinearOperator, typename Preconditioner= pc::identity<LinearOperator>, + typename RightPreconditioner= pc::identity<LinearOperator> > +class cgs_solver +{ + public: + /// Construct solver from a linear operator; generate (left) preconditioner from it + explicit cgs_solver(const LinearOperator& A) : A(A), L(A) + { + if (!pc::static_is_identity<RightPreconditioner>::value) + std::cerr << "Right Preconditioner ignored!" << std::endl; + } + + /// Construct solver from a linear operator and (left) preconditioner + cgs_solver(const LinearOperator& A, const Preconditioner& L) : A(A), L(L) + { + if (!pc::static_is_identity<RightPreconditioner>::value) + std::cerr << "Right Preconditioner ignored!" << std::endl; + } + + /// Solve linear system approximately as specified by \p iter + template < typename HilbertSpaceB, typename HilbertSpaceX, typename Iteration > + int solve(const HilbertSpaceB& b, HilbertSpaceX& x, Iteration& iter) const + { + return cgs(A, x, b, L, iter); + } + + /// Perform one CGS iteration on linear system + template < typename HilbertSpaceB, typename HilbertSpaceX > + int solve(const HilbertSpaceB& b, HilbertSpaceX& x) const + { + itl::basic_iteration<double> iter(x, 1, 0, 0); + return solve(b, x, iter); + } + + private: + const LinearOperator& A; + Preconditioner L; +}; + +} // namespace itl + +#endif // ITL_CGS_INCLUDE + + + diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/krylov/fsm.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/krylov/fsm.hpp new file mode 100644 index 0000000000000000000000000000000000000000..e398bcef1dbf113fcf6fbe4a1c67389430e08c75 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/krylov/fsm.hpp @@ -0,0 +1,39 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef ITL_FSM_INCLUDE +#define ITL_FSM_INCLUDE + +#include <boost/numeric/mtl/operation/two_norm.hpp> + +namespace itl { + +/// Folded spectrum method +/** Computed and named as in http://en.wikipedia.org/wiki/Folded_spectrum_method **/ +template < typename LinearOperator, typename VectorSpace, typename EigenValue, + typename Damping, typename Iteration > +int fsm(const LinearOperator& H, VectorSpace& phi, EigenValue eps, Damping alpha, Iteration& iter) +{ + VectorSpace v1(H * phi - eps * phi); + for (; !iter.finished(v1); ++iter) { + VectorSpace v2(H * v1 - eps * v1); + phi-= alpha * v2; + phi/= two_norm(phi); + v1= H * phi - eps * phi; + } + return iter; +} + + +} // namespace itl + +#endif // ITL_FSM_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/krylov/gmres.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/krylov/gmres.hpp new file mode 100644 index 0000000000000000000000000000000000000000..1a0235a171a15600314261b1dcee4a21732e34dc --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/krylov/gmres.hpp @@ -0,0 +1,181 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +// Written by Cornelius Steinhardt + + +#ifndef ITL_GMRES_INCLUDE +#define ITL_GMRES_INCLUDE + +#include <algorithm> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/vector/dense_vector.hpp> +#include <boost/numeric/mtl/matrix/dense2D.hpp> +#include <boost/numeric/mtl/matrix/multi_vector.hpp> +#include <boost/numeric/mtl/operation/givens.hpp> +#include <boost/numeric/mtl/operation/two_norm.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/irange.hpp> + +namespace itl { + +/// Generalized Minimal Residual method (without restart) +/** It computes at most kmax_in iterations (or size(x) depending on what is smaller) + regardless on whether the termination criterion is reached or not. **/ +template < typename Matrix, typename Vector, typename LeftPreconditioner, typename RightPreconditioner, typename Iteration > +int gmres_full(const Matrix &A, Vector &x, const Vector &b, + LeftPreconditioner &L, RightPreconditioner &R, Iteration& iter) +{ + using mtl::size; using mtl::irange; using mtl::iall; using std::abs; using std::sqrt; + typedef typename mtl::Collection<Vector>::value_type Scalar; + typedef typename mtl::Collection<Vector>::size_type Size; + + if (size(b) == 0) throw mtl::logic_error("empty rhs vector"); + + const Scalar zero= math::zero(Scalar()); + Scalar rho, nu, hr; + Size k, kmax(std::min(size(x), Size(iter.max_iterations() - iter.iterations()))); + Vector r0(b - A *x), r(solve(L,r0)), va(resource(x)), va0(resource(x)), va00(resource(x)); + mtl::matrix::multi_vector<Vector> V(Vector(resource(x), zero), kmax+1); + mtl::vector::dense_vector<Scalar> s(kmax+1, zero), c(kmax+1, zero), g(kmax+1, zero), y(kmax, zero); // replicated in distributed solvers + mtl::matrix::dense2D<Scalar> H(kmax+1, kmax); // dito + H= 0; + + rho= g[0]= two_norm(r); + if (iter.finished(rho)) + return iter; + V.vector(0)= r / rho; + H= zero; + + // GMRES iteration + for (k= 0; k < kmax ; ++k, ++iter) { + va0= A * Vector(solve(R, V.vector(k))); + V.vector(k+1)= va= solve(L,va0); + // orth(V, V[k+1], false); + // modified Gram Schmidt method + for (Size j= 0; j < k+1; j++) { + H[j][k]= dot(V.vector(j), V.vector(k+1)); + V.vector(k+1)-= H[j][k] * V.vector(j); + } + H[k+1][k]= two_norm(V.vector(k+1)); + //reorthogonalize + for(Size j= 0; j < k+1; j++) { + hr= dot(V.vector(k+1), V.vector(j)); + H[j][k]+= hr; + V.vector(k+1)-= hr * V.vector(j); + } + H[k+1][k]= two_norm(V.vector(k+1)); + if (H[k+1][k] != zero) // watch for breakdown + V.vector(k+1)*= 1. / H[k+1][k]; + + // k Given's rotations + for(Size i= 0; i < k; i++) + mtl::matrix::givens<mtl::matrix::dense2D<Scalar> >(H, H[i][k-1], H[i+1][k-1]).trafo(i); + + nu= sqrt(H[k][k]*H[k][k]+H[k+1][k]*H[k+1][k]); + if(nu != zero){ + c[k]= H[k][k]/nu; + s[k]= -H[k+1][k]/nu; + H[k][k]=c[k]*H[k][k]-s[k]*H[k+1][k]; + H[k+1][k]=0; + mtl::vector::givens<mtl::vector::dense_vector<Scalar> >(g, c[k], s[k]).trafo(k); + } + rho= abs(g[k+1]); + } + + //reduce k, to get regular matrix + while (k > 0 && abs(g[k-1]<= iter.atol())) k--; + + // iteration is finished -> compute x: solve H*y=g as far as rank of H allows + irange range(k); + for (; !range.empty(); --range) { + try { + y[range]= lu_solve(H[range][range], g[range]); + } catch (mtl::matrix_singular) { continue; } // if singular then try with sub-matrix + break; + } + + if (range.finish() < k) + std::cerr << "GMRES orhogonalized with " << k << " vectors but matrix singular, can only use " + << range.finish() << " vectors!\n"; + if (range.empty()) + return iter.fail(2, "GMRES did not find any direction to correct x"); + x+= Vector(solve(R, Vector(V.vector(range)*y[range]))); + + r= b - A*x; + return iter.terminate(r); +} + +/// Generalized Minimal Residual method with restart +template < typename Matrix, typename Vector, typename LeftPreconditioner, + typename RightPreconditioner, typename Iteration > +int gmres(const Matrix &A, Vector &x, const Vector &b, + LeftPreconditioner &L, RightPreconditioner &R, + Iteration& iter, typename mtl::Collection<Vector>::size_type restart) +{ + do { + Iteration inner(iter); + inner.set_max_iterations(std::min(int(iter.iterations()+restart), iter.max_iterations())); + inner.suppress_resume(true); + gmres_full(A, x, b, L, R, inner); + iter.update_progress(inner); + } while (!iter.finished()); + + return iter; +} + +/// Solver class for GMRES; right preconditioner ignored (prints warning if not identity) +template < typename LinearOperator, typename Preconditioner= pc::identity<LinearOperator>, + typename RightPreconditioner= pc::identity<LinearOperator> > +class gmres_solver +{ + public: + /// Construct solver from a linear operator; generate (left) preconditioner from it + explicit gmres_solver(const LinearOperator& A, size_t restart= 8) + : A(A), restart(restart), L(A), R(A) {} + + /// Construct solver from a linear operator and left preconditioner + gmres_solver(const LinearOperator& A, size_t restart, const Preconditioner& L) + : A(A), restart(restart), L(L), R(A) {} + + /// Construct solver from a linear operator and left preconditioner + gmres_solver(const LinearOperator& A, size_t restart, const Preconditioner& L, const RightPreconditioner& R) + : A(A), restart(restart), L(L), R(R) {} + + /// Solve linear system approximately as specified by \p iter + template < typename HilbertSpaceB, typename HilbertSpaceX, typename Iteration > + int solve(const HilbertSpaceB& b, HilbertSpaceX& x, Iteration& iter) const + { + return gmres(A, x, b, L, R, iter, restart); + } + + /// Perform one GMRES iteration on linear system + template < typename HilbertSpaceB, typename HilbertSpaceX > + int solve(const HilbertSpaceB& b, HilbertSpaceX& x) const + { + itl::basic_iteration<double> iter(x, 1, 0, 0); + return solve(b, x, iter); + } + + private: + const LinearOperator& A; + size_t restart; + Preconditioner L; + RightPreconditioner R; +}; + + +} // namespace itl + +#endif // ITL_GMRES_INCLUDE + + diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/krylov/idr_s.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/krylov/idr_s.hpp new file mode 100644 index 0000000000000000000000000000000000000000..9979361adbadbe51fa59a25e2f3773a530e6fa87 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/krylov/idr_s.hpp @@ -0,0 +1,144 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +// Peter Sonneveld and Martin B. van Gijzen, IDR(s): a family of simple and fast algorithms for solving large nonsymmetric linear systems. +// SIAM J. Sci. Comput. Vol. 31, No. 2, pp. 1035-1062 (2008). (copyright SIAM) + +#ifndef ITL_IDR_S_INCLUDE +#define ITL_IDR_S_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/vector/dense_vector.hpp> +#include <boost/numeric/mtl/operation/random.hpp> +#include <boost/numeric/mtl/operation/orth.hpp> +#include <boost/numeric/mtl/operation/resource.hpp> +#include <boost/numeric/mtl/matrix/strict_upper.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/irange.hpp> +#include <boost/numeric/linear_algebra/identity.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace itl { + +/// Induced Dimension Reduction on s dimensions (IDR(s)) +template < typename LinearOperator, typename Vector, + typename LeftPreconditioner, typename RightPreconditioner, + typename Iteration > +int idr_s(const LinearOperator &A, Vector &x, const Vector &b, + const LeftPreconditioner &, const RightPreconditioner &, + Iteration& iter, size_t s) +{ + mtl::vampir_trace<7010> tracer; + using mtl::size; using mtl::iall; using mtl::matrix::strict_upper; + typedef typename mtl::Collection<Vector>::value_type Scalar; + typedef typename mtl::Collection<Vector>::size_type Size; + + if (size(b) == 0) throw mtl::logic_error("empty rhs vector"); + if (s < 1) s= 1; + + const Scalar zero= math::zero(Scalar()); + Scalar omega(zero); + Vector x0(x), y(resource(x)), v(resource(x)), t(resource(x)), q(resource(x)), r(b - A * x); + mtl::matrix::multi_vector<Vector> dR(Vector(resource(x), zero), s), dX(Vector(resource(x), zero), s), P(Vector(resource(x), zero), s); + mtl::vector::dense_vector<Scalar> m(s), c(s), dm(s); // replicated in distributed solvers + mtl::matrix::dense2D<Scalar> M(s, s); // dito + + random(P); + P.vector(0)= r; + orth(P); + + for (size_t k= 0; k < s; k++) { + v= A * r; + omega= dot(v, r) / dot(v, v); + dX.vector(k)= omega * r; + dR.vector(k)= -omega * v; + x+= dX.vector(k); + r+= dR.vector(k); + if ((++iter).finished(r)) return iter; + M[iall][k]= trans(P) * dR.vector(k); + } + + Size oldest= 0; + m= trans(P) * r; + + while (! iter.finished(r)) { + + for (size_t k= 0; k < s; k++) { + c= lu_solve(M, m); + q= dR * -c; + v= r + q; + if (k == 0) { + t= A * v; + omega= dot(t, v) / dot(t, t); + dR.vector(oldest)= q - omega * t; + dX.vector(oldest)= omega * v - dX * c; + } else { + dX.vector(oldest)= omega * v - dX * c; + dR.vector(oldest)= A * -dX.vector(oldest); + } + r+= dR.vector(oldest); + x+= dX.vector(oldest); + + if ((++iter).finished(r)) + return iter; + + dm= trans(P) * dR.vector(oldest); + M[iall][oldest]= dm; + m+= dm; + oldest= (oldest + 1) % s; + } + } + return iter; +} + +/// Solver class for IDR(s) method; right preconditioner ignored (prints warning if not identity) +template < typename LinearOperator, typename Preconditioner= pc::identity<LinearOperator>, + typename RightPreconditioner= pc::identity<LinearOperator> > +class idr_s_solver +{ + public: + /// Construct solver from a linear operator; generate (left) preconditioner from it + explicit idr_s_solver(const LinearOperator& A, size_t s= 8) : A(A), s(s), L(A), R(A) {} + + /// Construct solver from a linear operator and left preconditioner + idr_s_solver(const LinearOperator& A, size_t s, const Preconditioner& L) : A(A), s(s), L(L), R(A) {} + + /// Construct solver from a linear operator and left preconditioner + idr_s_solver(const LinearOperator& A, size_t s, const Preconditioner& L, const RightPreconditioner& R) + : A(A), s(s), L(L), R(R) {} + + /// Solve linear system approximately as specified by \p iter + template < typename HilbertSpaceB, typename HilbertSpaceX, typename Iteration > + int solve(const HilbertSpaceB& b, HilbertSpaceX& x, Iteration& iter) const + { + return idr_s(A, x, b, L, R, iter, s); + } + + /// Perform one IDR(s) iteration on linear system + template < typename HilbertSpaceB, typename HilbertSpaceX > + int solve(const HilbertSpaceB& b, HilbertSpaceX& x) const + { + itl::basic_iteration<double> iter(x, 1, 0, 0); + return solve(b, x, iter); + } + + private: + const LinearOperator& A; + size_t s; + Preconditioner L; + RightPreconditioner R; +}; + + +} // namespace itl + +#endif // ITL_IDR_S_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/krylov/qmr.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/krylov/qmr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..151c5eeb0187b68b1a88a070b7ef1bab8b0d6402 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/krylov/qmr.hpp @@ -0,0 +1,150 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +// Written by Cornelius Steinhardt + + +#ifndef ITL_QMR_INCLUDE +#define ITL_QMR_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/operation/trans.hpp> +#include <boost/numeric/mtl/operation/resource.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace itl { + +/// Quasi-Minimal Residual method +template < typename Matrix, typename Vector,typename LeftPreconditioner, + typename RightPreconditioner, typename Iteration > +int qmr(const Matrix& A, Vector& x, const Vector& b, LeftPreconditioner& L, + const RightPreconditioner& R, Iteration& iter) +{ + mtl::vampir_trace<7008> tracer; + using mtl::size; + typedef typename mtl::Collection<Vector>::value_type Scalar; + if (size(b) == 0) throw mtl::logic_error("empty rhs vector"); + + const Scalar zero= math::zero(Scalar()), one= math::one(Scalar()); + Scalar beta, gamma(one), gamma_1, delta, eta(-one), ep(one), rho_1, theta(zero), theta_1; + Vector r(b - A * x), v_tld(r), y(solve(L, v_tld)), w_tld(r), z(adjoint_solve(R,w_tld)), v(resource(x)), w(resource(x)), + y_tld(resource(x)), z_tld(resource(x)), p(resource(x)), q(resource(x)), p_tld(resource(x)), d(resource(x)), s(resource(x)); + + if (iter.finished(r)) + return iter; + + Scalar rho = two_norm(y), xi = two_norm(z); + while(! iter.finished(rho)) { + ++iter; + if (rho == zero) + return iter.fail(1, "qmr breakdown #1, rho=0"); + if (xi == zero) + return iter.fail(2, "qmr breakdown #2, xi=0"); + + v= v_tld / rho; + y/= rho; + w= w_tld / xi; + z/= xi; + + delta = dot(z,y); + if (delta == zero) + return iter.fail(3, "qmr breakdown, delta=0 #3"); + + y_tld = solve(R,y); + z_tld = adjoint_solve(L,z); + + if (iter.first()) { + p = y_tld; + q = z_tld; + } else { + p = y_tld - ((xi * delta) / ep) * p; + q = z_tld - ((rho* delta) / ep) * q; + } + + p_tld = A * p; + ep = dot(q, p_tld); + if (ep == zero) + return iter.fail(4, "qmr breakdown ep=0 #4"); + beta= ep / delta; + if (beta == zero) + return iter.fail(5, "qmr breakdown beta=0 #5"); + v_tld = p_tld - beta * v; + y = solve(L,v_tld); + rho_1 = rho; + rho = two_norm(y); + w_tld= trans(A)*q - beta*w; + z = adjoint_solve(R, w_tld); + xi = two_norm(z); + gamma_1 = gamma; + theta_1 = theta; + theta = rho / (gamma_1 * beta); + gamma = one / (sqrt(one + theta * theta)); + + if (gamma == zero) + return iter.fail(6, "qmr breakdown gamma=0 #6"); + + eta= -eta * rho_1 * gamma * gamma / (beta * gamma_1 * gamma_1); + if (iter.first()) { + d= eta * p; + s= eta * p_tld; + } else { + d= eta * p + (theta_1 * theta_1 * gamma * gamma) * d; + s= eta * p_tld + (theta_1 * theta_1 * gamma * gamma) * s; + } + x += d; + r -= s; + } + return iter; +} + +/// Solver class for Quasi-minimal residual method; right preconditioner ignored (prints warning if not identity) +template < typename LinearOperator, typename Preconditioner= pc::identity<LinearOperator>, + typename RightPreconditioner= pc::identity<LinearOperator> > +class qmr_solver +{ + public: + /// Construct solver from a linear operator; generate (left) preconditioner from it + explicit qmr_solver(const LinearOperator& A) : A(A), L(A), R(A) {} + + /// Construct solver from a linear operator and left preconditioner + qmr_solver(const LinearOperator& A, const Preconditioner& L) : A(A), L(L), R(A) {} + + /// Construct solver from a linear operator and left preconditioner + qmr_solver(const LinearOperator& A, const Preconditioner& L, const RightPreconditioner& R) + : A(A), L(L), R(R) {} + + /// Solve linear system approximately as specified by \p iter + template < typename HilbertSpaceB, typename HilbertSpaceX, typename Iteration > + int solve(const HilbertSpaceB& b, HilbertSpaceX& x, Iteration& iter) const + { + return qmr(A, x, b, L, R, iter); + } + + /// Perform one QMR iteration on linear system + template < typename HilbertSpaceB, typename HilbertSpaceX > + int solve(const HilbertSpaceB& b, HilbertSpaceX& x) const + { + itl::basic_iteration<double> iter(x, 1, 0, 0); + return solve(b, x, iter); + } + + private: + const LinearOperator& A; + Preconditioner L; + RightPreconditioner R; +}; + + +} // namespace itl + +#endif // ITL_QMR_INCLUDE + diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/krylov/repeating_solver.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/krylov/repeating_solver.hpp new file mode 100644 index 0000000000000000000000000000000000000000..9716cf2620ab256a835bc86228a9ab9e7a2e8f56 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/krylov/repeating_solver.hpp @@ -0,0 +1,52 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef ITL_REPEATING_SOLVER_INCLUDE +#define ITL_REPEATING_SOLVER_INCLUDE + +#include <boost/mpl/if.hpp> +#include <boost/static_assert.hpp> +#include <boost/numeric/itl/itl_fwd.hpp> + +namespace itl { + +/// Class for calling \tparam N iterations of the given \tparam Solver +/** If \tparam Stored is true then the \tparam Solver object is stored (i.e. possibly copied) here. + Otherwise it is only referred and passing temporary objects to the constructor will cause errors. **/ +template <typename Solver, unsigned N, bool Stored> +class repeating_solver +{ + typedef typename boost::mpl::if_c<Stored, Solver, const Solver&>::type solver_type; + public: + explicit repeating_solver(const Solver& s) : s(s) {} + + template <typename Matrix> + explicit repeating_solver(const Matrix& A) : s(A) + { + BOOST_STATIC_ASSERT((Stored)); // if matrix is passed class must own solver + } + + /// Perform one GMRES iteration on linear system + template < typename VectorIn, typename VectorOut > + int solve(const VectorIn& b, VectorOut& x) const + { + itl::basic_iteration<double> iter(x, N, 0, 0); + return s.solve(b, x, iter); + } + + private: + solver_type s; +}; + +} // namespace itl + +#endif // ITL_REPEATING_SOLVER_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/krylov/tfqmr.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/krylov/tfqmr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..eb2284bca4c8f0a18fe9fda06bd0f668ee30e1ba --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/krylov/tfqmr.hpp @@ -0,0 +1,135 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +// Written by Cornelius Steinhardt + + +#ifndef ITL_TFQMR_INCLUDE +#define ITL_TFQMR_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/linear_algebra/identity.hpp> +#include <boost/numeric/linear_algebra/inverse.hpp> +#include <boost/numeric/mtl/utility/irange.hpp> +#include <boost/numeric/mtl/operation/resource.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace itl { + +/// Transposed-free Quasi-minimal residual +template < typename Matrix, typename Vector, + typename LeftPreconditioner, typename RightPreconditioner, typename Iteration > +int tfqmr(const Matrix &A, Vector &x, const Vector &b, const LeftPreconditioner &L, + const RightPreconditioner &R, Iteration& iter) +{ + mtl::vampir_trace<7009> tracer; + using math::reciprocal; using mtl::size; + typedef typename mtl::Collection<Vector>::value_type Scalar; + + if (size(b) == 0) throw mtl::logic_error("empty rhs vector"); + + const Scalar zero= math::zero(Scalar()), one= math::one(Scalar()); + Scalar theta(zero), eta(zero), tau, rho, rhon, sigma, alpha, beta, c; + Vector rt(b - A*Vector(solve(R, x))) /* shift x= R*x */, r(solve(L, rt)), u1(resource(x)), u2(resource(x)), + y1(resource(x)), y2(resource(x)), w(resource(x)), d(resource(x), zero), v(resource(x)); + + if (iter.finished(rt)) + return iter; + y1= w= r; + rt= A * Vector(solve(R, y1)); + u1= v= solve(L,rt); + tau= two_norm(r); + rho= tau * tau; + + // TFQMR iteration + while (! iter.finished(tau)) { + ++iter; + sigma= dot(r,v); + if (sigma == zero) + return iter.fail(1, "tfgmr breakdown, sigma=0 #1"); + alpha= rho / sigma; + + // inner loop + for(int j=1; j < 3; j++) { + if (j == 1) { + w-= alpha * u1; + d= y1+ (theta * theta * eta / alpha) * d; + } else { + y2= y1 - alpha * v; + rt= A * Vector(solve(R, y2)); + u2= solve(L, rt); + w-= alpha * u2; + d= y2 + (theta * theta * eta / alpha) * d; + } + theta= two_norm(w) / tau; + c= reciprocal(sqrt(one + theta*theta)); + tau*= theta * c; + eta= c * c * alpha; + x+= eta * d; + } // end inner loop + if (rho == zero) + return iter.fail(1, "tfgmr breakdown, rho=0 #2"); + rhon= dot(r,w); + beta= rhon/rho; + rho= rhon; + y1= w + beta*y2; + rt= A * Vector(solve(R, y1)); + u1= solve(L, rt); + v= u1 + beta*(u2 + beta*v); + rt= A * x - b; + } + //shift back + x= solve(R, x); + return iter; +} + +/// Solver class for Transposed-free quasi-minimal residual method; right preconditioner ignored (prints warning if not identity) +template < typename LinearOperator, typename Preconditioner= pc::identity<LinearOperator>, + typename RightPreconditioner= pc::identity<LinearOperator> > +class tfqmr_solver +{ + public: + /// Construct solver from a linear operator; generate (left) preconditioner from it + explicit tfqmr_solver(const LinearOperator& A) : A(A), L(A), R(A) {} + + /// Construct solver from a linear operator and left preconditioner + tfqmr_solver(const LinearOperator& A, const Preconditioner& L) : A(A), L(L), R(A) {} + + /// Construct solver from a linear operator and left preconditioner + tfqmr_solver(const LinearOperator& A, const Preconditioner& L, const RightPreconditioner& R) + : A(A), L(L), R(R) {} + + /// Solve linear system approximately as specified by \p iter + template < typename HilbertSpaceB, typename HilbertSpaceX, typename Iteration > + int solve(const HilbertSpaceB& b, HilbertSpaceX& x, Iteration& iter) const + { + return tfqmr(A, x, b, L, R, iter); + } + + /// Perform one TFQMR iteration on linear system + template < typename HilbertSpaceB, typename HilbertSpaceX > + int solve(const HilbertSpaceB& b, HilbertSpaceX& x) const + { + itl::basic_iteration<double> iter(x, 1, 0, 0); + return solve(b, x, iter); + } + + private: + const LinearOperator& A; + Preconditioner L; + RightPreconditioner R; +}; + +} // namespace itl + +#endif // ITL_TFQMR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/minimization/quasi_newton.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/minimization/quasi_newton.hpp new file mode 100644 index 0000000000000000000000000000000000000000..2136952be262c5f759f42ae149c939687b7de40b --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/minimization/quasi_newton.hpp @@ -0,0 +1,61 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef ITL_QUASI_NEWTON_INCLUDE +#define ITL_QUASI_NEWTON_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/matrix/dense2D.hpp> +#include <boost/numeric/mtl/matrix/operators.hpp> +#include <boost/numeric/mtl/operation/operators.hpp> +#include <boost/numeric/mtl/operation/trans.hpp> +#include <boost/numeric/mtl/utility/gradient.hpp> + +// #include <iostream> + +namespace itl { + +/// Quasi-Newton method +template <typename Matrix, typename Vector, typename F, typename Grad, + typename Step, typename Update, typename Iter> +Vector quasi_newton(Vector& x, F f, Grad grad_f, Step step, Update update, Iter& iter) +{ + typedef typename mtl::Collection<Vector>::value_type value_type; + Vector d, y, x_k, s; + Matrix H(size(x), size(x)); + + H= 1; + for (; !iter.finished(two_norm(grad_f(x))); ++iter) { + d= H * -grad_f(x); // std::cout << "d is " << d << '\n'; + value_type alpha= step(x, d, f, grad_f); assert(alpha == alpha); + x_k= x + alpha * d; // std::cout << "x_k is " << x_k << '\n'; + s= alpha * d; // std::cout << "alpha is " << alpha << '\n'; + y= grad_f(x_k) - grad_f(x); + update(H, y, s); + x= x_k; + } + return x; +} + +/// Quasi-Newton method +template <typename Vector, typename F, typename Grad, typename Step, typename Update, typename Iter> +Vector inline quasi_newton(Vector& x, F f, Grad grad_f, Step step, Update update, Iter& iter) +{ + typedef typename mtl::traits::gradient<Vector>::type hessian_type; + // typedef typename mtl::Collection<Vector>::value_type value_type; + return quasi_newton<hessian_type>(x, f, grad_f, step, update, iter); +} + + +} // namespace itl + +#endif // ITL_QUASI_NEWTON_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/pc/binary_heap.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/pc/binary_heap.hpp new file mode 100644 index 0000000000000000000000000000000000000000..399ae33d39bf2305395cd1fa3ce46c464f2d44e2 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/pc/binary_heap.hpp @@ -0,0 +1,607 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. +// +// Algorithm inspired by Nick Vannieuwenhoven, rewritten by Cornelius Steinhardt +// +// Created on: Jan 10, 2010 +// Author: heazk + + +#ifndef MTL_BINARY_HEAP_INCLUDE +#define MTL_BINARY_HEAP_INCLUDE + +namespace utils { + +/** + * An intrusive binary min-heap. + * + * KeyType: The type of the keys. Assumed to be a signed integer type. + * KeyComparator: A functor to compare values of the key type. Should be a + * total order. + */ +template< + class DirectAccessIterator, + class KeyType, + class KeyComparator, + class ValueType, + class GetKey, + class GetParent, + class GetLeft, + class GetRight +> +class binary_heap { + + +/******************************************************************************* + * Type Definitions + ******************************************************************************/ + + +public: + /** + * The value type. + */ + typedef ValueType value_type; + + /** + * The key type. + */ + typedef KeyType key_type; + + /** + * The type of this heap. + */ + typedef binary_heap< + DirectAccessIterator, + KeyType, + KeyComparator, + ValueType, + GetKey, + GetParent, + GetLeft, + GetRight + > heap_type; + + +/******************************************************************************* + * Constructors and Destructors + ******************************************************************************/ + + +public: + binary_heap( + DirectAccessIterator values_begin, + DirectAccessIterator values_end, + KeyComparator compare_keys, + GetKey get_key, + GetParent get_parent, + GetLeft get_left_child, + GetRight get_right_child + ) : + m_root(values_begin), + m_compare_keys(compare_keys), + m_key(get_key), + m_parent(get_parent), + m_left_child(get_left_child), + m_right_child(get_right_child) + { + build_heap(values_begin, values_end); + } + +public: + binary_heap( + KeyComparator compare_keys, + GetKey get_key, + GetParent get_parent, + GetLeft get_left_child, + GetRight get_right_child + ) : + m_root(0), + m_last(0), + m_compare_keys(compare_keys), + m_key(get_key), + m_parent(get_parent), + m_left_child(get_left_child), + m_right_child(get_right_child) + { + } + + /** + * Default destructor. + */ +public: + ~binary_heap() { + // Nothing here. + } + + /** + * Copying of heaps is disallowed. + */ +private: + binary_heap(const heap_type&); + void operator=(const heap_type&); + + +/******************************************************************************* + * Heap Construction and Maintaining + ******************************************************************************/ + + + /** + * Builds the min-heap. + */ +private: + void build_heap( + DirectAccessIterator values_begin, + DirectAccessIterator values_end + ) { + std::cout << "building heap ..." << std::endl; + // Construct heap connections. + const int size = values_end - values_begin; + m_parent(values_begin) = 0; + m_left_child(values_begin) = 1 < size ? values_begin+1 : 0; + m_right_child(values_begin) = 2 < size ? values_begin+2 : 0; + for(int i = 1; i < size; ++i) { + m_parent(values_begin+i) = values_begin+(((i+1)/2) - 1); + m_left_child(values_begin+i) = + 2*(i+1)-1 < size ? values_begin+(2*(i+1)-1) : 0; + m_right_child(values_begin+i) = + 2*(i+1) < size ? values_begin+(2*(i+1)) : 0; + } + + m_root = size > 0 ? values_begin : 0; + m_last = size > 0 ? values_end-1 : 0; + + build_heap_rec(m_root); + + } + + /** + * Applies the min-heapify procedure at each node in postfix style. + */ +private: + void build_heap_rec(value_type node) { + if(node) { +// dump(node); + build_heap_rec(m_left_child(node)); + build_heap_rec(m_right_child(node)); + min_heapify(node); + } + } + + /** + * The min-heapify operation to restore the min heap property at a given + * node. + */ +private: + void min_heapify(value_type node) { + +// std::cout << "heapify: " << m_key(node) << std::endl; + + value_type seek = node; + value_type smallest = seek; + do { + value_type left_child = m_left_child(seek); + value_type right_child = m_right_child(seek); + smallest = seek; + + if( + left_child && + m_compare_keys(left_child, seek) + ) { + smallest = left_child; + } + if( + right_child && + m_compare_keys(right_child, smallest) + ) { + smallest = right_child; + } + if(smallest != seek) { + exchange(smallest, seek); + } + } while(smallest != seek); + + } + + /** + * Exchanges two nodes. + */ +private: + inline void exchange(value_type fst, value_type snd) { + if(!fst && !snd) { + return; + } + if(!fst || !snd) { + assert(false); + } + if(fst == snd) { + return; + } + + // Update root and last pointers. + if(fst == m_root) { + m_root = snd; + } else if(snd == m_root) { + m_root = fst; + } + if(fst == m_last) { + m_last = snd; + } else if(snd == m_last) { + m_last = fst; + } + +// std::cout << "fst pre" << std::endl; +// dump(fst); +// std::cout << "snd pre" << std::endl; +// dump(snd); + + // Canonize the situation when fst and snd are directly connected such + // that fst is always the higher node. + if( m_parent(fst) == snd ) { + value_type tmp = fst; + fst = snd; + snd = tmp; + } + + // Set the new parent pointers for the children. + value_type left_child = m_left_child(fst); + value_type right_child = m_right_child(fst); + if(left_child) { + m_parent(left_child) = snd; + } + if(right_child) { + m_parent(right_child) = snd; + } + left_child = m_left_child(snd); + right_child = m_right_child(snd); + if(left_child) { + m_parent(left_child) = fst; + } + if(right_child) { + m_parent(right_child) = fst; + } + + // Set the new children pointers. + const value_type fst_left_child = m_left_child(fst); + const value_type fst_right_child = m_right_child(fst); + m_left_child(fst) = m_left_child(snd); + m_right_child(fst) = m_right_child(snd); + m_left_child(snd) = fst_left_child; + m_right_child(snd) = fst_right_child; + + // Set the new children pointers of the parents. + if(m_parent(fst)) { + if( m_left_child(m_parent(fst)) == fst ) { + m_left_child(m_parent(fst)) = snd; + } else { + m_right_child(m_parent(fst)) = snd; + } + } + if(m_parent(snd)) { + if( m_left_child(m_parent(snd)) == snd ) { + m_left_child(m_parent(snd)) = fst; + } else { + m_right_child(m_parent(snd)) = fst; + } + } + + // Set the new parent pointers. + const value_type fst_parent = m_parent(fst); + m_parent(fst) = m_parent(snd); + m_parent(snd) = fst_parent; + +// std::cout << "fst post" << std::endl; +// dump(snd); +// std::cout << "snd post" << std::endl; +// dump(fst); + +// if( m_parent(fst) == snd || m_parent(snd) == fst) { +// // Canonize the situation to this whereby fst is the higher node. +// if( m_parent(fst) == snd ) { +// value_type tmp = fst; +// fst = snd; +// snd = tmp; +// } +// +// // Update root and last pointers. +// if(fst == m_root) { +// m_root = snd; +// } +// if(snd == m_last) { +// m_last = fst; +// } +// +// // Get a hold on every value we need. +// value_type fst_parent = m_parent(fst); +// value_type fst_left_child = m_left_child(fst); +// value_type fst_right_child = m_right_child(fst); +// value_type snd_left_child = m_left_child(snd); +// value_type snd_right_child = m_right_child(snd); +// +// // Set up fst's new pointers. +// m_left_child(fst) = snd_left_child; +// m_right_child(fst) = snd_right_child; +// m_parent(snd_left_child) = fst; +// m_parent(snd_right_child) = fst; +// m_parent(fst) = snd; +// +// // Set up snd's new pointers. +// m_parent(snd) = fst_parent; +// if(fst_parent) { +// if( m_left_child(fst_parent) == fst ) { +// m_left_child(fst_parent) = snd; +// } else { +// m_right_child(fst_parent) = snd; +// } +// } +// +// if(fst_left_child == snd) { +// m_parent(fst_right_child) = snd; +// m_right_child(snd) = fst_right_child; +// m_left_child(snd) = fst; +// } else { +// m_parent(fst_left_child) = snd; +// m_left_child(snd) = fst_left_child; +// m_right_child(snd) = fst; +// } +// } + } + + +/******************************************************************************* + * Heap Operations + ******************************************************************************/ + + /** + * Checks whether the heap is empty. + */ +public: + bool empty() { + return m_root == 0; + } + + /** + * Returns a reference to the top of the heap. + */ +public: + value_type& top() { + return m_root; + } + + /** + * Pops the top of the heap. + */ +public: + void pop() { + assert(top()); + assert(m_last); + +// dump(m_root); +// dump(m_last); + + value_type new_last = m_last; + if(m_root != m_last) { + +// std::cout << "gonna exchange" << std::endl; + exchange(m_root, m_last); + + assert(m_root == new_last); + + new_last = m_last; +// std::cout << "donna exchange" << std::endl; + +// dump(m_root); +// dump(m_last); + + // Determine the new "last" node of the tree. + // The algorithm also works when the last node at the deepest level + // is removed. The algorithm will then continue from the rightmost + // node at the level one lower. + while( + m_parent(new_last) && + m_left_child(m_parent(new_last)) == new_last + ) { + new_last = m_parent(new_last); +// std::cout << "moving up ..." << std::endl; + } +// std::cout << "stopped moving up ..." << std::endl; + if(m_parent(new_last)) { + new_last = m_left_child(m_parent(new_last)); +// std::cout << "moved left ..." << std::endl; + } + while(m_right_child(new_last)) { + new_last = m_right_child(new_last); +// std::cout << "moving right ..." << std::endl; + } +// std::cout << "stopped moving right ..." << std::endl; + } + + if( m_parent(m_last) ) { + if( m_left_child(m_parent(m_last)) == m_last ) { + m_left_child(m_parent(m_last)) = 0; + } else { + m_right_child(m_parent(m_last)) = 0; + } + } + m_parent(m_last) = 0; + m_left_child(m_last) = 0; + m_right_child(m_last) = 0; +// m_key(m_last) = -1; + + if(m_root != m_last) { + m_last = new_last; + min_heapify(m_root); + } else { + m_root = m_last = 0; + } + } + + /** + * Updates the key of a given node. + */ +public: + void update_key(value_type node, key_type new_key) { + m_key(node) = new_key; + + value_type seek = node; + while( + m_parent(seek) && + m_compare_keys(seek, m_parent(seek)) + ) { + exchange(seek, m_parent(seek)); + } + } + + /** + * Inserts a new value into the binary heap with the given key. + */ +public: + void insert(value_type node, key_type key) { + + // Special case handling an empty heap. + if(m_last == m_root && m_last == 0) { + m_last = m_root = node; + m_parent(node) = 0; + m_left_child(node) = 0; + m_right_child(node) = 0; + m_key(node) = key; + return; + } + + // Search the new "last" position to insert the new node at. + value_type new_last = m_last; + + // While the current node is right w.r.t. its parent, move up the tree. + while( + m_parent(new_last) && + m_right_child(m_parent(new_last)) == new_last + ) { + new_last = m_parent(new_last); + } + // If there is a right sibling, go to it and descent to the left. + if(m_parent(new_last) && m_right_child(m_parent(new_last))) { + new_last = m_right_child(m_parent(new_last)); + while(m_left_child(new_last)) { + new_last = m_left_child(new_last); + } + } + // If there is a parent at this point, the right sibling does not exist, + // and the given node should be placed there. + if(m_parent(new_last)) { + // Add the node to the tree. + if(m_right_child(m_parent(new_last)) == 0) { + new_last = m_parent(new_last); + m_right_child(new_last) = node; + } else { + m_left_child(new_last) = node; + } + } else { + // We came from the very last node at the current level and hence + // must begin a new level. Descent to the left. + while( m_left_child(new_last) ) { + new_last = m_left_child(new_last); + } + + // Add the node to the tree. + m_left_child(new_last) = node; + } + + m_parent(node) = new_last; + m_left_child(node) = 0; + m_right_child(node) = 0; + m_key(node) = key; + m_last = node; + + // Update the key and force the heap to rebalance itself. + update_key(node, key); + } + + /** + * Removes the node. The operation can safely be applied to an element no + * longer in the heap. + */ +public: + void remove(value_type node) { + if( m_parent(node) == 0 && m_root != node) { + return; + } + + // Move the node up the tree. + value_type seek = node; + while(m_parent(seek)) { + exchange(seek, m_parent(seek)); + } + // Remove it. + pop(); + } + + +public: + void dump(value_type node) { + std::cout << "seq: " << node->get_sequence_number() << std::endl; + std::cout << "key: " << m_key(node) << std::endl; + std::cout << "par: " << (m_parent(node) ? (m_parent(node))->get_sequence_number() : -1) << std::endl; + std::cout << "lef: " << (m_left_child(node) ? (m_left_child(node))->get_sequence_number() : -1) << std::endl; + std::cout << "rig: " << (m_right_child(node) ? (m_right_child(node))->get_sequence_number() : -1) << std::endl; + + } + +/******************************************************************************* + * Data Members + ******************************************************************************/ + + +public: + /** + * The root of the binary heap. + */ + ValueType m_root; + + /** + * The "last" node of the binary heap. The last node is the node that can + * safely be removed such that the resulting tree is still a complete binary + * tree, with the additional constraint that the nodes in the last level are + * all in the "left" part of the tree. + */ + ValueType m_last; + + /** + * A functor to compare keys. + */ + KeyComparator m_compare_keys; + + /** + * A functor to obtain the key. + */ + GetKey m_key; + + /** + * A functor to obtain the parent. + */ + GetParent m_parent; + + /** + * A functor to obtain the left child. + */ + GetLeft m_left_child; + + /** + * A functor to obtain the right child. + */ + GetRight m_right_child; + +}; + +} + +#endif // MTL_BINARY_HEAP_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/pc/comparators.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/pc/comparators.hpp new file mode 100644 index 0000000000000000000000000000000000000000..5d660c2b1585fe08342ac44a35e8fa51c6be212a --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/pc/comparators.hpp @@ -0,0 +1,64 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. +// +// Algorithm inspired by Nick Vannieuwenhoven, written by Cornelius Steinhardt + + + +/* + * + * Created on: Oct 14, 2010 + * Author: heazk + */ + + +#ifndef MTL_COMPARATORS_INCLUDE +#define MTL_COMPARATORS_INCLUDE + +#define POINTER long + +namespace compare { + +/** + * Compares two given pointers based on the address to which they point. + */ +template<class Type> +struct address_compare { + bool operator()(const Type *const a, const Type *const b) const { + return reinterpret_cast<POINTER>(a) < reinterpret_cast<POINTER>(b); + } +}; + +/** + * Compares two given pointers based on the address to which they point. + */ +template<class Type> +struct address_compare_equal { + bool operator()(const Type *const a, const Type *const b) const { + return reinterpret_cast<POINTER>(a) == reinterpret_cast<POINTER>(b); + } +}; + +/** + * Hashes a given pointer based on its address. + */ +template<class Type> +struct address_hasher { + POINTER operator()(const Type *const a) const { + return reinterpret_cast<POINTER>(a); + } +}; + +} // end namespace compare + + +#endif // MTL_COMPARATORS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/pc/concat.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/pc/concat.hpp new file mode 100644 index 0000000000000000000000000000000000000000..6fd880b4d073b701e1c02222d24f3f03568f9665 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/pc/concat.hpp @@ -0,0 +1,117 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef ITL_PC_CONCAT_INCLUDE +#define ITL_PC_CONCAT_INCLUDE + +#include <boost/mpl/if.hpp> +#include <boost/numeric/mtl/operation/resource.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> +#include <boost/numeric/itl/pc/solver.hpp> + +namespace itl { namespace pc { + +/// Class for concatenating \tparam PC1 and \tparam PC2 +template <typename PC1, typename PC2, typename Matrix, bool Store1= true, bool Store2= true> +class concat +{ + typedef typename boost::mpl::if_c<Store1, PC1, const PC1&>::type pc1_type; + typedef typename boost::mpl::if_c<Store2, PC2, const PC2&>::type pc2_type; + + public: + /// Construct both preconditioners from matrix \p A + explicit concat(const Matrix& A) : A(A), pc1(A), pc2(A) + { + BOOST_STATIC_ASSERT((Store1 && Store2)); + } + + /// Both preconditioners are already constructed and passed as arguments + /** If pc1 or pc2 is only constructed temporarily in the constructor call, + the according Store argument must be true; otherwise the preconditioner + will be a stale reference. + Conversely, if the preconditioner is already build outside the constructor call, + the according Store argument should be false for not storing the preconditioner twice. **/ + concat(const Matrix& A, const PC1& pc1, const PC2& pc2) : A(A), pc1(pc1), pc2(pc2) {} + + private: + template <typename VectorOut> + VectorOut& create_r(const VectorOut& y) const + { + static VectorOut r(resource(y)); + return r; + } + + template <typename VectorOut> + VectorOut& create_d(const VectorOut& y) const + { + static VectorOut d(resource(y)); + return d; + } + + public: + /// Concatenated preconditioning: pc2 is applied regularly and pc1 afterwards by defect correction + template <typename VectorIn, typename VectorOut> + void solve(const VectorIn& x, VectorOut& y) const + { + mtl::vampir_trace<5058> tracer; + y.checked_change_resource(x); + pc2.solve(x, y); + + VectorOut &r= create_r(y), &d= create_d(y); + r= x; + r-= A * y; + + pc1.solve(r, d); + y+= d; + } + + + /// Concatenated preconditioning: adjoint of pc1 is applied regularly and pc2's adjoint afterwards by defect correction + template <typename VectorIn, typename VectorOut> + void adjoint_solve(const VectorIn& x, VectorOut& y) const + { + mtl::vampir_trace<5059> tracer; + y.checked_change_resource(x); + pc1.adjoint_solve(x, y); + + VectorOut &r= create_r(y), &d= create_d(y); + r= x; + r-= adjoint(A) * y; + + pc2.adjoint_solve(r, d); + y+= d; + } + + private: + const Matrix& A; + pc1_type pc1; + pc2_type pc2; +}; + +template <typename PC1, typename PC2, typename Matrix, bool Store1, bool Store2, typename Vector> +solver<concat<PC1, PC2, Matrix, Store1, Store2>, Vector, false> +inline solve(const concat<PC1, PC2, Matrix, Store1, Store2>& P, const Vector& x) +{ + return solver<concat<PC1, PC2, Matrix, Store1, Store2>, Vector, false>(P, x); +} + +template <typename PC1, typename PC2, typename Matrix, bool Store1, bool Store2, typename Vector> +solver<concat<PC1, PC2, Matrix, Store1, Store2>, Vector, true> +inline adjoint_solve(const concat<PC1, PC2, Matrix, Store1, Store2>& P, const Vector& x) +{ + return solver<concat<PC1, PC2, Matrix, Store1, Store2>, Vector, true>(P, x); +} + + +}} // namespace itl::pc + +#endif // ITL_PC_CONCAT_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/pc/diagonal.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/pc/diagonal.hpp new file mode 100644 index 0000000000000000000000000000000000000000..12c02e048d57d71e5900e91dcf0af7c934bbb89d --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/pc/diagonal.hpp @@ -0,0 +1,108 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef ITL_PC_DIAGONAL_INCLUDE +#define ITL_PC_DIAGONAL_INCLUDE + +#include <boost/numeric/linear_algebra/inverse.hpp> + +#include <boost/numeric/mtl/vector/dense_vector.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/operation/resource.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> +#include <boost/numeric/itl/pc/solver.hpp> + +namespace itl { namespace pc { + +/// Diagonal Preconditioner +template <typename Matrix, typename Value= typename mtl::Collection<Matrix>::value_type> +class diagonal +{ + public: + typedef Value value_type; + typedef typename mtl::Collection<Matrix>::size_type size_type; + typedef diagonal self; + + /// Constructor takes matrix reference + explicit diagonal(const Matrix& A) : inv_diag(num_rows(A)) + { + mtl::vampir_trace<5050> tracer; + MTL_THROW_IF(num_rows(A) != num_cols(A), mtl::matrix_not_square()); + using math::reciprocal; + + for (size_type i= 0; i < num_rows(A); ++i) + inv_diag[i]= reciprocal(A[i][i]); + } + + /// Member function solve, better use free function solve + template <typename Vector> + Vector solve(const Vector& x) const + { + Vector y(resource(x)); + solve(x, y); + return y; + } + + template <typename VectorIn, typename VectorOut> + void solve(const VectorIn& x, VectorOut& y) const + { + mtl::vampir_trace<5051> tracer; + y.checked_change_resource(x); + MTL_THROW_IF(size(x) != size(inv_diag), mtl::incompatible_size()); + for (size_type i= 0; i < size(inv_diag); ++i) + y[i]= inv_diag[i] * x[i]; + } + + /// Member function for solving adjoint problem, better use free function adjoint_solve + template <typename Vector> + Vector adjoint_solve(const Vector& x) const + { + Vector y(resource(x)); + adjoint_solve(x, y); + return y; + } + + template <typename VectorIn, typename VectorOut> + void adjoint_solve(const VectorIn& x, VectorOut& y) const + { + using mtl::conj; + y.checked_change_resource(x); + MTL_THROW_IF(size(x) != size(inv_diag), mtl::incompatible_size()); + for (size_type i= 0; i < size(inv_diag); ++i) + y[i]= conj(inv_diag[i]) * x[i]; + } + + protected: + mtl::vector::dense_vector<value_type> inv_diag; +}; + +/// Solve approximately a sparse system in terms of inverse diagonal +template <typename Matrix, typename Vector> +solver<diagonal<Matrix>, Vector, false> +inline solve(const diagonal<Matrix>& P, const Vector& x) +{ + return solver<diagonal<Matrix>, Vector, false>(P, x); +} + +/// Solve approximately the adjoint of a sparse system in terms of inverse diagonal +template <typename Matrix, typename Vector> +solver<diagonal<Matrix>, Vector, true> +inline adjoint_solve(const diagonal<Matrix>& P, const Vector& x) +{ + return solver<diagonal<Matrix>, Vector, true>(P, x); +} + + +}} // namespace itl::pc + +#endif // ITL_PC_DIAGONAL_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/pc/ic_0.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/pc/ic_0.hpp new file mode 100644 index 0000000000000000000000000000000000000000..d38b8b4a5ac0c2564cbeaa64ef6a7726090ca464 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/pc/ic_0.hpp @@ -0,0 +1,278 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef ITL_PC_IC_0_INCLUDE +#define ITL_PC_IC_0_INCLUDE + +#include <boost/mpl/bool.hpp> + +#include <boost/numeric/linear_algebra/identity.hpp> +#include <boost/numeric/linear_algebra/inverse.hpp> + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/ashape.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/operation/lower_trisolve.hpp> +#include <boost/numeric/mtl/operation/upper_trisolve.hpp> +#include <boost/numeric/mtl/matrix/upper.hpp> +#include <boost/numeric/mtl/matrix/strict_lower.hpp> +#include <boost/numeric/mtl/matrix/compressed2D.hpp> +#include <boost/numeric/mtl/matrix/parameter.hpp> +#include <boost/numeric/mtl/matrix/transposed_view.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> +#include <boost/numeric/itl/pc/solver.hpp> + + +namespace itl { namespace pc { + +template <typename Matrix, typename Value= typename mtl::Collection<Matrix>::value_type> +class ic_0 +{ + public: + typedef Value value_type; + typedef typename mtl::Collection<Matrix>::size_type size_type; + typedef ic_0 self; + + typedef mtl::matrix::parameters<mtl::row_major, mtl::index::c_index, mtl::non_fixed::dimensions, false, size_type> para; + typedef mtl::matrix::compressed2D<value_type, para> U_type; +#ifndef ITL_IC_0_ONE_MATRIX + typedef U_type L_type; +#else + typedef typename mtl::matrix::transposed_view<U_type> L_type; +#endif + typedef mtl::matrix::detail::lower_trisolve_t<L_type, mtl::tag::inverse_diagonal, true> lower_solver_t; + typedef mtl::matrix::detail::upper_trisolve_t<U_type, mtl::tag::inverse_diagonal, true> upper_solver_t; + + ic_0(const Matrix& A) : f(A, U), L(trans(U)), lower_solver(L), upper_solver(U) {} + + + // solve x = U^* U y --> y= U^{-1} U^{-*} x + template <typename Vector> + Vector solve(const Vector& x) const + { + mtl::vampir_trace<5036> tracer; + return inverse_upper_trisolve(U, inverse_lower_trisolve(adjoint(U), x)); + } + + // solve x = U^* y --> y0= U^{-*} x + template <typename VectorIn, typename VectorOut> + const VectorOut& solve_lower(const VectorIn& x, VectorOut&) const + { + static VectorOut y0; + y0.change_resource(resource(x)); + lower_solver(x, y0); + return y0; + } + + // solve x = U^* U y --> y= U^{-1} U^{-*} x + template <typename VectorIn, typename VectorOut> + void solve(const VectorIn& x, VectorOut& y) const + { + mtl::vampir_trace<5037> tracer; + const VectorOut& y0= solve_lower(x, y); + + y.checked_change_resource(x); + upper_solver(y0, y); + } + + // solve x = (LU)^* y --> y= L^{-*} U^{-*} x + template <typename Vector> + Vector adjoint_solve(const Vector& x) const + { + mtl::vampir_trace<5044> tracer; + return solve(x); + } + + // solve x = (LU)^* y --> y= L^{-*} U^{-*} x + template <typename VectorIn, typename VectorOut> + void adjoint_solve(const VectorIn& x, VectorOut& y) const + { + mtl::vampir_trace<5044> tracer; + solve(x, y); + } + + + L_type get_L() { return L_type(L); } + U_type get_U() { return U; } + + protected: + template <typename VectorOut, typename Solver> friend struct ic_0_evaluator; + + // Dummy type to perform factorization in initializer list not in + struct factorizer + { + factorizer(const Matrix &A, U_type& U) + { factorize(A, U, mtl::traits::is_sparse<Matrix>(), boost::is_same<Value, typename mtl::Collection<Matrix>::value_type>()); } + + template <typename T> + void factorize(const Matrix&, U_type&, boost::mpl::false_, T) + { MTL_THROW_IF(true, mtl::logic_error("IC(0) is not suited for dense matrices")); } + + // When we change the value_type then the factorization is still performed with that of A + template <typename UF> + void factorize(const Matrix& A, UF& U, boost::mpl::true_, boost::mpl::false_) + { + typedef mtl::matrix::compressed2D<typename mtl::Collection<Matrix>::value_type, para> tmp_type; + tmp_type U_tmp; + factorize(A, U_tmp, boost::mpl::true_(), boost::mpl::true_()); + U= U_tmp; + } + + // Factorization adapted from Saad + // Undefined (runtime) behavior if matrix is not symmetric + // UF is type for the factorization + template <typename UF> + void factorize(const Matrix& A, UF& U, boost::mpl::true_, boost::mpl::true_) + { + using namespace mtl; using namespace mtl::tag; using mtl::traits::range_generator; + using math::reciprocal; using mtl::matrix::upper; + mtl::vampir_trace<5035> tracer; + + // For the factorization we take still the value_type of A and later we copy it maybe to another value_type + typedef typename mtl::Collection<Matrix>::value_type value_type; + typedef typename range_generator<row, UF>::type cur_type; + typedef typename range_generator<nz, cur_type>::type icur_type; + + MTL_THROW_IF(num_rows(A) != num_cols(A), mtl::matrix_not_square()); + U= upper(A); + + typename mtl::traits::col<UF>::type col(U); + typename mtl::traits::value<UF>::type value(U); + + cur_type kc= begin<row>(U), kend= end<row>(U); + for (size_type k= 0; kc != kend; ++kc, ++k) { + + icur_type ic= begin<nz>(kc), iend= end<nz>(kc); + MTL_DEBUG_THROW_IF(col(*ic) != k, mtl::missing_diagonal()); + + // U[k][k]= 1.0 / sqrt(U[k][k]); + value_type inv_dia= reciprocal(sqrt(value(*ic))); + value(*ic, inv_dia); + // icur_type jbegin= + ++ic; + for (; ic != iend; ++ic) { + // U[k][i] *= U[k][k] + value_type d= value(*ic) * inv_dia; + value(*ic, d); + size_type i= col(*ic); + + // find non-zeros U[j][i] below U[k][i] for j in (k, i] + // 1. Go to ith row in U (== ith column in U) + cur_type irow(i, U); // = begin<row>(U); irow+= i; + // 2. Find nonzeros with col() in (k, i] + icur_type jc= begin<nz>(irow), jend= end<nz>(irow); + while (col(*jc) <= k) ++jc; + while (col(*--jend) > i) ; + ++jend; + + for (; jc != jend; ++jc) { + size_type j= col(*jc); + U.lvalue(j, i)-= d * U[k][j]; + } + // std::cout << "U after eliminating U[" << i << "][" << k << "] =\n" << U; + } + } + } + }; + + U_type U; + factorizer f; + L_type L; + lower_solver_t lower_solver; + upper_solver_t upper_solver; +}; + +#if 0 +template <typename Matrix, typename Value, typename Vector> +struct ic_0_solver + : mtl::vector::assigner<ic_0_solver<Matrix, Value, Vector> > +{ + typedef ic_0<Matrix, Value> pc_type; + + ic_0_solver(const ic_0<Matrix, Value>& P, const Vector& x) : P(P), x(x) {} + + template <typename VectorOut> + void assign_to(VectorOut& y) const + { P.solve(x, y); } + + const ic_0<Matrix, Value>& P; + const Vector& x; +}; +#endif + +template <typename VectorOut, typename Solver> +struct ic_0_evaluator +{ + typedef typename Solver::pc_type pc_type; + typedef typename pc_type::size_type size_type; + typedef typename mtl::Collection<VectorOut>::value_type out_value_type; + + + ic_0_evaluator(VectorOut& y, const Solver& s) + : y(y), s(s), U(s.P.U), y0(s.P.solve_lower(s.x, y)) { MTL_DEBUG_ARG(lr= 99999999); } + + + void operator()(size_type i) { at<0>(i); } + void operator[](size_type i) { at<0>(i); } + + template <unsigned Offset> + void at(size_type r) + { +#ifndef NDEBUG + MTL_THROW_IF(r+Offset >= lr, mtl::logic_error("Traversal must be backward")); lr= r+Offset; +#endif + size_type j0= U.ref_major()[r+Offset]; + const size_type cj1= U.ref_major()[r+Offset+1]; + MTL_DEBUG_THROW_IF(j0 == cj1 || U.ref_minor()[j0] != r+Offset, mtl::missing_diagonal()); + out_value_type rr= y0[r+Offset], dia= U.data[j0++]; + for (; j0 != cj1; ++j0) { + MTL_DEBUG_THROW_IF(U.ref_minor()[j0] <= r+Offset, mtl::logic_error("Matrix entries must be sorted for this.")); + rr-= U.data[j0] * y[U.ref_minor()[j0]]; + } + y[r+Offset]= rr * dia; + } + + VectorOut& y; + const Solver& s; + const typename pc_type::U_type& U; + const VectorOut& y0; + MTL_DEBUG_ARG(size_type lr;) +}; + +template <typename VectorOut, typename Solver> +inline std::size_t size(const ic_0_evaluator<VectorOut, Solver>& eval) +{ return size(eval.y); } + +template <typename Matrix, typename Value, typename Vector> +solver<ic_0<Matrix, Value>, Vector, false> +inline solve(const ic_0<Matrix, Value>& P, const Vector& x) +{ + return solver<ic_0<Matrix, Value>, Vector, false>(P, x); +} + +template <typename Matrix, typename Value, typename Vector> +solver<ic_0<Matrix, Value>, Vector, true> +inline adjoint_solve(const ic_0<Matrix, Value>& P, const Vector& x) +{ + return solver<ic_0<Matrix, Value>, Vector, true>(P, x); +} + + +}} // namespace itl::pc + +namespace mtl { namespace vector { + using itl::pc::size; +}} // namespace mtl::vector + +#endif // ITL_PC_IC_0_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/pc/identity.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/pc/identity.hpp new file mode 100644 index 0000000000000000000000000000000000000000..22d46f02e4808a62e776d223962301ff3cbd453a --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/pc/identity.hpp @@ -0,0 +1,76 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef ITL_PC_IDENTITY_INCLUDE +#define ITL_PC_IDENTITY_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> +#include <boost/numeric/itl/pc/solver.hpp> + +namespace itl { namespace pc { + +/// Identity preconditioner, i.e. no preconditioning and vector is just copied +/** Second template is just for a uniform interface with other preconditioners. **/ +template <typename Matrix, typename Value= double> +class identity +{ + public: + typedef typename mtl::Collection<Matrix>::value_type value_type; + typedef typename mtl::Collection<Matrix>::size_type size_type; + typedef identity self; + + identity(const Matrix&) {} + + template <typename Vector> + Vector solve(const Vector& x) const + { + mtl::vampir_trace<5032> tracer; + return x; + } + + template <typename VectorIn, typename VectorOut> + void solve(const VectorIn& b, VectorOut& x) const + { + mtl::vampir_trace<5032> tracer; + x= b; + } + + template <typename Vector> + Vector adjoint_solve(const Vector& x) const + { + mtl::vampir_trace<5034> tracer; + return x; + } + + template <typename VectorIn, typename VectorOut> + void adjoint_solve(const VectorIn& b, VectorOut& x) const + { + mtl::vampir_trace<5034> tracer; + x= b; + } +}; + +template <typename Matrix, typename Vector> +solver<identity<Matrix>, Vector, false> +inline solve(const identity<Matrix>& P, const Vector& x) +{ return solver<identity<Matrix>, Vector, false>(P, x); } + +template <typename Matrix, typename Vector> +solver<identity<Matrix>, Vector, true> +inline adjoint_solve(const identity<Matrix>& P, const Vector& x) +{ return solver<identity<Matrix>, Vector, true>(P, x); } + + +}} // namespace itl::pc + +#endif // ITL_PC_IDENTITY_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/pc/ilu.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/pc/ilu.hpp new file mode 100644 index 0000000000000000000000000000000000000000..1be76edc3130be98d27ef4c7ce574fdc789404c5 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/pc/ilu.hpp @@ -0,0 +1,212 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef ITL_PC_ILU_INCLUDE +#define ITL_PC_ILU_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/operation/adjoint.hpp> +#include <boost/numeric/mtl/operation/lower_trisolve.hpp> +#include <boost/numeric/mtl/operation/upper_trisolve.hpp> +#include <boost/numeric/mtl/operation/lu.hpp> +#include <boost/numeric/mtl/matrix/parameter.hpp> +#include <boost/numeric/mtl/matrix/compressed2D.hpp> +#include <boost/numeric/mtl/matrix/dense2D.hpp> +#include <boost/numeric/mtl/vector/dense_vector.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> +#include <boost/numeric/itl/pc/solver.hpp> + +namespace itl { namespace pc { + +/// Incomplete LU factorization of a \p Matrix into matrices of type \p Value using a \p Factorizer (e.g. ILU(0) or ILUT) +template <typename Matrix, typename Factorizer, typename Value= typename mtl::Collection<Matrix>::value_type> +class ilu +{ + public: + typedef Value value_type; + typedef typename mtl::Collection<Matrix>::size_type size_type; + typedef ilu self; + typedef Factorizer factorizer_type; + + typedef mtl::matrix::parameters<mtl::row_major, mtl::index::c_index, mtl::non_fixed::dimensions, false, size_type> para; + typedef mtl::matrix::compressed2D<value_type, para> L_type; + typedef mtl::matrix::compressed2D<value_type, para> U_type; + typedef typename mtl::matrix::traits::adjoint<L_type>::type adjoint_L_type; + typedef typename mtl::matrix::traits::adjoint<U_type>::type adjoint_U_type; + + typedef mtl::matrix::detail::lower_trisolve_t<L_type, mtl::tag::unit_diagonal, true> lower_solver_t; + typedef mtl::matrix::detail::upper_trisolve_t<U_type, mtl::tag::inverse_diagonal, true> upper_solver_t; + + typedef mtl::matrix::detail::lower_trisolve_t<adjoint_U_type, mtl::tag::inverse_diagonal, true> adjoint_lower_solver_t; + typedef mtl::matrix::detail::upper_trisolve_t<adjoint_L_type, mtl::tag::unit_diagonal, true> adjoint_upper_solver_t; + + /// Factorization adapted from Saad + explicit ilu(const Matrix& A) + : f(A, L, U), lower_solver(L), upper_solver(U), adjoint_L(adjoint(L)), adjoint_U(adjoint(U)), + adjoint_lower_solver(adjoint_U), adjoint_upper_solver(adjoint_L) {} + + template <typename FactPara> + ilu(const Matrix& A, const FactPara& p) + : f(A, p, L, U), lower_solver(L), upper_solver(U), adjoint_L(adjoint(L)), adjoint_U(adjoint(U)), + adjoint_lower_solver(adjoint_U), adjoint_upper_solver(adjoint_L) {} + + /// Solve LU y = x --> y= U^{-1} L^{-1} x + template <typename Vector> + Vector solve(const Vector& x) const + { + Vector y; + solve(x, y); + return y; + } + + // solve x = L y --> y0= L^{-1} x + template <typename VectorIn, typename VectorOut> + const VectorOut& solve_lower(const VectorIn& x, VectorOut&) const + { + static VectorOut y0; + y0.change_resource(resource(x)); + lower_solver(x, y0); + return y0; + } + + // Solve LU y = x --> y= U^{-1} L^{-1} x + template <typename VectorIn, typename VectorOut> + void solve(const VectorIn& x, VectorOut& y) const + { + mtl::vampir_trace<5039> tracer; + const VectorOut& y0= solve_lower(x, y); + + y.checked_change_resource(x); + upper_solver(y0, y); + } + + + /// Solve (LU)^H y = x --> y= L^{-H} U^{-H} x + template <typename Vector> + Vector adjoint_solve(const Vector& x) const + { + mtl::vampir_trace<5040> tracer; + Vector y(resource(x)); + adjoint_solve(x, y); + return y; + } + + /// Solve (LU)^H y = x --> y= L^{-H} U^{-H} x + template <typename VectorIn, typename VectorOut> + void adjoint_solve(const VectorIn& x, VectorOut& y) const + { + mtl::vampir_trace<5040> tracer; + y.checked_change_resource(x); + // y= unit_upper_trisolve(adjoint(L), inverse_lower_trisolve(adjoint(U), x)); + static VectorOut y0; + y0.change_resource(resource(x)); + adjoint_lower_solver(x, y0); + adjoint_upper_solver(y0, y); + } + + + L_type get_L() { return L; } + U_type get_U() { return U; } + + public: + L_type L; + U_type U; + private: + Factorizer f; + lower_solver_t lower_solver; + upper_solver_t upper_solver; + adjoint_L_type adjoint_L; + adjoint_U_type adjoint_U; + adjoint_lower_solver_t adjoint_lower_solver; + adjoint_upper_solver_t adjoint_upper_solver; + +}; + +template <typename Value, typename Factorizer, typename V2> +class ilu<mtl::matrix::dense2D<Value, mtl::matrix::parameters<> >, Factorizer, V2> // last 2 arguments are dummies +{ + public: + typedef mtl::matrix::dense2D<Value, mtl::matrix::parameters<> > Matrix; + typedef typename mtl::Collection<Matrix>::value_type value_type; + typedef typename mtl::Collection<Matrix>::size_type size_type; + typedef ilu self; + typedef Matrix LU_type; + + ilu(const Matrix& A) : LU(A) { lu(LU, P); std::cout << "LU is\n" << LU << "P is " << P << "\n"; } + + // Solve P^{-1}LU x = b --> x= U^{-1} L^{-1} P b + template <typename Vector> + Vector solve(const Vector& b) const { return lu_apply(LU, P, b); } + + // Solve P^{-1}LU x = b --> x= U^{-1} L^{-1} P b + template <typename VectorIn, typename VectorOut> + void solve(const VectorIn& b, VectorOut& x) const { x= lu_apply(LU, P, b); } + + // Solve (P^{-1}LU)^H x = b --> x= P^{-1}L^{-H} U^{-H} b // P^{-1}^{-1}^H = P^{-1}) + template <typename Vector> + Vector adjoint_solve(const Vector& b) const { return lu_adjoint_apply(LU, P, b); } + + // Solve (P^{-1}LU)^H x = b --> x= P^{-1}L^{-H} U^{-H} b // P^{-1}^{-1}^H = P^{-1}) + template <typename VectorIn, typename VectorOut> + void adjoint_solve(const VectorIn& b, VectorOut& x) const { x= lu_adjoint_apply(LU, P, b); } + + private: + LU_type LU; + mtl::vector::dense_vector<size_type, mtl::vector::parameters<> > P; +}; + +#if 0 +template <typename Matrix, typename Factorizer, typename Value, typename Vector> +struct ilu_solver + : mtl::vector::assigner<ilu_solver<Matrix, Factorizer, Value, Vector> > +{ + typedef ilu<Matrix, Factorizer, Value> pc_type; + + ilu_solver(const pc_type& P, const Vector& x) : P(P), x(x) {} + + template <typename VectorOut> + void assign_to(VectorOut& y) const + { P.solve(x, y); } + + const pc_type& P; + const Vector& x; +}; +#endif + + + +/// Solve LU x = b --> x= U^{-1} L^{-1} b +template <typename Matrix, typename Factorizer, typename Value, typename Vector> +// ilu_solver<Matrix, Factorizer, Value, Vector> +solver<ilu<Matrix, Factorizer, Value>, Vector, false> +inline solve(const ilu<Matrix, Factorizer, Value>& P, const Vector& x) +{ + return solver<ilu<Matrix, Factorizer, Value>, Vector, false>(P, x); +} + + +/// Solve (LU)^H x = b --> x= L^{-H} U^{-H} b +template <typename Matrix, typename Factorizer, typename Value, typename Vector> +// Vector +solver<ilu<Matrix, Factorizer, Value>, Vector, true> +inline adjoint_solve(const ilu<Matrix, Factorizer, Value>& P, const Vector& b) +{ + return solver<ilu<Matrix, Factorizer, Value>, Vector, true>(P, b); +} + +// ic_0_evaluator not needed IC(0) and ILU(0) do the same at the upper triangle ;-) + +}} // namespace itl::pc + + +#endif // ITL_PC_ILU_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/pc/ilu_0.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/pc/ilu_0.hpp new file mode 100644 index 0000000000000000000000000000000000000000..3e2109e8d413f6c98cf41245bdc0f02e42602c2f --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/pc/ilu_0.hpp @@ -0,0 +1,99 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef ITL_PC_ILU_0_INCLUDE +#define ITL_PC_ILU_0_INCLUDE + +#include <boost/mpl/bool.hpp> +#include <boost/numeric/linear_algebra/identity.hpp> + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/operation/invert_diagonal.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/matrix/strict_lower.hpp> +#include <boost/numeric/mtl/matrix/upper.hpp> +#include <boost/numeric/mtl/matrix/compressed2D.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +#include <boost/numeric/itl/pc/ilu.hpp> + +namespace itl { namespace pc { + +// Dummy type to perform factorization in initializer list not in +struct ilu_0_factorizer +{ + template <typename Matrix, typename L_type, typename U_type> + ilu_0_factorizer(const Matrix &A, L_type& L, U_type& U) + { factorize(A, L, U, mtl::traits::is_sparse<Matrix>()); } + + template <typename Matrix, typename L_type, typename U_type> + void factorize(const Matrix&, L_type&, U_type&, boost::mpl::false_) + { MTL_THROW_IF(true, mtl::logic_error("ILU is not intended for dense matrices")); } + + template <typename Matrix, typename L_type, typename U_type> + void factorize(const Matrix& A, L_type& L, U_type& U, boost::mpl::true_) + { + using namespace mtl; using namespace mtl::tag; using mtl::traits::range_generator; + using math::reciprocal; + MTL_THROW_IF(num_rows(A) != num_cols(A), mtl::matrix_not_square()); + mtl::vampir_trace<5038> tracer; + + typedef typename mtl::Collection<Matrix>::value_type value_type; + typedef typename mtl::Collection<Matrix>::size_type size_type; + typedef mtl::matrix::parameters<mtl::row_major, mtl::index::c_index, mtl::non_fixed::dimensions, false, size_type> para; + typedef mtl::matrix::compressed2D<value_type, para> LU_type; + LU_type LU(A); + + typedef typename range_generator<row, LU_type>::type cur_type; + typedef typename range_generator<nz, cur_type>::type icur_type; + typename mtl::traits::col<LU_type>::type col(LU); + typename mtl::traits::value<LU_type>::type value(LU); + mtl::vector::dense_vector<value_type, mtl::vector::parameters<> > inv_dia(num_rows(A)); + cur_type ic= begin<row>(LU), iend= end<row>(LU); + for (size_type i= 0; ic != iend; ++ic, ++i) { + + for (icur_type kc= begin<nz>(ic), kend= end<nz>(ic); kc != kend; ++kc) { + size_type k= col(*kc); + if (k == i) break; + + value_type aik= value(*kc) * inv_dia[k]; + value(*kc, aik); + + for (icur_type jc= kc + 1; jc != kend; ++jc) + value(*jc, value(*jc) - aik * LU[k][col(*jc)]); + // std::cout << "LU after eliminating A[" << i << "][" << k << "] =\n" << LU; + } + inv_dia[i]= reciprocal(LU[i][i]); + } + invert_diagonal(LU); + L= strict_lower(LU); + U= upper(LU); + } +}; + +template <typename Matrix, typename Value= typename mtl::Collection<Matrix>::value_type> +class ilu_0 + : public ilu<Matrix, ilu_0_factorizer, Value> +{ + typedef ilu<Matrix, ilu_0_factorizer, Value> base; + public: + ilu_0(const Matrix& A) : base(A) {} +}; + +// ic_0_evaluator not needed IC(0) and ILU(0) do the same at the upper triangle ;-) + +}} // namespace itl::pc + + +#endif // ITL_PC_ILU_0_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/pc/ilut.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/pc/ilut.hpp new file mode 100644 index 0000000000000000000000000000000000000000..707d2f7bf7579661612d03f2ba964e7662ab21ff --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/pc/ilut.hpp @@ -0,0 +1,137 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef ITL_PC_ILUT_INCLUDE +#define ITL_PC_ILUT_INCLUDE + +#include <boost/numeric/mtl/vector/sparse_vector.hpp> +#include <boost/numeric/mtl/operation/invert_diagonal.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace itl { namespace pc { + + +struct ilut_factorizer +{ + + template <typename Matrix, typename Para, typename L_type, typename U_type> + ilut_factorizer(const Matrix &A, const Para& p, L_type& L, U_type& U) + { factorize(A, p, L, U, mtl::traits::is_row_major<Matrix>()); } + + // column-major matrices are copied first + template <typename Matrix, typename Para, typename L_type, typename U_type, bool B> + void factorize(const Matrix &A, const Para& p, L_type& L, U_type& U, boost::mpl::bool_<B>) + { + typedef typename mtl::Collection<Matrix>::value_type value_type; + typedef typename mtl::Collection<Matrix>::size_type size_type; + typedef mtl::matrix::parameters<mtl::row_major, mtl::index::c_index, mtl::non_fixed::dimensions, false, size_type> para; + typedef mtl::matrix::compressed2D<value_type, para> LU_type; + LU_type LU(A); + factorize(LU, p, L, U, boost::mpl::true_()); + } + + // According Yousef Saad: ILUT, NLAA, Vol 1(4), 387-402 (1994) +#if 0 + template <typename Value, typename MPara, typename Para, typename L_type, typename U_type> + factorize(const mtl::matrix::compressed2D<Value, MPara>& A, const Para& p, L_type& L, U_type& U, boost::mpl::true_) +#endif + + template <typename Matrix, typename Para, typename L_type, typename U_type> + void factorize(const Matrix& A, const Para& p, L_type& L, U_type& U, boost::mpl::true_) + + { + mtl::vampir_trace<5049> tracer; + using std::abs; using mtl::traits::range_generator; using mtl::begin; using mtl::end; + using namespace mtl::tag; + MTL_THROW_IF(num_rows(A) != num_cols(A), mtl::matrix_not_square()); + + typedef typename mtl::Collection<Matrix>::value_type value_type; + typedef typename mtl::Collection<Matrix>::size_type size_type; + typedef typename range_generator<row, Matrix>::type cur_type; + typedef typename range_generator<nz, cur_type>::type icur_type; + typename mtl::traits::col<Matrix>::type col(A); + typename mtl::traits::const_value<Matrix>::type value(A); + + size_type n= num_rows(A); + L.change_dim(n, n); + U.change_dim(n, n); + { + mtl::matrix::inserter<L_type> L_ins(L, p.first); + mtl::matrix::inserter<U_type> U_ins(U, p.first + 1); // plus one for diagonal + + mtl::vector::sparse_vector<value_type> vec(n); // corr. row in paper + cur_type ic= begin<row>(A); // , iend= end<row>(A); + for (size_type i= 0; i < n; ++i, ++ic) { + + for (icur_type kc= begin<nz>(ic), kend= end<nz>(ic); kc != kend; ++kc) // row= A[i][*] + vec.insert(col(*kc), value(*kc)); + // std::cerr << "vec_" << i << " = " << vec << std::endl; + value_type tau_i= p.second * two_norm(vec); // threshold for i-th row + // loop over non-zeros in vec; changes in vec considered + for (size_type j= 0; j < vec.nnz() && vec.index(j) < i; j++) { + size_type k= vec.index(j); + value_type ukk= U_ins.value(k, k); + MTL_DEBUG_THROW_IF(ukk == value_type(0), mtl::missing_diagonal()); + value_type vec_k= vec.value(j)/= ukk; + // std::cout << "vec after updating from U[" << k << "][" << k << "] is " << vec << '\n'; + for (size_type j0= U_ins.ref_major()[k], j1= U_ins.ref_slot_ends()[k]; j0 < j1; j0++) { // U[k][k+1:n] + size_type k1= U_ins.ref_minor()[j0]; + if (k1 > k) + vec[k1]-= vec_k * U_ins.ref_elements()[j0]; + // std::cout << "vec after updating from U[" << k << "][" << k1 << "] is " << vec << '\n'; + } + // if (i > 1000 && i < 1010) std::cout << "vec before crop in row " << i << ", updating from row " << k << ": \n" << vec << "\n"; + vec.crop(tau_i); + // if (i > 1000 && i < 1010) std::cout << "vec after crop: \n" << vec << "\n"; + } + // std::cerr << "vec_" << i << " = " << vec << std::endl; + vec.sort_on_data(); + // std::cerr << "vec_" << i << " sorted on data = " << vec << std::endl; + + // std::cout << "vec at " << i << " is " << vec << '\n'; + // mtl::vampir_trace<9904> tracer2; + bool diag_found= false; + for (size_type cntu= 0, cntl= 0, j= 0; j < vec.nnz() && (cntu < p.first || cntl < p.first); j++) { + size_type k= vec.index(j); + value_type v= vec.value(j); + // if (abs(v) < tau_i) break; + if (i == k) { + U_ins[i][i] << v; diag_found= true; + } else if (i < k) { + if (cntu++ < p.first) + U_ins[i][k] << v; + } else // i > k + if (cntl++ < p.first) + L_ins[i][k] << v; + } + if (!diag_found) std::cerr << "Deleted diagonal!!!!\n"; + vec.make_empty(); + } + } // destroy inserters + invert_diagonal(U); + } +}; + +// Not usable yet !!!!! +template <typename Matrix, typename Value= typename mtl::Collection<Matrix>::value_type> +class ilut + : public ilu<Matrix, ilut_factorizer, Value> +{ + typedef ilu<Matrix, ilut_factorizer, Value> base; + public: + ilut(const Matrix& A, std::size_t p, typename mtl::Collection<Matrix>::value_type tau) + : base(A, std::make_pair(p, tau)) {} +}; + +}} // namespace itl::pc + +#endif // ITL_PC_ILUT_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/pc/imf_algorithms.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/pc/imf_algorithms.hpp new file mode 100644 index 0000000000000000000000000000000000000000..8bf58cc337780aeb1f49867b1ca6d4210c28550b --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/pc/imf_algorithms.hpp @@ -0,0 +1,821 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. +// +// Algorithm inspired by Nick Vannieuwenhoven, written by Cornelius Steinhardt + +/* + * Implementation of the IMF factorization and application routines. + */ + +#ifndef MTL_IMF_ALGORITHMS_INCLUDE +#define MTL_IMF_ALGORITHMS_INCLUDE + +#include <iostream> +#include <string.h> +#include <vector> +#include <map> +#include <set> +#include <complex> +#include <limits> + +#include <boost/numeric/mtl/interface/vpt.hpp> +#include <boost/numeric/mtl/matrix/compressed2D.hpp> +#include <boost/numeric/mtl/matrix/coordinate2D.hpp> +#include <boost/numeric/mtl/operation/clone.hpp> +#include <boost/numeric/mtl/utility/irange.hpp> +#include <boost/numeric/mtl/utility/make_copy_or_reference.hpp> + +#include <boost/numeric/itl/pc/binary_heap.hpp> +#include <boost/numeric/itl/pc/sorting.hpp> + +#include "boost/unordered_map.hpp" +#include "boost/unordered_set.hpp" + + +namespace itl { namespace pc { +//////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// +// +// INTRUSIVE HEAP HELPER FUNCTORS +// +//////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// + +namespace heap { +/** + * An information extending structure for elements to support the reduction + * process. + */ +template<class Element, class Key> +struct HeapInformation { + Key m_key; + Element* m_parent; + Element* m_left_child; + Element* m_right_child; + + HeapInformation() : + m_key(0.0), m_parent(0), m_left_child(0), m_right_child(0) {} +}; + +/** + * A functor returning a reference to the degree of an element. + */ +template<class Element, class Key> +struct GetKey { + Key& operator()(Element* element) const { + return static_cast<HeapInformation<Element,Key>* >( + element->get_extra_pointer() + )->m_key; + } +}; + +/** + * A functor returning a reference to the parent of an element (in a heap). + */ +template<class Element, class Key> +struct GetParent { + Element*& operator()(Element* element) const { + return static_cast<HeapInformation<Element,Key>* >( + element->get_extra_pointer() + )->m_parent; + } +}; + +/** + * A functor returning a reference to the left child of an element (in a heap). + */ +template<class Element, class Key> +struct GetLeftChild { + Element*& operator()(Element* element) const { + return static_cast<HeapInformation<Element,Key>* >( + element->get_extra_pointer() + )->m_left_child; + } +}; + +/** + * A functor returning a reference to the right child of an element (in a heap). + */ +template<class Element, class Key> +struct GetRightChild { + Element*& operator()(Element* element) const { + return static_cast<HeapInformation<Element,Key>* >( + element->get_extra_pointer() + )->m_right_child; + } +}; + +/** + * Compares two elements based on their degrees. + */ +template<class Element, class Key> +struct DegreeCompare { + /** + * Compares two elements based on their degree. Ties are broken by the + * sequence numbers of the elements. + */ + inline bool operator()(Element* first, Element* second) const { + const int seq_fst = first->get_id(); + const int seq_snd = second->get_id(); + + const Key key_fst = static_cast<HeapInformation<Element,Key>* >( + first->get_extra_pointer() + )->m_key; + const Key key_snd = static_cast<HeapInformation<Element,Key>* >( + second->get_extra_pointer() + )->m_key; + + if (key_fst == key_snd) { + return seq_fst < seq_snd; + } + return key_fst < key_snd; + } +}; + +} // end namespace heap + + +enum Status { UNMARKED, DIAGONAL, MARKED_CURRENT, REMOVED, NON_DIAGONAL }; + + +//////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// +// +// DIAGONAL BLOCK SELECTION PRIORITY ESTIMATORS +// +//////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// + +/** + * Estimates the priority based on the number of nodes the element is connected + * to for the purpose of the local Schur complement computation. A higher + * priority is given if the element is connected to fewer nodes. + */ +template< class Element, class NodeStatusVector, bool UseStatus = false > +struct MinConnectedNodesEstimation { + inline int operator()( + const Element& el, + const NodeStatusVector& status + ) const { + typedef typename Element::neighbor_collection_type neigh_type; + + // Determine set of all nodes. + std::vector<int> nodes; + const neigh_type& neighs = el.get_neighbors(); + for(int i = 0; i < el.get_nb_neighbors(); ++i) { + nodes.insert( + nodes.end(), + neighs[i]->get_indices().begin(), + neighs[i]->get_indices().end() + ); + } + +// radix_sort( &nodes[0], nodes.size() ); // TODO INCLUDE RADIX_SORT + std::sort( nodes.begin(), nodes.end() ); + + int degree = -el.nb_vars()+1; + for(unsigned int i = 1; i < nodes.size(); ++i) + if( nodes[i-1] != nodes[i] ) + if (!UseStatus || status[nodes[i]] == UNMARKED) + ++degree; + return degree; + } +}; + + + +//////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// +// +// IMF Factorization +// +//////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// + + +template<class Type> +struct AddressHasher { + long operator()(const Type*& object) const { + return reinterpret_cast<long>( object ); + } +}; + +template<class Element, class StatusVector> +struct IsRemoved { + const StatusVector& m_status; + IsRemoved(const StatusVector& status) : m_status(status) { } + + bool operator()(const Element *const el) const { + return m_status[ el->get_id() ] == REMOVED; + } +}; + +/** + * Constructs the EBE-ML-ILU preconditioner from the given mesh. The mesh is + * altered in the process. + */ +template< typename ValType > +template< class Mesh > +void itl::pc::imf_preconditioner<ValType>::factor(const Mesh& mesh , const int maxlofi +) { + mtl::vampir_trace<5052> tracer; + typedef typename Mesh::element_type element_type; + typedef typename Mesh::element_iterator element_iterator; + typedef typename element_type::value_type value_type; + typedef typename element_type::neighbor_collection_type neigh_coll_type; + typedef typename element_type::neighbor_iterator neigh_iterator; + typedef typename element_type::neighbor_set_type neigh_set_type; + typedef typename element_type::neighbor_set_iterator_type neigh_set_iterator; + // typedef typename neigh_coll_type::const_iterator const_neigh_iterator; + typedef typename element_type::index_type index_type; + typedef typename element_type::matrix_type matrix_type; + + typedef typename mtl::matrix::coordinate2D<value_type> coo_sparse_type_upper; + typedef typename mtl::matrix::coordinate2D<value_type> coo_sparse_type_lower; + + + typedef std::map<int, int> cmap; + // typedef typename cmap::iterator cmap_iterator; + + typedef value_type key_type; + typedef utils::binary_heap< + element_iterator, + key_type, + heap::DegreeCompare<element_type, key_type>, + element_type*, + heap::GetKey<element_type, key_type>, + heap::GetParent<element_type, key_type>, + heap::GetLeftChild<element_type, key_type>, + heap::GetRightChild<element_type, key_type> + > my_heap; + + + // Constants. + const int nb_elements = mesh.get_total_elements(); + const int nb_vars = mesh.get_total_vars(); + const int UNPERMUTED = -1; + const value_type zero(0); + // A DS tracking the set of elements during the construction. + // Invariant: elements[i]->get_sequence_number() == i + // Invariant: elements[i] == 0 iff element[i] is removed + std::vector<element_type*> elements; + elements.reserve( nb_elements + (nb_elements >> 4) ); + element_iterator it = mesh.element_begin(); + for (int i = 0; i < nb_elements; ++i) { + elements.push_back( *&it ); + ++it; + } + + + // Data structures for the preconditioner. + std::vector<element_type*> block_diagonal; + std::vector<coo_sparse_type_upper*> upper_matrices; + std::vector<coo_sparse_type_lower*> lower_matrices; + std::vector<int> diagonal_offsets; + diagonal_offsets.push_back(0); + m_ordering = UNPERMUTED; + + //////////////////////////////////////////////////////////////////////////// + // Auxiliary data structures. + //////////////////////////////////////////////////////////////////////////// + + // Binary heap containing the dense elements that should still be + // considered for selection on the diagonal of the current level. + heap::DegreeCompare<element_type, key_type> key_compare; + heap::GetKey<element_type, key_type> get_key; + heap::GetParent<element_type, key_type> get_parent; + heap::GetLeftChild<element_type, key_type> get_left; + heap::GetRightChild<element_type, key_type> get_right; + my_heap unmarked_elements( + key_compare, + get_key, + get_parent, + get_left, + get_right + ); + std::vector< heap::HeapInformation<element_type, key_type>* > red_info( nb_elements ); + + // Another data structure for the elements that should be considered + // for the diagonal + std::vector<element_type*> unmarked_elements_srtd; + std::vector<int > unmarked_elements_degr; + unmarked_elements_srtd.reserve( nb_elements ); + unmarked_elements_degr.reserve( nb_elements ); + + // A DS to keep track of whether the element is on the diagonal, not + // on the diagonal or not yet marked. + std::vector<Status> el_status(nb_elements, UNMARKED); + + // A DS to keep track of the variables that have been forced into the + // reduced system. + std::vector<Status> in_reduced( mesh.get_total_vars(), UNMARKED ); + + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + + // Degree estimators. + const MinConnectedNodesEstimation<element_type, std::vector<Status> > min_nodes_estimate = + MinConnectedNodesEstimation<element_type, std::vector<Status> >(); + + std::cout << mesh.get_total_vars() << " nodes remaining" << std::endl; + + int level = 1; + int perm_off = 0; + int perm_high = 0; + int block_diag_low = 0; + int max_sequence_number = nb_elements; + + do { + mtl::vampir_trace<9901> tb1; + + block_diag_low = block_diagonal.size(); + +/*************************************************************************** + * Phase 0: Determine priority of unmarked elements + **************************************************************************/ + + // Make sure the set of unmarked elements is empty again. + assert( unmarked_elements.empty() ); + unmarked_elements_degr.clear(); + unmarked_elements_srtd.clear(); + // Construct the set of available diagonal elements along with their + // degrees. + for( unsigned int i = 0; i < elements.size(); ++i ) { + // Skip the element if it no longer exists, or it is a diagonal + // element. + if( (el_status[i] == REMOVED) || (el_status[i] == DIAGONAL) ) { + continue; + } + + element_type& el = *(elements[i]); + // Reset the status. + el_status[i] = UNMARKED; + + int degree = min_nodes_estimate(el, in_reduced); + unmarked_elements_degr.push_back( degree ); + unmarked_elements_srtd.push_back( &el ); + } + +/*************************************************************************** + * Phase 1: Select the block diagonal elements + **************************************************************************/ +/********************************SKIP UPDATE***********************************/ + + // Sort the candidate diagonal elements by their degree in ascending + // order. + sort_along<int, element_type*>( + &*(unmarked_elements_degr.begin()), + &*(unmarked_elements_srtd.begin()), + unmarked_elements_degr.size() + ); + + // For each of the candidate diagonal elements ... + for(unsigned int i = 0; i < unmarked_elements_srtd.size(); ++i) { + // Select the minimum element. + element_type& el = *(unmarked_elements_srtd[i]); + // If the element is already marked, skip it. + if( el_status[el.get_id()] != UNMARKED ) { + continue; + } + + // If the element is unmarked, add it to the set of diagonal + // elements + block_diagonal.push_back(&el); + // Mark the element. + el_status[el.get_id()] = DIAGONAL; + + // Update permutation vector + for(int i = 0; i < el.nb_vars(); ++i) { + m_ordering( el.get_indices()(i) ) = perm_off; + ++perm_off; + assert(perm_off <= mesh.get_total_vars()); + } + + // Determine level-2 neighbors. + neigh_set_type lvl2_neighs = el.get_level_neighbors( 2 ); + + // Mark all level-2 neighbors. + for(neigh_set_iterator neigh_it = lvl2_neighs.begin(); neigh_it != lvl2_neighs.end(); ++neigh_it) { + element_type& neigh = **neigh_it; + assert( el_status[neigh.get_id()] != DIAGONAL ); + el_status[ neigh.get_id() ] = MARKED_CURRENT; + } + } + + +/*******************************UPDATE DEGREE**********************************/ + // Update diagonal block offset. + diagonal_offsets.push_back( perm_off ); + //save upperbound for number of L and U entrys + unsigned int upperbound(0); + for(unsigned int i=0;i< block_diagonal.size();i++){ + mtl::vector::dense_vector<int> involve_node(block_diagonal[i]->get_indices()); + for(unsigned int j=0;j< block_diagonal[i]->get_neighbors().size();j++){ + mtl::vector::dense_vector<int> involve_neigh(block_diagonal[i]->get_neighbors()[j]->get_indices()); + unsigned int c(0); + for(unsigned int a= 0; a < size(involve_node); a++){ + for(unsigned int b= 0; b < size(involve_neigh); b++){ + if(involve_node[a] == involve_neigh[b]) + c++; + } + } + upperbound+= c*(size(involve_neigh)-c); + } + } + + // Update permutation offsets. + perm_high = perm_off; + +/*************************************************************************** + * Phase 2: Compute the update matrices + **************************************************************************/ + mtl::vampir_trace<9902> tb2; + + + coo_sparse_type_lower* L=new coo_sparse_type_lower(nb_vars, nb_vars, upperbound); + coo_sparse_type_upper* U=new coo_sparse_type_lower(nb_vars, nb_vars, upperbound); + lower_matrices.push_back(L); + upper_matrices.push_back(U); + // For each diagonal block element ... (in parallel) + unsigned int ku= 0, kl= 0; + for(std::size_t b_i = block_diag_low; b_i < block_diagonal.size();++b_i ) { + element_type& diag_el = *block_diagonal[b_i]; + // Copy the level-1 neighbors. + neigh_coll_type& diag_neighs = diag_el.get_neighbors(); + + // Determine the set of incident nodes. + boost::unordered_set<int> diag_incident_nodes = + diag_el.get_incident_nodes(); + index_type& p = diag_el.get_indices(); + index_type q( + diag_incident_nodes.size() == 0 ? + 1 : diag_incident_nodes.size() + ); + typename boost::unordered_set<int>::const_iterator it = + diag_incident_nodes.begin(); + for(unsigned int i = 0; i < diag_incident_nodes.size(); ++i) { + q(i) = *it; + ++it; + } + const int n1 = size(p); + const int n2 = diag_incident_nodes.size(); + sort(q); + assert(n1 > 0); + + // Construct a mapping from global to local node numbers. + cmap to_local; + for(int i = 0; i < n1; ++i) { + to_local[p(i)] = i; + } + + for(int i = 0; i < n2; ++i) { + to_local[q(i)] = mtl::size(p) + i; + } + // Construct the frontal matrix. + block_type frontal( n1+n2, n1+n2 ); + frontal = zero; + + // For each connected neighbor, add their values to the frontal + // matrix. + for(neigh_iterator neigh_it = diag_neighs.begin(); neigh_it != diag_neighs.end(); ++neigh_it) { + element_type& neigh = **neigh_it; + assert( el_status[neigh.get_id()] != DIAGONAL ); + assert( el_status[neigh.get_id()] != REMOVED ); + + // Remap indices. + index_type local_idx( neigh.get_indices() ); + + for(int i = 0; i < neigh.nb_vars(); ++i) { + local_idx(i) = to_local[ local_idx(i) ]; + } + //insert connectet neighbor + { + mtl::matrix::inserter<mtl::matrix::dense2D<value_type>, mtl::operations::update_plus<value_type> > ins(frontal); + ins << element_matrix(neigh.get_values(), local_idx, local_idx); + } + neigh.get_values()= zero; + } + // Add the values of the diagonal element to the frontal matrix. + { + // Remap indices. + index_type local_idx( diag_el.get_indices() ); + for(int i = 0; i < diag_el.nb_vars(); ++i) { + local_idx(i) = to_local[ local_idx(i) ]; + } + //insert the diagonal element + { + mtl::matrix::inserter<matrix_type, mtl::operations::update_plus<value_type> > ins(frontal); + ins << element_matrix( + diag_el.get_values(), local_idx, local_idx); + } + diag_el.get_values()= zero; + } + // + // Store the L and U part. + // + for(int i = 0; i < n1; ++i) { // p-part + for(int j = n1; j < n1+n2; ++j) { // q-part + // Assumption: structural symmetry. + if(frontal(i,j) != zero) { + U->insert(p(i),q(j-n1),frontal(i,j)); + ku++; + } + if(frontal(j,i) != zero){ + L->insert(q(j-n1),p(i),frontal(j,i)); + kl++; + } + } + } + + mtl::irange n0(0,n1); + diag_el.get_values() = inv(mtl::clone(frontal[n0][n0])); + frontal[n0][n0] = diag_el.get_values(); + + if( (level <= maxlofi) && (n2 > 0) ) { +//------------------------------------------------------------------------------ +// ELEMENT COALESCING APPROACH +//------------------------------------------------------------------------------ + // The lofi is below the user-requested level. Use Algorithm 2 + // in [1]. + // Compute the Schur complement. + mtl::irange n1r(0,n1), n2r(n1, mtl::imax); + frontal[n2r][n2r]-= frontal[n2r][n1r] * frontal[n1r][n1r] * frontal[n1r][n2r]; + mtl::irange nz(n1,n1+n2); + matrix_type Z( mtl::clone(frontal[nz][nz]) ); + // Construct the new element. + element_type* fill = new element_type(max_sequence_number, q, Z); + // Add processing information to the required DSs. + elements.push_back( fill ); + el_status.push_back( UNMARKED ); + + + // Determine the level-2 neighbors. + neigh_set_type lvl2_neighs = diag_el.get_level_neighbors( 2 ); + // Remove the level-1 neighbors of the diagonal element. + for(neigh_iterator it = diag_neighs.begin(); it != diag_neighs.end(); ++it) { + element_type& neigh = **it; + neigh.clear(); + el_status[neigh.get_id()] = REMOVED; + } + + // Update the neighborhood of the level-2 neighbors. + const IsRemoved<element_type, std::vector<Status> > is_removed( el_status ); + for(neigh_set_iterator it = lvl2_neighs.begin(); it != lvl2_neighs.end(); ++it) { + element_type& neigh = **it; + + // Skip the level-1 neighbors (removed) and the diagonal + // element. + if((el_status[neigh.get_id()] == DIAGONAL) || (el_status[neigh.get_id()] == REMOVED)) { + continue; + } + // The element is in the strict level-2 neighborhood. + // Remove the level-1 neighbors from its set of neighbors. + neigh_coll_type& neigh_neighs = neigh.get_neighbors(); + neigh_iterator new_end = std::remove_if(neigh_neighs.begin(), neigh_neighs.end(), is_removed); + neigh_neighs.erase(new_end, neigh_neighs.end()); + + // Add the newly generated element as neighbor, and vice + // versa. + neigh_neighs.push_back( fill ); + fill->get_neighbors().push_back( &neigh ); + + } + // Update sequence number. + ++max_sequence_number; + } else if (n2 > 0) { + +//------------------------------------------------------------------------------ +// ELEMENT DISTRIBUTION APPROACH +//------------------------------------------------------------------------------ + // The lofi is above the user-requested level. Use Algorithm 3 + // in [1] to compute the approximate Schur complement element- + // wise. + + // Distribute the values of the generalized element across the + // level-2 neighbors of the diagonal element. + + // Remove the nodes of the diagonal element from its + // neighbors. + for(neigh_iterator neigh_it = diag_neighs.begin(); neigh_it != diag_neighs.end(); ++neigh_it) + { + element_type& neigh = **neigh_it; + neigh.remove_nodes( diag_el.get_indices(), diag_el ); + + assert( el_status[neigh.get_id()] != DIAGONAL ); + assert( el_status[neigh.get_id()] != REMOVED ); + + // If the element is entirely removed, mark it as such. + if( neigh.nb_vars() == 0 ) { + el_status[neigh.get_id()] = REMOVED; + } + } + + // Compute the Schur complement. + mtl::irange n1r(0,n1), n2r(n1, mtl::imax); + frontal[n2r][n2r]-= frontal[n2r][n1r] * frontal[n1r][n1r] * frontal[n1r][n2r]; + // Distribute the values of the (modified) update matrix + // over the level-1 neighbors. + mtl::irange nz(n1,n1+n2); + matrix_type S( frontal[nz][nz] ); + for(neigh_iterator neigh_it = diag_neighs.begin(); neigh_it != diag_neighs.end();++neigh_it) { + element_type& el = **neigh_it; + if( el_status[el.get_id()] != REMOVED ) { + el.absorb(S, q); + } + } + // Do not distribute over the entire level-2 neighborhood. + // This is expensive, while not adding much in terms of quality + // of the approximation. + + } else { + // There are no more nodes in the Schur complement, but it could + // be that some elements other than the diagonal element overlap + // completely with said element. + + // In this case, simply remove all neighbors. + for(neigh_iterator neigh_it = diag_neighs.begin(); neigh_it != diag_neighs.end(); ++neigh_it) { + element_type& neigh = **neigh_it; + neigh.remove_nodes( diag_el.get_indices(), diag_el ); + assert( el_status[neigh.get_id()] != DIAGONAL ); + assert( el_status[neigh.get_id()] != REMOVED ); + // The element is now entirely removed, mark it as such. + assert( neigh.nb_vars() == 0 ); + el_status[neigh.get_id()] = REMOVED; + } + + } // END ELEMENT DISTRIBUTION + // Clear the neighborhood of the diagonal element. + diag_el.get_neighbors().clear(); + } + + std::cout << "level " << level << " complete: "; + std::cout << mesh.get_total_vars()-perm_high << " nodes remaining."<< "\n"; + + ++level; + } while( (mesh.get_total_vars() - perm_high > 0) ); // There are still variables to cover. + + + diagonal_offsets.push_back( mesh.get_total_vars() ); + assert( mesh.get_total_vars() - perm_high == 0 ); + assert( lower_matrices.size()+2 == diagonal_offsets.size() ); + /*************************************************************************** + * Phase 3: Apply permutation vector to lower and upper matrices + **************************************************************************/ + mtl::vampir_trace<9903> tb3; + + + mtl::matrix::traits::permutation<>::type P(permutation(m_ordering)); + typedef typename coo_sparse_type_lower::size_type size_type; + + for( std::size_t k = 0; k < lower_matrices.size(); ++k ) { + coo_sparse_type_lower& L = *(lower_matrices[k]); + coo_sparse_type_upper& U = *(upper_matrices[k]); + if (nnz(L)> 0) { + std::vector<size_type> &L_row(L.row_index_array()), + &L_col(L.column_index_array()), + &U_row(U.row_index_array()), + &U_col(U.column_index_array()); + const int off_low = diagonal_offsets[k]; + for(unsigned int i = 0; i < nnz(L); ++i) { + L_row[i] = m_ordering( L_row[i] ); + L_col[i] = m_ordering( L_col[i] ) - off_low; + }; + for(unsigned int i = 0; i < nnz(U); ++i) { + U_row[i] = m_ordering( U_row[i] ) - off_low; + U_col[i] = m_ordering( U_col[i] ); + } + } + + m_lower.push_back(mtl::matrix::compressed2D<value_type>(L)); + m_upper.push_back(mtl::matrix::compressed2D<value_type>(U)); + } + /*************************************************************************** + * Phase 4: Construct the IMF preconditioner + **************************************************************************/ + // Copy the block diagonal values into a consecutive array. +// mtl::vampir_trace<9904> tb4; + + m_diagonal = new matrix_type[ block_diagonal.size() ]; + for(std::size_t i = 0; i < block_diagonal.size(); ++i) { + assert( el_status[block_diagonal[i]->get_id()] == DIAGONAL ); + unsigned int diarows(num_rows(block_diagonal[i]->get_values())); + m_diagonal[i].change_dim(diarows,diarows); + m_diagonal[i] = block_diagonal[i]->get_values(); + } + // Copy the diagonal offsets to a consecutive array. + int* diagonal_index = new int[ diagonal_offsets.size() ]; + memcpy( + diagonal_index, + &(diagonal_offsets[0]), + sizeof(int)*diagonal_offsets.size() + ); + assert( diagonal_offsets.back() == mesh.get_total_vars() ); + assert( lower_matrices.size()+2 == diagonal_offsets.size() ); + + m_levels = lower_matrices.size(); + m_nb_blocks = block_diagonal.size(); + m_diagonal_index = diagonal_index; + + // Todo: create element_structure from all elements + // Delete only elements that we generated; those at the beginning are just referred + for (unsigned i= nb_elements; i < elements.size(); i++) + delete elements[i]; + + for (unsigned i= 0; i < lower_matrices.size(); i++) + delete lower_matrices[i]; + for (unsigned i= 0; i < upper_matrices.size(); i++) + delete upper_matrices[i]; +} + +//////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// +// +// IMF APPLICATION +// +//////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// + + +/** + * Applies the IMF preconditioner to a matrix. The contents of the rhs vector + * are overwritten. + * + * The algorithm is implemented without recursion, as was already suggested by + * Y. Saad in [2]. + */ + +template< class ValType > +template< class Vector > +Vector imf_preconditioner<ValType>::imf_apply(const Vector& rhs) const +{ + using namespace mtl; + Vector res(rhs); + ValType zero(0); + // Forward elimination. + { + mtl::vampir_trace<9901> tb1; + int b_off = 0; + for(int level = 0; level < m_levels; ++level) { + const int off_low = m_diagonal_index[level]; + const int off_high = m_diagonal_index[level+1]; + const int n1 = off_high - off_low; + assert(off_low <= off_high); + // Compute dy = inv(D)*y + vector_type dy(n1); + dy = zero; + for(int off = off_low; off < off_high; ++b_off ) { //parallel + const int block_size = num_rows( m_diagonal[b_off] ); + dy[mtl::irange(off-off_low, off-off_low+block_size)] = m_diagonal[b_off] * res[mtl::irange(off, off + block_size)]; + off += block_size; + } + // Compute x = x - E*dy + Vector big(num_cols(m_lower[level]), ValType(0)); + big[mtl::irange(0,n1)] = dy; + res -= m_lower[level] * big; + } + } + + // Backward elimination. + { + mtl::vampir_trace<9902> tb2; + int b_off = m_nb_blocks-1; + for(int level = m_levels-1; level >= 0; --level) { + + const int off_low = m_diagonal_index[level]; + const int off_high = m_diagonal_index[level+1]; + // y' = y - Fx +// assert( m_upper[level] ); + + vector_type yp(m_upper[level] * res); + res[mtl::irange(off_low, off_high) ] -= yp[mtl::irange(0, off_high-off_low) ]; + // y = inv(D)*y' + for(int off = off_high; off > off_low; --b_off ) { + const int block_size = num_rows(m_diagonal[b_off]); + assert(b_off >= 0); + assert(off-block_size >= off_low); + + vector_type dy(m_diagonal[b_off] * res[irange(off-block_size, off)] ); + res[irange(off-block_size, off)] = dy; + off -= block_size; + } + } + assert(b_off == -1); + } + return res; +} + + +} // end namespace pc +} // end namespace itl + + +#endif // MTL_IMF_ALGORITHMS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/pc/imf_preconditioner.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/pc/imf_preconditioner.hpp new file mode 100644 index 0000000000000000000000000000000000000000..728a97d7176a9ddc5c9eb17da311d6c7e33a9f78 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/pc/imf_preconditioner.hpp @@ -0,0 +1,169 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. +// +// Algorithm inspired by Nick Vannieuwenhoven, written by Cornelius Steinhardt + +/* + * The IMF preconditioner. + * + * References + * [1] N. Vannieuwenhoven and K. Meerbergen, IMF: An incomplete multifron- + * tal LU-factorization for element-structured sparse linear systems, + * Tech. Rep. TW581, Department of Computer Science, KULeuven, + * December 2010. + */ + +#ifndef MTL_IMF_PRECONDITIONER_INCLUDE +#define MTL_IMF_PRECONDITIONER_INCLUDE + +#include <boost/numeric/itl/pc/matrix_algorithms.hpp> +#include <boost/numeric/itl/pc/solver.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> +#include <boost/numeric/mtl/matrix/compressed2D.hpp> +#include <boost/numeric/mtl/matrix/coordinate2D.hpp> +#include <boost/numeric/mtl/matrix/dense2D.hpp> +#include <boost/numeric/mtl/vector/dense_vector.hpp> + + +namespace itl { namespace pc { + +/// The IMF preconditioner, as described in [1]. +template<class ValType> +class imf_preconditioner { + +public: + /// The type of the values. + typedef ValType value_type; + + /// The type of the sparse data structure for the upper matrices. + typedef mtl::matrix::coordinate2D<value_type> sparse_type_upper; + + /// The type of the sparse data structure for the lower matrices. + typedef mtl::matrix::coordinate2D<value_type> sparse_type_lower; + + /// The type of the vectors. + typedef mtl::vector::dense_vector<value_type> vector_type; + + ///The type of the permutation vector. + typedef mtl::vector::dense_vector<int> index_type; + + /// The type of the matrices on the block diagonal. + typedef mtl::matrix::dense2D<value_type> block_type; + + /// The type of the sequence of lower matrices. + typedef std::vector<mtl::matrix::compressed2D<value_type> > lower_matrix_coll_type; + + /// The type of the sequence of upper matrices. + typedef std::vector<mtl::matrix::compressed2D<value_type> > upper_matrix_coll_type; + + /// Constructor + template< class ElementStructure > + imf_preconditioner( + const ElementStructure& element_structure , + const int maxlofi=0, + const bool copy_on=true + ) + : m_nb_vars( element_structure.get_total_vars() ), + m_ordering( element_structure.get_total_vars() ), + m_diagonal_index(0), + m_diagonal(0) + { + mtl::vampir_trace<5053> tracer; + if(copy_on){ + ElementStructure es(element_structure); + factor(es, maxlofi); + } else { + factor(element_structure, maxlofi); + } + P= permutation(m_ordering); + } + + /// Destructor + ~imf_preconditioner() + { + delete[] m_diagonal_index; + delete[] m_diagonal; + } + +private: + /// Disallow the copy constructor and assignment. + imf_preconditioner(); + imf_preconditioner(const imf_preconditioner& other); + void operator=(const imf_preconditioner& other); + + /// Constructs the IMF preconditioner.Forward declaration + template< class ElementStructure > + void factor(const ElementStructure&, const int); + +public: + + /// Returns the number of levels (equals the number of lower and upper matrices. + int get_nb_levels() const { return m_levels; } + + /// Returns the number of blocks on the diagonal. + int get_nb_blocks() const { return m_nb_blocks; } + + + /// Applies the preconditioner to the given matrix. + template <typename VectorIn, typename VectorOut> + void solve(const VectorIn& b, VectorOut& x) const + { + VectorIn m(trans(P)*b), m_tmp(imf_apply(m)); + x= P * m_tmp; + } + +private: + /// Applies the preconditioner prototype + template< class Vector > + Vector imf_apply(const Vector&) const; + + /// The number of variables (also the size of the m_ordering vector). + unsigned int m_nb_vars; + + /// The number of blocks on the diagonal. + unsigned int m_nb_blocks; + + /// A vector containing the renumbering of IMF. + index_type m_ordering; + + /// A matrix containing the renumbering of IMF. + mtl::matrix::traits::permutation<>::type P; + + /// The number of levels (equals the number of entries in the diagonal index array minus one). + int m_levels; + + /** The index array for the matrices on the block diagonal. The i^th entry + * indicates where the i^th level of block diagonal matrices starts in the + * right hand side vector. */ + int* m_diagonal_index; + + /// The matrices on the block diagonal. + block_type* m_diagonal; + + /// The sparse lower matrices of each level, sorted by level. + lower_matrix_coll_type m_lower; + + /// The sparse upper matrices of each level, sorted by level. + upper_matrix_coll_type m_upper; +}; + +/// Solve +template <typename Matrix, typename Vector> +solver<imf_preconditioner<Matrix>, Vector, false> +inline solve(const imf_preconditioner<Matrix>& P, const Vector& b) +{ + mtl::vpt::vampir_trace<5054> tracer; + return solver<imf_preconditioner<Matrix>, Vector, false>(P, b); +} +}//namespace pc +}//namespace itl +#endif // MTL_IMF_PRECONDITIONER_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/pc/is_identity.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/pc/is_identity.hpp new file mode 100644 index 0000000000000000000000000000000000000000..5a5ce5190e8464a87ae75a7467acfd5f69cf225a --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/pc/is_identity.hpp @@ -0,0 +1,41 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef ITL_PC_IS_IDENTITY_INCLUDE +#define ITL_PC_IS_IDENTITY_INCLUDE + +#include <boost/mpl/bool.hpp> +#include <boost/numeric/itl/itl_fwd.hpp> + +namespace itl { namespace pc { + +template <typename PC> +bool is_identity(const PC&) +{ return false; } + +template <typename Matrix, typename Value> +bool is_identity(const itl::pc::identity<Matrix, Value>&) +{ return true; } + +template <typename PC> +struct static_is_identity + : boost::mpl::false_ +{}; + +template <typename Matrix, typename Value> +struct static_is_identity<itl::pc::identity<Matrix, Value> > + : boost::mpl::true_ +{}; + +}} // namespace itl::pc + +#endif // ITL_PC_IS_IDENTITY_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/pc/matrix_algorithms.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/pc/matrix_algorithms.hpp new file mode 100644 index 0000000000000000000000000000000000000000..b0f73b759a4162e6413a38b37fa9045632ba996b --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/pc/matrix_algorithms.hpp @@ -0,0 +1,74 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. +// +// Algorithm inspired by Nick Vannieuwenhoven, written by Cornelius Steinhardt + + + +#ifndef MTL_MATRIX_ALGORITHMS_INCLUDE +#define MTL_MATRIX_ALGORITHMS_INCLUDE + +#include <boost/numeric/mtl/interface/vpt.hpp> +#include <boost/numeric/mtl/mtl.hpp> +#include <boost/numeric/mtl/matrix/element.hpp> +#include <boost/numeric/mtl/matrix/element_structure.hpp> + +#include <iostream> + +namespace mtl { namespace matrix { + +/// Construct the sparse data structure from an elementstructure +template< typename ElementStructure, typename Matrix, typename Vector> +void assemble_compressed(const ElementStructure& es, Matrix& A, Vector& order) +{ + + typedef typename ElementStructure::element_type::value_type value_type; + typedef typename ElementStructure::element_iterator iterator; + typedef typename ElementStructure::element_type element_type; + typedef typename element_type::index_type index_type; + typedef typename element_type::matrix_type matrix_type; + typedef typename matrix_type::size_type size_type; + A.change_dim(es.get_total_vars(), es.get_total_vars()); + set_to_zero(A); + value_type zero(0); + + {//start inserterblock + mtl::matrix::inserter<Matrix, mtl::operations::update_plus<value_type> > ins(A); + for(iterator it = es.element_begin(); it != es.element_end(); ++it) { + element_type& element = *it; + const index_type& idx = element.get_indices(); + matrix_type& values = element.get_values(); + for(int i = 0; i < element.nb_vars(); ++i) { + for(int j = 0; j < element.nb_vars(); ++j) { + if(values(i,j) != zero) { + ins[size_type(order(idx(i)))][size_type(order(idx(j)))] << values(i,j); + } + } + } + } + }//end inserterblock +} + + +/// Construct the sparse data structure from an elementstructure +template< typename ElementStructure, typename Matrix> +void assemble_compressed(const ElementStructure& es, Matrix& A) +{ + typedef typename ElementStructure::element_type::matrix_type::size_type size_type; + mtl::dense_vector<size_type> ident(es.get_total_vars()); + iota(ident); + assemble_compressed(es, A, ident); +} + +}}//end namespace mtl + +#endif // MTL_MATRIX_ALGORITHMS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/pc/solver.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/pc/solver.hpp new file mode 100644 index 0000000000000000000000000000000000000000..2afcf730bdb8f0419f8a7490a56eca46ada20cda --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/pc/solver.hpp @@ -0,0 +1,56 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef ITL_PC_SOLVER_INCLUDE +#define ITL_PC_SOLVER_INCLUDE + +#include <boost/mpl/bool.hpp> +#include <boost/numeric/mtl/vector/assigner.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace itl { namespace pc { + +/// Helper class for delayed (i.e. copy-free) evaluation of preconditioners +template <typename PC, typename Vector, bool adjoint= false> +struct solver + : mtl::vector::assigner<solver<PC, Vector> > +{ + typedef PC pc_type; + + /// Constructor taking preconditioner and source vector + solver(const pc_type& P, const Vector& x) : P(P), x(x) {} + + /// Assign result to vector \p y, if possible without copying + template <typename VectorOut> + void assign_to(VectorOut& y) const + { + mtl::vampir_trace<5055> tracer; + assign_to(y, boost::mpl::bool_<adjoint>()); + } + + protected: + + template <typename VectorOut> + void assign_to(VectorOut& y, boost::mpl::false_) const + { P.solve(x, y); } + + template <typename VectorOut> + void assign_to(VectorOut& y, boost::mpl::true_) const + { P.adjoint_solve(x, y); } + + const pc_type& P; + const Vector& x; +}; + +}} // namespace itl::pc + +#endif // ITL_PC_SOLVER_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/pc/sorting.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/pc/sorting.hpp new file mode 100644 index 0000000000000000000000000000000000000000..a118f3ecec53e94e8f1652923970a789aae705b8 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/pc/sorting.hpp @@ -0,0 +1,307 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. +// +// Algorithm inspired by Nick Vannieuwenhoven, written by Cornelius Steinhardt + +/* + * + * Created on: Nov 3, 2009 + * Author: heazk + */ + +#ifndef MTL_SORTING_INCLUDE +#define MTL_SORTING_INCLUDE + +#include <string.h> +#include <stdlib.h> + +#define BITS_PER_BYTE 8 + +//////////////////////////////////////////////////////////////////////////////// +// RADIX-SORT +//////////////////////////////////////////////////////////////////////////////// + +template< + class Type +> +void radix_sort( + Type* values, + const int size, + Type* tmp = 0 +) { + if(size < 2) { + return; + } + + Type *const orig_ptr = values; + if(tmp == 0) { + tmp = new Type[size]; + } + +#if VERBOSE_MODE > 10 + std::cout << "unsorted: "; + for(int i = 0; i < size; ++i) { + std::cout << values[i] << ", "; + } + std::cout << std::endl; +#endif + + // Determine the maximum number of bits needed. + int max = INT_MIN; + for(int i = 0; i < size; ++i) { + max = (values[i] <= max) ? max : values[i]; + } + int maxBits = 1; + for(; max; max >>= 1, ++maxBits){}; + for(max = 0; max < maxBits; max += BITS_PER_BYTE){}; + maxBits = max; + + const int groupBits = BITS_PER_BYTE; + const int intBits = maxBits; + const int groupSize = 1 << groupBits; + + const int nbIterations = intBits / groupBits; + const int mask = groupSize-1; + + // Counting and prefix arrays. + int* count = new int[groupSize]; + + for ( + int shift = 0, it = 0; + it < nbIterations; + ++it, shift += groupBits + ) { + // Reset count array. + memset(count, 0, groupSize*sizeof(int)); + + // Counting elements in the it-th group. + for (int i = 0; i < size; ++i) { + count[ (values[i] >> shift) & mask ]++; + } + + // Calculate prefixes. + int currIncrement = -1; + int prevCount = count[0]; + count[0] = 0; + for (int i = 1; i < groupSize; ++i) { + currIncrement = prevCount; + prevCount = count[i]; + count[i] = count[i-1] + currIncrement; + } + + // Sort elements in the it-th group. + for (int i = 0; i < size; ++i) { + int& index = count[( values[i] >> shift) & mask]; + tmp[ index ] = values[i]; + ++index; + } + + // Swap pointers. + Type* tmp_values = values; + values = tmp; + tmp = tmp_values; + } + + // Make sure the sorted keys and values reside in the input array. + if( values != orig_ptr ) { + memcpy( orig_ptr, values, sizeof(Type)*size ); + tmp = values; + } + +#if VERBOSE_MODE > 10 + std::cout << "sorted: "; + for(int i = 0; i < size; ++i) { + std::cout << values[i] << ", "; + } + std::cout << std::endl; +#endif + + if(count) { + delete[] count; + } + if(tmp) { + delete[] tmp; + } +} + +template< + class Key, class Val +> +void radix_sort( + Key* keys, Val* vals, + const int size, + Key* tmpKeys = 0, Val* tmpVals = 0 +) { + if(size < 2) { + return; + } + + // The pointers to the original data. + Key *const origKey = keys; + Val *const origVal = vals; + + // Helper arrays. + bool ownKeys = false; + bool ownVals = false; + if(!tmpKeys) { + tmpKeys = new Key[size]; + ownKeys = true; + } + if(!tmpVals) { + tmpVals = new Val[size]; + ownVals = true; + } + + // Determine the maximum number of bits needed. + int max = -(INT_MAX-1); + for(int i = 0; i < size; ++i) { + max = keys[i] <= max ? max : keys[i]; + } + int maxBits = 1; + for(; max; max >>= 1, ++maxBits){}; + for(max = 0; max < maxBits; max += BITS_PER_BYTE){}; + maxBits = max; + + const int groupBits = BITS_PER_BYTE; + const int intBits = maxBits; + const int groupSize = 1 << groupBits; + + const int nbIterations = intBits / groupBits; + const int mask = groupSize-1; + + // Counting and prefix arrays. + int* count = new int[groupSize]; + // Allocation of memory could fail! + + for ( + int shift = 0, it = 0; + it < nbIterations; + ++it, shift += groupBits + ) { + // Reset count array. + for(int i = 0; i < groupSize; ++i) { + count[i] = 0; + } + + // Counting elements in the it-th group. + for (int i = 0; i < size; ++i) { + count[ (keys[i] >> shift) & mask ]++; + } + + // Calculate prefixes. + int currIncrement = -1; + int prevCount = count[0]; + count[0] = 0; + for (int i = 1; i < groupSize; ++i) { + currIncrement = prevCount; + prevCount = count[i]; + count[i] = count[i-1] + currIncrement; + } + + // Sort elements in the it-th group. + for (int i = 0; i < size; ++i) { + int& index = count[( keys[i] >> shift) & mask]; + tmpKeys[ index ] = keys[i]; + tmpVals[ index ] = vals[i]; + ++index; + } + + // Swap pointers. + Key* tmpKeyPtr = tmpKeys; + Val* tmpValuePtr = tmpVals; + tmpKeys = keys; + tmpVals = vals; + keys = tmpKeyPtr; + vals = tmpValuePtr; + } + + // Make sure the sorted keys and values reside in the input array. + if(keys != origKey) { + memcpy( origKey, keys, sizeof(Key)*size ); + tmpKeys = keys; + } + if(vals != origVal) { + memcpy( origVal, vals, sizeof(Val)*size ); + tmpVals = vals; + } + + if(count) delete[] count; + if(ownKeys && tmpKeys) delete[] tmpKeys; + if(ownVals && tmpVals) delete[] tmpVals; + tmpKeys = 0; + tmpVals = 0; + count = 0; +} + +//////////////////////////////////////////////////////////////////////////////// +// QUICK-SORT +//////////////////////////////////////////////////////////////////////////////// + +template<typename Key, typename Val> +inline void swap(Key& key0, Val& val0, Key& key1, Val& val1) { + Key tmp_key = key0; + Val tmp_val = val0; + key0 = key1; + val0 = val1; + key1 = tmp_key; + val1 = tmp_val; +} + +template<typename Key, typename Value> +inline void sort_along(Key* keys, Value* values, int size) { + + + if(size < 2) { + return; + } + if( size == 2 ) { + if(keys[0] > keys[1]) { + swap( + keys[0], values[0], + keys[1], values[1] + ); + } + return; + } + + int piv = std::rand() % size; + + + swap( + keys[0], values[0], + keys[piv], values[piv] + ); + int begin = 1; + int end = size-1; + while(begin < end) { + for(; (begin < end) && (keys[begin] <= keys[0]); ++begin){}; + for(; (begin <= end) && (keys[end] > keys[0]); --end){}; + + if(begin < end) { + swap( + keys[begin], values[begin], + keys[end], values[end] + ); + } + } + piv = end; + swap( + keys[0], values[0], + keys[piv], values[piv] + ); + + + sort_along( keys, values, piv ); + sort_along( keys+(piv+1), values+(piv+1), size-piv-1); +} + +#endif // MTL_SORTING_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/pc/sub_matrix_pc.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/pc/sub_matrix_pc.hpp new file mode 100644 index 0000000000000000000000000000000000000000..20d48a9e67d9f4dd749a7eb85d452b192b8cc951 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/pc/sub_matrix_pc.hpp @@ -0,0 +1,198 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef ITL_PC_SUB_MATRIX_PC_INCLUDE +#define ITL_PC_SUB_MATRIX_PC_INCLUDE + +#include <boost/static_assert.hpp> +#include <boost/mpl/if.hpp> + +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/utility/property_map.hpp> +#include <boost/numeric/mtl/vector/dense_vector.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> +#include <boost/numeric/itl/pc/solver.hpp> + +namespace itl { namespace pc { + +/// Class for applying \tparam Preconditioner only on a sub-matrix +/** Other entries are just copied. + Optionally preconditioner can be referred from outside instead of storing it by setting + \tparam Store to true. +**/ +template <typename Preconditioner, typename Matrix, bool Store= true> +class sub_matrix_pc +{ + typedef mtl::vector::dense_vector<bool> tag_type; + typedef typename boost::mpl::if_c<Store, Preconditioner, const Preconditioner&>::type pc_type; + + struct matrix_container + { + matrix_container() : Ap(0) {} + + matrix_container(const tag_type& tags, const Matrix& src) + { + using std::size_t; + using namespace mtl; + + mtl::vector::dense_vector<size_t> perm(size(tags)); + size_t n= 0; + for (size_t i= 0; i < size(tags); ++i) { + perm[i]= n; + if (tags[i]) + ++n; + } + + Ap= new Matrix(n, n); + + typename traits::row<Matrix>::type row(src); + typename traits::col<Matrix>::type col(src); + typename traits::const_value<Matrix>::type value(src); + typedef typename traits::range_generator<tag::major, Matrix>::type cursor_type; + + matrix::inserter<Matrix> ins(*Ap, Ap->nnz() / Ap->dim1()); + + for (cursor_type cursor = mtl::begin<tag::major>(src), cend = mtl::end<tag::major>(src); + cursor != cend; ++cursor) { + // std::cout << dest << '\n'; + + typedef typename traits::range_generator<tag::nz, cursor_type>::type icursor_type; + for (icursor_type icursor = mtl::begin<tag::nz>(cursor), icend = mtl::end<tag::nz>(cursor); + icursor != icend; ++icursor) + if (tags[row(*icursor)] && tags[col(*icursor)]) + ins(perm[row(*icursor)], perm[col(*icursor)]) << value(*icursor); + } + } + + ~matrix_container() { delete Ap; } + + Matrix* Ap; + }; + + size_t count_entries() const + { + using mtl::size; + size_t n= 0; + for (size_t i= 0; i < size(tags); ++i) + if (tags[i]) ++n; + return n; + } + + public: + + sub_matrix_pc(const tag_type& tags, const Matrix& A) + : tags(tags), n(count_entries()), mc(tags, A), P(*mc.Ap) + { + BOOST_STATIC_ASSERT((Store)); + delete mc.Ap; + mc.Ap= 0; + } + +#if 0 // to do later + sub_matrix_pc(const tag_type& tags, const Preconditioner& P) + : tags(tags), P(P) + { + // check sizes + } +#endif + + private: + template <typename VectorIn> + VectorIn& create_x0(VectorIn) const + { + static VectorIn x0(n); + return x0; + } + + template <typename VectorOut> + VectorOut& create_y0(VectorOut) const + { + static VectorOut y0(n); + return y0; + } + + template <typename VectorIn> + void restrict(const VectorIn& x, VectorIn& x0) const + { + for (size_t i= 0, j= 0; i < size(tags); ++i) + if (tags[i]) + x0[j++]= x[i]; + } + + template <typename VectorIn, typename VectorOut> + void prolongate(const VectorIn& x, const VectorOut& y0, VectorOut& y) const + { + for (size_t i= 0, j= 0; i < size(tags); ++i) + if (tags[i]) + y[i]= y0[j++]; + else + y[i]= x[i]; + } + + public: + /// Solve Px = y approximately on according sub-system; remaining entries are copied + template <typename VectorIn, typename VectorOut> + void solve(const VectorIn& x, VectorOut& y) const + { + mtl::vampir_trace<5056> tracer; + y.checked_change_resource(x); + + VectorIn& x0= create_x0(x); + VectorOut& y0= create_y0(y); + + restrict(x, x0); + P.solve(x0, y0); + // y0= solve(P, x0); // doesn't compile yet for unknown reasons + prolongate(x, y0, y); + } + + /// Solve Px = y approximately on according sub-system; remaining entries are copied + template <typename VectorIn, typename VectorOut> + void adjoint_solve(const VectorIn& x, VectorOut& y) const + { + mtl::vampir_trace<5057> tracer; + y.checked_change_resource(x); + + VectorIn& x0= create_x0(x); + VectorOut& y0= create_y0(y); + + restrict(x, x0); + P.adjoint_solve(x0, y0); + // y0= adjoint_solve(P, x0); // doesn't compile yet for unknown reasons + prolongate(x, y0, y); + } + + private: + tag_type tags; + size_t n; + matrix_container mc; + pc_type P; +}; + +template <typename Preconditioner, typename Matrix, bool Store, typename Vector> +solver<sub_matrix_pc<Preconditioner, Matrix, Store>, Vector, false> +inline solve(const sub_matrix_pc<Preconditioner, Matrix, Store>& P, const Vector& x) +{ + return solver<sub_matrix_pc<Preconditioner, Matrix, Store>, Vector, false>(P, x); +} + +template <typename Preconditioner, typename Matrix, bool Store, typename Vector> +solver<sub_matrix_pc<Preconditioner, Matrix, Store>, Vector, true> +inline adjoint_solve(const sub_matrix_pc<Preconditioner, Matrix, Store>& P, const Vector& x) +{ + return solver<sub_matrix_pc<Preconditioner, Matrix, Store>, Vector, true>(P, x); +} + + +}} // namespace itl::pc + +#endif // ITL_PC_SUB_MATRIX_PC_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/smoother/gauss_seidel.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/smoother/gauss_seidel.hpp new file mode 100644 index 0000000000000000000000000000000000000000..0703b71c0f9486ff5cbb6cf27bf8666ac0e43609 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/smoother/gauss_seidel.hpp @@ -0,0 +1,137 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef ITL_GAUSS_SEIDEL_INCLUDE +#define ITL_GAUSS_SEIDEL_INCLUDE + +#include <boost/assert.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/is_row_major.hpp> +#include <boost/numeric/mtl/utility/property_map.hpp> +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/matrix/compressed2D.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace itl { + +/// Gauss-Seidel smoother +/** Constructor takes references to a matrix and a right-hand side vector. + operator() is applied on a vector and changes it in place. + Matrix must be square, stored row-major and free of zero entries in the diagonal. + Vectors b and x must have the same number of rows as A. +**/ +template <typename Matrix> +class gauss_seidel +{ + typedef typename mtl::Collection<Matrix>::value_type Scalar; + typedef typename mtl::Collection<Matrix>::size_type size_type; + public: + /// Construct with constant references to matrix and RHS vector + gauss_seidel(const Matrix& A) : A(A), dia_inv(num_rows(A)) + { + BOOST_STATIC_ASSERT((mtl::traits::is_row_major<Matrix>::value)); // No CCS + assert(num_rows(A) == num_cols(A)); // Matrix must be square + for (size_type i= 0; i < num_rows(A); ++i) { + Scalar a= A[i][i]; + MTL_THROW_IF(a == 0, mtl::missing_diagonal()); + dia_inv[i]= 1.0 / a; + } + } + + /// Apply Gauss-Seidel on vector \p x, i.e. \p x is changed + template <typename Vector, typename RHSVector> + Vector& operator()(Vector& x, const RHSVector& b) const + { + mtl::vampir_trace<8551> tracer; + namespace tag= mtl::tag; using namespace mtl::traits; + using mtl::begin; using mtl::end; + + typedef typename range_generator<tag::row, Matrix>::type a_cur_type; + typedef typename range_generator<tag::nz, a_cur_type>::type a_icur_type; + typename col<Matrix>::type col_a(A); + typename const_value<Matrix>::type value_a(A); + + typedef typename mtl::Collection<Vector>::value_type value_type; + + a_cur_type ac= begin<tag::row>(A), aend= end<tag::row>(A); + for (unsigned i= 0; ac != aend; ++ac, ++i) { + value_type tmp= b[i]; + for (a_icur_type aic= begin<tag::nz>(ac), aiend= end<tag::nz>(ac); aic != aiend; ++aic) + if (col_a(*aic) != i) + tmp-= value_a(*aic) * x[col_a(*aic)]; + x[i]= dia_inv[i] * tmp; + } + return x; + } + + private: + const Matrix& A; + mtl::vector::dense_vector<Scalar> dia_inv; +}; + + +template <typename Value, typename Parameters> +class gauss_seidel<mtl::matrix::compressed2D<Value, Parameters> > +{ + typedef mtl::matrix::compressed2D<Value, Parameters> Matrix; + typedef typename mtl::Collection<Matrix>::value_type Scalar; + typedef typename mtl::Collection<Matrix>::size_type size_type; + public: + /// Construct with constant references to matrix and RHS vector + gauss_seidel(const Matrix& A) + : A(A), dia_inv(num_rows(A)), dia_pos(num_rows(A)) + { + BOOST_STATIC_ASSERT((mtl::traits::is_row_major<Matrix>::value)); // No CCS + assert(num_rows(A) == num_cols(A)); // Matrix must be square + for (size_type i= 0; i < num_rows(A); ++i) { + mtl::utilities::maybe<size_type> pos = A.indexer(A, i, i); + MTL_THROW_IF(!pos, mtl::missing_diagonal()); + dia_inv[i]= 1.0 / A.value_from_offset(pos); + dia_pos[i]= pos; + } + } + + /// Apply Gauss-Seidel on vector \p x, i.e. \p x is changed + template <typename Vector, typename RHSVector> + Vector& operator()(Vector& x, const RHSVector& b) const + { + mtl::vampir_trace<8551> tracer; + typedef typename mtl::Collection<Vector>::value_type value_type; + typedef typename mtl::Collection<Matrix>::size_type size_type; + const size_type nr= num_rows(A); + size_type cj1= A.ref_major()[0]; + for (size_type i= 0; i < nr; ++i) { + value_type tmp= b[i]; + size_type cj0= cj1, cjm= dia_pos[i]; + cj1= A.ref_major()[i+1]; + for (; cj0 < cjm; cj0++) + tmp-= A.data[cj0] * x[A.ref_minor()[cj0]]; + for (size_type j= cjm+1; j < cj1; j++) + tmp-= A.data[j] * x[A.ref_minor()[j]]; + x[i]= dia_inv[i] * tmp; + } + return x; + } + + + private: + const Matrix& A; + mtl::vector::dense_vector<Scalar> dia_inv; + mtl::vector::dense_vector<size_type> dia_pos; +}; + + +} // namespace itl + +#endif // ITL_GAUSS_SEIDEL_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/smoother/jacobi.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/smoother/jacobi.hpp new file mode 100644 index 0000000000000000000000000000000000000000..55436ad04eba08ec5f9781a999dd18002265b912 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/smoother/jacobi.hpp @@ -0,0 +1,139 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef ITL_JACOBI_INCLUDE +#define ITL_JACOBI_INCLUDE + +#include <boost/assert.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/operations.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/is_row_major.hpp> +#include <boost/numeric/mtl/utility/property_map.hpp> +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/matrix/compressed2D.hpp> + +namespace itl { + +/// Jacobi smoother +/** Constructor takes references to a matrix and a right-hand side vector. + operator() is applied on a vector and changes it in place. + Matrix must be square, stored row-major and free of zero entries in the diagonal. + Vectors b and x must have the same number of rows as A. +**/ +template <typename Matrix> +class jacobi +{ + typedef typename mtl::Collection<Matrix>::value_type Scalar; + typedef typename mtl::Collection<Matrix>::size_type size_type; + public: + /// Construct with constant references to matrix and RHS vector + jacobi(const Matrix& A) : A(A), dia_inv(num_rows(A)) + { + BOOST_STATIC_ASSERT((mtl::traits::is_row_major<Matrix>::value)); // No CCS + assert(num_rows(A) == num_cols(A)); // Matrix must be square + for (size_type i= 0; i < num_rows(A); ++i) { + Scalar a= A[i][i]; + MTL_THROW_IF(a == 0, mtl::missing_diagonal()); + dia_inv[i]= 1.0 / a; + } + } + + /// Apply Jacobi on vector \p x, i.e. \p x is changed + template <typename Vector, typename RHSVector> + Vector& operator()(Vector& x, const RHSVector& b) const + { + namespace tag= mtl::tag; using namespace mtl::traits; + using mtl::begin; using mtl::end; using std::swap; + + typedef typename range_generator<tag::row, Matrix>::type a_cur_type; + typedef typename range_generator<tag::nz, a_cur_type>::type a_icur_type; + typename col<Matrix>::type col_a(A); + typename const_value<Matrix>::type value_a(A); + + typedef typename mtl::Collection<Vector>::value_type value_type; + + static Vector x0(resource(x)); + a_cur_type ac= begin<tag::row>(A), aend= end<tag::row>(A); + for (unsigned i= 0; ac != aend; ++ac, ++i) { + value_type tmp= b[i]; + for (a_icur_type aic= begin<tag::nz>(ac), aiend= end<tag::nz>(ac); aic != aiend; ++aic) + if (col_a(*aic) != i) + tmp-= value_a(*aic) * x[col_a(*aic)]; + x0[i]= dia_inv[i] * tmp; + } + swap(x0, x); + return x; + } + + private: + const Matrix& A; + mtl::vector::dense_vector<Scalar> dia_inv; +}; + + +template <typename Value, typename Parameters> +class jacobi<mtl::matrix::compressed2D<Value, Parameters> > +{ + typedef mtl::matrix::compressed2D<Value, Parameters> Matrix; + typedef typename mtl::Collection<Matrix>::value_type Scalar; + typedef typename mtl::Collection<Matrix>::size_type size_type; + public: + /// Construct with constant references to matrix and RHS vector + jacobi(const Matrix& A) + : A(A), dia_inv(num_rows(A)), dia_pos(num_rows(A)) + { + BOOST_STATIC_ASSERT((mtl::traits::is_row_major<Matrix>::value)); // No CCS + assert(num_rows(A) == num_cols(A)); // Matrix must be square + for (size_type i= 0; i < num_rows(A); ++i) { + mtl::utilities::maybe<size_type> pos = A.indexer(A, i, i); + MTL_THROW_IF(!pos, mtl::missing_diagonal()); + dia_inv[i]= 1.0 / A.value_from_offset(pos); + dia_pos[i]= pos; + } + } + + /// Apply Jacobi on vector \p x, i.e. \p x is changed + template <typename Vector, typename RHSVector> + Vector& operator()(Vector& x, const RHSVector& b) const + { + typedef typename mtl::Collection<Vector>::value_type value_type; + typedef typename mtl::Collection<Matrix>::size_type size_type; + const size_type nr= num_rows(A); + static Vector x0(resource(x)); + size_type cj1= A.ref_major()[0]; + for (size_type i= 0; i < nr; ++i) { + value_type tmp= b[i]; + size_type cj0= cj1, cjm= dia_pos[i]; + cj1= A.ref_major()[i+1]; + for (; cj0 < cjm; cj0++) + tmp-= A.data[cj0] * x[A.ref_minor()[cj0]]; + for (size_type j= cjm+1; j < cj1; j++) + tmp-= A.data[j] * x[A.ref_minor()[j]]; + x0[i]= dia_inv[i] * tmp; + } + swap(x0, x); + return x; + } + + + private: + const Matrix& A; + mtl::vector::dense_vector<Scalar> dia_inv; + mtl::vector::dense_vector<size_type> dia_pos; +}; + + +} // namespace itl + +#endif // ITL_JACOBI_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/smoother/jor.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/smoother/jor.hpp new file mode 100644 index 0000000000000000000000000000000000000000..42b7df7c3fa9418f72769f54beb0456c01b0c36a --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/smoother/jor.hpp @@ -0,0 +1,140 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef ITL_JOR_INCLUDE +#define ITL_JOR_INCLUDE + +#include <boost/assert.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/is_row_major.hpp> +#include <boost/numeric/mtl/utility/property_map.hpp> +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/matrix/compressed2D.hpp> + +#include "./relaxation_parameter.hpp" + +namespace itl { + +/// Jacobi smoother with relaxation +/** Constructor takes references to a matrix and a right-hand side vector. + operator() is applied on a vector and changes it in place. + Matrix must be square, stored row-major and free of zero entries in the diagonal. + Vectors b and x must have the same number of rows as A. +**/ +template <typename Matrix, typename Omega = default_omega> +class jor +{ + typedef typename mtl::Collection<Matrix>::value_type Scalar; + typedef typename mtl::Collection<Matrix>::size_type size_type; + public: + /// Construct with constant references to matrix and RHS vector + jor(const Matrix& A) : A(A), dia_inv(num_rows(A)) + { + BOOST_STATIC_ASSERT((mtl::traits::is_row_major<Matrix>::value)); // No CCS + assert(num_rows(A) == num_cols(A)); // Matrix must be square + for (size_type i= 0; i < num_rows(A); ++i) { + Scalar a= A[i][i]; + MTL_THROW_IF(a == 0, mtl::missing_diagonal()); + dia_inv[i]= 1.0 / a; + } + } + + /// Apply JOR on vector \p x, i.e. \p x is changed + template <typename Vector, typename RHSVector> + Vector& operator()(Vector& x, const RHSVector& b) const + { + namespace tag= mtl::tag; using namespace mtl::traits; + using mtl::begin; using mtl::end; using std::swap; + + typedef typename range_generator<tag::row, Matrix>::type a_cur_type; + typedef typename range_generator<tag::nz, a_cur_type>::type a_icur_type; + typename col<Matrix>::type col_a(A); + typename const_value<Matrix>::type value_a(A); + + typedef typename mtl::Collection<Vector>::value_type value_type; + + static Vector x0(resource(x)); + a_cur_type ac= begin<tag::row>(A), aend= end<tag::row>(A); + for (unsigned i= 0; ac != aend; ++ac, ++i) { + value_type tmp= b[i]; + for (a_icur_type aic= begin<tag::nz>(ac), aiend= end<tag::nz>(ac); aic != aiend; ++aic) + if (col_a(*aic) != i) + tmp-= value_a(*aic) * x[col_a(*aic)]; + x0[i]= Omega::value * (dia_inv[i] * tmp) + (1. - Omega::value)*x0[i]; + } + swap(x0, x); + return x; + } + + private: + const Matrix& A; + mtl::vector::dense_vector<Scalar> dia_inv; +}; + + +template <typename Value, typename Parameters, typename Omega> +class jor<mtl::matrix::compressed2D<Value, Parameters> , Omega> +{ + typedef mtl::matrix::compressed2D<Value, Parameters> Matrix; + typedef typename mtl::Collection<Matrix>::value_type Scalar; + typedef typename mtl::Collection<Matrix>::size_type size_type; + public: + /// Construct with constant references to matrix and RHS vector + jor(const Matrix& A) + : A(A), dia_inv(num_rows(A)), dia_pos(num_rows(A)) + { + BOOST_STATIC_ASSERT((mtl::traits::is_row_major<Matrix>::value)); // No CCS + assert(num_rows(A) == num_cols(A)); // Matrix must be square + for (size_type i= 0; i < num_rows(A); ++i) { + mtl::utilities::maybe<size_type> pos = A.indexer(A, i, i); + MTL_THROW_IF(!pos, mtl::missing_diagonal()); + dia_inv[i]= 1.0 / A.value_from_offset(pos); + dia_pos[i]= pos; + } + } + + /// Apply JOR on vector \p x, i.e. \p x is changed + template <typename Vector, typename RHSVector> + Vector& operator()(Vector& x, const RHSVector& b) const + { + typedef typename mtl::Collection<Vector>::value_type value_type; + typedef typename mtl::Collection<Matrix>::size_type size_type; + const size_type nr= num_rows(A); + static Vector x0(resource(x)); + size_type cj1= A.ref_major()[0]; + for (size_type i= 0; i < nr; ++i) { + value_type tmp= b[i]; + size_type cj0= cj1, cjm= dia_pos[i]; + cj1= A.ref_major()[i+1]; + for (; cj0 < cjm; cj0++) + tmp-= A.data[cj0] * x[A.ref_minor()[cj0]]; + for (size_type j= cjm+1; j < cj1; j++) + tmp-= A.data[j] * x[A.ref_minor()[j]]; + x0[i] = Omega::value * (dia_inv[i] * tmp) + (1. - Omega::value)*x0[i]; + } + swap(x0, x); + return x; + } + + + private: + const Matrix& A; + mtl::vector::dense_vector<Scalar> dia_inv; + mtl::vector::dense_vector<size_type> dia_pos; +}; + + +} // namespace itl + +#endif // ITL_JOR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/smoother/relaxation_parameter.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/smoother/relaxation_parameter.hpp new file mode 100644 index 0000000000000000000000000000000000000000..800d194ff0497d3f99ebaa833c6cac203e1ad1fd --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/smoother/relaxation_parameter.hpp @@ -0,0 +1,28 @@ +/* + * Marcel Schiffel, 13.10.11 + * + * definition of default relaxation parameter for iterative solvers + */ + + +#ifndef MTL_ITL_RELAXATION_PARAMETER_HPP +#define MTL_ITL_RELAXATION_PARAMETER_HPP + + +namespace itl { + + +/** + * default relaxation parameter for iterative solvers + */ +struct default_omega +{ + static const double value; +}; + +const double default_omega::value= 2./3.; + +} /* namespace itl */ + +#endif + diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/smoother/repeated.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/smoother/repeated.hpp new file mode 100644 index 0000000000000000000000000000000000000000..e569ad4d2d60f623ed4c70f0d5415b5ff4bdc5ed --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/smoother/repeated.hpp @@ -0,0 +1,50 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef ITL_REPEATED_INCLUDE +#define ITL_REPEATED_INCLUDE + +namespace itl { + +/// Repeat the smoother +template <typename Smoother, std::size_t N= 1> +class repeated +{ + public: + + typedef Smoother smoother_type; + + /// Construct with \p smoother + repeated(const Smoother& smoother) : smoother(smoother) {} + + /// Construct with \p smoother and number of repetitions \p n + template <typename Matrix> + repeated(const Matrix& A) : smoother(A) {} + + /// Apply smoother n times on vector \p x, i.e. \p x is changed + template <typename Vector, typename RHSVector> + Vector& operator()(Vector& x, const RHSVector& b) const + { + for (std::size_t i= 0; i < N; i++) + smoother(x, b); + return x; + } + + private: + Smoother smoother; + std::size_t n; +}; + + +} // namespace itl + +#endif // ITL_REPEATED_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/smoother/sor.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/smoother/sor.hpp new file mode 100644 index 0000000000000000000000000000000000000000..902b230691f0942c5a5530f3d75cf6c1fbe653e4 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/smoother/sor.hpp @@ -0,0 +1,138 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef ITL_SOR_INCLUDE +#define ITL_SOR_INCLUDE + +#include <boost/assert.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/is_row_major.hpp> +#include <boost/numeric/mtl/utility/property_map.hpp> +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/matrix/compressed2D.hpp> + +#include "./relaxation_parameter.hpp" + +namespace itl { + +/// Gauss-Seidel smoother with relaxation +/** Constructor takes references to a matrix and a right-hand side vector. + operator() is applied on a vector and changes it in place. + Matrix must be square, stored row-major and free of zero entries in the diagonal. + Vectors b and x must have the same number of rows as A. +**/ +template <typename Matrix, typename Omega = default_omega> +class sor +{ + typedef typename mtl::Collection<Matrix>::value_type Scalar; + typedef typename mtl::Collection<Matrix>::size_type size_type; + + public: + /// Construct with constant references to matrix and RHS vector + sor(const Matrix& A) : A(A), dia_inv(num_rows(A)) + { + BOOST_STATIC_ASSERT((mtl::traits::is_row_major<Matrix>::value)); // No CCS + assert(num_rows(A) == num_cols(A)); // Matrix must be square + for (size_type i= 0; i < num_rows(A); ++i) { + Scalar a= A[i][i]; + MTL_THROW_IF(a == 0, mtl::missing_diagonal()); + dia_inv[i]= 1.0 / a; + } + } + + /// Apply SOR on vector \p x, i.e. \p x is changed + template <typename Vector, typename RHSVector> + Vector& operator()(Vector& x, const RHSVector& b) const + { + namespace tag= mtl::tag; using namespace mtl::traits; + using mtl::begin; using mtl::end; + + typedef typename range_generator<tag::row, Matrix>::type a_cur_type; + typedef typename range_generator<tag::nz, a_cur_type>::type a_icur_type; + typename col<Matrix>::type col_a(A); + typename const_value<Matrix>::type value_a(A); + + typedef typename mtl::Collection<Vector>::value_type value_type; + + a_cur_type ac= begin<tag::row>(A), aend= end<tag::row>(A); + for (unsigned i= 0; ac != aend; ++ac, ++i) { + value_type tmp= b[i]; + for (a_icur_type aic= begin<tag::nz>(ac), aiend= end<tag::nz>(ac); aic != aiend; ++aic) + if (col_a(*aic) != i) + tmp-= value_a(*aic) * x[col_a(*aic)]; + x[i] = Omega::value * (dia_inv[i] * tmp) + (1. - Omega::value)*x[i]; + } + return x; + } + + private: + const Matrix& A; + mtl::vector::dense_vector<Scalar> dia_inv; +}; + + +template <typename Value, typename Parameters, typename Omega> +class sor<mtl::matrix::compressed2D<Value, Parameters> , Omega> +{ + typedef mtl::matrix::compressed2D<Value, Parameters> Matrix; + typedef typename mtl::Collection<Matrix>::value_type Scalar; + typedef typename mtl::Collection<Matrix>::size_type size_type; + + public: + /// Construct with constant references to matrix and RHS vector + sor(const Matrix& A) + : A(A), dia_inv(num_rows(A)), dia_pos(num_rows(A)) + { + BOOST_STATIC_ASSERT((mtl::traits::is_row_major<Matrix>::value)); // No CCS + assert(num_rows(A) == num_cols(A)); // Matrix must be square + for (size_type i= 0; i < num_rows(A); ++i) { + mtl::utilities::maybe<size_type> pos = A.indexer(A, i, i); + MTL_THROW_IF(!pos, mtl::missing_diagonal()); + dia_inv[i]= 1.0 / A.value_from_offset(pos); + dia_pos[i]= pos; + } + } + + /// Apply SOR on vector \p x, i.e. \p x is changed + template <typename Vector, typename RHSVector> + Vector& operator()(Vector& x, const RHSVector& b) const + { + typedef typename mtl::Collection<Vector>::value_type value_type; + typedef typename mtl::Collection<Matrix>::size_type size_type; + const size_type nr= num_rows(A); + size_type cj1= A.ref_major()[0]; + for (size_type i= 0; i < nr; ++i) { + value_type tmp= b[i]; + size_type cj0= cj1, cjm= dia_pos[i]; + cj1= A.ref_major()[i+1]; + for (; cj0 < cjm; cj0++) + tmp-= A.data[cj0] * x[A.ref_minor()[cj0]]; + for (size_type j= cjm+1; j < cj1; j++) + tmp-= A.data[j] * x[A.ref_minor()[j]]; + x[i]= Omega::value * (dia_inv[i] * tmp) + (1. - Omega::value)*x[i]; + } + return x; + } + + + private: + const Matrix& A; + mtl::vector::dense_vector<Scalar> dia_inv; + mtl::vector::dense_vector<size_type> dia_pos; +}; + + +} // namespace itl + +#endif // ITL_GAUSS_SEIDEL_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/stepper/armijo.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/stepper/armijo.hpp new file mode 100644 index 0000000000000000000000000000000000000000..8f4aa41b8a5004a200290c6f1d979fbf78125cdf --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/stepper/armijo.hpp @@ -0,0 +1,53 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling, Cornelius Steinhardt and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef ITL_ARMIJO_INCLUDE +#define ITL_ARMIJO_INCLUDE + +namespace itl { + +/// Step size control by Armijo +/** + **/ +template <typename Value= double> +class armijo +{ + public: + typedef Value value_type; + + // Defaults from Prof. Fischer's lecture + armijo(Value delta= 0.5, Value gamma= 0.5, Value beta1= 0.25, Value beta2= 0.5) + : delta(delta), gamma(gamma), beta1(beta1), beta((beta1 + beta2) / 2.0) {} + + /// + template <typename Vector, typename F, typename Grad> + typename mtl::Collection<Vector>::value_type + operator() (const Vector& x, const Vector& d, F f, Grad grad_f) const + { + // Star's step size + typename mtl::Collection<Vector>::value_type alpha= -gamma * dot(grad_f(x), d) / dot(d, d); + Vector x_k(x + alpha * d); + + while (f(x_k) > f(x) + (beta1 * alpha) * dot(grad_f(x), d)) { + alpha*= beta; + x_k= x+ alpha * d; + } + return alpha; + } + private: + Value delta, gamma, beta1, beta; +}; + + +} // namespace itl + +#endif // ITL_ARMIJO_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/stepper/wolf.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/stepper/wolf.hpp new file mode 100644 index 0000000000000000000000000000000000000000..fedf04f330b1b231a07da31d0fc7c721f8503468 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/stepper/wolf.hpp @@ -0,0 +1,55 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling, Cornelius Steinhardt and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef ITL_WOLF_INCLUDE +#define ITL_WOLF_INCLUDE + +namespace itl { + +/// Step size control by Wolf +/** + **/ +template <typename Value= double> +class wolf +{ + public: + typedef Value value_type; + + // Defaults from Prof. Fischer's lecture + wolf(Value delta= 0.5, Value gamma= 0.5, Value beta1= 0.25, Value beta2= 0.5) + : delta(delta), gamma(gamma), beta1(beta1), beta2(beta2) {} + + /// + template <typename Vector, typename F, typename Grad> + typename mtl::Collection<Vector>::value_type + operator() (const Vector& x, const Vector& d, F f, Grad grad_f) const + { + // Star's step size + typename mtl::Collection<Vector>::value_type alpha= -gamma * dot(grad_f(x), d) / dot(d, d); + Vector x_k(x + alpha * d); + + Value beta= (beta1 + beta2) / 2; + while (f(x_k) > f(x) + (beta1 * alpha) * dot(grad_f(x), d) + && dot(grad_f(x_k), d) < beta2 * dot(grad_f(x), d)) { + alpha*= beta; + x_k= x+ alpha * d; + } + return alpha; + } + private: + Value delta, gamma, beta1, beta2; +}; + + +} // namespace itl + +#endif // ITL_WOLF_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/updater/bfgs.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/updater/bfgs.hpp new file mode 100644 index 0000000000000000000000000000000000000000..dde5183977dbe72df3cba7634ecf3be59a075d29 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/updater/bfgs.hpp @@ -0,0 +1,44 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef ITL_BFGS_INCLUDE +#define ITL_BFGS_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/itl/utility/exception.hpp> + +namespace itl { + +/// Update of Hessian matrix for e.g. Quasi-Newton by Broyden, Fletcher, Goldfarb, and Shanno +struct bfgs +{ + /// \f$ H_{k+1}=B_{k+1}^{-1}=(I-\frac{y_k\cdot s_k^T}{y_k^T\cdot s_k})^T\cdot H_k \cdot (I-\frac{y_k\cdot s_k^T}{y_k^T\cdot s_k}) + \frac{s_k\cdot s_k^T}{y_k^T\cdot s_k}\f$ + template <typename Matrix, typename Vector> + void operator() (Matrix& H, const Vector& y, const Vector& s) + { + typedef typename mtl::Collection<Vector>::value_type value_type; + assert(num_rows(H) == num_cols(H)); + + value_type gamma= 1 / dot(y,s); + MTL_THROW_IF(gamma == 0.0, unexpected_orthogonality()); + Matrix A(math::one(H) - gamma * s * trans(y)), + H2(A * H * trans(A) + gamma * s * trans(s)); + swap(H2, H); // faster than H= H2 + } +}; + + + +} // namespace itl + +#endif // ITL_BFGS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/updater/broyden.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/updater/broyden.hpp new file mode 100644 index 0000000000000000000000000000000000000000..40b34703927ea71f215f303f80c655d26796c286 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/updater/broyden.hpp @@ -0,0 +1,45 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef ITL_BROYDEN_INCLUDE +#define ITL_BROYDEN_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/itl/utility/exception.hpp> + +namespace itl { + +/// Update of Hessian matrix for e.g. Quasi-Newton by Broyden formula +struct broyden +{ + /// \f$ H_{k+1}=B_{k+1}^{-1}=H_k+\frac{(s_k-H_k\cdot y_k)\cdot y_k^T\cdot H_k}{y_k^T\cdot H_k\cdot s_k} \f$ + template <typename Matrix, typename Vector> + void operator() (Matrix& H, const Vector& y, const Vector& s) + { + typedef typename mtl::Collection<Vector>::value_type value_type; + assert(num_rows(H) == num_cols(H)); + + Vector h(H * y), d(s - h); + value_type gamma= 1 / dot(y, h); + MTL_THROW_IF(gamma == 0.0, unexpected_orthogonality()); + Matrix A(gamma * d * trans(y)), + H2(H + A * H); + swap(H2, H); // faster than H= H2 + } +}; + + + +} // namespace itl + +#endif // ITL_BROYDEN_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/updater/dfp.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/updater/dfp.hpp new file mode 100644 index 0000000000000000000000000000000000000000..8715011144cf951ce1dcd3085b8dcdd1a1f4aec1 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/updater/dfp.hpp @@ -0,0 +1,46 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef ITL_DFP_INCLUDE +#define ITL_DFP_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/itl/utility/exception.hpp> + +namespace itl { + +/// Update of Hessian matrix for e.g. Quasi-Newton by Davidon, Fletcher and Powell formula +struct dfp +{ + /// \f$ H_{k+1}=B_{k+1}^{-1}=H_k+\frac{s_k\cdot s_k^T}{y_k^T\cdot s_k}- \frac{H_k\cdot y_k\cdot y_k^T\cdot H_k^T}{y_k^TH_k\cdot y_k}\f$ + template <typename Matrix, typename Vector> + void operator() (Matrix& H, const Vector& y, const Vector& s) + { + typedef typename mtl::Collection<Vector>::value_type value_type; + assert(num_rows(H) == num_cols(H)); + + Vector h(H*y); + value_type gamma= 1 / dot(y,s), alpha= 1 / dot(y,h); + MTL_THROW_IF(gamma == 0.0, unexpected_orthogonality()); + MTL_THROW_IF(alpha == 0.0, unexpected_orthogonality()); + Matrix A(alpha * y * trans(y)), + H2(H - H * A * H + gamma * s * trans(s)); + swap(H2, H); // faster than H= H2 + } +}; + + + +} // namespace itl + +#endif // ITL_DFP_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/updater/psb.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/updater/psb.hpp new file mode 100644 index 0000000000000000000000000000000000000000..304da7790cf69582617efd2847b984246e3b76ec --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/updater/psb.hpp @@ -0,0 +1,44 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef ITL_PSB_INCLUDE +#define ITL_PSB_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/itl/utility/exception.hpp> + +namespace itl { + +/// Update of Hessian matrix for e.g. Quasi-Newton by Powell's symmetric Broyden formula +struct psb +{ + /// \f$ H_{k+1}=B_{k+1}^{-1}=H_k+\frac{(y_k-H_k\cdot s_k)s_k^T+s_k(y_k-H_k\cdot s_k)^T}{s_k^T\cdot s_k}-\frac{(y_k-H_k\cdot s_k)^T\cdot s_k}{(s_k^ts_k)^2}s_k\cdot s_k^T \f$ + template <typename Matrix, typename Vector> + void operator() (Matrix& H, const Vector& y, const Vector& s) + { + typedef typename mtl::Collection<Vector>::value_type value_type; + assert(num_rows(H) == num_cols(H)); + Vector a(s - H * y); + value_type gamma= 1 / dot (y, y); + MTL_THROW_IF(gamma == 0.0, unexpected_orthogonality()); + + H+= gamma * a * trans(y) + gamma * y * trans(a) - dot(a, y) * gamma * gamma * y * trans(y); + } +}; + + + +} // namespace itl + +#endif // ITL_PSB_INCLUDE + diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/updater/sr1.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/updater/sr1.hpp new file mode 100644 index 0000000000000000000000000000000000000000..a8caaace426f6eb824a36816606f3f4a7ae63062 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/updater/sr1.hpp @@ -0,0 +1,40 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef ITL_SR1_INCLUDE +#define ITL_SR1_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/itl/utility/exception.hpp> + +namespace itl { + +/// Update of Hessian matrix for e.g. Quasi-Newton by SR1 formulas +struct sr1 +{ + /// \f$ H_{k+1}=B_{k+1}^{-1}=H_k+\frac{(s_k-H_k\cdot y_k)(s_k-H_k\cdot y_k)^T}{(s_k-H_k\cdot y_k)^T\cdot y_k} \f$ + template <typename Matrix, typename Vector> + void operator() (Matrix& H, const Vector& y, const Vector& s) + { + assert(num_rows(H) == num_cols(H)); + Vector d(s - H * y); + MTL_THROW_IF(dot(d, y) == 0.0, unexpected_orthogonality()); + H+= 1 / dot(d, y) * d * trans(d); + } +}; + + + +} // namespace itl + +#endif // ITL_SR1_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/itl/utility/exception.hpp b/AMDiS/lib/mtl4/boost/numeric/itl/utility/exception.hpp new file mode 100644 index 0000000000000000000000000000000000000000..4ce324c19299b3adc219f518363f384d5ebd3cdd --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/itl/utility/exception.hpp @@ -0,0 +1,35 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef ITL_EXCEPTION_INCLUDE +#define ITL_EXCEPTION_INCLUDE + +#include <boost/numeric/mtl/utility/exception.hpp> + +namespace itl { + +/// Exception for iterative solvers that exhausted the search space, i.e. search direction(s) parallel to already visited Krylov subspace +/** Either your matrix is too badly conditioned or your termination criterion is too strict for the used arithmetic (maybe use Gnu Multi-precision library). **/ +struct search_space_exhaustion + : mtl::runtime_error +{ + /// Error can be specified more precisely in constructor if desired + explicit search_space_exhaustion(const char *s= "Iterative solvers that exhausted the search space, i.e. search direction(s) parallel to already visited Krylov subspace") + : mtl::runtime_error(s) {} +}; + +/// Vectors unexpectedly become orthogonal, special case of search_space_exhaustion. +struct unexpected_orthogonality : search_space_exhaustion {}; + +} // namespace itl + +#endif // ITL_EXCEPTION_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/linear_algebra/accumulate.hpp b/AMDiS/lib/mtl4/boost/numeric/linear_algebra/accumulate.hpp new file mode 100644 index 0000000000000000000000000000000000000000..05572bd0ccd688c4fa6ccbca2f72482b3f1a689b --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/linear_algebra/accumulate.hpp @@ -0,0 +1,66 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + + +#ifndef MATH_ACCUMULATE_INCLUDE +#define MATH_ACCUMULATE_INCLUDE + +#include <concepts> + +#include <boost/numeric/linear_algebra/identity.hpp> +#include <boost/numeric/linear_algebra/new_concepts.hpp> + +namespace math { + +// Dispatching between simple and unrolled version +template <std::InputIterator Iter, std::CopyConstructible Value, typename Op> + requires std::Callable2<Op, Value, Value> + && std::CopyAssignable<Value, std::Callable2<Op, Value, Value>::result_type> +Value inline accumulate(Iter first, Iter last, Value init, Op op) +{ + // std::cout << "Simple accumulate\n"; + for (; first != last; ++first) + init= op(init, Value(*first)); + return init; +} + + +template <std::RandomAccessIterator Iter, std::CopyConstructible Value, typename Op> + requires std::Callable2<Op, Value, Value> + && std::CopyAssignable<Value, std::Callable2<Op, Value, Value>::result_type> + && Commutative<Op, Value> + && Monoid<Op, Value> + && std::Convertible<Monoid<Op, Value>::identity_result_type, Value> +Value inline accumulate(Iter first, Iter last, Value init, Op op) +{ + // std::cout << "Unrolled accumulate\n"; + typedef typename std::RandomAccessIterator<Iter>::difference_type difference_type; + Value t0= identity(op, init), t1= identity(op, init), + t2= identity(op, init), t3= init; + difference_type size= last - first, bsize= size >> 2 << 2, i; + + for (i= 0; i < bsize; i+= 4) { + t0= op(t0, Value(first[i])); + t1= op(t1, Value(first[i+1])); + t2= op(t2, Value(first[i+2])); + t3= op(t3, Value(first[i+3])); + } + for (; i < size; i++) + t0= op(t0, Value(first[i])); + + t0= op(t0, t1), t2= op(t2, t3), t0= op(t0, t2); + return t0; +} + +} // namespace math + +#endif // MATH_ACCUMULATE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/linear_algebra/algebraic_concepts.hpp b/AMDiS/lib/mtl4/boost/numeric/linear_algebra/algebraic_concepts.hpp new file mode 100644 index 0000000000000000000000000000000000000000..6b8817016d28bc9cefe0854df567697db32ff504 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/linear_algebra/algebraic_concepts.hpp @@ -0,0 +1,521 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef LA_ALGEBRAIC_CONCEPTS_DOC_INCLUDE +#define LA_ALGEBRAIC_CONCEPTS_DOC_INCLUDE + +#ifdef __GXX_CONCEPTS__ +# include <concepts> +#else +# include <boost/numeric/linear_algebra/pseudo_concept.hpp> +#endif + +#include <boost/numeric/linear_algebra/identity.hpp> +#include <boost/numeric/linear_algebra/inverse.hpp> + +/// Namespace for purely algebraic concepts +namespace algebra { + +/** @addtogroup Concepts + * @{ + */ + +#ifndef __GXX_CONCEPTS__ + //! Concept Commutative + /*! + \param Operation A functor implementing a binary operation + \param Element The type upon the binary operation is defined + + \par Notation: + <table summary="notation"> + <tr> + <td>op</td> + <td>Object of type Operation</td> + </tr> + <tr> + <td>x, y</td> + <td>Objects of type Element</td> + </tr> + </table> + \invariant + <table summary="invariants"> + <tr> + <td>Commutativity</td> + <td>op(x, y) == op(y, x)</td> + </tr> + </table> + */ + template <typename Operation, typename Element> + struct Commutative + {}; +#else + concept Commutative<typename Operation, typename Element> + { + axiom Commutativity(Operation op, Element x, Element y) + { + op(x, y) == op(y, x); + } + }; +#endif + + +#ifndef __GXX_CONCEPTS__ + //! Concept Associative + /*! + \param Operation A functor implementing a binary operation + \param Element The type upon the binary operation is defined + + \par Notation: + <table summary="notation"> + <tr> + <td>op</td> + <td>Object of type Operation</td> + </tr> + <tr> + <td>x, y, z</td> + <td>Objects of type Element</td> + </tr> + </table> + \invariant + <table summary="invariants"> + <tr> + <td>Associativity</td> + <td>op(x, op(y, z)) == op(op(x, y), z)</td> + </tr> + </table> + */ + template <typename Operation, typename Element> + struct Associative + {}; +#else + concept Associative<typename Operation, typename Element> + { + axiom Associativity(Operation op, Element x, Element y, Element z) + { + op(x, op(y, z)) == op(op(x, y), z); + } + }; +#endif + + +#ifndef __GXX_CONCEPTS__ + //! Concept SemiGroup + /*! + \param Operation A functor implementing a binary operation + \param Element The type upon the binary operation is defined + + \note + -# The algebraic concept SemiGroup only requires associativity and is identical with the concept Associative. + */ + template <typename Operation, typename Element> + struct SemiGroup + : Associative<Operation, Element> + {}; +#else + auto concept SemiGroup<typename Operation, typename Element> + : Associative<Operation, Element> + {}; +#endif + + +#ifndef __GXX_CONCEPTS__ + //! Concept Monoid + /*! + \param Operation A functor implementing a binary operation + \param Element The type upon the binary operation is defined + + \par Refinement of: + - SemiGroup + \par Notation: + <table summary="notation"> + <tr> + <td>op</td> + <td>Object of type Operation</td> + </tr> + <tr> + <td>x</td> + <td>Object of type Element</td> + </tr> + </table> + \invariant + <table summary="invariants"> + <tr> + <td>Neutrality from right</td> + <td>op( x, identity(op, x) ) == x</td> + </tr> + <tr> + <td>Neutrality from left</td> + <td>op( identity(op, x), x ) == x</td> + </tr> + </table> + */ + template <typename Operation, typename Element> + struct Monoid + : SemiGroup<Operation, Element> + { + /// Associated type; if not defined in concept_map automatically detected as result of identity + typedef associated_type identity_result_type; + identity_result_type identity(Operation, Element); ///< Identity element of Operation + }; +#else + concept Monoid<typename Operation, typename Element> + : SemiGroup<Operation, Element> + { + typename identity_result_type; + identity_result_type identity(Operation, Element); + + axiom Neutrality(Operation op, Element x) + { + op( x, identity(op, x) ) == x; + op( identity(op, x), x ) == x; + } + }; +#endif + +#ifdef __GXX_CONCEPTS__ + auto concept Inversion<typename Operation, typename Element> + { + typename inverse_result_type; + inverse_result_type inverse(Operation, Element); + + }; +#else + //! Concept Inversion + /*! + \param Operation A functor implementing a binary operation + \param Element The type upon the binary operation is defined + + \par Associated Types: + - inverse_result_type + \par Valid Expressions: + - inverse(op, x); + */ + template <typename Operation, typename Element> + struct Inversion + { + /// Associated type; if not defined in concept_map automatically detected as result of inverse + typedef associated_type inverse_result_type; + + /// Returns inverse of \p x regarding operation \p op + inverse_result_type inverse(Operation op, Element x); + }; +#endif + + +#ifdef __GXX_CONCEPTS__ + concept Group<typename Operation, typename Element> + : Monoid<Operation, Element>, Inversion<Operation, Element> + { + axiom Inversion(Operation op, Element x) + { + op( x, inverse(op, x) ) == identity(op, x); + op( inverse(op, x), x ) == identity(op, x); + } + }; +#else + //! Concept Group + /*! + \param Operation A functor implementing a binary operation + \param Element The type upon the binary operation is defined + + \par Refinement of: + - Monoid + - Inversion + \par Notation: + <table summary="notation"> + <tr> + <td>op</td> + <td>Object of type Operation</td> + </tr> + <tr> + <td>x</td> + <td>Object of type Element</td> + </tr> + </table> + \invariant + <table summary="invariants"> + <tr> + <td>Inverse from right</td> + <td>op( x, inverse(op, x) ) == identity(op, x)</td> + </tr> + <tr> + <td>Inverse from left</td> + <td>op( inverse(op, x), x ) == identity(op, x)</td> + </tr> + </table> + */ + template <typename Operation, typename Element> + struct Group + : Monoid<Operation, Element>, + Inversion<Operation, Element> + {}; +#endif + + +#ifdef __GXX_CONCEPTS__ + auto concept AbelianGroup<typename Operation, typename Element> + : Group<Operation, Element>, Commutative<Operation, Element> + {}; +#else + //! Concept AbelianGroup + /*! + \param Operation A functor implementing a binary operation + \param Element The type upon the binary operation is defined + + \par Refinement of: + - Group + - Commutative + */ + template <typename Operation, typename Element> + struct AbelianGroup + : Group<Operation, Element>, + Commutative<Operation, Element> + {}; +#endif + + +#ifdef __GXX_CONCEPTS__ + concept Distributive<typename AddOp, typename MultOp, typename Element> + { + axiom Distributivity(AddOp add, MultOp mult, Element x, Element y, Element z) + { + // From left + mult(x, add(y, z)) == add(mult(x, y), mult(x, z)); + // z right + mult(add(x, y), z) == add(mult(x, z), mult(y, z)); + } + }; +#else + //! Concept Distributive + /*! + \param AddOp A functor implementing a binary operation representing addition + \param MultOp A functor implementing a binary operation representing multiplication + \param Element The type upon the binary operation is defined + + \par Notation: + <table summary="notation"> + <tr> + <td>add</td> + <td>Object of type AddOp</td> + </tr> + <tr> + <td>mult</td> + <td>Object of type Multop</td> + </tr> + <tr> + <td>x, y, z</td> + <td>Objects of type Element</td> + </tr> + </table> + \invariant + <table summary="invariants"> + <tr> + <td>Distributivity from left</td> + <td>mult(x, add(y, z)) == add(mult(x, y), mult(x, z))</td> + </tr> + <tr> + <td>Distributivity from right</td> + <td>mult(add(x, y), z) == add(mult(x, z), mult(y, z))</td> + </tr> + </table> + */ + template <typename AddOp, typename MultOp, typename Element> + struct Distributive + {}; +#endif + + +#ifdef __GXX_CONCEPTS__ + auto concept Ring<typename AddOp, typename MultOp, typename Element> + : AbelianGroup<AddOp, Element>, + SemiGroup<MultOp, Element>, + Distributive<AddOp, MultOp, Element> + {}; +#else + //! Concept Ring + /*! + \param AddOp A functor implementing a binary operation representing addition + \param MultOp A functor implementing a binary operation representing multiplication + \param Element The type upon the binary operation is defined + + \par Refinement of: + - AbelianGroup <MultOp, Element> + - SemiGroup <MultOp, Element> + - Distributive <AddOp, MultOp, Element> + */ + template <typename AddOp, typename MultOp, typename Element> + struct Ring + : AbelianGroup<AddOp, Element>, + SemiGroup<MultOp, Element>, + Distributive<AddOp, MultOp, Element> + {}; +#endif + + +#ifdef __GXX_CONCEPTS__ + auto concept RingWithIdentity<typename AddOp, typename MultOp, typename Element> + : Ring<AddOp, MultOp, Element>, + Monoid<MultOp, Element> + {}; +#else + //! Concept RingWithIdentity + /*! + \param AddOp A functor implementing a binary operation representing addition + \param MultOp A functor implementing a binary operation representing multiplication + \param Element The type upon the binary operation is defined + + \par Refinement of: + - Ring <AddOp, MultOp, Element> + - Monoid <MultOp, Element> + */ + template <typename AddOp, typename MultOp, typename Element> + struct RingWithIdentity + : Ring<AddOp, MultOp, Element>, + Monoid<MultOp, Element> + {}; +#endif + + +#ifdef __GXX_CONCEPTS__ + concept DivisionRing<typename AddOp, typename MultOp, typename Element> + : RingWithIdentity<AddOp, MultOp, Element>, + Inversion<MultOp, Element> + { + // 0 != 1, otherwise trivial + axiom ZeroIsDifferentFromOne(AddOp add, MultOp mult, Element x) + { + identity(add, x) != identity(mult, x); + } + + // Non-zero divisibility from left and from right + axiom NonZeroDivisibility(AddOp add, MultOp mult, Element x) + { + if (x != identity(add, x)) + mult(inverse(mult, x), x) == identity(mult, x); + if (x != identity(add, x)) + mult(x, inverse(mult, x)) == identity(mult, x); + } + }; +#else + //! Concept DivisionRing + /*! + \param AddOp A functor implementing a binary operation representing addition + \param MultOp A functor implementing a binary operation representing multiplication + \param Element The type upon the binary operation is defined + + \par Refinement of: + - RingWithIdentity <AddOp, MultOp, Element> + - Inversion <MultOp, Element> + + \par Notation: + <table summary="notation"> + <tr> + <td>add</td> + <td>Object of type AddOp</td> + </tr> + <tr> + <td>mult</td> + <td>Object of type Multop</td> + </tr> + <tr> + <td>x, y, z</td> + <td>Objects of type Element</td> + </tr> + </table> + + \invariant + <table summary="invariants"> + <tr> + <td>Non-zero divisibility from left</td> + <td>mult(inverse(mult, x), x) == identity(mult, x)</td> + <td>if x != identity(add, x)</td> + </tr> + <tr> + <td>Non-zero divisibility from right</td> + <td>mult(x, inverse(mult, x)) == identity(mult, x)</td> + <td>if x != identity(add, x)</td> + </tr> + <tr> + <td>Zero is different from one</td> + <td>identity(add, x) != identity(mult, x)</td> + <td></td> + </tr> + </table> + + \note + -# Zero and one can be theoretically identical in a DivisionRing. However, + this implies that there is only one element x in the Ring with x + x = x and + x * x = x (which is actually even a Field). + Because this structure has no practical value we exclude it from + consideration. + */ + template <typename AddOp, typename MultOp, typename Element> + struct DivisionRing + : RingWithIdentity<AddOp, MultOp, Element>, + Inversion<MultOp, Element> + {}; +#endif + + +#ifdef __GXX_CONCEPTS__ + // SkewField is defined as synonym for DivisionRing + auto concept SkewField<typename AddOp, typename MultOp, typename Element> + : DivisionRing<AddOp, MultOp, Element> + {}; +#else + //! Concept SkewField + /*! + \param AddOp A functor implementing a binary operation representing addition + \param MultOp A functor implementing a binary operation representing multiplication + \param Element The type upon the binary operation is defined + + \par Refinement of: + - DivisionRing <AddOp, MultOp, Element> + \note + - Because the refinement of DivisionRing to SkewField is automatic the two concepts + are identical. + */ + template <typename AddOp, typename MultOp, typename Element> + struct SkewField + : DivisionRing<AddOp, MultOp, Element> + {}; +#endif + + +#ifdef __GXX_CONCEPTS__ + auto concept Field<typename AddOp, typename MultOp, typename Element> + : DivisionRing<AddOp, MultOp, Element>, + Commutative<MultOp, Element> + {}; +#else + //! Concept Field + /*! + \param AddOp A functor implementing a binary operation representing addition + \param MultOp A functor implementing a binary operation representing multiplication + \param Element The type upon the binary operation is defined + + \par Refinement of: + - DivisionRing <AddOp, MultOp, Element> + - Commutative <MultOp, Element> + */ + template <typename AddOp, typename MultOp, typename Element> + struct Field + : DivisionRing<AddOp, MultOp, Element>, + Commutative<MultOp, Element> + {}; +#endif + +/*@}*/ // end of group Concepts + +} // algebra + +#endif // LA_ALGEBRAIC_CONCEPTS_DOC_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/linear_algebra/concept_maps.hpp b/AMDiS/lib/mtl4/boost/numeric/linear_algebra/concept_maps.hpp new file mode 100644 index 0000000000000000000000000000000000000000..30c1804975025a673735f3ae1378aaceb765b6c5 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/linear_algebra/concept_maps.hpp @@ -0,0 +1,87 @@ +// $COPYRIGHT$ + +#ifndef MATH_CONCEPT_MAPS_INCLUDE +#define MATH_CONCEPT_MAPS_INCLUDE + +#include <boost/numeric/linear_algebra/intrinsic_concept_maps.hpp> +#include <boost/numeric/linear_algebra/new_concepts.hpp> + + +namespace math { + +#if 0 // Why this doesn't work??? + template <typename T> + requires IntrinsicUnsignedIntegral<T> + concept_map UnsignedIntegral<T> {} + + template <typename T> + requires IntrinsicSignedIntegral<T> + concept_map SignedIntegral<T> {} +#endif + + concept_map UnsignedIntegral<unsigned int> {} + concept_map AdditiveMonoid<unsigned int> {} + + concept_map SignedIntegral<int> {} + concept_map AdditiveSemiGroup<int> {} + + concept_map Commutative< add<int>, int > {} + concept_map Monoid< add<int>, int > {} + concept_map AbelianGroup< add<int>, int > {} + + concept_map Commutative< mult<int>, int > {} + concept_map Monoid< mult<int>, int > {} + concept_map PIMonoid< mult<int>, int > {} + + concept_map Commutative< min<int>, int > {} + concept_map Monoid< min<int>, int > {} + + concept_map Commutative< max<int>, int > {} + //concept_map Monoid< max<int>, int > {} + + + concept_map Commutative< add<float>, float > {} + concept_map Monoid< add<float>, float > {} + concept_map AbelianGroup< add<float>, float > {} + + concept_map Commutative< mult<float>, float > {} + concept_map Monoid< mult<float>, float > {} + concept_map PIMonoid< mult<float>, float > {} + + concept_map AdditiveMonoid< float > {} + // concept_map AdditiveAbelianGroup< float > {} + + // concept_map OperatorField<float> {} + + concept_map Commutative< min<float>, float > {} + concept_map Monoid< min<float>, float > {} + + concept_map Commutative< max<float>, float > {} + concept_map Monoid< max<float>, float > {} + + + + concept_map Commutative< add<double>, double > {} + concept_map Monoid< add<double>, double > {} + concept_map AbelianGroup< add<double>, double > {} + + concept_map Commutative< mult<double>, double > {} + concept_map Monoid< mult<double>, double > {} + concept_map PIMonoid< mult<double>, double > {} + + concept_map AdditiveMonoid< double > {} + // concept_map AdditiveAbelianGroup< double > {} + + // concept_map OperatorField<double> {} + + concept_map Commutative< min<double>, double > {} + concept_map Monoid< min<double>, double > {} + + concept_map Commutative< max<double>, double > {} + concept_map Monoid< max<double>, double > {} + + + +} // namespace math + +#endif // MATH_CONCEPT_MAPS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/linear_algebra/concepts.hpp b/AMDiS/lib/mtl4/boost/numeric/linear_algebra/concepts.hpp new file mode 100644 index 0000000000000000000000000000000000000000..8fc6d5291c9456b3cd9db66d2e7c675b300e889d --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/linear_algebra/concepts.hpp @@ -0,0 +1,602 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_NEW_ALGEBRAIC_CONCEPTS_INCLUDE +#define MTL_NEW_ALGEBRAIC_CONCEPTS_INCLUDE + +#include <concepts> +#include <boost/numeric/linear_algebra/intrinsic_concept_maps.hpp> +#include <boost/numeric/linear_algebra/operators.hpp> + + +namespace math { + +concept Commutative<typename Operation, typename Element> + : std::Callable2<Op, Element, Element> +{ + axiom Commutativity(Operation op, Element x, Element y) + { + op(x, y) == op(y, x); + } +}; + + +concept SemiGroup<typename Operation, typename Element> + : std::Callable2<Op, Element, Element> +{ + axiom Associativity(Operation op, Element x, Element y, Element z) + { + op(x, op(y, z)) == op(op(x, y), z); + } +}; + + +concept Monoid<typename Operation, typename Element> + : SemiGroup<Operation, Element> +{ + typename identity_result_type; + identity_result_type identity(Operation, Element); + + axiom Neutrality(Operation op, Element x) + { + op( x, identity(op, x) ) == x; + op( identity(op, x), x ) == x; + } +}; + + +auto concept Inversion<typename Operation, typename Element> +{ + typename result_type; + result_type inverse(Operation, Element); + +}; + + +concept PIMonoid<typename Operation, typename Element> + : Monoid<Operation, Element>, + Inversion<Operation, Element> +{ + bool is_invertible(Operation, Element); + + requires std::Convertible<Inversion<Operation, Element>::result_type, Element>; + + axiom Invertibility(Operation op, Element x) + { + // Only for invertible elements: + if (is_invertible(op, x)) + op( x, inverse(op, x) ) == identity(op, x); + if ( is_invertible(op, x) ) + op( inverse(op, x), x ) == identity(op, x); + } +} + +#if 0 + // Alternative approach to convert the result of inversion to Element + // Unfortunately, this doesn't compile + template <typename Operation, typename Element> + requires PIMonoid<Operation, Element> + concept_map PIMonoid<Operation, Inversion<Operation, Element>::result_type> {} +#endif + + +concept Group<typename Operation, typename Element> + : PIMonoid<Operation, Element> +{ + bool is_invertible(Operation, Element) { return true; } + + // Just in case somebody redefines is_invertible + axiom AlwaysInvertible(Operation op, Element x) + { + is_invertible(op, x); + } + + // In fact this is implied by AlwaysInvertible and inherited Invertibility axiom + // Maybe remove + axiom GlobalInvertibility(Operation op, Element x) + { + op( x, inverse(op, x) ) == identity(op, x); + op( inverse(op, x), x ) == identity(op, x); + } +}; + + +auto concept AbelianGroup<typename Operation, typename Element> + : Group<Operation, Element>, Commutative<Operation, Element> +{}; + + +// ======================= +// Operator-based concepts +// ======================= + + +concept Additive<typename Element> + : std::HasPlus<Element> +{ + typename plus_assign_result_type; + plus_assign_result_type operator+=(Element& x, Element y) + { + x= x + y; return x; + } + + requires std::Convertible<plus_assign_result_type, Element&>; + + // Do we need the opposite conversion too? + // This line produces a compiler error + // requires std::Convertible<add<Element>::result_type, + // std::HasPlus<Element>::result_type>; + + axiom Consistency(add<Element> op, Element x, Element y) + { + op(x, y) == x + y; + op(x, y) == (x += y, x); + } +} + + +auto concept AdditiveCommutative<typename Element> + : Additive<Element>, + Commutative< add<Element>, Element > +{} + + +auto concept AdditiveSemiGroup<typename Element> + : Additive<Element>, + SemiGroup< add<Element>, Element > +{} + + +concept AdditiveMonoid<typename Element> + : AdditiveSemiGroup<Element>, + Monoid< add<Element>, Element > +{ + Element zero(Element x) + { + return identity(add<Element>(), x); + } + + // If we don't use the default definition + axiom IdentityConsistency (add<Element> op, Element x) + { + zero(x) == identity(op, x); + } +}; + +#ifndef CONCEPTS_WITHOUT_OVERLOADED_REQUIREMENTS // Uncompilable due to error in compiler +concept AdditivePIMonoid<typename Element> + : std::HasMinus<Element>, AdditiveMonoid<Element>, + PIMonoid< add<Element>, Element > +{ + typename minus_assign_result_type; + minus_assign_result_type operator-=(Element& x, Element y) + { + x= x - y; return x; + } + + requires std::Convertible<minus_assign_result_type, Element&>; + + typename unary_result_type; + unary_result_type operator-(Element x) + { + return zero(x) - x; + } + + axiom InverseConsistency(add<Element> op, Element x, Element y) + { + // consistency between additive and functor concept + if ( is_invertible(op, y) ) + op(x, inverse(op, y)) == x - y; + if ( is_invertible(op, y) ) + op(x, y) == (x -= y, x); + + // consistency of unary inversion + if ( is_invertible(op, y) ) + inverse(op, y) == -y; + + // consistency between unary and binary - + if ( is_invertible(op, x) ) + identity(op, x) - x == -x; + } +} + + +auto concept AdditiveGroup<typename Element> + : AdditivePIMonoid<Element>, + Group< add<Element>, Element > +{}; + + +auto concept AdditiveAbelianGroup<typename Element> + : AdditiveGroup<Element>, + Commutative< add<Element>, Element > +{} + +#endif + + +concept Multiplicative<typename Element> + : std::HasMultiply<Element> +{ + typename times_assign_result_type; + times_assign_result_type operator*=(Element& x, Element y) + { + x= x * y; return x; + } + + requires std::Convertible<times_assign_result_type, Element&>; + + // Do we need the opposite conversion too? + // This line produces a compiler error + // requires std::Convertible<mult<Element>::result_type, + // std::HasMultiply<Element>::result_type>; + + axiom Consistency(mult<Element> op, Element x, Element y) + { + op(x, y) == x * y; + op(x, y) == (x *= y, x); + } +} + + +auto concept MultiplicativeCommutative<typename Element> + : Multiplicative<Element>, + Commutative< mult<Element>, Element > +{} + + +auto concept MultiplicativeSemiGroup<typename Element> + : Multiplicative<Element>, + SemiGroup< mult<Element>, Element > +{} + + +concept MultiplicativeMonoid<typename Element> + : MultiplicativeSemiGroup<Element>, + Monoid< mult<Element>, Element > +{ + Element one(Element x) + { + return identity(mult<Element>(), x); + } + + // If we don't use the default definition + axiom IdentityConsistency (math::mult<Element> op, Element x) + { + one(x) == identity(op, x); + } +}; + +#ifndef CONCEPTS_WITHOUT_OVERLOADED_REQUIREMENTS // Uncompilable due to error in compiler +concept MultiplicativePIMonoid<typename Element> + : std::HasDivide<Element>, MultiplicativeMonoid<Element>, + PIMonoid< mult<Element>, Element > +{ + typename divide_assign_result_type; + divide_assign_result_type operator/=(Element& x, Element y) + { + x= x / y; return x; + } + + requires std::Convertible<divide_assign_result_type, Element&>; + + axiom InverseConsistency(mult<Element> op, Element x, Element y) + { + // consistency between multiplicative and functor concept + if ( is_invertible(op, y) ) + op(x, inverse(op, y)) == x / y; + if ( is_invertible(op, y) ) + op(x, y) == (x /= y, x); + } +} + + +auto concept MultiplicativeGroup<typename Element> + : MultiplicativePIMonoid<Element>, + Group< mult<Element>, Element > +{}; + + +auto concept MultiplicativeAbelianGroup<typename Element> + : MultiplicativeGroup<Element>, + Commutative< mult<Element>, Element > +{} + + +// ========================== +// Concepts with 2 operations +// ========================== + + + +concept Distributive<typename AddOp, typename MultOp, typename Element> +{ + axiom Distributivity(AddOp add, MultOp mult, Element x, Element y, Element z) + { + // From left + mult(x, add(y, z)) == add(mult(x, y), mult(x, z)); + // from right + mult(add(x, y), z) == add(mult(x, z), mult(y, z)); + } +} + + +auto concept Ring<typename AddOp, typename MultOp, typename Element> + : AbelianGroup<AddOp, Element>, + SemiGroup<MultOp, Element>, + Distributive<AddOp, MultOp, Element> +{} + + +auto concept RingWithIdentity<typename AddOp, typename MultOp, typename Element> + : Ring<AddOp, MultOp, Element>, + Monoid<MultOp, Element> +{} + + +concept DivisionRing<typename AddOp, typename MultOp, typename Element> + : RingWithIdentity<AddOp, MultOp, Element>, + Inversion<MultOp, Element> +{ + // 0 != 1, otherwise trivial + axiom ZeroIsDifferentFromOne(AddOp add, MultOp mult, Element x) + { + identity(add, x) != identity(mult, x); + } + + // Non-zero divisibility from left and from right + axiom NonZeroDivisibility(AddOp add, MultOp mult, Element x) + { + if (x != identity(add, x)) + mult(inverse(mult, x), x) == identity(mult, x); + if (x != identity(add, x)) + mult(x, inverse(mult, x)) == identity(mult, x); + } +} + + +auto concept Field<typename AddOp, typename MultOp, typename Element> + : DivisionRing<AddOp, MultOp, Element>, + Commutative<MultOp, Element> +{} + + +auto concept OperatorRing<typename Element> + : AdditiveAbelianGroup<Element>, + MultiplicativeSemiGroup<Element>, + Ring<add<Element>, mult<Element>, Element> +{} + + +auto concept OperatorRingWithIdentity<typename Element> + : OperatorRing<Element>, + MultiplicativeMonoid<Element>, + RingWithIdentity<add<Element>, mult<Element>, Element> +{} + + +auto concept OperatorDivisionRing<typename Element> + : OperatorRingWithIdentity<Element>, + MultiplicativePIMonoid<Element>, + DivisionRing<add<Element>, mult<Element>, Element> +{} + + +auto concept OperatorField<typename Element> + : OperatorDivisionRing<Element>, + Field<add<Element>, mult<Element>, Element> +{} + + + +#endif + +concept IntrinsicType<typename T> {} + +concept IntrinsicArithmetic<typename T> : IntrinsicType<T> {} + +concept IntrinsicIntegral<typename T> : IntrinsicArithmetic<T> {} + +concept IntrinsicSignedIntegral<typename T> + : std::SignedIntegralLike<T>, + IntrinsicIntegral<T> +{} + +concept IntrinsicUnsignedIntegral<typename T> + : std::UnsignedIntegralLike<T>, + IntrinsicIntegral<T> +{} + +concept IntrinsicFloatingPoint<typename T> + : std::FloatingPointLike<T>, + IntrinsicArithmetic<T> +{} + + +// Intrinsic types are chategorized: + +concept_map IntrinsicSignedIntegral<char> {} +concept_map IntrinsicSignedIntegral<signed char> {} +concept_map IntrinsicUnsignedIntegral<unsigned char> {} +concept_map IntrinsicSignedIntegral<short> {} +concept_map IntrinsicUnsignedIntegral<unsigned short> {} +concept_map IntrinsicSignedIntegral<int> {} +concept_map IntrinsicUnsignedIntegral<unsigned int> {} +concept_map IntrinsicSignedIntegral<long> {} +concept_map IntrinsicUnsignedIntegral<unsigned long> {} +concept_map IntrinsicSignedIntegral<long long> {} +concept_map IntrinsicUnsignedIntegral<unsigned long long> {} + +concept_map IntrinsicFloatingPoint<float> {} +concept_map IntrinsicFloatingPoint<double> {} + + +#ifndef CONCEPTS_WITHOUT_OVERLOADED_REQUIREMENTS + +// ==================== +// Default Concept Maps +// ==================== + +// ============== +// Arithmetic +// ============== + +// ---------------- +// Signed integrals +// ---------------- + +template <typename T> + requires IntrinsicSignedIntegral<T> +concept_map OperatorRingWithIdentity<T> {} + +template <typename T> + requires IntrinsicSignedIntegral<T> +concept_map MultiplicativeCommutative<T> {} + +// ------------------ +// Unsigned integrals +// ------------------ + + +template <typename T> + requires IntrinsicUnsignedIntegral<T> +concept_map AdditiveCommutative<T> {} + +template <typename T> + requires IntrinsicUnsignedIntegral<T> +concept_map AdditiveMonoid<T> {} + +template <typename T> + requires IntrinsicUnsignedIntegral<T> +concept_map MultiplicativeCommutative<T> {} + +template <typename T> + requires IntrinsicUnsignedIntegral<T> +concept_map MultiplicativeMonoid<T> {} + +// --------------- +// Floationg Point +// --------------- + + +template <typename T> + requires IntrinsicFloatingPoint<T> +concept_map Field<T> {} + +template <typename T> + requires IntrinsicFloatingPoint<T> +concept_map Field< std::complex<T> > {} + + +// =========== +// Min and Max +// =========== + + +template <typename T> + requires IntrinsicArithmetic<T> +concept_map Commutative< max<T>, T > {} + +template <typename T> + requires IntrinsicArithmetic<T> +concept_map Monoid< max<T>, T > {} + +template <typename T> + requires IntrinsicArithmetic<T> +concept_map Commutative< min<T>, T > {} + +template <typename T> + requires IntrinsicArithmetic<T> +concept_map Monoid< min<T>, T > {} + + +// ========== +// And and Or +// ========== + +template <typename T> + requires Intrinsic<T> && std::HasLogicalAnd<T> +concept_map Commutative< std::logical_and<T>, T > {} + +template <typename T> + requires Intrinsic<T> && std::HasLogicalAnd<T> +concept_map Monoid< std::logical_and<T>, T > {} + +template <typename T> + requires Intrinsic<T> && std::HasLogicalOr<T> +concept_map Commutative< std::logical_or<T>, T > {} + +template <typename T> + requires Intrinsic<T> && std::HasLogicalOr<T> +concept_map Monoid< std::logical_or<T>, T > {} + +template <typename T> + requires Intrinsic<T> && std::HasLogicalAnd<T> && std::HasLogicalOr<T> +concept_map Distributive<std::logical_and<T>, std::logical_or<T>, T> {} + +template <typename T> + requires Intrinsic<T> && std::HasLogicalAnd<T> && std::HasLogicalOr<T> +concept_map Distributive<std::logical_or<T>, std::logical_and<T>, T> {} + + +// ================== +// Bitwise operations +// ================== + +// not yet defined + +template <typename T> + requires IntrinsicIntegral<T> +concept_map Commutative< bit_and<T>, T > {} + +template <typename T> + requires IntrinsicIntegral<T> +concept_map Monoid< bit_and<T>, T > {} + +template <typename T> + requires IntrinsicIntegral<T> +concept_map Commutative< bit_or<T>, T > {} + +template <typename T> + requires IntrinsicIntegral<T> +concept_map Monoid< bit_or<T>, T > {} + +template <typename T> + requires IntrinsicIntegral<T> +concept_map Distributive<bit_and<T>, bit_or<T>, T> {} + +template <typename T> + requires IntrinsicIntegral<T> +concept_map Distributive<bit_or<T>, bit_and<T>, T> {} + +template <typename T> + requires IntrinsicIntegral<T> +concept_map Commutative< bit_xor<T>, T > {} + +template <typename T> + requires IntrinsicIntegral<T> +concept_map SemiGroup< bit_xor<T>, T > {} + +// ==================== +// String concatenation +// ==================== + +concept_map AdditiveMonoid<std::string> {} + + +#endif + + + +} // namespace math + +#endif // MTL_NEW_ALGEBRAIC_CONCEPTS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/linear_algebra/ets_concepts.hpp b/AMDiS/lib/mtl4/boost/numeric/linear_algebra/ets_concepts.hpp new file mode 100755 index 0000000000000000000000000000000000000000..f71ea48c3f004f9849986333a5bbbcfe5a8f0050 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/linear_algebra/ets_concepts.hpp @@ -0,0 +1,47 @@ +// Copyright 2006. Peter Gottschling, Matthias Troyer, Rolf Bonderer + +#ifndef LA_ETS_CONCEPTS_INCLUDE +#define LA_ETS_CONCEPTS_INCLUDE + +#include <boost/numeric/linear_algebra/concepts.hpp> + +#ifdef __GXX_CONCEPTS__ + +//"Namespace ETS = Expression Templates Support": +// This file contains concepts that support the concepts defined in the namespace math. +// They are required since the math-concepts do not support ExpressionTemplates so far. +// The list of valid expressions is in fact infinite, so we just name some of them. +// Once ExpressionTemplates are supported by the math-concepts, the ets-concepts are no longer required. + +namespace ets { + + auto concept Field<typename Element> + { + requires std::Assignable<Element, math::AdditivePartiallyInvertibleMonoid<Element>::unary_result_type>; //"x=-y" valid + }; + + auto concept VectorSpace<typename Vector, typename Scalar> + { + // valid expression: "vector2 += scalar*vector1" + typename res_type_1; + res_type_1 operator+=(Vector&, math::Multiplicable<Scalar, Vector>::result_type); + + // valid expression: "vector2 -= scalar*vector1" + typename res_type_2; + res_type_2 operator-=(Vector&, math::Multiplicable<Scalar, Vector>::result_type); + + //valid expression: "vector *= -scalar" + typename res_type_3; + res_type_3 operator*=(Vector&, const math::AdditivePartiallyInvertibleMonoid<Scalar>::unary_result_type&); + + //valid expression: "vector3 = vector1 + scalar*vector2" + requires math::Addable<Vector, math::Multiplicable<Scalar, Vector>::result_type>; //"vector1+scalar*vector2" valid + requires std::Assignable<Vector, math::Addable<Vector, math::Multiplicable<Scalar, Vector>::result_type>::result_type>; //"vector3 = vector1 + scalar*vector2" valid + + }; + +} //namespace ets + +#endif //__GXX_CONCEPTS__ + +#endif //LA_ETS_CONCEPTS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/linear_algebra/identity.hpp b/AMDiS/lib/mtl4/boost/numeric/linear_algebra/identity.hpp new file mode 100644 index 0000000000000000000000000000000000000000..b17561651d78391ccd7d01b167b9fff3c4d37009 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/linear_algebra/identity.hpp @@ -0,0 +1,208 @@ +// Copyright 2006. Peter Gottschling, Matthias Troyer, Rolf Bonderer +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MATH_IDENTITY_INCLUDE +#define MATH_IDENTITY_INCLUDE + +#include <boost/math/tools/config.hpp> +#include <limits> +#include <string> +#include <functional> + +#include <boost/numeric/linear_algebra/operators.hpp> + +namespace math { + +template <typename Operation, typename Element> +struct identity_t {}; + +// TBD: Do we the case that the return type is different? Using std::unary_function? + +// Additive identity of Element type is by default a converted 0 +// However, for vectors one needs to know the dimension +// (and in parallel eventually also the distribution). +// Therefore, an element is passed as reference. +// It is strongly recommended to specialize this functor +// for better efficiency. +template <typename Element> +struct identity_t< add<Element>, Element > + : public std::binary_function<add<Element>, Element, Element> +{ + Element operator() (const add<Element>&, const Element& ref) const + { + Element tmp(ref); + tmp= 0; + return tmp; + } +}; + +template <> +struct identity_t< add<std::string>, std::string > + : public std::binary_function<add<std::string>, std::string, std::string> +{ + std::string operator() (const add<std::string>&, const std::string&) const + { + return std::string(); + } +}; + +// Multiplicative identity of Element type is by default a converted 1 +// Same comments as above. +// In contrast to additive identity, this default more likely to be wrong (e.g. matrices with all 1s) +template <typename Element> +struct identity_t< mult<Element>, Element > + : public std::binary_function<mult<Element>, Element, Element> +{ + Element operator() (const mult<Element>&, const Element& ref) const + { + Element tmp(ref); + tmp= 1; + return tmp; + } +}; + + +// Identity of max is minimal representable value, for standard types defined in numeric_limits +template <typename Element> +struct identity_t< max<Element>, Element > + : public std::binary_function<max<Element>, Element, Element> +{ + Element operator() (const max<Element>&, const Element& ) const + { + using std::numeric_limits; + return numeric_limits<Element>::min(); + } +}; + +template <> +struct identity_t< max<float>, float > + : public std::binary_function<max<float>, float, float> +{ + float operator() (const max<float>&, const float& ) const + { + using std::numeric_limits; + return -numeric_limits<float>::max(); + } +}; + +template <> +struct identity_t< max<double>, double > + : public std::binary_function<max<double>, double, double> +{ + double operator() (const max<double>&, const double& ) const + { + using std::numeric_limits; + return -numeric_limits<double>::max(); + } +}; + + +#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS + +template <> +struct identity_t< max<long double>, long double > + : public std::binary_function<max<long double>, long double, long double> +{ + long double operator() (const max<long double>&, const long double& ) const + { + using std::numeric_limits; + return -numeric_limits<long double>::max(); + } +}; + +#endif + + + +// Identity of min is maximal representable value, for standard types defined in numeric_limits +template <typename Element> +struct identity_t< min<Element>, Element > + : public std::binary_function<min<Element>, Element, Element> +{ + Element operator() (const min<Element>&, const Element& ) const + { + using std::numeric_limits; + return numeric_limits<Element>::max(); + } +}; + +// Identity of bit-wise and +template <typename Element> +struct identity_t< bitwise_and<Element>, Element > + : public std::binary_function<bitwise_and<Element>, Element, Element> +{ + Element operator() (const bitwise_and<Element>&, const Element&) const + { + return 0; + } +}; + +// Identity of bit-wise or +template <typename Element> +struct identity_t< bitwise_or<Element>, Element > + : public std::binary_function<bitwise_or<Element>, Element, Element> +{ + Element operator() (const bitwise_or<Element>&, const Element&) const + { + return 0 - 1; + } +}; + +#if 0 // ambiguous specialization +template <template <typename> class Operation, typename First, typename Second> +struct identity_t< Operation<std::pair<First, Second> >, std::pair<First, Second> > +{ + typedef std::pair<First, Second> pt; + + pt operator()(const Operation<pt>&, const pt& ref) const + { + return std::make_pair(identity(Operation<First>(), ref.first), identity(Operation<Second>(), ref.second)); + } +}; +#endif + +// Function is shorter than typetrait-like functor +template <typename Operation, typename Element> +inline Element identity(const Operation& op, const Element& v) +{ + return identity_t<Operation, Element>() (op, v); +} + +#if 1 +// I shouldn't do this (but as functor I'd need too many specializations) +template <template <typename> class Operation, typename First, typename Second> +inline std::pair<First, Second> identity(const Operation<std::pair<First, Second> >&, const std::pair<First, Second>& v) +{ + return std::pair<First, Second>(math::identity(Operation<First>(), v.first), math::identity(Operation<Second>(), v.second)); +} +#endif + +// Short-cut for additive identity +template <typename Element> +inline Element zero(const Element& v) +{ + return identity_t<math::add<Element>, Element>() (math::add<Element>(), v); +} + + +// Short-cut for multiplicative identity +template <typename Element> +inline Element one(const Element& v) +{ + return identity_t<math::mult<Element>, Element>() (math::mult<Element>(), v); +} + + +} // namespace math + +#endif // MATH_IDENTITY_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/linear_algebra/intrinsic_concept_maps.hpp b/AMDiS/lib/mtl4/boost/numeric/linear_algebra/intrinsic_concept_maps.hpp new file mode 100644 index 0000000000000000000000000000000000000000..4bd754f4cc99ee7ec1c51a61c3ed6fe0af8fb00a --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/linear_algebra/intrinsic_concept_maps.hpp @@ -0,0 +1,116 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MATH_INTRINSIC_CONCEPT_MAPS_INCLUDE +#define MATH_INTRINSIC_CONCEPT_MAPS_INCLUDE + +#include <concepts> + +namespace math { + + + // The following concepts are used to classify intrinsic arithmetic types. + // The standard concepts already define the syntactic requirements, + // i.e. the interface. + // However they sey nothing about the semantics. + // Therefore, user-defined types can model the syntactic/interface + // requirements while still having a different mathematical behavior. + // For that reason, we introduce concepts that are only used for intrinsic types. + // For them we can define concept_maps regarding semantic behavior as monoids. + + concept IntrinsicSignedIntegral<typename T> + : std::SignedIntegralLike<T> + {} + + concept IntrinsicUnsignedIntegral<typename T> + : std::UnsignedIntegralLike<T> + {} + + concept IntrinsicFloatingPoint<typename T> + : std::FloatingPointLike<T> + {} + + + // Intrinsic types are chategorized: + + // concept_map IntrinsicSignedIntegral<char> {}; ??? + concept_map IntrinsicSignedIntegral<signed char> {}; + concept_map IntrinsicUnsignedIntegral<unsigned char> {}; + concept_map IntrinsicSignedIntegral<short> {}; + concept_map IntrinsicUnsignedIntegral<unsigned short> {}; + concept_map IntrinsicSignedIntegral<int> {}; + concept_map IntrinsicUnsignedIntegral<unsigned int> {}; + concept_map IntrinsicSignedIntegral<long> {}; + concept_map IntrinsicUnsignedIntegral<unsigned long> {}; + concept_map IntrinsicSignedIntegral<long long> {}; + concept_map IntrinsicUnsignedIntegral<unsigned long long> {}; + + concept_map IntrinsicFloatingPoint<float> { } + concept_map IntrinsicFloatingPoint<double> { } + + concept Integral<typename T> : std::CopyAssignable<T> + { + requires std::HasPlus<T> && std::HasMinus<T> && std::HasMultiply<T> && std::HasDivide<T> + && std::HasUnaryPlus<T> && std::HasNegate<T>; + + + T& operator++(T&); + T operator++(T& t, int) { T tmp(t); ++t; return tmp; } + T& operator--(T&); + T operator--(T& t, int) { T tmp(t); --t; return tmp; } + + requires std::Convertible<std::HasUnaryPlus<T>::result_type, T> + && std::Convertible<std::HasNegate<T>::result_type, T> + && std::Convertible<std::HasPlus<T>::result_type, T> + && std::Convertible<std::HasMinus<T>::result_type, T> + && std::Convertible<std::HasMultiply<T>::result_type, T> + && std::Convertible<std::HasDivide<T>::result_type, T>; + + T& operator*=(T&, T); + T& operator/=(T&, T); + T& operator+=(T&, T); + T& operator-=(T&, T); + + requires std::HasComplement<T> && std::HasModulus<T> && std::HasBitAnd<T> + && std::HasBitOr<T> && std::HasBitXor<T> && std::HasLeftShift<T> + && std::HasRightShift<T>; + + requires std::Convertible<std::HasComplement<T>::result_type, T> + && std::Convertible<std::HasModulus<T>::result_type, T> + && std::Convertible<std::HasBitAnd<T>::result_type, T> + && std::Convertible<std::HasBitOr<T>::result_type, T> + && std::Convertible<std::HasBitXor<T>::result_type, T> + && std::Convertible<std::HasLeftShift<T>::result_type, T> + && std::Convertible<std::HasRightShift<T>::result_type, T>; + + requires std::LessThanComparable<T> && std::EqualityComparable<T>; + + T& operator%=(T&, T); + T& operator&=(T&, T); + T& operator|=(T&, T); + T& operator^=(T&, T); + T& operator<<=(T&, T); + T& operator>>=(T&, T); + } + + + template <typename T> + requires IntrinsicUnsignedIntegral<T> + concept_map Integral<T> {typedef T result_type;} + + template <IntrinsicSignedIntegral T> + concept_map Integral<T> {typedef T result_type;} + + +} // namespace math + +#endif // MATH_INTRINSIC_CONCEPT_MAPS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/linear_algebra/inverse.hpp b/AMDiS/lib/mtl4/boost/numeric/linear_algebra/inverse.hpp new file mode 100644 index 0000000000000000000000000000000000000000..e6e252f07f85289df5e9c966f3b79639e131f7af --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/linear_algebra/inverse.hpp @@ -0,0 +1,65 @@ +// Copyright 2006. Peter Gottschling, Matthias Troyer, Rolf Bonderer +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MATH_INVERSE_INCLUDE +#define MATH_INVERSE_INCLUDE + +#include <boost/numeric/linear_algebra/operators.hpp> +#include <boost/numeric/linear_algebra/identity.hpp> + +namespace math { + +template <typename Operation, typename Element> +struct inverse_t {} ; + + +template <typename Element> +struct inverse_t< add<Element>, Element > + : public std::binary_function<add<Element>, Element, Element> +{ + Element operator()(const add<Element>&, const Element& v) const + { + return -v; + } +}; + + +template <typename Element> +struct inverse_t< mult<Element>, Element > + : public std::binary_function<mult<Element>, Element, Element> +{ + Element operator()(const mult<Element>&, const Element& v) const + { + return one(v) / v ; + } +}; + + +// Function is shorter than typetrait-like functor +template <typename Operation, typename Element> +inline Element inverse(const Operation& op, const Element& v) +{ + return inverse_t<Operation, Element>() (op, v); +} + + +// Short-cut for multiplicative inverse +template <typename Element> +inline Element reciprocal(const Element& v) +{ + return inverse(math::mult<Element>(), v); +} + +} // namespace math + +#endif // MATH_INVERSE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/linear_algebra/is_invertible.hpp b/AMDiS/lib/mtl4/boost/numeric/linear_algebra/is_invertible.hpp new file mode 100644 index 0000000000000000000000000000000000000000..727df0e4e727193a9f509a892e1f888ae348170a --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/linear_algebra/is_invertible.hpp @@ -0,0 +1,82 @@ +// Copyright 2006. Peter Gottschling, Matthias Troyer, Rolf Bonderer +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MATH_IS_INVERTIBLE_INCLUDE +#define MATH_IS_INVERTIBLE_INCLUDE + +#include <boost/numeric/linear_algebra/operators.hpp> +#include <boost/numeric/linear_algebra/identity.hpp> + +namespace math { + +template <typename Operation, typename Element> +struct is_invertible_t +{ + // bool operator()(const Operation&, const Element&) const; +}; + + +// By default all elements are invertible w.r.t. addition +// If only part of the elements are invertible it shall be handled by specialization of the type +// Whether invertibility is relevant at all shall be concrolled by the user with concept maps +template <typename Element> +struct is_invertible_t< add<Element>, Element > + : public std::binary_function<add<Element>, Element, Element> +{ + bool operator() (const add<Element>&, const Element&) const + { + return true; + } +}; + + +// By default all non-zero elements are invertible w.r.t. multiplication +// If another part of the elements or all elements are invertible it shall be handled by specialization of the type +// Whether invertibility is relevant at all shall be concrolled by the user with concept maps +template <typename Element> +struct is_invertible_t< mult<Element>, Element > + : public std::binary_function<mult<Element>, Element, Element> +{ + bool operator() (const mult<Element>&, const Element& v) const + { + return v != zero(v); + } +}; + + +// Function is shorter than typetrait-like functor +template <typename Operation, typename Element> +inline bool is_invertible(const Operation& op, const Element& v) +{ + return is_invertible_t<Operation, Element>() (op, v); +} + + +namespace detail { + + // Helper type whose operator returns true if v is not 0 + // 0 must be convertible into Element and Element must be EqualityComparable + template <typename Operation, typename Element> + struct non_zero_is_invertible_t + { + bool operator() (const Operation&, const Element& v) + { + return v != Element(0); + } + }; + +} // namespace detail + +} // namespace math + +#endif // MATH_IS_INVERTIBLE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/linear_algebra/linear_operator.hpp b/AMDiS/lib/mtl4/boost/numeric/linear_algebra/linear_operator.hpp new file mode 100644 index 0000000000000000000000000000000000000000..43b95151f5ff2ca9526b727fc156023d7d3af1ad --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/linear_algebra/linear_operator.hpp @@ -0,0 +1,247 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MATH_LINEAR_OPERATOR_INCLUDE +#define MATH_LINEAR_OPERATOR_INCLUDE + +#ifdef __GXX_CONCEPTS__ +# include <concepts> +#else +# include <boost/numeric/linear_algebra/pseudo_concept.hpp> +#endif + +namespace math { + +/** @addtogroup Concepts + * @{ + */ + +#ifdef __GXX_CONCEPTS__ + concept LinearOperator<typename Operator, typename VectorDomain, typename VectorImage> + { + requires VectorSpace<VectorDomain>; + requires VectorSpace<VectorImage>; + + typename result_type; + result_type operator* (Operator, VectorDomain); + + typename assign_type; + assign_type operator= (VectorImage, result_type); + + // The following two requirements are subject to discussion + typename plus_assign_type; + plus_assign_type operator+= (VectorImage, result_type); + + typename minus_assign_type; + minus_assign_type operator-= (VectorImage, result_type); + + axiom Addability(Operator A, VectorDomain x, VectorDomain y) + { + A * (x + y) == A*x + A*y; + } + + // The two vector spaces must be scalable with the same scalar types + axiom Scalability(Operator A, VectorSpace<VectorDomain>::scalar_type alpha, VectorDomain x) + { + A * (alpha * x) == alpha * (A * x); + } + }; +#else + //! Concept LinearOperator + /*! + Linear operator from one vector space into another one. + + \param Operator The type of the operator, e.g., some matrix type + \param VectorDomain The the type of a vector in the domain vector space + \param VectorImage The the type of a vector in the image vector space + + \par Associated Types: + - result_type + - assign_type + - plus_assign_type + - minus_assign_type + + \par Requires: + - VectorSpace < VectorDomain > + - VectorSpace < VectorImage > + + \par Notation: + <table summary="notation"> + <tr> + <td>A</td> + <td>Object of type Operation</td> + </tr> + <tr> + <td>x, y</td> + <td>Objects of type VectorDomain</td> + </tr> + <tr> + <td>u</td> + <td>Object of type VectorImage</td> + </tr> + </table> + + \par Valid Expressions: + <table> + <tr> + <td>Assign product:</td> + <td>u= A * x</td> + </tr> + <tr> + <td>Add product:</td> + <td>u+= A * x</td> + </tr> + <tr> + <td>Subtract product:</td> + <td>u-= A * x</td> + </tr> + </table> + + \invariant + <table summary="invariants"> + <tr> + <td>Addability</td> + <td>A * (x + y) == A*x + A*y</td> + </tr> + <tr> + <td>Scalability</td> + <td>alpha * (A * x) == A * (alpha * x)</td> + </tr> + </table> + + \note + -# Using matrix vector products in arbitrary expressions requires + storing it in temporary objects to avoid redundant computation. + On the other hand, it is not always obvious to choose an appropriate + type for such temporary depending on arbitrary operator and vector types. + Using the products directly in assignments allows implementation without + temporaries, e.g., by calling a function mult(A, x, u) internally. + */ + template <typename Operator, typename VectorDomain, typename VectorImage> + struct LinearOperator + { + /// Associated type: result of multiplication; automatically deducted + typedef associated_type result_type; + /// Multiplication of linear operator with vector + result_type operator* (Operator, VectorDomain); + + /// Associated type: return type of assigning product to vector. + /** Automatically deducted. Using expression templates it can be different from VectorImage& */ + typedef associated_type assign_type; + /// Product must be assignable + assign_type operator= (VectorImage, result_type); + + // The following two requirements are subject to discussion + /// Associated type: return type of incrementally assigning product to vector. + /** Automatically deducted. Using expression templates it can be different from VectorImage& */ + typedef associated_type plus_assign_type; + /// Product must be assignable with increment + plus_assign_type operator+= (VectorImage, result_type); + + // The following two requirements are subject to discussion + /// Associated type: return type of decrementally assigning product to vector. + /** Automatically deducted. Using expression templates it can be different from VectorImage& */ + typedef associated_type minus_assign_type; + /// Product must be assignable with decrement + minus_assign_type operator+= (VectorImage, result_type); + + /// Invariant: the linear projection of a sum is the sum of the linear projections + axiom Addability(Operator A, VectorDomain x, VectorDomain y) + { + A * (x + y) == A*x + A*y; + } + + /// Invariant: the linear projection of a scaled vector is the scaling of the vector's linear projections + axiom Scalability(Operator A, VectorSpace<VectorDomain>::scalar_type alpha, VectorDomain x) + { + A * (alpha * x) == alpha * (A * x); + } + }; +#endif + + +#ifdef __GXX_CONCEPTS__ + concept SelfAdjointOperator<typename Operator, typename VectorDomain, typename VectorImage> + : LinearOperator<Operator, VectorDomain, VectorImage> + {}; +#else + //! Concept SelfAdjointOperator + /*! + + + \param Operator The type of the operator, e.g., some matrix type + \param VectorDomain The the type of a vector in the domain vector space + \param VectorImage The the type of a vector in the image vector space + + \par Refinement of: + - LinearOperator <Operator, VectorDomain, VectorImage> + */ + template <typename Operator, typename VectorDomain, typename VectorImage> + struct SelfAdjointOperator + : LinearOperator<Operator, VectorDomain, VectorImage> + {}; +#endif + + +#ifdef __GXX_CONCEPTS__ + concept RealOperator<typename Operator, typename VectorDomain, typename VectorImage> + : LinearOperator<Operator, VectorDomain, VectorImage> + {}; +#else + //! Concept RealOperator + /*! + + + \param Operator The type of the operator, e.g., some matrix type + \param VectorDomain The the type of a vector in the domain vector space + \param VectorImage The the type of a vector in the image vector space + + \par Refinement of: + - LinearOperator <Operator, VectorDomain, VectorImage> + */ + template <typename Operator, typename VectorDomain, typename VectorImage> + struct RealOperator + : LinearOperator<Operator, VectorDomain, VectorImage> + {}; +#endif + + +#ifdef __GXX_CONCEPTS__ + concept SymmetricOperator<typename Operator, typename VectorDomain, typename VectorImage> + : SelfAdjointOperator<Operator, VectorDomain, VectorImage>, + RealOperator<Operator, VectorDomain, VectorImage> + {}; +#else + //! Concept SymmetricOperator + /*! + + + \param Operator The type of the operator, e.g., some matrix type + \param VectorDomain The the type of a vector in the domain vector space + \param VectorImage The the type of a vector in the image vector space + + \par Refinement of: + - SelfAdjointOperator <Operator, VectorDomain, VectorImage> + - RealOperator <Operator, VectorDomain, VectorImage> + */ + template <typename Operator, typename VectorDomain, typename VectorImage> + struct SymmetricOperator + : SelfAdjointOperator<Operator, VectorDomain, VectorImage>, + RealOperator<Operator, VectorDomain, VectorImage> + {}; +#endif + +/*@}*/ // end of group Concepts + +} // namespace math + +#endif // MATH_LINEAR_OPERATOR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/linear_algebra/new_concepts.hpp b/AMDiS/lib/mtl4/boost/numeric/linear_algebra/new_concepts.hpp new file mode 100644 index 0000000000000000000000000000000000000000..3d955cff6d1e2c9d761e04b83517557c4352e32f --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/linear_algebra/new_concepts.hpp @@ -0,0 +1,586 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_NEW_ALGEBRAIC_CONCEPTS_INCLUDE +#define MTL_NEW_ALGEBRAIC_CONCEPTS_INCLUDE + +#include <concepts> +#include <boost/numeric/linear_algebra/intrinsic_concept_maps.hpp> +#include <boost/numeric/linear_algebra/operators.hpp> + + +namespace math { + +concept Commutative<typename Operation, typename Element> + : std::Callable2<Operation, Element, Element> +{ + axiom Commutativity(Operation op, Element x, Element y) + { + op(x, y) == op(y, x); + } +}; + + +concept SemiGroup<typename Operation, typename Element> + : std::Callable2<Operation, Element, Element> +{ + axiom Associativity(Operation op, Element x, Element y, Element z) + { + op(x, op(y, z)) == op(op(x, y), z); + } +}; + + +concept Monoid<typename Operation, typename Element> + : SemiGroup<Operation, Element> +{ + typename identity_result_type; + identity_result_type identity(Operation, Element); + + axiom Neutrality(Operation op, Element x) + { + op( x, identity(op, x) ) == x; + op( identity(op, x), x ) == x; + } +}; + + +auto concept Inversion<typename Operation, typename Element> +{ + typename result_type; + result_type inverse(Operation, Element); + +}; + + +concept PIMonoid<typename Operation, typename Element> + : Monoid<Operation, Element>, + Inversion<Operation, Element> +{ + bool is_invertible(Operation, Element); + + requires std::Convertible<Inversion<Operation, Element>::result_type, Element>; + + axiom Invertibility(Operation op, Element x) + { + // Only for invertible elements: + if (is_invertible(op, x)) + op( x, inverse(op, x) ) == identity(op, x); + if ( is_invertible(op, x) ) + op( inverse(op, x), x ) == identity(op, x); + } +} + +#if 0 + // Alternative approach to convert the result of inversion to Element + // Unfortunately, this doesn't compile + template <typename Operation, typename Element> + requires PIMonoid<Operation, Element> + concept_map PIMonoid<Operation, Inversion<Operation, Element>::result_type> {} +#endif + + +concept Group<typename Operation, typename Element> + : PIMonoid<Operation, Element> +{ + bool is_invertible(Operation, Element) { return true; } + + // Just in case somebody redefines is_invertible + axiom AlwaysInvertible(Operation op, Element x) + { + is_invertible(op, x); + } + + // In fact this is implied by AlwaysInvertible and inherited Invertibility axiom + // Maybe remove + axiom GlobalInvertibility(Operation op, Element x) + { + op( x, inverse(op, x) ) == identity(op, x); + op( inverse(op, x), x ) == identity(op, x); + } +}; + + +auto concept AbelianGroup<typename Operation, typename Element> + : Group<Operation, Element>, Commutative<Operation, Element> +{}; + + +// ======================= +// Operator-based concepts +// ======================= + + +concept Additive<typename Element> + : std::HasPlus<Element> +{ + typename plus_assign_result_type; + plus_assign_result_type operator+=(Element& x, Element y) + { + x= x + y; return x; + } + + requires std::Convertible<plus_assign_result_type, Element&>; + + // Do we need the opposite conversion too? + // This line produces a compiler error + // requires std::Convertible<add<Element>::result_type, + // std::HasPlus<Element>::result_type>; + + axiom Consistency(add<Element> op, Element x, Element y) + { + op(x, y) == x + y; + op(x, y) == (x += y, x); + } +} + + +auto concept AdditiveCommutative<typename Element> + : Additive<Element>, + Commutative< add<Element>, Element > +{} + + +auto concept AdditiveSemiGroup<typename Element> + : Additive<Element>, + SemiGroup< add<Element>, Element > +{} + + +#ifdef COMPILER_WITHOUT_OVERLOAD_ERROR // Uncompilable due to error in compiler +concept AdditiveMonoid<typename Element> + : AdditiveSemiGroup<Element>, + Monoid< add<Element>, Element > +{ + Element zero(Element x) + { + return identity(add<Element>(), x); + } + + // If we don't use the default definition + axiom IdentityConsistency (add<Element> op, Element x) + { + zero(x) == identity(op, x); + } +}; + +concept AdditivePIMonoid<typename Element> + : std::HasMinus<Element>, AdditiveMonoid<Element>, + PIMonoid< add<Element>, Element > +{ + typename minus_assign_result_type; + minus_assign_result_type operator-=(Element& x, Element y) + { + x= x - y; return x; + } + + requires std::Convertible<minus_assign_result_type, Element&>; + + typename unary_result_type; + unary_result_type operator-(Element x) + { + return zero(x) - x; + } + + axiom InverseConsistency(add<Element> op, Element x, Element y) + { + // consistency between additive and functor concept + if ( is_invertible(op, y) ) + op(x, inverse(op, y)) == x - y; + if ( is_invertible(op, y) ) + op(x, y) == (x -= y, x); + + // consistency of unary inversion + if ( is_invertible(op, y) ) + inverse(op, y) == -y; + + // consistency between unary and binary - + if ( is_invertible(op, x) ) + identity(op, x) - x == -x; + } +} + + +auto concept AdditiveGroup<typename Element> + : AdditivePIMonoid<Element>, + Group< add<Element>, Element > +{}; + + +auto concept AdditiveAbelianGroup<typename Element> + : AdditiveGroup<Element>, + Commutative< add<Element>, Element > +{} + +#endif + + +concept Multiplicative<typename Element> + : std::HasMultiply<Element> +{ + typename times_assign_result_type; + times_assign_result_type operator*=(Element& x, Element y) + { + x= x * y; return x; + } + + requires std::Convertible<times_assign_result_type, Element&>; + + // Do we need the opposite conversion too? + // This line produces a compiler error + // requires std::Convertible<mult<Element>::result_type, + // std::HasMultiply<Element>::result_type>; + + axiom Consistency(mult<Element> op, Element x, Element y) + { + op(x, y) == x * y; + op(x, y) == (x *= y, x); + } +} + + +auto concept MultiplicativeCommutative<typename Element> + : Multiplicative<Element>, + Commutative< mult<Element>, Element > +{} + + +auto concept MultiplicativeSemiGroup<typename Element> + : Multiplicative<Element>, + SemiGroup< mult<Element>, Element > +{} + + +#ifdef COMPILER_WITHOUT_OVERLOAD_ERROR // Uncompilable due to error in compiler +concept MultiplicativeMonoid<typename Element> + : MultiplicativeSemiGroup<Element>, + Monoid< mult<Element>, Element > +{ + Element one(Element x) + { + return identity(mult<Element>(), x); + } + + // If we don't use the default definition + axiom IdentityConsistency (math::mult<Element> op, Element x) + { + one(x) == identity(op, x); + } +}; + +concept MultiplicativePIMonoid<typename Element> + : std::HasDivide<Element>, MultiplicativeMonoid<Element>, + PIMonoid< mult<Element>, Element > +{ + typename divide_assign_result_type; + divide_assign_result_type operator/=(Element& x, Element y) + { + x= x / y; return x; + } + + requires std::Convertible<divide_assign_result_type, Element&>; + + axiom InverseConsistency(mult<Element> op, Element x, Element y) + { + // consistency between multiplicative and functor concept + if ( is_invertible(op, y) ) + op(x, inverse(op, y)) == x / y; + if ( is_invertible(op, y) ) + op(x, y) == (x /= y, x); + } +} + + +auto concept MultiplicativeGroup<typename Element> + : MultiplicativePIMonoid<Element>, + Group< mult<Element>, Element > +{}; + + +auto concept MultiplicativeAbelianGroup<typename Element> + : MultiplicativeGroup<Element>, + Commutative< mult<Element>, Element > +{} + + +// ========================== +// Concepts with 2 operations +// ========================== + + + +concept Distributive<typename AddOp, typename MultOp, typename Element> +{ + axiom Distributivity(AddOp add, MultOp mult, Element x, Element y, Element z) + { + // From left + mult(x, add(y, z)) == add(mult(x, y), mult(x, z)); + // from right + mult(add(x, y), z) == add(mult(x, z), mult(y, z)); + } +} + + +auto concept Ring<typename AddOp, typename MultOp, typename Element> + : AbelianGroup<AddOp, Element>, + SemiGroup<MultOp, Element>, + Distributive<AddOp, MultOp, Element> +{} + + +auto concept RingWithIdentity<typename AddOp, typename MultOp, typename Element> + : Ring<AddOp, MultOp, Element>, + Monoid<MultOp, Element> +{} + + +concept DivisionRing<typename AddOp, typename MultOp, typename Element> + : RingWithIdentity<AddOp, MultOp, Element>, + Inversion<MultOp, Element> +{ + // 0 != 1, otherwise trivial + axiom ZeroIsDifferentFromOne(AddOp add, MultOp mult, Element x) + { + identity(add, x) != identity(mult, x); + } + + // Non-zero divisibility from left and from right + axiom NonZeroDivisibility(AddOp add, MultOp mult, Element x) + { + if (x != identity(add, x)) + mult(inverse(mult, x), x) == identity(mult, x); + if (x != identity(add, x)) + mult(x, inverse(mult, x)) == identity(mult, x); + } +} + + +auto concept Field<typename AddOp, typename MultOp, typename Element> + : DivisionRing<AddOp, MultOp, Element>, + Commutative<MultOp, Element> +{} + + +auto concept OperatorRing<typename Element> + : AdditiveAbelianGroup<Element>, + MultiplicativeSemiGroup<Element>, + Ring<add<Element>, mult<Element>, Element> +{} + + +auto concept OperatorRingWithIdentity<typename Element> + : OperatorRing<Element>, + MultiplicativeMonoid<Element>, + RingWithIdentity<add<Element>, mult<Element>, Element> +{} + + +auto concept OperatorDivisionRing<typename Element> + : OperatorRingWithIdentity<Element>, + MultiplicativePIMonoid<Element>, + DivisionRing<add<Element>, mult<Element>, Element> +{} + + +auto concept OperatorField<typename Element> + : OperatorDivisionRing<Element>, + Field<add<Element>, mult<Element>, Element> +{} + + + +#endif + +concept IntrinsicType<typename T> {} + +concept IntrinsicArithmetic<typename T> : IntrinsicType<T> {} + +concept IntrinsicIntegral<typename T> : IntrinsicArithmetic<T> {} + +concept IntrinsicSignedIntegral<typename T> + : std::SignedIntegralLike<T>, + IntrinsicIntegral<T> +{} + +concept IntrinsicUnsignedIntegral<typename T> + : std::UnsignedIntegralLike<T>, + IntrinsicIntegral<T> +{} + +concept IntrinsicFloatingPoint<typename T> + : std::FloatingPointLike<T>, + IntrinsicArithmetic<T> +{} + + + + +#if 0 + +// ==================== +// Default Concept Maps +// ==================== + +// ============== +// Arithmetic +// ============== + +// ---------------- +// Signed integrals +// ---------------- + +template <typename T> + requires IntrinsicSignedIntegral<T> +concept_map OperatorRingWithIdentity<T> {} + +template <typename T> + requires IntrinsicSignedIntegral<T> +concept_map MultiplicativeCommutative<T> {} + +// ------------------ +// Unsigned integrals +// ------------------ + + +template <typename T> + requires IntrinsicUnsignedIntegral<T> +concept_map AdditiveCommutative<T> {} + +template <typename T> + requires IntrinsicUnsignedIntegral<T> +concept_map AdditiveMonoid<T> {} + +template <typename T> + requires IntrinsicUnsignedIntegral<T> +concept_map MultiplicativeCommutative<T> {} + +template <typename T> + requires IntrinsicUnsignedIntegral<T> +concept_map MultiplicativeMonoid<T> {} + +// --------------- +// Floationg Point +// --------------- + + +template <typename T> + requires IntrinsicFloatingPoint<T> +concept_map Field<T> {} + +template <typename T> + requires IntrinsicFloatingPoint<T> +concept_map Field< std::complex<T> > {} + + +// =========== +// Min and Max +// =========== + + +template <typename T> + requires IntrinsicArithmetic<T> +concept_map Commutative< max<T>, T > {} + +template <typename T> + requires IntrinsicArithmetic<T> +concept_map Monoid< max<T>, T > {} + +template <typename T> + requires IntrinsicArithmetic<T> +concept_map Commutative< min<T>, T > {} + +template <typename T> + requires IntrinsicArithmetic<T> +concept_map Monoid< min<T>, T > {} + + +// ========== +// And and Or +// ========== + +template <typename T> + requires Intrinsic<T> && std::HasLogicalAnd<T> +concept_map Commutative< std::logical_and<T>, T > {} + +template <typename T> + requires Intrinsic<T> && std::HasLogicalAnd<T> +concept_map Monoid< std::logical_and<T>, T > {} + +template <typename T> + requires Intrinsic<T> && std::HasLogicalOr<T> +concept_map Commutative< std::logical_or<T>, T > {} + +template <typename T> + requires Intrinsic<T> && std::HasLogicalOr<T> +concept_map Monoid< std::logical_or<T>, T > {} + +template <typename T> + requires Intrinsic<T> && std::HasLogicalAnd<T> && std::HasLogicalOr<T> +concept_map Distributive<std::logical_and<T>, std::logical_or<T>, T> {} + +template <typename T> + requires Intrinsic<T> && std::HasLogicalAnd<T> && std::HasLogicalOr<T> +concept_map Distributive<std::logical_or<T>, std::logical_and<T>, T> {} + + +// ================== +// Bitwise operations +// ================== + +// not yet defined + +template <typename T> + requires IntrinsicIntegral<T> +concept_map Commutative< bit_and<T>, T > {} + +template <typename T> + requires IntrinsicIntegral<T> +concept_map Monoid< bit_and<T>, T > {} + +template <typename T> + requires IntrinsicIntegral<T> +concept_map Commutative< bit_or<T>, T > {} + +template <typename T> + requires IntrinsicIntegral<T> +concept_map Monoid< bit_or<T>, T > {} + +template <typename T> + requires IntrinsicIntegral<T> +concept_map Distributive<bit_and<T>, bit_or<T>, T> {} + +template <typename T> + requires IntrinsicIntegral<T> +concept_map Distributive<bit_or<T>, bit_and<T>, T> {} + +template <typename T> + requires IntrinsicIntegral<T> +concept_map Commutative< bit_xor<T>, T > {} + +template <typename T> + requires IntrinsicIntegral<T> +concept_map SemiGroup< bit_xor<T>, T > {} + +// ==================== +// String concatenation +// ==================== + +concept_map AdditiveMonoid<std::string> {} + + +#endif + + + +} // namespace math + +#endif // MTL_NEW_ALGEBRAIC_CONCEPTS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/linear_algebra/old_concepts.hpp b/AMDiS/lib/mtl4/boost/numeric/linear_algebra/old_concepts.hpp new file mode 100644 index 0000000000000000000000000000000000000000..128551e701255dd5d236d1499af60eebe9e5037f --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/linear_algebra/old_concepts.hpp @@ -0,0 +1,1159 @@ +// Copyright 2006. Peter Gottschling, Matthias Troyer, Rolf Bonderer +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef LA_CONCEPTS_INCLUDE +#define LA_CONCEPTS_INCLUDE + +#include <boost/config/concept_macros.hpp> + +#ifdef __GXX_CONCEPTS__ +# include <concepts> +#else +# ifdef LA_SHOW_WARNINGS +# warning "Concepts are not used" +# endif +#endif + + +#include <boost/numeric/linear_algebra/identity.hpp> +#include <boost/numeric/linear_algebra/is_invertible.hpp> +#include <boost/numeric/linear_algebra/inverse.hpp> +#include <boost/numeric/linear_algebra/operators.hpp> +#include <boost/numeric/linear_algebra/algebraic_concepts.hpp> +#include <complex> + +// If desired one can disable the default concept maps with LA_NO_CONCEPT_MAPS + +// We consider to change the namespace from math to numeric +// More precisely, the concepts may be moved into namespace numeric and the standard functions stay in math + +/// Namespace for mathematical concepts +/** In contrast to the ones in algebra the concepts can require + basic implementation concepts like std::CopyAssignable */ +namespace math { + +#ifdef __GXX_CONCEPTS__ + +// ================================== +// Classification of Arithmetic Types +// ================================== + +// We omit this now because it became part of the standard concepts + +#if 0 + +// In addtion to std::Integral +concept Float<typename T> + : std::DefaultConstructible<T>, std::CopyConstructible<T>, + std::LessThanComparable<T>, std::EqualityComparable<T> +{ + T operator+(T); + T operator+(T, T); + T& operator+=(T&, T); + T operator-(T, T); + T operator-(T); + T& operator-=(T&, T); + T operator*(T, T); + T& operator*=(T&, T); + T operator/(T, T); + T& operator/=(T&, T); + + requires std::CopyAssignable<T> + && std::SameType<std::CopyAssignable<T>::result_type, T&>; +} + +concept_map Float<float> {} +concept_map Float<double> {} +concept_map Float<long double> {} + +// The difference to Float is the lack of LessThanComparable +concept Complex<typename T> + : std::DefaultConstructible<T>, std::CopyConstructible<T>, + std::EqualityComparable<T> +{ + T operator+(T); + T operator+(T, T); + T& operator+=(T&, T); + T operator-(T, T); + T operator-(T); + T& operator-=(T&, T); + T operator*(T, T); + T& operator*=(T&, T); + T operator/(T, T); + T& operator/=(T&, T); + + requires std::CopyAssignable<T> + && std::SameType<std::CopyAssignable<T>::result_type, T&>; +} + +template <typename T> + requires Float<T> +concept_map Complex<std::complex<T> > {} + + +// TBD: Concept Arithmetic is useless like this, it should have operations and then be the base for +// Integral, Float and Complex +concept Arithmetic<typename T> {} + +template <typename T> + requires std::Integral<T> +concept_map Arithmetic<T> {} + +template <typename T> + requires Float<T> +concept_map Arithmetic<T> {} + +template <typename T> + requires Arithmetic<T> +concept_map Arithmetic< std::complex<T> > {} + +#endif + +// The following concepts are used to classify intrinsic arithmetic types. +// The standard concepts already define the syntactic requirements, +// i.e. the interface. +// However they sey nothing about the semantics. +// Therefore, user-defined types can model the syntactic/interface +// requirements while still having a different mathematical behavior. +// For that reason, we introduce concepts that are only used for intrinsic types. +// For them we can define concept_maps regarding semantic behavior as monoids. + +concept IntrinsicSignedIntegral<typename T> + : std::SignedIntegralLike<T> +{} + +concept IntrinsicUnsignedIntegral<typename T> + : std::UnsignedIntegralLike<T> +{} + +concept IntrinsicFloatingPoint<typename T> + : std::FloatingPointLike<T> +{} + + +// Intrinsic types are chategorized: + +concept_map IntrinsicSignedIntegral<char> {} +concept_map IntrinsicSignedIntegral<signed char> {} +concept_map IntrinsicUnsignedIntegral<unsigned char> {} +concept_map IntrinsicSignedIntegral<short> {} +concept_map IntrinsicUnsignedIntegral<unsigned short> {} +concept_map IntrinsicSignedIntegral<int> {} +concept_map IntrinsicUnsignedIntegral<unsigned int> {} +concept_map IntrinsicSignedIntegral<long> {} +concept_map IntrinsicUnsignedIntegral<unsigned long> {} +concept_map IntrinsicSignedIntegral<long long> {} +concept_map IntrinsicUnsignedIntegral<unsigned long long> {} + +concept_map IntrinsicFloatingPoint<float> {} +concept_map IntrinsicFloatingPoint<double> {} + + + +// ================ +// Utility Concepts +// ================ + +// Concepts for functions mapping to same type or convertible +auto concept UnaryIsoFunction<typename Operation, typename Element> +{ + requires std::Callable1<Operation, Element>; + requires std::Convertible<std::Callable1<Operation, Element>::result_type, Element>; + + typename result_type = std::Callable1<Operation, Element>::result_type; +}; + + +auto concept BinaryIsoFunction<typename Operation, typename Element> +{ + requires std::Callable2<Operation, Element, Element>; + requires std::Convertible<std::Callable2<Operation, Element, Element>::result_type, Element>; + + typename result_type = std::Callable2<Operation, Element, Element>::result_type; +}; + +#if 0 +auto concept CompatibleBinaryFunction<typename A1, typename A2, typename Result> +{ + typename result_type; + result_type F(A1, A2); + requires std::Convertible<result_type, Result>; +} +#endif + +// ================== +// Algebraic Concepts +// ================== + + +auto concept Magma<typename Operation, typename Element> + : BinaryIsoFunction<Operation, Element> +{ + requires std::CopyAssignable<Element> + && std::CopyAssignable<Element, BinaryIsoFunction<Operation, Element>::result_type>; +}; + + +// For algebraic structures that are commutative but not associative +// As an example floating point numbers are commutative but not associative +// w.r.t. addition and multiplication +auto concept CommutativeMagma<typename Operation, typename Element> + : Magma<Operation, Element>, + algebra::Commutative<Operation, Element> +{}; + + +// SemiGroup is a refinement which must be nominal +auto concept SemiGroup<typename Operation, typename Element> + : Magma<Operation, Element>, + algebra::SemiGroup<Operation, Element> +{}; + + +auto concept CommutativeSemiGroup<typename Operation, typename Element> + : SemiGroup<Operation, Element>, + CommutativeMagma<Operation, Element> +{}; + + +// Adding identity +// auto +concept Monoid<typename Operation, typename Element> + : SemiGroup<Operation, Element>, + algebra::Monoid<Operation, Element> +{ + requires std::Convertible<identity_result_type, Element>; +}; + + +auto concept CommutativeMonoid<typename Operation, typename Element> + : CommutativeSemiGroup<Operation, Element>, + Monoid<Operation, Element> +{}; + + +concept PartiallyInvertibleMonoid<typename Operation, typename Element> + : Monoid<Operation, Element>, + algebra::Inversion<Operation, Element> +{ + typename is_invertible_result_type; + is_invertible_result_type is_invertible(Operation, Element); + requires std::Convertible<is_invertible_result_type, bool>; + + requires std::Convertible<inverse_result_type, Element>; + + // Does it overwrites the axiom from algebra::Inversion + axiom Inversivity(Operation op, Element x) + { + // Only for invertible elements: + if (is_invertible(op, x)) + op( x, inverse(op, x) ) == identity(op, x); + if ( is_invertible(op, x) ) + op( inverse(op, x), x ) == identity(op, x); + } +}; + + +auto concept PartiallyInvertibleCommutativeMonoid<typename Operation, typename Element> + : PartiallyInvertibleMonoid<Operation, Element>, + CommutativeMonoid<Operation, Element> +{}; + + +concept Group<typename Operation, typename Element> + : PartiallyInvertibleMonoid<Operation, Element>, + algebra::Group<Operation, Element> +{ + axiom AlwaysInvertible(Operation op, Element x) + { + is_invertible(op, x); + } + + axiom GlobalInversivity(Operation op, Element x) + { + // In fact this is implied by AlwaysInvertible and inherited Inversion axiom + // However, we don't rely on the compiler to deduce this + op( x, inverse(op, x) ) == identity(op, x); + op( inverse(op, x), x ) == identity(op, x); + } +}; + + +auto concept AbelianGroup<typename Operation, typename Element> + : Group<Operation, Element>, + PartiallyInvertibleCommutativeMonoid<Operation, Element>, + algebra::AbelianGroup<Operation, Element> +{}; + + +// ======================== +// Additive scalar concepts +// ======================== + + +concept AdditiveMagma<typename Element> + : Magma< math::add<Element>, Element > +{ + typename plus_assign_result_type; + plus_assign_result_type operator+=(Element& x, Element y); + // requires std::Convertible<plus_assign_result_type, Element>; + + // Operator + is by default defined with += + typename addition_result_type; + addition_result_type operator+(Element x, Element y); +#if 0 + { + Element tmp(x); + return tmp += y; defaults NYS + } +#endif + requires std::Convertible<addition_result_type, Element>; + + // Type consistency with Magma + requires std::Convertible< addition_result_type, + Magma< math::add<Element>, Element >::result_type>; + + // SameType requires more rigorous specializations on pure algebraic functors + // requires std::SameType< addition_result_type, + // Magma< math::add<Element>, Element >::result_type>; + + axiom Consistency(math::add<Element> op, Element x, Element y) + { + op(x, y) == x + y; + + // Consistency definition between + and += might change later + x + y == x += y; + // Element tmp = x; tmp+= y; tmp == x + y; not proposal-compliant + } +} + + +auto concept AdditiveCommutativeMagma<typename Element> + : AdditiveMagma<Element>, + CommutativeMagma< math::add<Element>, Element > +{}; + + +auto concept AdditiveSemiGroup<typename Element> + : AdditiveMagma<Element>, + SemiGroup< math::add<Element>, Element > +{}; + + +// We really need only one of the additive concepts for the requirements, +// the requirements of the other would be implied. +// Vice versa, to derive concept maps of nested concepts from +// concept maps of refined concepts, they are needed all. +auto concept AdditiveCommutativeSemiGroup<typename Element> + : AdditiveSemiGroup<Element>, + AdditiveCommutativeMagma<Element>, + CommutativeSemiGroup< math::add<Element>, Element > +{}; + + +concept AdditiveMonoid<typename Element> + : AdditiveSemiGroup<Element>, + Monoid< math::add<Element>, Element > +{ + Element zero(Element v); + + axiom Consistency (math::add<Element> op, Element x) + { + zero(x) == identity(op, x); + } +}; + + +// We really need only one of the additive concepts for the requirements, +// the requirements of the other would be implied. +// Vice versa, to derive concept maps of nested concepts from +// concept maps of refined concepts, they are needed all. +auto concept AdditiveCommutativeMonoid<typename Element> + : AdditiveMonoid<Element>, + AdditiveCommutativeSemiGroup<Element>, + CommutativeMonoid< math::add<Element>, Element > +{}; + + +concept AdditivePartiallyInvertibleMonoid<typename Element> + : AdditiveMonoid<Element>, + PartiallyInvertibleMonoid< math::add<Element>, Element > +{ + typename minus_assign_result_type; + minus_assign_result_type operator-=(Element& x, Element y); + // requires std::Convertible<minus_assign_result_type, Element>; + + // Operator - by default defined with -= + typename subtraction_result_type; + subtraction_result_type operator-(Element& x, Element y); +#if 0 + { + Element tmp(x); + return tmp -= y; defaults NYS + } +#endif + requires std::Convertible<subtraction_result_type, Element>; + + + typename unary_result_type; + unary_result_type operator-(Element x); +#if 0 + { + return zero(x) - x; defaults NYS + } +#endif + requires std::Convertible<unary_result_type, Element>; + + axiom Consistency(math::add<Element> op, Element x, Element y) + { + // consistency between additive and pure algebraic concept + if ( is_invertible(op, y) ) + op(x, inverse(op, y)) == x - y; + if ( is_invertible(op, y) ) + inverse(op, y) == -y; + + // consistency between unary and binary - + if ( is_invertible(op, x) ) + identity(op, x) - x == -x; + + // Might change later + if ( is_invertible(op, y) ) + x - y == x -= y; + // Element tmp = x; tmp-= y; tmp == x - y; not proposal-compliant + } + +}; + + +auto concept AdditivePartiallyInvertibleCommutativeMonoid<typename Element> + : AdditivePartiallyInvertibleMonoid<Element>, + AdditiveCommutativeMonoid<Element>, + PartiallyInvertibleCommutativeMonoid< math::add<Element>, Element > +{}; + + + +auto concept AdditiveGroup<typename Element> + : AdditivePartiallyInvertibleMonoid<Element>, + Group< math::add<Element>, Element > +{}; + + +auto concept AdditiveAbelianGroup<typename Element> + : AdditiveGroup<Element>, + AdditiveCommutativeMonoid<Element>, + AbelianGroup< math::add<Element>, Element > +{}; + + +// ============================ +// Multiplitive scalar concepts +// ============================ + + +concept MultiplicativeMagma<typename Element> + : Magma< math::mult<Element>, Element > +{ + typename mult_assign_result_type; + mult_assign_result_type operator*=(Element& x, Element y); + // requires std::Convertible<mult_assign_result_type, Element>; + + // Operator * is by default defined with *= + typename mult_result_type; + mult_result_type operator*(Element x, Element y); +#if 0 + { + Element tmp(x); + return tmp *= y; defaults NYS + } +#endif + requires std::Convertible<mult_result_type, Element>; + + // Type consistency with Magma + requires std::Convertible< mult_result_type, + Magma< math::mult<Element>, Element >::result_type>; + + // SameType requires more rigorous specializations on pure algebraic functors + // requires std::SameType< mult_result_type, + // Magma< math::mult<Element>, Element >::result_type>; + + + axiom Consistency(math::mult<Element> op, Element x, Element y) + { + op(x, y) == x * y; + + // Consistency definition between * and *= might change later + x * y == x *= y; + // Element tmp = x; tmp*= y; tmp == x * y; not proposal-compliant + } + +} + + +auto concept MultiplicativeSemiGroup<typename Element> + : MultiplicativeMagma<Element>, + SemiGroup< math::mult<Element>, Element > +{}; + + +auto concept MultiplicativeCommutativeSemiGroup<typename Element> + : MultiplicativeSemiGroup<Element>, + CommutativeSemiGroup< math::mult<Element>, Element > +{}; + + +concept MultiplicativeMonoid<typename Element> + : MultiplicativeSemiGroup<Element>, + Monoid< math::mult<Element>, Element > +{ + Element one(Element v); + + axiom Consistency (math::mult<Element> op, Element x) + { + one(x) == identity(op, x); + } +}; + + +auto concept MultiplicativeCommutativeMonoid<typename Element> + : MultiplicativeMonoid<Element>, + MultiplicativeCommutativeSemiGroup<Element>, + CommutativeMonoid< math::mult<Element>, Element > +{}; + + +concept MultiplicativePartiallyInvertibleMonoid<typename Element> + : MultiplicativeMonoid<Element>, + PartiallyInvertibleMonoid< math::mult<Element>, Element > +{ + typename divide_assign_result_type; + divide_assign_result_type operator/=(Element& x, Element y); + // requires std::Convertible<divide_assign_result_type, Element>; + + // Operator / by default defined with /= + typename division_result_type = Element; + division_result_type operator/(Element x, Element y); +#if 0 + { + Element tmp(x); + return tmp /= y; defaults NYS + } +#endif + requires std::Convertible<division_result_type, Element>; + + axiom Consistency(math::mult<Element> op, Element x, Element y) + { + // consistency between multiplicative and pure algebraic concept + if ( is_invertible(op, y) ) + op(x, inverse(op, y)) == x / y; + + // Consistency between / and /=, might change later + if ( is_invertible(op, y) ) + x / y == x /= y; + // Element tmp = x; tmp/= y; tmp == x / y; not proposal-compliant + } +}; + + +auto concept MultiplicativePartiallyInvertibleCommutativeMonoid<typename Element> + : MultiplicativePartiallyInvertibleMonoid<Element>, + MultiplicativeCommutativeMonoid<Element>, + PartiallyInvertibleCommutativeMonoid< math::mult<Element>, Element > +{}; + + +auto concept MultiplicativeGroup<typename Element> + : MultiplicativeMonoid<Element>, + Group< math::mult<Element>, Element > +{}; + + +auto concept MultiplicativeAbelianGroup<typename Element> + : MultiplicativeGroup<Element>, + MultiplicativeCommutativeMonoid<Element>, + AbelianGroup< math::mult<Element>, Element > +{}; + + +// ====================================== +// Algebraic concepts with two connectors +// ====================================== + +// ----------------- +// Based on functors +// ----------------- + +// More generic, less handy to use + +auto concept GenericRing<typename AddOp, typename MultOp, typename Element> + : AbelianGroup<AddOp, Element>, + SemiGroup<MultOp, Element>, + algebra::Ring<AddOp, MultOp, Element> +{}; + + +auto concept GenericCommutativeRing<typename AddOp, typename MultOp, typename Element> + : GenericRing<AddOp, MultOp, Element>, + CommutativeSemiGroup<MultOp, Element> +{}; + + +auto concept GenericRingWithIdentity<typename AddOp, typename MultOp, typename Element> + : GenericRing<AddOp, MultOp, Element>, + Monoid<MultOp, Element>, + algebra::RingWithIdentity<AddOp, MultOp, Element> +{}; + + +auto concept GenericCommutativeRingWithIdentity<typename AddOp, typename MultOp, typename Element> + : GenericRingWithIdentity<AddOp, MultOp, Element>, + GenericCommutativeRing<AddOp, MultOp, Element>, + CommutativeMonoid<MultOp, Element> +{}; + + +// auto +concept GenericDivisionRing<typename AddOp, typename MultOp, typename Element> + : GenericRingWithIdentity<AddOp, MultOp, Element>, + algebra::DivisionRing<AddOp, MultOp, Element> +{ + requires std::Convertible<inverse_result_type, Element>; +}; + + +auto concept GenericField<typename AddOp, typename MultOp, typename Element> + : GenericDivisionRing<AddOp, MultOp, Element>, + GenericCommutativeRingWithIdentity<AddOp, MultOp, Element>, + algebra::Field<AddOp, MultOp, Element> +{}; + + +// ------------------ +// Based on operators +// ------------------ + +// Handier, less generic + +// Alternative definitions use MultiplicativeMonoid<Element> for Ring +// and call such concepts Pseudo-Ring + + +auto concept Ring<typename Element> + : AdditiveAbelianGroup<Element>, + MultiplicativeSemiGroup<Element>, + GenericRing<math::add<Element>, math::mult<Element>, Element> +{}; + + +auto concept CommutativeRing<typename Element> + : Ring<Element>, + MultiplicativeCommutativeSemiGroup<Element>, + GenericCommutativeRing<math::add<Element>, math::mult<Element>, Element> +{}; + + +auto concept RingWithIdentity<typename Element> + : Ring<Element>, + MultiplicativeMonoid<Element>, + GenericRingWithIdentity<math::add<Element>, math::mult<Element>, Element> +{}; + + +auto concept CommutativeRingWithIdentity<typename Element> + : RingWithIdentity<Element>, + CommutativeRing<Element>, + MultiplicativeCommutativeMonoid<Element>, + GenericCommutativeRingWithIdentity<math::add<Element>, math::mult<Element>, Element> +{}; + + +concept DivisionRing<typename Element> + : RingWithIdentity<Element>, + MultiplicativePartiallyInvertibleMonoid<Element>, + GenericDivisionRing<math::add<Element>, math::mult<Element>, Element> +{ + axiom NonZeroDivisibility(Element x) + { + if (x != zero(x)) + x / x == one(x); + } +}; + + +auto concept Field<typename Element> + : DivisionRing<Element>, + CommutativeRingWithIdentity<Element>, + GenericField<math::add<Element>, math::mult<Element>, Element> +{}; + + +// ====================== +// Miscellaneous concepts +// ====================== + +// that shall find a better place later + + +// EqualityComparable will have the != when defaults are supported +// At this point the following won't needed anymore +auto concept FullEqualityComparable<typename T, typename U = T> +{ + //requires std::EqualityComparable<T, U>; + + bool operator==(const T&, const U&); + bool operator!=(const T&, const U&); +}; + +// Closure of EqualityComparable under a binary operation: +// That is, the result of this binary operation is also EqualityComparable +// with itself and with the operand type. +auto concept Closed2EqualityComparable<typename Operation, typename Element> + : BinaryIsoFunction<Operation, Element> +{ + requires FullEqualityComparable<Element>; + requires FullEqualityComparable< BinaryIsoFunction<Operation, Element>::result_type >; + requires FullEqualityComparable< Element, BinaryIsoFunction<Operation, Element>::result_type >; + requires FullEqualityComparable< BinaryIsoFunction<Operation, Element>::result_type, Element >; +}; + + +// LessThanComparable will have the other operators when defaults are supported +// At this point the following won't needed anymore +auto concept FullLessThanComparable<typename T, typename U = T> +{ + bool operator<(const T&, const U&); + bool operator<=(const T&, const U&); + bool operator>(const T&, const U&); + bool operator>=(const T&, const U&); +}; + + +// Same for LessThanComparable +auto concept Closed2LessThanComparable<typename Operation, typename Element> + : BinaryIsoFunction<Operation, Element> +{ + requires FullLessThanComparable<Element>; + requires FullLessThanComparable< BinaryIsoFunction<Operation, Element>::result_type >; + requires FullLessThanComparable< Element, BinaryIsoFunction<Operation, Element>::result_type >; + requires FullLessThanComparable< BinaryIsoFunction<Operation, Element>::result_type, Element >; +}; + +#if 0 +auto concept NumericOperatorResultConvertible<typename T> + : AddableWithAssign<T>, + SubtractableWithAssign<T>, + MultiplicableWithAssign<T>, + DivisibleWithAssign<T> +{ + requires std::Convertible< AddableWithAssign<T>::result_type, T>; + requires std::Convertible< SubtractableWithAssign<T>::result_type, T>; + requires std::Convertible< MultiplicableWithAssign<T>::result_type, T>; + requires std::Convertible< DivisibleWithAssign<T>::result_type, T>; +} +#endif + +auto concept AdditionResultConvertible<typename T> +{ + typename result_type; + result_type operator+(T t, T u); + requires std::Convertible<result_type, T>; + + typename result_type; + result_type operator+=(T& t, T u); + requires std::Convertible<result_type, T>; +}; + + +auto concept SubtractionResultConvertible<typename T> +{ + typename result_type; + result_type operator-(T t, T u); + requires std::Convertible<result_type, T>; + + typename result_type; + result_type operator-=(T& t, T u); + requires std::Convertible<result_type, T>; +}; + +auto concept NumericOperatorResultConvertible<typename T> + : AdditionResultConvertible<T>, + SubtractionResultConvertible<T> +{}; + +// ==================== +// Default Concept Maps +// ==================== + +#ifndef LA_NO_CONCEPT_MAPS + +// ============== +// Integral Types +// ============== + +template <typename T> + requires IntrinsicSignedIntegral<T> +concept_map CommutativeRingWithIdentity<T> {} + + +template <typename T> + requires IntrinsicUnsignedIntegral<T> +concept_map AdditiveCommutativeMonoid<T> {} + +template <typename T> + requires IntrinsicUnsignedIntegral<T> +concept_map MultiplicativeCommutativeMonoid<T> {} + + +// ==================== +// Floating Point Types +// ==================== + +template <typename T> + requires IntrinsicFloatingPoint<T> +concept_map Field<T> {} + + +template <typename T> + requires IntrinsicFloatingPoint<T> +concept_map Field< std::complex<T> > {} + + +// =========== +// Min and Max +// =========== + +// Draft version: defined generously unless there will be problems with some types + +template <typename Element> +concept_map CommutativeMonoid< max<Element>, Element > +{ + // Why do we need this? + typedef Element identity_result_type; +} + +template <typename Element> +concept_map CommutativeMonoid< min<Element>, Element > +{ + // Why do we need this? + typedef Element identity_result_type; +} + +#endif // LA_NO_CONCEPT_MAPS + +// Here come some mathematical concepts to be defined later + +/// Specify the semantic Behavior of natural numbers (TBD) +/** Mathematic properties are in most cases only approximated + but not held exactly. Rigorous definition would impede + usage of real processors. **/ +concept NaturalNumber<typename T> {} + +/// Specify the semantic Behavior of integral numbers (TBD) +/** Mathematic properties are in most cases only approximated + but not held exactly. Rigorous definition would impede + usage of real processors. + It is arguable if this is really a refinement **/ +concept IntegralNumber<typename T> : NaturalNumber<T> {} + +/// Specify the semantic Behavior of complex numbers (TBD) +/** Mathematic properties are in most cases only approximated + but not held exactly. Rigorous definition would impede + usage of real processors. **/ +concept ComplexNumber<typename T> {} + +/// Specify the semantic Behavior of real numbers (TBD) +/** Mathematic properties are in most cases only approximated + but not held exactly. Rigorous definition would impede + usage of real processors. **/ +concept RealNumber<typename T> : ComplexNumber<T> {} + +#endif // __GXX_CONCEPTS__ + + + + +// ================================================= +// Concept to specify return type of abs (and norms) +// ================================================= + + +#ifdef __GXX_CONCEPTS__ + +// Concept to specify to specify projection of scalar value to comparable type +// For instance as return type of abs +// Minimalist definition for maximal applicability +auto concept Magnitude<typename T> +{ + typename type = T; +}; + +template <typename T> +concept_map Magnitude<std::complex<T> > +{ + typedef T type; +} + + +// Concept for norms etc., which are real values in mathematical definitions +auto concept RealMagnitude<typename T> + : Magnitude<T> +{ + requires FullEqualityComparable<type>; + requires FullLessThanComparable<type>; + + requires Field<type>; + + type sqrt(type); + // typename sqrt_result; + // sqrt_result sqrt(type); + // requires std::Convertible<sqrt_result, type>; + + // using std::abs; + type abs(T); +} + +#else // now without concepts + +template <typename T> +struct Magnitude +{ + typename type = T; +}; + +template <typename T> +struct Magnitude<std::complex<T> > +{ + typedef T type; +} + +template <typename T> struct RealMagnitude + : public Magnitude<T> +{} + +#endif // __GXX_CONCEPTS__ + +// Type trait version both available with and w/o concepts (TBD: Macro finally :-( ) +// For the moment everything is its own magnitude type, unless stated otherwise +template <typename T> +struct magnitude_type_trait +{ + typedef T type; +}; + +template <typename T> +struct magnitude_type_trait< std::complex<T> > +{ + typedef T type; +}; + + +// ========================================= +// Concepts for convenience (many from Rolf) +// ========================================= + + +#ifdef __GXX_CONCEPTS__ + +//The following concepts Addable, Subtractable etc. differ from std::Addable, std::Subtractable +//etc. in so far that no default for result_type is provided, thus allowing automated return type deduction + +auto concept Addable<typename T, typename U = T> +{ + typename result_type; + result_type operator+(const T& t, const U& u); +}; + + +// Usually + and += are both defined +// + can be efficiently derived from += but not vice versa +auto concept AddableWithAssign<typename T, typename U = T> +{ + typename assign_result_type; + assign_result_type operator+=(T& x, U y); + + // Operator + is by default defined with += + typename result_type; + result_type operator+(T x, U y); +#if 0 + { + // Default requires std::CopyConstructible, without default not needed + Element tmp(x); + return tmp += y; defaults NYS + } +#endif +}; + + +auto concept Subtractable<typename T, typename U = T> +{ + typename result_type; + result_type operator-(const T& t, const U& u); +}; + + +// Usually - and -= are both defined +// - can be efficiently derived from -= but not vice versa +auto concept SubtractableWithAssign<typename T, typename U = T> +{ + typename assign_result_type; + assign_result_type operator-=(T& x, U y); + + // Operator - is by default defined with -= + typename result_type; + result_type operator-(T x, U y); +#if 0 + { + // Default requires std::CopyConstructible, without default not needed + Element tmp(x); + return tmp -= y; defaults NYS + } +#endif +}; + + +auto concept Multiplicable<typename T, typename U = T> +{ + typename result_type; + result_type operator*(const T& t, const U& u); +}; + + +// Usually * and *= are both defined +// * can be efficiently derived from *= but not vice versa +auto concept MultiplicableWithAssign<typename T, typename U = T> +{ + typename assign_result_type; + assign_result_type operator*=(T& x, U y); + + // Operator * is by default defined with *= + typename result_type; + result_type operator*(T x, U y); +#if 0 + { + // Default requires std::CopyConstructible, without default not needed + Element tmp(x); + return tmp *= y; defaults NYS + } +#endif +}; + + +auto concept Divisible<typename T, typename U = T> +{ + typename result_type; + result_type operator / (const T&, const U&); +}; + + +// Usually * and *= are both defined +// * can be efficiently derived from *= but not vice versa +auto concept DivisibleWithAssign<typename T, typename U = T> +{ + typename assign_result_type; + assign_result_type operator*=(T& x, U y); + + // Operator * is by default defined with *= + typename result_type; + result_type operator*(T x, U y); +#if 0 + { + // Default requires std::CopyConstructible, without default not needed + Element tmp(x); + return tmp *= y; defaults NYS + } +#endif +}; + + +auto concept Transposable<typename T> +{ + typename result_type; + result_type trans(T&); +}; + + +// Unary Negation -> Any suggestions for better names?! Is there a word as "negatable"?! +auto concept Negatable<typename S> +{ + typename result_type = S; + result_type operator-(const S&); +}; + +// Or HasAbs? +using std::abs; +auto concept AbsApplicable<typename S> +{ + // There are better ways to define abs than the way it is done in std + // Likely we replace the using one day + typename result_type; + result_type abs(const S&); +}; + + +using std::conj; +auto concept HasConjugate<typename S> +{ + typename result_type; + result_type conj(const S&); +}; + + +// We need the following; might be placed somewhere else later +template <Float T> +concept_map HasConjugate<T> +{ + typedef T result_type; + result_type conj(const T& s) {return s;} +} + + + +// Dot product to be defined: +auto concept Dottable<typename T, typename U = T> +{ + typename result_type = T; + result_type dot(const T&t, const U& u); +}; + + +auto concept OneNormApplicable<typename V> +{ + typename result_type; + result_type one_norm(const V&); +}; + + +auto concept TwoNormApplicable<typename V> +{ + typename result_type; + result_type two_norm(const V&); +}; + + +auto concept InfinityNormApplicable<typename V> +{ + typename result_type; + result_type inf_norm(const V&); +}; + + + + +#endif // __GXX_CONCEPTS__ + + +} // namespace math + + + +#endif // LA_CONCEPTS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/linear_algebra/operators.hpp b/AMDiS/lib/mtl4/boost/numeric/linear_algebra/operators.hpp new file mode 100644 index 0000000000000000000000000000000000000000..e58051f7b50cd2e4e2b5f8dadfb19fe3467e6796 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/linear_algebra/operators.hpp @@ -0,0 +1,156 @@ +// Copyright 2006. Peter Gottschling, Matthias Troyer, Rolf Bonderer +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MATH_OPERATORS_INCLUDE +#define MATH_OPERATORS_INCLUDE + +#include <functional> + +#ifndef MATH_DEFAULT_FUNCTORS_WITH_CONCEPTS +namespace math { + +template <typename Element> +struct add : public std::binary_function<Element, Element, Element> +{ + Element operator() (const Element& x, const Element& y) + { + return x + y; + } +}; + + +// Heterogeneous addition, i.e. addends and result type may be different +template <typename A1, typename A2, typename R> +struct heterogeneous_add + : public std::binary_function<A1, A2, R> +{ + R operator() (const A1& x, const A2& y) + { + return x + y; + } +}; + + +// The results of char and short additions are int, dito unsigned +template <> struct add<char> : heterogeneous_add<char, char, int> {}; +template <> struct add<short> : heterogeneous_add<short, short, int> {}; +template <> struct add<unsigned char> : heterogeneous_add<unsigned char, unsigned char, unsigned int> {}; +template <> struct add<unsigned short> : heterogeneous_add<unsigned short, unsigned short, unsigned int> {}; + + +template <typename Element> +struct mult : public std::binary_function<Element, Element, Element> +{ + Element operator() (const Element& x, const Element& y) + { + return x * y; + } +}; + + +template <typename A1, typename A2, typename R> +struct heterogeneous_mult + : public std::binary_function<A1, A2, R> +{ + R operator() (const A1& x, const A2& y) + { + return x * y; + } +}; + + +// The results of char and short multiplications are int, dito unsigned +template <> struct mult<char> : heterogeneous_mult<char, char, int> {}; +template <> struct mult<short> : heterogeneous_mult<short, short, int> {}; +template <> struct mult<unsigned char> : heterogeneous_mult<unsigned char, unsigned char, unsigned int> {}; +template <> struct mult<unsigned short> : heterogeneous_mult<unsigned short, unsigned short, unsigned int> {}; + +#else + +// Now the same with concepts + +template <typename Element> + requires std::HasPlus<Element> +struct add : public std::binary_function<Element, Element, result_type> +{ + result_type operator() (const Element& x, const Element& y) + { + return x + y; + } +}; + +template <typename Element> + requires std::HasMultiply<Element> +struct mult : public std::binary_function<Element, Element, result_type> +{ + result_type operator() (const Element& x, const Element& y) + { + return x * y; + } +}; + + + + +#endif // MATH_DEFAULT_FUNCTORS_WITH_CONCEPTS + +template <typename Element> +struct min : public std::binary_function<Element, Element, Element> +{ + Element operator() (const Element& x, const Element& y) + { + return x <= y ? x : y; + } +}; + + +template <typename Element> +struct max : public std::binary_function<Element, Element, Element> +{ + Element operator() (const Element& x, const Element& y) + { + return x >= y ? x : y; + } +}; + +template <typename Element> +struct bitwise_and : public std::binary_function<Element, Element, Element> +{ + Element operator() (const Element& x, const Element& y) + { + return x & y; + } +}; + +template <typename Element> +struct bitwise_or : public std::binary_function<Element, Element, Element> +{ + Element operator() (const Element& x, const Element& y) + { + return x | y; + } +}; + +template <typename Element> +struct bitwise_xor : public std::binary_function<Element, Element, Element> +{ + Element operator() (const Element& x, const Element& y) + { + return x ^ y; + } +}; + + +} // namespace math + +#endif // MATH_OPERATORS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/linear_algebra/power.hpp b/AMDiS/lib/mtl4/boost/numeric/linear_algebra/power.hpp new file mode 100644 index 0000000000000000000000000000000000000000..d3ee807e08faa27186fab55cfce884d7bd7e2a7b --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/linear_algebra/power.hpp @@ -0,0 +1,198 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MATH_POWER_INCLUDE +#define MATH_POWER_INCLUDE + +#include <concepts> +#include <boost/numeric/linear_algebra/concepts.hpp> +#include <boost/numeric/linear_algebra/identity.hpp> +#include <stdexcept> + + +namespace math { + + template <typename Op, std::Semiregular Element, Integral Exponent> + requires std::Callable2<Op, Element, Element> + && std::Convertible<std::Callable2<Op, Element, Element>::result_type, Element> + inline Element power(const Element& a, Exponent n, Op op) + { + std::cout << "[Magma] "; + if (n < 1) throw std::range_error("power [magma]: n must be > 0"); + + Element value= a; + for (; n > 1; --n) + value= op(value, a); + return value; + } + +#if 0 + template <typename Op, std::Semiregular Element, Integral Exponent> + requires SemiGroup<Op, Element> + && std::Callable2<Op, Element, Element> + && std::Convertible<std::Callable2<Op, Element, Element>::result_type, Element> + inline Element multiply_and_square_horner(const Element& a, Exponent n, Op op) + { + if (n < 1) throw std::range_error("mult&square Horner: n must be > 0"); + + // Set mask to highest bit + Exponent mask= 1 << (8 * sizeof(mask) - 1); + + // If this is a negative number right shift can insert 1s instead of 0s -> infinite loop + // Therefore we take the 2nd-highest bit + if (mask < 0) + mask= 1 << (8 * sizeof(mask) - 2); + + // Find highest 1 bit + while(!bool(mask & n)) mask>>= 1; + + Element value= a; + for (mask>>= 1; mask; mask>>= 1) { + value= op(value, value); + if (n & mask) + value= op(value, a); + } + return value; + } + + template <typename Op, std::Semiregular Element, Integral Exponent> + requires SemiGroup<Op, Element> + && std::Callable2<Op, Element, Element> + && std::Convertible<std::Callable2<Op, Element, Element>::result_type, Element> + inline Element power(const Element& a, Exponent n, Op op) + { + return multiply_and_square_horner(a, n, op); + } +#endif + + +#if 1 + // With Horner scheme we can avoid recursion + // This one is more intuitive (I believe) + template <typename Op, std::Semiregular Element, Integral Exponent> + requires SemiGroup<Op, Element> + && std::Callable2<Op, Element, Element> + && std::Convertible<std::Callable2<Op, Element, Element>::result_type, Element> + inline Element power(const Element& a, Exponent n, Op op) + { + std::cout << "[SemiGroup] "; + if (n < 1) throw std::range_error("power [SemiGroup]: n must be > 0"); + + Exponent half(n / 2); + // If half is 0 then n must be 1 and the result is a + if (half == 0) + return a; + + // Compute power of downward rounded exponent and "square" the result + Element value= power(a, half, op); + value= op(value, value); + + // If n is odd another operation with a is needed + if (n & 1) + value= op(value, a); + return value; + } +#endif + + + + template <typename Op, std::Semiregular Element, Integral Exponent> + requires Monoid<Op, Element> + && std::Callable2<Op, Element, Element> + && std::Convertible<std::Callable2<Op, Element, Element>::result_type, Element> + inline Element multiply_and_square(const Element& a, Exponent n, Op op) + { + // Same as the simpler form except that the first multiplication is made before + // the loop and one squaring is saved this way + if (n < 0) throw std::range_error("mult&square: n must be >= 0"); + + using math::identity; + Element value= bool(n & 1) ? Element(a) : Element(identity(op, a)), square= a; + + for (n>>= 1; n > 0; n>>= 1) { + square= op(square, square); + if (n & 1) + value= op(value, square); + } + return value; + } + + + template <typename Op, std::Semiregular Element, Integral Exponent> + requires Monoid<Op, Element> + && std::Callable2<Op, Element, Element> + && std::Convertible<std::Callable2<Op, Element, Element>::result_type, Element> + inline Element power(const Element& a, Exponent n, Op op) + { + std::cout << "[Monoid] "; + return multiply_and_square(a, n, op); + } + + + + + template <typename Op, std::Semiregular Element, Integral Exponent> + requires PIMonoid<Op, Element> + && std::Callable2<Op, Element, Element> + && std::Convertible<std::Callable2<Op, Element, Element>::result_type, Element> + inline Element power(const Element& a, Exponent n, Op op) + { + std::cout << "[PIMonoid] "; + if (n < 0 && !is_invertible(op, a)) + throw std::range_error("power [PIMonoid]: a must be invertible with n < 0"); + + return n < 0 ? multiply_and_square(Element(inverse(op, a)), Exponent(-n), op) + : multiply_and_square(a, n, op); + } + +#if 1 + template <typename Op, std::Semiregular Element, Integral Exponent> + requires Group<Op, Element> + && std::Callable2<Op, Element, Element> + && std::Convertible<std::Callable2<Op, Element, Element>::result_type, Element> + inline Element power(const Element& a, Exponent n, Op op) + { + std::cout << "[Group] "; + // For groups we don't need any range test + + return n < 0 ? multiply_and_square(Element(inverse(op, a)), Exponent(-n), op) + : multiply_and_square(a, n, op); + } +#endif + + +#if 0 + template <typename Op, typename Element, typename Exponent> + requires Group<Op, Element> + && Integral<Exponent> + && std::Semiregular<Element> + && std::Callable2<Op, Element, Element> + && std::Convertible<std::Callable2<Op, Element, Element>::result_type, Element> + && std::Semiregular<math::Inversion<Op, Element>::result_type> + && std::HasNegate<Exponent> + && math::Monoid<Op, math::Inversion<Op, Element>::result_type> + && Integral< std::HasNegate<Exponent>::result_type> + && std::Callable2<Op, math::Inversion<Op, Element>::result_type, + math::Inversion<Op, Element>::result_type> + && std::Convertible<std::Callable2<Op, math::Inversion<Op, Element>::result_type, + math::Inversion<Op, Element>::result_type>::result_type, + math::Inversion<Op, Element>::result_type> + inline Element power(const Element& a, Exponent n, Op op) + { + return n < 0 ? multiply_and_square(inverse(op, a), -n, op) + : multiply_and_square(a, n, op); + } +#endif + +} // namespace math + +#endif // MATH_POWER_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/linear_algebra/pseudo_concept.hpp b/AMDiS/lib/mtl4/boost/numeric/linear_algebra/pseudo_concept.hpp new file mode 100644 index 0000000000000000000000000000000000000000..5506a20291ef06bbd35da46b65ac1a31203b9fb1 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/linear_algebra/pseudo_concept.hpp @@ -0,0 +1,34 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef PSEUDO_CONCEPT_INCLUDE +#define PSEUDO_CONCEPT_INCLUDE + +/** @addtogroup Concepts + * @{ + */ + +#ifndef __GXX_CONCEPTS__ + +//! Pseudo type for invariants in concepts +/// Pseudo type used to document invariants in concepts +struct axiom {}; + +//! Pseudo type used to document associated types in concepts +/// Pseudo type for associated types in concepts +struct associated_type {}; + +#endif // __GXX_CONCEPTS__ + +/*@}*/ // end of group Concepts + +#endif // PSEUDO_CONCEPT_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/linear_algebra/vector_concepts.hpp b/AMDiS/lib/mtl4/boost/numeric/linear_algebra/vector_concepts.hpp new file mode 100644 index 0000000000000000000000000000000000000000..0f37105c7705023ea689c7398339e9c2bbba7724 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/linear_algebra/vector_concepts.hpp @@ -0,0 +1,508 @@ +// Copyright 2006. Peter Gottschling, Matthias Troyer, Rolf Bonderer +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef LA_VECTOR_CONCEPTS_INCLUDE +#define LA_VECTOR_CONCEPTS_INCLUDE + + +#include <boost/numeric/linear_algebra/concepts.hpp> +#include <boost/numeric/linear_algebra/ets_concepts.hpp> + +#ifdef __GXX_CONCEPTS__ +# include <concepts> +#else +# include <boost/numeric/linear_algebra/pseudo_concept.hpp> +#endif + + +namespace math { + +/** @addtogroup Concepts + * @{ + */ + +#ifdef __GXX_CONCEPTS__ +concept VectorSpace<typename Vector, typename Scalar = typename Vector::value_type> +: AdditiveAbelianGroup<Vector> +{ + requires Field<Scalar>; + requires Multiplicable<Scalar, Vector>; + requires MultiplicableWithAssign<Vector, Scalar>; + requires DivisibleWithAssign<Vector, Scalar>; + + requires std::Assignable<Vector, Multiplicable<Scalar, Vector>::result_type>; + requires std::Assignable<Vector, Multiplicable<Vector, Scalar>::result_type>; + requires std::Assignable<Vector, Divisible<Vector, Scalar>::result_type>; + + // Associated types of Field<Scalar> and AdditiveAbelianGroup<Vector> collide + // typename result_type = AdditiveAbelianGroup<Vector>::result_type; + // typename assign_result_type = AdditiveAbelianGroup<Vector>::assign_result_type; + + axiom Distributivity(Vector v, Vector w, Scalar a, Scalar b) + { + a * (v + w) == a * v + a * w; + (a + b) * v == a * v + b * v; + // The following properties are implied by the above, Field and Abelian group + // Can we be sure that compilers can deduce/interfere it? + (v + w) * a == v * a + w * a; + v * (a + b) == v * a + v * b; + } +} +#else + //! Concept VectorSpace + /*! + \param Vector The the type of a vector or a collection + \param Scalar The scalar over which the vector field is defined + + \par Requires: + - Field < Scalar >; + - Multiplicable <Scalar, Vector>; + - MultiplicableWithAssign <Vector, Scalar>; + - DivisibleWithAssign <Vector, Scalar>; + - std::Assignable <Vector, Multiplicable<Scalar, Vector>::result_type>; + - std::Assignable <Vector, Multiplicable<Vector, Scalar>::result_type>; + - std::Assignable <Vector, Divisible<Vector, Scalar>::result_type>; + + */ + template <typename Vector, typename Scalar = typename Vector::value_type> + struct VectorSpace + : AdditiveAbelianGroup<Vector> + { + /// Invariant: Distributivity of scalars and vectors from left and from right + axiom Distributivity(Vector v, Vector w, Scalar a, Scalar b) + { + /// a * (v + w) == a * v + a * w; // Scalar from left + + /// Vector from right: (a + b) * v == a * v + b * v; + + /// Scalar from right: (v + w) * a == v * a + w * a; + + /// Vector from left: v * (a + b) == v * a + v * b; + } + }; +#endif + +#ifdef __GXX_CONCEPTS__ +concept Norm<typename N, typename Vector, + typename Scalar = typename Vector::value_type> + : std::Callable1<N, Vector> +{ + requires VectorSpace<Vector, Scalar>; + requires RealMagnitude<Scalar>; + typename magnitude_type = MagnitudeType<Scalar>::type; + requires std::Convertible<magnitude_type, Scalar>; + + typename result_type_norm = std::Callable1<N, Vector>::result_type; + requires std::Convertible<result_type_norm, RealMagnitude<Scalar>::magnitude_type>; + requires std::Convertible<result_type_norm, Scalar>; + + // Version with function instead functor, as used by Rolf and Matthias + // Axioms there defined without norm functor and concept has only 2 types +#if 0 + typename result_type_norm; + result_type_norm norm(const Vector&); + requires std::Convertible<result_type_norm, magnitude_type>; + requires std::Convertible<result_type_norm, Scalar>; +#endif + + axiom Positivity(N norm, Vector v, magnitude_type ref) + { + norm(v) >= zero(ref); + } + + // The following is covered by RealMagnitude + // requires AbsApplicable<Scalar>; + // requires std::Convertible<AbsApplicable<Scalar>::result_type, magnitude_type>; + // requires Multiplicable<magnitude_type>; + + axiom PositiveHomogeneity(N norm, Vector v, Scalar a) + { + norm(a * v) == abs(a) * norm(v); + } + + axiom TriangleInequality(N norm, Vector u, Vector v) + { + norm(u + v) <= norm(u) + norm(v); + } +} +#else + //! Concept Norm + /*! + Semantic requirements of a norm + + \param N Norm functor + \param Vector The the type of a vector or a collection + \param Scalar The scalar over which the vector field is defined + + \par Refinement of: + - std::Callable1 <N, Vector> + + \par Associated types: + - magnitude_type + - result_type_norm + + \par Requires: + - VectorSpace <Vector, Scalar>; + - RealMagnitude < Scalar >; + - std::Convertible <magnitude_type, Scalar>; + - std::Convertible <result_type_norm, RealMagnitude<Scalar>::magnitude_type>; + - std::Convertible <result_type_norm, Scalar>; + + */ +template <typename N, typename Vector, + typename Scalar = typename Vector::value_type> +struct Norm + : std::Callable1<N, Vector> +{ + /// Associated type to represent real values in teh Field of scalar (with default) + /** By default MagnitudeType<Scalar>::type */ + typedef associated_type magnitude_type; + + /// Associated type for result of norm functor + /** Automatically detected */ + typedef associated_type result_type_norm; + + /// Invariant: norm of vector is larger than zero + axiom Positivity(N norm, Vector v, magnitude_type ref) + { + /// norm(v) >= zero(ref); + } + + /// Invariant: positive homogeneity with scalar + axiom PositiveHomogeneity(N norm, Vector v, Scalar a) + { + /// norm(a * v) == abs(a) * norm(v); + } + + /// Invariant: triangle inequality + axiom TriangleInequality(N norm, Vector u, Vector v) + { + /// norm(u + v) <= norm(u) + norm(v); + } +}; +#endif + + +#ifdef __GXX_CONCEPTS__ +concept SemiNorm<typename N, typename Vector, + typename Scalar = typename Vector::value_type> + : Norm<N, Vector, Scalar> +{ + axiom PositiveDefiniteness(N norm, Vector v, magnitude_type ref) + { + if (norm(v) == zero(ref)) + v == zero(v); + if (v == zero(v)) + norm(v) == zero(ref); + } +} +#else + //! Concept SemiNorm + /*! + Semantic requirements of a semi-norm + + \param N Norm functor + \param Vector The the type of a vector or a collection + \param Scalar The scalar over which the vector field is defined + + \par Refinement of: + - Norm <N, Vector, Scalar> + */ +template <typename N, typename Vector, + typename Scalar = typename Vector::value_type> +struct SemiNorm + : Norm<N, Vector, Scalar> +{ + /// The norm of a vector is zero if and only if the vector is the zero vector + axiom PositiveDefiniteness(N norm, Vector v, magnitude_type ref) + { + /// if (norm(v) == zero(ref)) v == zero(v); + + /// if (v == zero(v)) norm(v) == zero(ref); + } +}; +#endif + +#ifdef __GXX_CONCEPTS__ +concept BanachSpace<typename N, typename Vector, + typename Scalar = typename Vector::value_type> + : Norm<N, Vector, Scalar>, + VectorSpace<Vector, Scalar> +{}; +#else + //! Concept BanachSpace + /*! + A Banach space is a vector space with a norm + + \param N Norm functor + \param Vector The the type of a vector or a collection + \param Scalar The scalar over which the vector field is defined + + \par Refinement of: + - Norm <N, Vector, Scalar> + - VectorSpace <Vector, Scalar> + + \note + - The (expressible) requirements of Banach Space are already given in Norm. + - The difference between the requirements is the completeness of the + Banach space, i.e. that every Cauchy sequence w.r.t. norm(v-w) has a limit + in the space. Unfortunately, completeness is never satisfied for + finite precision arithmetic types. + - Another subtle difference is that Norm is not a refinement of Vectorspace + */ +template <typename N, typename Vector, + typename Scalar = typename Vector::value_type> +struct BanachSpace + : Norm<N, Vector, Scalar>, + VectorSpace<Vector, Scalar> +{}; +#endif + + +#ifdef __GXX_CONCEPTS__ +concept InnerProduct<typename I, typename Vector, + typename Scalar = typename Vector::value_type> + : std::Callable2<I, Vector, Vector> +{ + // Result of the inner product must be convertible to Scalar + requires std::Convertible<std::Callable2<I, Vector, Vector>::result_type, Scalar>; + + // Let's try without this + // requires ets::InnerProduct<I, Vector, Scalar>; + + requires HasConjugate<Scalar>; + + axiom ConjugateSymmetry(I inner, Vector v, Vector w) + { + inner(v, w) == conj(inner(w, v)); + } + + axiom SequiLinearity(I inner, Scalar a, Scalar b, Vector u, Vector v, Vector w) + { + inner(v, b * w) == b * inner(v, w); + inner(u, v + w) == inner(u, v) + inner(u, w); + // This implies the following (will compilers infere/deduce?) + inner(a * v, w) == conj(a) * inner(v, w); + inner(u + v, w) == inner(u, w) + inner(v, w); + } + + requires RealMagnitude<Scalar>; + typename magnitude_type = RealMagnitude<Scalar>::type; + // requires FullLessThanComparable<magnitude_type>; + + axiom NonNegativity(I inner, Vector v, MagnitudeType<Scalar>::type magnitude) + { + // inner(v, v) == conj(inner(v, v)) implies inner(v, v) is real + // ergo representable as magnitude type + magnitude_type(inner(v, v)) >= zero(magnitude) + } + + axiom NonDegeneracy(I inner, Vector v, Vector w, Scalar s) + { + if (v == zero(v)) + inner(v, w) == zero(s); + if (inner(v, w) == zero(s)) + v == zero(v); + } +}; +#else + //! Concept InnerProduct + /*! + Semantic requirements of a inner product + + \param I The inner product functor + \param Vector The the type of a vector or a collection + \param Scalar The scalar over which the vector field is defined + + \par Refinement of: + - std::Callable2 <I, Vector, Vector> + + \par Associated types: + - magnitude_type + + \par Requires: + - std::Convertible<std::Callable2 <I, Vector, Vector>::result_type, Scalar> ; + result of inner product convertible to scalar to be used in expressions + - HasConjugate < Scalar > + - RealMagnitude < Scalar > ; the scalar value needs a real magnitude type + */ +template <typename I, typename Vector, + typename Scalar = typename Vector::value_type> +struct InnerProduct + : std::Callable2<I, Vector, Vector> +{ + /// Associated type: the real magnitude type of the scalar + /** By default RealMagnitude<Scalar>::type */ + typename associated_type magnitude_type; + // requires FullLessThanComparable<magnitude_type>; + + /// The arguments can be changed and the result is then the complex conjugate + axiom ConjugateSymmetry(I inner, Vector v, Vector w) + { + /// inner(v, w) == conj(inner(w, v)); + } + + /// The inner product is linear in the second argument and conjugate linear in the first one + /** The equalities are partly redundant with ConjugateSymmetry */ + axiom SequiLinearity(I inner, Scalar a, Scalar b, Vector u, Vector v, Vector w) + { + /// inner(v, b * w) == b * inner(v, w); + + /// inner(u, v + w) == inner(u, v) + inner(u, w); + + /// inner(a * v, w) == conj(a) * inner(v, w); + + /// inner(u + v, w) == inner(u, w) + inner(v, w); + } + + /// The inner product of a vector with itself is not negative + /** inner(v, v) == conj(inner(v, v)) implies inner(v, v) is representable as real */ + axiom NonNegativity(I inner, Vector v, MagnitudeType<Scalar>::type magnitude) + { + /// magnitude_type(inner(v, v)) >= zero(magnitude); + } + + /// Non-degeneracy not representable with axiom + axiom NonDegeneracy(I inner, Vector v, Vector w, Scalar s) + { + /// \f$\langle v, w\rangle = 0 \forall w \Leftrightarrow v = \vec{0}\f$ + } +}; +#endif + + + + +#ifdef __GXX_CONCEPTS_ +// A dot product is only a semantically special case of an inner product +// Questionable if we want such a concept +concept DotProduct<typename I, typename Vector, + typename Scalar = typename Vector::value_type> + : InnerProduct<I, Vector, Scalar> +{}; +#else + //! Concept DotProduct + /*! + Semantic requirements of dot product. The dot product is a specific inner product. + + \param I Norm functor + \param Vector The the type of a vector or a collection + \param Scalar The scalar over which the vector field is defined + + \par Refinement of: + - InnerProduct <I, Vector, Scalar> + */ +template <typename I, typename Vector, + typename Scalar = typename Vector::value_type> +struct DotProduct + : InnerProduct<I, Vector, Scalar> +{}; +#endif + + + + +// Norm induced by inner product +// Might be moved to another place later +// Definition as class and function +// Conversion from scalar to magnitude_type is covered by norm concept +template <typename I, typename Vector, + typename Scalar = typename Vector::value_type> + _GLIBCXX_WHERE(InnerProduct<I, Vector, Scalar> + && RealMagnitude<Scalar>) +struct induced_norm_t +{ + // Return type evtl. with macro to use concept definition + typename magnitude_type_trait<Scalar>::type + operator() (const I& inner, const Vector& v) + { + // Check whether inner product is positive real + // assert(Scalar(abs(inner(v, v))) == inner(v, v)); + + // Similar check while accepting small imaginary values + // assert( (abs(inner(v, v)) - inner(v, v)) / abs(inner(v, v)) < 1e-6; ) + + // Could also be defined with abs but that might introduce extra ops + // typedef RealMagnitude<Scalar>::type magnitude_type; + + typedef typename magnitude_type_trait<Scalar>::type magnitude_type; + return sqrt(static_cast<magnitude_type> (inner(v, v))); + } +}; + + +#if 0 +template <typename I, typename Vector, + typename Scalar = typename Vector::value_type> + LA_WHERE( InnerProduct<I, Vector, Scalar> + && RealMagnitude<Scalar> ) +magnitude_type_trait<Scalar>::type +induced_norm(const I& inner, const Vector& v) +{ + return induced_norm_t<I, Vector, Scalar>() (inner, v); +} +#endif + +#ifdef __GXX_CONCEPTS__ + + +concept HilbertSpace<typename I, typename Vector, + typename Scalar = typename Vector::value_type, + typename N = induced_norm_t<I, Vector, Scalar> > + : InnerProduct<I, Vector, Scalar>, + BanachSpace<N, Vector, Scalar> +{ + axiom Consistency(Vector v) + { + math::induced_norm_t<I, Vector, Scalar>()(v) == N()(v); + } +}; +#else + //! Concept HilbertSpace + /*! + A Hilbert space is a vector space with an inner product that induces a norm + + \param I Inner product functor + \param Vector The the type of a vector or a collection + \param Scalar The scalar over which the vector field is defined + \param N Norm functor + + \par Refinement of: + - InnerProduct <I, Vector, Scalar> + - BanachSpace <N, Vector, Scalar> + + \note + - The (expressible) requirements of Banach Space are already given in InnerProduct + (besides consistency of the functors). + - A difference is that InnerProduct is not a refinement of Vectorspace + */ +template <typename I, typename Vector, + typename Scalar = typename Vector::value_type, + typename N = induced_norm_t<I, Vector, Scalar> > +struct HilbertSpace + : InnerProduct<I, Vector, Scalar>, + BanachSpace<N, Vector, Scalar> +{ + /// Consistency between norm and induced norm + axiom Consistency(Vector v) + { + /// math::induced_norm_t<I, Vector, Scalar>()(v) == N()(v); + } +}; +#endif // __GXX_CONCEPTS__ + +/*@}*/ // end of group Concepts + +} // namespace math + +#endif // LA_VECTOR_CONCEPTS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/meta_math/abs.hpp b/AMDiS/lib/mtl4/boost/numeric/meta_math/abs.hpp new file mode 100644 index 0000000000000000000000000000000000000000..fdf5e9ed642df909488e4cf505f3ea5f2c78d234 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/meta_math/abs.hpp @@ -0,0 +1,27 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef META_MATH_ABS_INCLUDE +#define META_MATH_ABS_INCLUDE + +namespace meta_math { + +template <long int x> +struct abs +{ + static long int const value = x < 0 ? -x : x; +}; + + +} // namespace meta_math + +#endif // META_MATH_ABS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/meta_math/is_power_of_2.hpp b/AMDiS/lib/mtl4/boost/numeric/meta_math/is_power_of_2.hpp new file mode 100644 index 0000000000000000000000000000000000000000..e629a6d30f0401f18702b2f22c41719b8ab7693f --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/meta_math/is_power_of_2.hpp @@ -0,0 +1,28 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef META_MATH_IS_POWER_OF_2_INCLUDE +#define META_MATH_IS_POWER_OF_2_INCLUDE + +#include <boost/numeric/meta_math/least_significant_one_bit.hpp> + +namespace meta_math { + +template <unsigned long X> +struct is_power_of_2 +{ + static const bool value= X == least_significant_one_bit<X>::value; +}; + +} // namespace meta_math + +#endif // META_MATH_IS_POWER_OF_2_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/meta_math/is_prime.hpp b/AMDiS/lib/mtl4/boost/numeric/meta_math/is_prime.hpp new file mode 100644 index 0000000000000000000000000000000000000000..e6aa21de3e5a55bf7fe37ab9164f1f774c934617 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/meta_math/is_prime.hpp @@ -0,0 +1,95 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef META_MATH_IS_PRIME_INCLUDE +#define META_MATH_IS_PRIME_INCLUDE + +#include <boost/mpl/bool.hpp> +#include <boost/numeric/meta_math/sqrt.hpp> +// #include <boost/config/concept_macros.hpp> +#ifdef __GXX_CONCEPTS__ +# include <concepts> +#endif + + +namespace meta_math { + +namespace mpl = boost::mpl; + +namespace impl { + + // Checks if 'x' is divisible by some odd number >= max_odd, checking decreasingly + template <long int x, long int max_odd> + struct is_prime_to_max_odd + { + static bool const value = x % max_odd != 0 + && is_prime_to_max_odd<x, max_odd-2>::value; + }; + + // Once we reach 1, it's prime + template <long int x> struct is_prime_to_max_odd<x, 1> : mpl::true_ {}; + + + // Returns the largest number that x is tried to divided by. + // This is a odd number slightly larger than the approximated square root. + template <long int x> + struct max_prime_compare + { + static long int const tmp = sqrt<x>::value, + value = tmp % 2 == 0 ? tmp + 1 : tmp + 2; + }; + + + // Checks if there is an odd number between 3 and sqrt(x)+1 that divides x + // if there is no divisor found then x is prime (otherwise not) + // must be disabled when x is even + template <long int x, bool Disable> + struct check_odd + { + static bool const value = is_prime_to_max_odd<x, max_prime_compare<x>::value>::value; + }; + + // Intended for even numbers (> 2) which are always prime + template <long int x> + struct check_odd<x, true> + { + static bool const value = false; + }; + +} + +template <long int x> +struct is_prime +{ + static bool const value = impl::check_odd<x, x % 2 == 0>::value; +}; + +template <> struct is_prime<0> : mpl::false_ {}; +template <> struct is_prime<1> : mpl::false_ {}; +template <> struct is_prime<2> : mpl::true_ {}; +template <> struct is_prime<3> : mpl::true_ {}; +template <> struct is_prime<5> : mpl::true_ {}; + + +#ifdef __GXX_CONCEPTS__ + concept Prime<long int N> {} + + template <long int N> + where std::True<is_prime<N>::value> + concept_map Prime<N> {} +#endif + + + +} // namespace meta_math + +#endif // META_MATH_IS_PRIME_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/meta_math/least_significant_one_bit.hpp b/AMDiS/lib/mtl4/boost/numeric/meta_math/least_significant_one_bit.hpp new file mode 100644 index 0000000000000000000000000000000000000000..faf1e7f699fa9865ff22b6a23dc080701c9207a6 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/meta_math/least_significant_one_bit.hpp @@ -0,0 +1,27 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef META_MATH_LEAST_SIGNIFICANT_ONE_BIT_INCLUDE +#define META_MATH_LEAST_SIGNIFICANT_ONE_BIT_INCLUDE + +namespace meta_math { + +template <unsigned long X> +struct least_significant_one_bit +{ + static const unsigned long value= ((X ^ (X-1)) + 1) >> 1; +}; + + +} // namespace meta_math + +#endif // META_MATH_LEAST_SIGNIFICANT_ONE_BIT_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/meta_math/log_2.hpp b/AMDiS/lib/mtl4/boost/numeric/meta_math/log_2.hpp new file mode 100644 index 0000000000000000000000000000000000000000..8f474a4aa393e452dafcf6f4157b7c4d921c7e6b --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/meta_math/log_2.hpp @@ -0,0 +1,43 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef META_MATH_LOG_2_INCLUDE +#define META_MATH_LOG_2_INCLUDE + +#include <boost/numeric/meta_math/is_power_of_2.hpp> + +namespace meta_math { + +// Computes the logarithm to the basis 2 +// Without testing if power of 2 it rounds values down to next integer +template <unsigned long X> +struct log_2 +{ + // BOOST_STATIC_ASSERT(is_power_of_2_meta<X>::value); + static const unsigned long tmp= X >> 1, value= log_2<tmp>::value + 1; +}; + +template <> struct log_2<1> +{ + static const unsigned long value= 0; +}; + +template <> struct log_2<0> +{ + // #error "Logarithm of 0 is undefined" + BOOST_STATIC_ASSERT(true); // Logarithm of 0 is undefined +}; + + +} // namespace meta_math + +#endif // META_MATH_LOG_2_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/meta_math/loop.hpp b/AMDiS/lib/mtl4/boost/numeric/meta_math/loop.hpp new file mode 100644 index 0000000000000000000000000000000000000000..cb1b3538475388064d1b032987cf462249cd4289 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/meta_math/loop.hpp @@ -0,0 +1,20 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef META_MATH_LOOP_INCLUDE +#define META_MATH_LOOP_INCLUDE + +#include <boost/numeric/meta_math/loop1.hpp> +#include <boost/numeric/meta_math/loop2.hpp> +#include <boost/numeric/meta_math/loop3.hpp> + +#endif // META_MATH_LOOP_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/meta_math/loop1.hpp b/AMDiS/lib/mtl4/boost/numeric/meta_math/loop1.hpp new file mode 100644 index 0000000000000000000000000000000000000000..491781539383d1b4cdfae8a171229d6aced61219 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/meta_math/loop1.hpp @@ -0,0 +1,36 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef META_MATH_LOOP1_INCLUDE +#define META_MATH_LOOP1_INCLUDE + +// See loop3.hpp for example + +namespace meta_math { + +template <std::size_t Index0, std::size_t Max0> +struct loop1 +{ + static std::size_t const index0= Index0 - 1, next_index0= Index0 + 1; +}; + + +template <std::size_t Max0> +struct loop1<Max0, Max0> +{ + static std::size_t const index0= Max0 - 1; +}; + + +} // namespace meta_math + +#endif // META_MATH_LOOP1_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/meta_math/loop2.hpp b/AMDiS/lib/mtl4/boost/numeric/meta_math/loop2.hpp new file mode 100644 index 0000000000000000000000000000000000000000..e00227b42c6f32e1f0451d5073fd375b86e45e2c --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/meta_math/loop2.hpp @@ -0,0 +1,46 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef META_MATH_LOOP2_INCLUDE +#define META_MATH_LOOP2_INCLUDE + +// See loop3.hpp for example + +namespace meta_math { + +template <std::size_t Index0, std::size_t Max0, std::size_t Index1, std::size_t Max1> +struct loop2 +{ + static const std::size_t index0= Index0 - 1, next_index0= Index0, + index1= Index1 - 1, next_index1= Index1 + 1; +}; + + +template <std::size_t Index0, std::size_t Max0, std::size_t Max1> +struct loop2<Index0, Max0, Max1, Max1> +{ + static const std::size_t index0= Index0 - 1, next_index0= Index0 + 1, + index1= Max1 - 1, next_index1= 1; +}; + + +template <std::size_t Max0, std::size_t Max1> +struct loop2<Max0, Max0, Max1, Max1> +{ + static const std::size_t index0= Max0 - 1, + index1= Max1 - 1; +}; + + +} // namespace meta_math + +#endif // META_MATH_LOOP2_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/meta_math/loop3.hpp b/AMDiS/lib/mtl4/boost/numeric/meta_math/loop3.hpp new file mode 100644 index 0000000000000000000000000000000000000000..eaf4858d7a5ba2a5aabf117bbeb007eacdd049c8 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/meta_math/loop3.hpp @@ -0,0 +1,96 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef META_MATH_LOOP3_INCLUDE +#define META_MATH_LOOP3_INCLUDE + +// See below for example + +namespace meta_math { + +template <std::size_t Index0, std::size_t Max0, std::size_t Index1, std::size_t Max1, + std::size_t Index2, std::size_t Max2> +struct loop3 +{ + static std::size_t const index0= Index0 - 1, next_index0= Index0, + index1= Index1 - 1, next_index1= Index1, + index2= Index2 - 1, next_index2= Index2 + 1; +}; + + +template <std::size_t Index0, std::size_t Max0, std::size_t Index1, std::size_t Max1, + std::size_t Max2> +struct loop3<Index0, Max0, Index1, Max1, Max2, Max2> +{ + static std::size_t const index0= Index0 - 1, next_index0= Index0, + index1= Index1 - 1, next_index1= Index1 + 1, + index2= Max2 - 1, next_index2= 1; +}; + + +template <std::size_t Index0, std::size_t Max0, std::size_t Max1, std::size_t Max2> +struct loop3<Index0, Max0, Max1, Max1, Max2, Max2> +{ + static std::size_t const index0= Index0 - 1, next_index0= Index0 + 1, + index1= Max1 - 1, next_index1= 1, + index2= Max2 - 1, next_index2= 1; +}; + + +template <std::size_t Max0, std::size_t Max1, std::size_t Max2> +struct loop3<Max0, Max0, Max1, Max1, Max2, Max2> +{ + static std::size_t const index0= Max0 - 1, + index1= Max1 - 1, + index2= Max2 - 1; +}; + + + + +#if 0 + +// ============================ +// Use the meta loop like this: +// ============================ + + +template <std::size_t Index0, std::size_t Max0, std::size_t Index1, std::size_t Max1, + std::size_t Index2, std::size_t Max2> +struct loop3_trace : public loop3<Index0, Max0, Index1, Max1, Index2, Max2> +{ + typedef loop3<Index0, Max0, Index1, Max1, Index2, Max2> base; + typedef loop3_trace<base::next_index0, Max0, base::next_index1, Max1, base::next_index2, Max2> next_t; + + void operator() () + { + std::cout << this->index0 << " : " << this->index1 << " : " << this->index2 << "\n"; + next_t() (); + } +}; + + +template <std::size_t Max0, std::size_t Max1, std::size_t Max2> +struct loop3_trace<Max0, Max0, Max1, Max1, Max2, Max2> + : public loop3<Max0, Max0, Max1, Max1, Max2, Max2> +{ + void operator() () + { + std::cout << this->index0 << " : " << this->index1 << " : " << this->index2 << "\n"; + } +}; + +#endif + +} // namespace meta_math + +#endif // META_MATH_LOOP3_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/meta_math/max.hpp b/AMDiS/lib/mtl4/boost/numeric/meta_math/max.hpp new file mode 100644 index 0000000000000000000000000000000000000000..58356018b8f6de829ebdd324cb1dbecb03423625 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/meta_math/max.hpp @@ -0,0 +1,27 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef META_MATH_MAX_INCLUDE +#define META_MATH_MAX_INCLUDE + +namespace meta_math { + +template <long int x, long int y> +struct max +{ + typedef long int type; + static long int const value = x < y ? y : x; +}; + +} // namespace meta_math + +#endif // META_MATH_MAX_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/meta_math/min.hpp b/AMDiS/lib/mtl4/boost/numeric/meta_math/min.hpp new file mode 100644 index 0000000000000000000000000000000000000000..94156eb79bdabae3e1baebc36022c8165772b08a --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/meta_math/min.hpp @@ -0,0 +1,27 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef META_MATH_MIN_INCLUDE +#define META_MATH_MIN_INCLUDE + +namespace meta_math { + +template <long int x, long int y> +struct min +{ + typedef long int type; + static long int const value = x < y ? x : y; +}; + +} // namespace meta_math + +#endif // META_MATH_MIN_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/meta_math/power_of_2.hpp b/AMDiS/lib/mtl4/boost/numeric/meta_math/power_of_2.hpp new file mode 100644 index 0000000000000000000000000000000000000000..b0f460d68e8551f00f064b266eec0378b61f6c90 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/meta_math/power_of_2.hpp @@ -0,0 +1,30 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef META_MATH_POWER_OF_2_INCLUDE +#define META_MATH_POWER_OF_2_INCLUDE + +namespace meta_math { + + +// Computes the n-th power of 2 +// So simple, everybody could do it, it is only there for the sake of completeness +template <unsigned long N> +struct power_of_2 +{ + static const unsigned long value= 1 << N; +}; + + +} // namespace meta_math + +#endif // META_MATH_POWER_OF_2_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/meta_math/sqrt.hpp b/AMDiS/lib/mtl4/boost/numeric/meta_math/sqrt.hpp new file mode 100644 index 0000000000000000000000000000000000000000..dd9dc426dda4c2b4d448251ad8a24a5fc7674d6e --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/meta_math/sqrt.hpp @@ -0,0 +1,59 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef META_MATH_SQRT_INCLUDE +#define META_MATH_SQRT_INCLUDE + +#include <boost/numeric/meta_math/abs.hpp> + +namespace meta_math { + +template <long int root, long int x> +struct sqrt_check +{ + static bool const value = root * root <= x && (root+1) * (root+1) > x; +}; + + +namespace impl { + + template <long int guess, long int x, bool Converged> + struct sqrt_impl + { + typedef long int type; + typedef sqrt_impl self; + static long int const quotient = x / guess, + new_value = (quotient + guess) / 2; + static bool const converging = abs<guess - quotient>::value < 2; + static long int const value = sqrt_impl<new_value, x, converging>::value; + }; + + // If the condition becomes true the guessed root will be the returned value + template <long int guess, long int x> + struct sqrt_impl<guess, x, true> + { + static long int const value = guess; + }; + +} + +template <long int x> +struct sqrt +{ + typedef long int type; + static long int const value = impl::sqrt_impl<1, x, false>::value; +}; + + +} // namespace meta_math + +#endif // META_MATH_SQRT_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/concept/collection.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/concept/collection.hpp new file mode 100644 index 0000000000000000000000000000000000000000..5f33eb947146a8a4b90f8eb348bd3addb39e28e3 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/concept/collection.hpp @@ -0,0 +1,1457 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_COLLECTION_INCLUDE +#define MTL_COLLECTION_INCLUDE + +#include <boost/type_traits/remove_const.hpp> +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <vector> + +#ifdef __GXX_CONCEPTS__ +# include <concepts> +#else +# include <boost/numeric/linear_algebra/pseudo_concept.hpp> +# include <boost/numeric/mtl/concept/std_concept.hpp> +#endif + +#include <boost/numeric/mtl/utility/transposed_orientation.hpp> + +namespace mtl { + +/** @addtogroup Concepts + * @{ + */ + +#ifdef __GXX_CONCEPTS__ + auto concept Collection<typename T> + { + typename value_type; + typename const_reference; + typename size_type; + }; +#else + /// Concept Collection + template <typename T> + struct Collection + { + /// Associated type: elements in the collection + typedef associated_type value_type; + + /// Associated type: return type of const element access (however implemented) + typedef associated_type const_reference; + + /// Associated type: size type used for indexing in collection + typedef associated_type size_type; + }; +#endif + + +#ifdef __GXX_CONCEPTS__ + auto concept MutableCollection<typename T> + : Collection<T> + { + typename reference; + } +#else + /// Concept MutableCollection + template <typename T> + struct MutableCollection + : public Collection<T> + { + /// Associated type: return type of non-const element access (however implemented) + typedef associated_type reference; + }; +#endif + + +#ifdef __GXX_CONCEPTS__ + concept ConstantSizeCollection<typename T> + : Collection<T> + {}; +#else + /// Concept ConstantSizeCollection: size parameters of collection are completely given at compile time + /* Which parameters determine collection size depends on type of collection, e.g. different for vector and matrix + \par Refinement of: + - Collection < T > + */ + template <typename T> + struct ConstantSizeCollection + : Collection<T> + {}; +#endif + + +#ifdef __GXX_CONCEPTS__ + auto concept AlgebraicCollection<typename T> + : Collection<T> + { + size_type num_rows(T); + size_type num_cols(T); + size_type size(T); + }; +#else + /// Concept AlgebraicCollection: common requirements of matrices, vectors, and scalars in computations + /** For more design clarity we consider them all as matrices (as Matlab does) and we regard + Scalar and Vector as special cases (see there). However, the implementation of vectors + is supposed to differ from the ones of matrices in order to provide efficient computations and storage. + \par Refinement of: + - Collection < T > + \par Notation: + - X is a type that models AlgebraicCollection + - x is an object of type X + \par Valid expressions: + - Number of rows: \n num_rows(x) \n Return Type: size_type + - Number of columns: \n num_cols(x) \n Return Type: size_type + - Number of elements: \n size(x) \n Return Type: size_type + \n Sematics: num_rows(x) * num_cols(x) (but possibly faster implemented) + */ + template <typename T> + struct AlgebraicCollection + : public Collection<T> + {}; +#endif + + +#ifdef __GXX_CONCEPTS__ + auto concept ConstantSizeAlgebraicCollection<typename T> + : AlgebraicCollection<T>, + ConstantSizeCollection<T> + { +#if 0 + // Is there a way to require static members???? + static Collection<T>::size_type T::static_num_rows; + static Collection<T>::size_type T::static_num_cols; + static Collection<T>::size_type T::static_size; +#endif + }; +#else + /// Concept ConstantSizeAlgebraicCollection: extension of AlgebraicCollection with meta-functions + /** This concept is used for algebraic collections with sizes known at compile time. + The motivation is that if the size of the collection is + is small, arithmetic operations can be unrolled at compile time. + + \par Refinement of: + - Collection < T > + \par Notation: + - X is a type that models ConstantSizeAlgebraicCollection + - x is an object of type X + \par Valid expressions: + - Number of rows: \n static_num_rows<X>::value + - Number of columns: \n static_num_cols<X>::value + - Number of elements: \n static_size<X>::value + \n Sematics: static_num_rows<X>::value * static_size<X>::value + \note + -# For more design clarity we consider them all as matrices (as Matlab does) and we regard + Scalar and Vector as special cases (see there). However, the implementation of vectors + is supposed to differ from the ones of matrices in order to provide efficient computations and storage. + + */ + template <typename T> + struct ConstantSizeAlgebraicCollection + : public AlgebraicCollection<T>, + public ConstantSizeCollection<T> + { + /// Associated type: meta-function for number of rows + typedef associated_type static_num_rows; + /// Associated type: meta-function for number of columns + typedef associated_type static_num_cols; + /// Associated type: meta-function for number of elements + typedef associated_type static_size; + }; +#endif + + + +#ifdef __GXX_CONCEPTS__ + auto concept TraversableCollection<typename Tag, typename C> + : Collection<C> + { +#if 0 + // This might be impossible to declare with concepts + typename cursor_type; + + cursor_type begin<Tag>(const C& c); + cursor_type end<Tag>(const C& c); +#endif + + // Maybe we switch to this syntax for the sake of concepts + typename cursor_type; + + cursor_type begin(const C& c, Tag); + cursor_type end(const C& c, Tag); + } +#else + /// Concept TraversableCollection: collections that can be traversed by cursor or iterator + template <typename Tag, typename C> + struct TraversableCollection + : public Collection<C> + { + /// Associated type: return type of tagged begin and end function + typedef associated_type cursor_type; + + /// Tagged free function that returns a cursor or iterator at the begin of an interval + /** The interval is specified by the Tag, i.e. the function is called begin<Tag>(c); */ + cursor_type begin(const C& c); + + /// Tagged free function that returns a cursor or iterator at the end of an interval + /** The interval is specified by the Tag, i.e. the function is called end<Tag>(c); */ + cursor_type end(const C& c); + }; +#endif + + +#ifdef __GXX_CONCEPTS__ + auto concept TraversableMutableCollection<typename Tag, typename C> + : MutableCollection<C> + { +#if 0 + typename cursor_type; + + cursor_type begin<Tag>(C& c); + cursor_type end<Tag>(C& c); +#endif + + // Maybe we switch to this syntax for the sake of concepts + typename cursor_type; + + cursor_type begin(C& c, Tag); + cursor_type end(C& c, Tag); + } +#else + /// Concept TraversableMutableCollection: collections that can be traversed by (mutable) iterator + template <typename Tag, typename C> + struct TraversableMutableCollection + : public MutableCollection<C> + { + /// Associated type: return type of tagged begin function + typedef associated_type cursor_type; + + /// Tagged free function that returns a cursor or iterator at the begin of an interval + /** The interval is specified by the Tag, i.e. the function is called begin<Tag>(c); */ + cursor_type begin(const C& c); + + /// Tagged free function that returns a cursor or iterator at the end of an interval + /** The interval is specified by the Tag, i.e. the function is called end<Tag>(c); */ + cursor_type end(const C& c); + }; +#endif + + + + +#ifdef __GXX_CONCEPTS__ +#if 0 + concept CategorizedType<typename T> + { + typedef associated_type type; + }; +#endif +#endif + + +#ifdef __GXX_CONCEPTS__ + concept OrientedCollection<typename T> + : Collection<T> + { + typename orientation; + + }; +#else + /// Concept OrientedCollection: collections with concept-awareness in terms of associated type + /** Concept-awareness is given for matrices as well as for vectors consistent to the unification in + AlgebraicCollection. The orientation of vectors determines whether it is a row or a column vector. + The orientation of matrices only characterizes the internal representation and has no semantic consequences. + \par Refinement of: + - Collection < T > + \par Associated type: + - orientation + */ + template <typename T> + struct OrientedCollection + : public Collection<T> + { + /// Associated type for orientation; by default identical with member type + typedef typename T::orientation orientation; + }; +#endif + + + + + + + +// ============================================ +// Concept maps (and emulations as type traits) +// ============================================ + +#ifdef __GXX_CONCEPTS__ + // Needs redefinition in refinements (at least in conceptg++) + // -> as a consequence we define it directly there +#else + template <typename Value, typename Parameters> + struct Collection<mtl::matrix::dense2D<Value, Parameters> > + { + typedef Value value_type; + typedef const Value& const_reference; + // Alleged ambiguity with mtl::tag::dense2D on MSVC + typedef typename mtl::matrix::dense2D<Value, Parameters>::size_type size_type; + }; +#endif + + +#ifdef __GXX_CONCEPTS__ + +#else + template <typename Value, std::size_t Mask, typename Parameters> + struct Collection<mtl::matrix::morton_dense<Value, Mask, Parameters> > + { + typedef Value value_type; + typedef const Value& const_reference; + typedef typename Parameters::size_type size_type; + }; +#endif + + +#ifdef __GXX_CONCEPTS__ + template <typename Value, typename Parameters> + concept_map Collection<mtl::matrix::compressed2D<Value, Parameters> > + { + typedef Value value_type; + typedef Value const_reference; + typedef typename mtl::matrix::compressed2D<Value, Parameters>::size_type size_type; + }; +#else + template <typename Value, typename Parameters> + struct Collection<mtl::matrix::compressed2D<Value, Parameters> > + { + typedef Value value_type; + typedef Value const_reference; + typedef typename Parameters::size_type size_type; + }; + +#endif + + +#ifdef __GXX_CONCEPTS__ +#else + template <typename Value, typename Parameters> + struct Collection<mtl::matrix::coordinate2D<Value, Parameters> > + { + typedef Value value_type; + typedef Value const_reference; + typedef typename Parameters::size_type size_type; + }; + +#endif + + +#ifdef __GXX_CONCEPTS__ +#else + template <typename Value, typename Parameters> + struct Collection<mtl::matrix::sparse_banded<Value, Parameters> > + { + typedef Value value_type; + typedef Value const_reference; + typedef typename Parameters::size_type size_type; + }; + +#endif + + +#ifdef __GXX_CONCEPTS__ + template <typename Vector> + concept_map Collection<mtl::matrix::multi_vector<Vector> > + { + typedef typename mtl::matrix::multi_vector<Vector>::value_type value_type; + typedef typename mtl::matrix::multi_vector<Vector>::const_reference const_reference; + typedef typename mtl::matrix::multi_vector<Vector>::size_type size_type; + }; +#else + template <typename Vector> + struct Collection<mtl::matrix::multi_vector<Vector> > + { + typedef typename mtl::matrix::multi_vector<Vector>::value_type value_type; + typedef typename mtl::matrix::multi_vector<Vector>::const_reference const_reference; + typedef typename mtl::matrix::multi_vector<Vector>::size_type size_type; + }; + +#endif + + + + +#ifdef __GXX_CONCEPTS__ + template <typename Vector> + concept_map Collection<mtl::matrix::multi_vector_range<Vector> > + { + typedef typename mtl::matrix::multi_vector_range<Vector>::value_type value_type; + typedef typename mtl::matrix::multi_vector_range<Vector>::const_reference const_reference; + typedef typename mtl::matrix::multi_vector_range<Vector>::size_type size_type; + }; +#else + template <typename Vector> + struct Collection<mtl::matrix::multi_vector_range<Vector> > + { + typedef typename mtl::matrix::multi_vector_range<Vector>::value_type value_type; + typedef typename mtl::matrix::multi_vector_range<Vector>::const_reference const_reference; + typedef typename mtl::matrix::multi_vector_range<Vector>::size_type size_type; + }; + +#endif + +#ifdef __GXX_CONCEPTS__ +#else + template <typename Value> + struct Collection<matrix::element_structure<Value> > + { + typedef Value value_type; + // typedef Value const_reference; + // typedef typename mtl::matrix::compressed2D<Value, Parameters>::size_type size_type; + }; + +#endif + +#ifdef __GXX_CONCEPTS__ +#else + template <typename Value, typename Parameters> + struct Collection<matrix::ell_matrix<Value, Parameters> > + { + typedef Value value_type; + typedef Value const_reference; + typedef typename Parameters::size_type size_type; + }; + +#endif + + +#ifdef __GXX_CONCEPTS__ + template <typename Scaling, typename Coll> + concept_map Collection<matrix::scaled_view<Scaling, Coll> > + { + typedef typename matrix::scaled_view<Scaling, Coll>::value_type value_type; + typedef typename matrix::scaled_view<Scaling, Coll>::const_reference const_reference; + typedef typename matrix::scaled_view<Scaling, Coll>::size_type size_type; + }; +#else + template <typename Scaling, typename Coll> + struct Collection<matrix::scaled_view<Scaling, Coll> > + { + typedef typename matrix::scaled_view<Scaling, Coll>::value_type value_type; + typedef typename matrix::scaled_view<Scaling, Coll>::const_reference const_reference; + typedef typename matrix::scaled_view<Scaling, Coll>::size_type size_type; + }; +#endif + +// added by Hui Li +#ifdef __GXX_CONCEPTS__ + template <typename Coll, typename RScaling> + concept_map Collection<matrix::rscaled_view<Coll,RScaling> > + { + typedef typename matrix::rscaled_view<Coll,RScaling>::value_type value_type; + typedef typename matrix::rscaled_view<Coll,RScaling>::const_reference const_reference; + typedef typename matrix::rscaled_view<Coll,RScaling>::size_type size_type; + }; +#else + template <typename Coll, typename RScaling> + struct Collection<matrix::rscaled_view<Coll,RScaling> > + { + typedef typename matrix::rscaled_view<Coll,RScaling>::value_type value_type; + typedef typename matrix::rscaled_view<Coll,RScaling>::const_reference const_reference; + typedef typename matrix::rscaled_view<Coll,RScaling>::size_type size_type; + }; +#endif + + + +#ifdef __GXX_CONCEPTS__ + // template <typename Functor, typename Coll> + // concept_map Collection< vector::map_view<Functor, Coll> > + // { + // typedef typename vector::map_view<Functor, Coll>::value_type value_type; + // typedef typename vector::map_view<Functor, Coll>::const_reference const_reference; + // typedef typename vector::map_view<Functor, Coll>::size_type size_type; + // }; +#else + template <typename Functor, typename Coll> + struct Collection< vector::map_view<Functor, Coll> > + { + // typedef typename Functor::result_type value_type; + // typedef typename Functor::result_type const_reference; + // typedef typename Collection<Coll>::size_type size_type; + + typedef typename vector::map_view<Functor, Coll>::value_type value_type; + typedef typename vector::map_view<Functor, Coll>::const_reference const_reference; + typedef typename vector::map_view<Functor, Coll>::size_type size_type; + }; +#endif + + +#ifdef __GXX_CONCEPTS__ + +#else + template <typename Scaling, typename Coll> + struct Collection<vector::scaled_view<Scaling, Coll> > + : Collection< vector::map_view<tfunctor::rscale<typename Collection<Coll>::value_type, Scaling>, Coll> > + { + // typedef typename vector::scaled_view<Scaling, Coll>::value_type value_type; + // typedef typename vector::scaled_view<Scaling, Coll>::const_reference const_reference; + // typedef typename vector::scaled_view<Scaling, Coll>::size_type size_type; + }; +#endif + + + +// added by Hui Li +#ifdef __GXX_CONCEPTS__ + template <typename Coll, typename RScaling> + concept_map Collection<vector::rscaled_view<Coll,RScaling> > + { + typedef typename vector::rscaled_view<Coll,RScaling>::value_type value_type; + typedef typename vector::rscaled_view<Coll,RScaling>::const_reference const_reference; + typedef typename vector::rscaled_view<Coll,RScaling>::size_type size_type; + }; +#else + template <typename Coll, typename RScaling> + struct Collection<vector::rscaled_view<Coll,RScaling> > + : Collection< vector::map_view<tfunctor::rscale<typename Collection<Coll>::value_type, RScaling>, Coll> > + { + // typedef typename vector::rscaled_view<Coll,RScaling>::value_type value_type; + // typedef typename vector::rscaled_view<Coll,RScaling>::const_reference const_reference; + // typedef typename vector::rscaled_view<Coll,RScaling>::size_type size_type; + }; +#endif + + +#ifdef __GXX_CONCEPTS__ + template <typename Coll> + concept_map Collection<vector::conj_view<Coll> > + { + typedef typename vector::conj_view<Coll>::value_type value_type; + typedef typename vector::conj_view<Coll>::const_reference const_reference; + typedef typename vector::conj_view<Coll>::size_type size_type; + }; +#else + template <typename Coll> + struct Collection<vector::conj_view<Coll> > + { + typedef typename vector::conj_view<Coll>::value_type value_type; + typedef typename vector::conj_view<Coll>::const_reference const_reference; + typedef typename vector::conj_view<Coll>::size_type size_type; + }; +#endif + +#ifdef __GXX_CONCEPTS__ +#else + template <typename Coll> + struct Collection<vector::real_view<Coll> > + { + typedef typename vector::real_view<Coll>::value_type value_type; + typedef typename vector::real_view<Coll>::const_reference const_reference; + typedef typename vector::real_view<Coll>::size_type size_type; + }; +#endif + +#ifdef __GXX_CONCEPTS__ +#else + template <typename Coll> + struct Collection<vector::imag_view<Coll> > + { + typedef typename vector::imag_view<Coll>::value_type value_type; + typedef typename vector::imag_view<Coll>::const_reference const_reference; + typedef typename vector::imag_view<Coll>::size_type size_type; + }; +#endif + +#ifdef __GXX_CONCEPTS__ + template <typename Coll> + concept_map Collection<vector::negate_view<Coll> > + { + typedef typename vector::negate_view<Coll>::value_type value_type; + typedef typename vector::negate_view<Coll>::const_reference const_reference; + typedef typename vector::negate_view<Coll>::size_type size_type; + }; +#else + template <typename Coll> + struct Collection<vector::negate_view<Coll> > + { + typedef typename vector::negate_view<Coll>::value_type value_type; + typedef typename vector::negate_view<Coll>::const_reference const_reference; + typedef typename vector::negate_view<Coll>::size_type size_type; + }; +#endif + +#ifdef __GXX_CONCEPTS__ +#else + template <class E1, class E2, typename SFunctor> + struct Collection< vector::vec_scal_aop_expr<E1, E2, SFunctor> > + { + typedef typename Collection<E1>::value_type value_type; + typedef value_type const_reference; + typedef typename Collection<E1>::size_type size_type; + }; +#endif + + +#ifdef __GXX_CONCEPTS__ +#else + template <class E1, class E2> + struct Collection<vector::vec_scal_asgn_expr<E1, E2> > + : Collection< vector::vec_scal_aop_expr<E1, E2, mtl::sfunctor::assign<typename Collection<E1>::value_type, E2> > > + {}; +#endif + + +#ifdef __GXX_CONCEPTS__ +#else + template <unsigned BSize, typename Vector> + struct Collection<vector::unrolled1<BSize, Vector> > + { + typedef typename Collection<Vector>::value_type value_type; + typedef value_type const_reference; + typedef typename Collection<Vector>::size_type size_type; + }; +#endif + + + + +#ifdef __GXX_CONCEPTS__ + template <typename Coll> + concept_map Collection<matrix::conj_view<Coll> > + { + typedef typename matrix::conj_view<Coll>::value_type value_type; + typedef typename matrix::conj_view<Coll>::const_reference const_reference; + typedef typename matrix::conj_view<Coll>::size_type size_type; + }; +#else + template <typename Coll> + struct Collection<matrix::conj_view<Coll> > + { + typedef typename matrix::conj_view<Coll>::value_type value_type; + typedef typename matrix::conj_view<Coll>::const_reference const_reference; + typedef typename matrix::conj_view<Coll>::size_type size_type; + }; +#endif + + + + +#ifdef __GXX_CONCEPTS__ + template <typename Coll> + concept_map Collection<matrix::imag_view<Coll> > + { + typedef typename matrix::imag_view<Coll>::value_type value_type; + typedef typename matrix::imag_view<Coll>::const_reference const_reference; + typedef typename matrix::imag_view<Coll>::size_type size_type; + }; +#else + template <typename Coll> + struct Collection<matrix::imag_view<Coll> > + { + typedef typename matrix::imag_view<Coll>::value_type value_type; + typedef typename matrix::imag_view<Coll>::const_reference const_reference; + typedef typename matrix::imag_view<Coll>::size_type size_type; + }; +#endif + + + + +#ifdef __GXX_CONCEPTS__ + template <typename Coll> + concept_map Collection<matrix::negate_view<Coll> > + { + typedef typename matrix::negate_view<Coll>::value_type value_type; + typedef typename matrix::negate_view<Coll>::const_reference const_reference; + typedef typename matrix::negate_view<Coll>::size_type size_type; + }; +#else + template <typename Coll> + struct Collection<matrix::negate_view<Coll> > + { + typedef typename matrix::negate_view<Coll>::value_type value_type; + typedef typename matrix::negate_view<Coll>::const_reference const_reference; + typedef typename matrix::negate_view<Coll>::size_type size_type; + }; +#endif + + + + +#ifdef __GXX_CONCEPTS__ + template <typename Coll> + concept_map Collection<matrix::real_view<Coll> > + { + typedef typename matrix::real_view<Coll>::value_type value_type; + typedef typename matrix::real_view<Coll>::const_reference const_reference; + typedef typename matrix::real_view<Coll>::size_type size_type; + }; +#else + template <typename Coll> + struct Collection<matrix::real_view<Coll> > + { + typedef typename matrix::real_view<Coll>::value_type value_type; + typedef typename matrix::real_view<Coll>::const_reference const_reference; + typedef typename matrix::real_view<Coll>::size_type size_type; + }; +#endif + + +#ifdef __GXX_CONCEPTS__ + template <typename Functor> + concept_map Collection<matrix::implicit_dense<Functor> > + { + typedef typename matrix::implicit_dense<Functor>::value_type value_type; + typedef typename matrix::implicit_dense<Functor>::const_reference const_reference; + typedef typename matrix::implicit_dense<Functor>::size_type size_type; + }; +#else + template <typename Functor> + struct Collection<matrix::implicit_dense<Functor> > + { + typedef typename matrix::implicit_dense<Functor>::value_type value_type; + typedef typename matrix::implicit_dense<Functor>::const_reference const_reference; + typedef typename matrix::implicit_dense<Functor>::size_type size_type; + }; +#endif + + +#ifdef __GXX_CONCEPTS__ + template <typename Value> + concept_map Collection<matrix::ones_matrix<Value> > + { + typedef typename matrix::ones_matrix<Value>::value_type value_type; + typedef typename matrix::ones_matrix<Value>::const_reference const_reference; + typedef typename matrix::ones_matrix<Value>::size_type size_type; + }; +#else + template <typename Value> + struct Collection<matrix::ones_matrix<Value> > + { + typedef typename matrix::ones_matrix<Value>::value_type value_type; + typedef typename matrix::ones_matrix<Value>::const_reference const_reference; + typedef typename matrix::ones_matrix<Value>::size_type size_type; + }; +#endif + + +#ifdef __GXX_CONCEPTS__ + template <typename Value> + concept_map Collection<matrix::hilbert_matrix<Value> > + { + typedef typename matrix::hilbert_matrix<Value>::value_type value_type; + typedef typename matrix::hilbert_matrix<Value>::const_reference const_reference; + typedef typename matrix::hilbert_matrix<Value>::size_type size_type; + }; +#else + template <typename Value> + struct Collection<matrix::hilbert_matrix<Value> > + { + typedef typename matrix::hilbert_matrix<Value>::value_type value_type; + typedef typename matrix::hilbert_matrix<Value>::const_reference const_reference; + typedef typename matrix::hilbert_matrix<Value>::size_type size_type; + }; +#endif + + +#ifdef __GXX_CONCEPTS__ + template <typename Vector1, typename Vector2> + concept_map Collection<matrix::outer_product_matrix<Vector1, Vector2> > + { + typedef typename matrix::outer_product_matrix<Vector1, Vector2>::value_type value_type; + typedef typename matrix::outer_product_matrix<Vector1, Vector2>::const_reference const_reference; + typedef typename matrix::outer_product_matrix<Vector1, Vector2>::size_type size_type; + }; +#else + template <typename Vector1, typename Vector2> + struct Collection<matrix::outer_product_matrix<Vector1, Vector2> > + { + typedef typename matrix::outer_product_matrix<Vector1, Vector2>::value_type value_type; + typedef typename matrix::outer_product_matrix<Vector1, Vector2>::const_reference const_reference; + typedef typename matrix::outer_product_matrix<Vector1, Vector2>::size_type size_type; + }; +#endif + + + + +#ifdef __GXX_CONCEPTS__ + template <typename Matrix> + concept_map Collection<mtl::matrix::transposed_view<Matrix> > + { + typedef typename mtl::matrix::transposed_view<Matrix>::value_type value_type; + typedef typename mtl::matrix::transposed_view<Matrix>::const_reference const_reference; + typedef typename mtl::matrix::transposed_view<Matrix>::size_type size_type; + }; +#else + template <typename Matrix> + struct Collection<mtl::matrix::transposed_view<Matrix> > + { + typedef typename mtl::matrix::transposed_view<Matrix>::value_type value_type; + typedef typename mtl::matrix::transposed_view<Matrix>::const_reference const_reference; + typedef typename mtl::matrix::transposed_view<Matrix>::size_type size_type; + }; +#endif + + +#ifdef __GXX_CONCEPTS__ + template <typename Matrix> + concept_map Collection<matrix::hermitian_view<Matrix> > + { + typedef typename Collection<Matrix>::value_type value_type; + typedef typename Collection<Matrix>::const_reference const_reference; + typedef typename Collection<Matrix>::size_type size_type; + }; +#else + template <typename Matrix> + struct Collection<matrix::hermitian_view<Matrix> > + { + typedef typename Collection<Matrix>::value_type value_type; + typedef typename Collection<Matrix>::const_reference const_reference; + typedef typename Collection<Matrix>::size_type size_type; + }; +#endif + +#ifdef __GXX_CONCEPTS__ + template <typename Coll> + concept_map Collection< matrix::banded_view<Coll> > + { + typedef typename matrix::banded_view<Coll>::value_type value_type; + typedef typename matrix::banded_view<Coll>::const_reference const_reference; + typedef typename matrix::banded_view<Coll>::size_type size_type; + }; +#else + template <typename Coll> + struct Collection< matrix::banded_view<Coll> > + { + typedef typename matrix::banded_view<Coll>::value_type value_type; + typedef typename matrix::banded_view<Coll>::const_reference const_reference; + typedef typename matrix::banded_view<Coll>::size_type size_type; + }; +#endif + +#ifdef __GXX_CONCEPTS__ +#else + template <typename Matrix> + struct Collection< matrix::indirect<Matrix> > + { + typedef typename Collection<Matrix>::value_type value_type; + typedef value_type const_reference; // maybe change later + typedef typename Collection<Matrix>::size_type size_type; + }; +#endif + + +#ifdef __GXX_CONCEPTS__ + +#else + template <typename Matrix, typename Tag, int level> + struct Collection<traits::detail::sub_matrix_cursor<Matrix, Tag, level> > + { + typedef typename Collection<Matrix>::value_type value_type; + typedef typename Collection<Matrix>::const_reference const_reference; + typedef typename Collection<Matrix>::size_type size_type; + }; +#endif + +#ifdef __GXX_CONCEPTS__ + +#else + template <typename E1, typename E2> + struct Collection<matrix::mat_mat_times_expr<E1, E2> > + { + typedef typename Collection<E1>::value_type ft; + typedef typename Collection<E2>::value_type st; + + typedef typename Multiplicable<ft, st>::result_type value_type; + typedef const value_type& const_reference; + typedef typename Collection<E1>::size_type size_type; + }; +#endif + +#ifdef __GXX_CONCEPTS__ + +#else + template <typename E1, typename E2> + struct Collection<matrix::mat_mat_plus_expr<E1, E2> > + { + typedef typename Collection<E1>::value_type ft; + typedef typename Collection<E2>::value_type st; + + typedef typename Addable<ft, st>::result_type value_type; + typedef const value_type& const_reference; + typedef typename Collection<E1>::size_type size_type; + }; +#endif + +#ifdef __GXX_CONCEPTS__ + +#else + template <typename E1, typename E2> + struct Collection<matrix::mv_mv_plus_expr<E1, E2> > + : Collection<matrix::mat_mat_plus_expr<E1, E2> > + {}; +#endif + +#ifdef __GXX_CONCECPTS__ + +#else + template< typename Matrix, typename Vector> + struct Collection<mtl::mat_cvec_times_expr<Matrix, Vector> > + { + typedef typename Collection< Matrix >::value_type value_type; + typedef const value_type& const_reference; + typedef typename Collection< Matrix >::size_type size_type; + }; +#endif + + +#ifdef __GXX_CONCEPTS__ + +#else + template <typename Value, typename Parameters> + struct Collection<mtl::vector::dense_vector<Value, Parameters> > + { + typedef Value value_type; + typedef const Value& const_reference; + typedef typename Parameters::size_type size_type; + }; +#endif + +#ifdef __GXX_CONCEPTS__ + +#else + template <typename Value, typename Parameters> + struct Collection<mtl::vector::strided_vector_ref<Value, Parameters> > + { + typedef typename boost::remove_const<Value>::type value_type; + typedef const Value& const_reference; + typedef typename mtl::vector::strided_vector_ref<Value, Parameters>::size_type size_type; + }; +#endif + +#ifdef __GXX_CONCEPTS__ +#else + template <typename Value, typename Parameters> + struct Collection<mtl::vector::sparse_vector<Value, Parameters> > + { + typedef Value value_type; + typedef value_type const_reference; + typedef typename Parameters::size_type size_type; + }; +#endif + + +#ifdef __GXX_CONCEPTS__ +#else + template <class E1, class E2, typename SFunctor> + struct Collection<mtl::vector::vec_vec_ele_prod_expr<E1, E2, SFunctor> > + { + typedef typename Multiplicable<typename Collection<E1>::value_type, + typename Collection<E2>::value_type>::result_type value_type; + typedef const value_type& const_reference; + typedef typename Collection<E1>::size_type size_type; + }; +#endif + +#ifdef __GXX_CONCEPTS__ +#else + template <class E1, class E2, typename SFunctor> + struct Collection<mtl::vector::vec_vec_pmop_expr<E1, E2, SFunctor> > + { + typedef typename Addable<typename Collection<E1>::value_type, + typename Collection<E2>::value_type>::result_type value_type; + typedef const value_type& const_reference; + typedef typename Collection<E1>::size_type size_type; + }; +#endif + +#ifdef __GXX_CONCEPTS__ +#else + template <class E1, class E2, typename SFunctor> + struct Collection<mtl::vector::vec_vec_op_expr<E1, E2, SFunctor> > + { + typedef typename SFunctor::result_type value_type; + typedef const value_type& const_reference; + typedef typename Collection<E1>::size_type size_type; + }; +#endif + +#ifdef __GXX_CONCEPTS__ +#else + template <class E1, class E2, typename SFunctor> + struct Collection<mtl::vector::vec_vec_aop_expr<E1, E2, SFunctor> > + { + typedef typename Collection<E1>::value_type value_type; + typedef const value_type& const_reference; + typedef typename Collection<E1>::size_type size_type; + }; +#endif + +#ifdef __GXX_CONCEPTS__ +#else + template <typename Matrix, typename VectorIn> + struct Collection<mtl::vector::mat_cvec_multiplier<Matrix, VectorIn> > + { + typedef typename Multiplicable<typename Collection<Matrix>::value_type, + typename Collection<VectorIn>::value_type>::result_type value_type; + typedef const value_type& const_reference; + typedef typename Collection<Matrix>::size_type size_type; + }; +#endif + + +#ifdef __GXX_CONCEPTS__ + +#else + // Dunno if this is really a good idea + template <typename T> + struct Collection<T const> + : Collection<T> + {}; +#endif + + +#ifdef __GXX_CONCEPTS__ + +#else + template <typename Value> + struct Collection<std::vector<Value> > + { + typedef typename std::vector<Value>::value_type value_type; + typedef typename std::vector<Value>::const_reference const_reference; + typedef typename std::vector<Value>::size_type size_type; + }; +#endif + +#ifdef __GXX_CONCEPTS__ +#else + template <typename Vector, typename Functor> + struct Collection<mtl::vector::lazy_reduction<Vector, Functor> > + { + typedef std::size_t size_type; + }; +#endif + + + +#ifdef __GXX_CONCEPTS__ + template <typename Value, typename Parameters> + concept_map MutableCollection<mtl::matrix::dense2D<Value, Parameters> > + { + typedef Value value_type; + typedef const Value& const_reference; + typedef typename mtl::matrix::dense2D<Value, Parameters>::size_type size_type; + + typedef Value& reference; + }; +#else + template <typename Value, typename Parameters> + struct MutableCollection<mtl::matrix::dense2D<Value, Parameters> > + : public Collection<mtl::matrix::dense2D<Value, Parameters> > + { + typedef Value& reference; + }; +#endif + +#ifdef __GXX_CONCEPTS__ + + template <typename Value, unsigned long Mask, typename Parameters> + concept_map MutableCollection<mtl::matrix::morton_dense<Value, Mask, Parameters> > + { + typedef Value value_type; + typedef const Value& const_reference; + typedef typename mtl::matrix::morton_dense<Value, Mask, Parameters>::size_type size_type; + + typedef Value& reference; + }; + +#else + + template <typename Value, unsigned long Mask, typename Parameters> + struct MutableCollection<mtl::matrix::morton_dense<Value, Mask, Parameters> > + : public Collection<mtl::matrix::morton_dense<Value, Mask, Parameters> > + { + typedef Value& reference; + }; + +#endif + + +#ifdef __GXX_CONCEPTS__ + template <typename Value, typename Parameters> + concept_map MutableCollection<mtl::vector::strided_vector_ref<Value, Parameters> > + { + typedef typename boost::remove_const<Value>::type value_type; + typedef const Value& const_reference; + typedef typename mtl::vector::strided_vector_ref<Value, Parameters>::size_type size_type; + + typedef Value& reference; + }; +#else + template <typename Value, typename Parameters> + struct MutableCollection<mtl::vector::strided_vector_ref<Value, Parameters> > + : public Collection<mtl::vector::strided_vector_ref<Value, Parameters> > + { + typedef Value& reference; + }; +#endif + + + +#ifdef __GXX_CONCEPTS__ + template <typename Value> + concept_map MutableCollection<<std::vector<Value> > + { + typedef typename std::vector<Value>::value_type value_type; + typedef typename std::vector<Value>::const_reference const_reference; + typedef typename std::vector<Value>::size_type size_type; + + typedef typename std::vector<Value>::reference reference; + }; +#else + template <typename Value> + struct MutableCollection<std::vector<Value> > + : public Collection<std::vector<Value> > + { + typedef typename std::vector<Value>::reference reference; + }; +#endif + +#ifdef __GXX_CONCEPTS__ +#else + template <typename T> + struct OrientedCollection<const T> + : OrientedCollection<T> + {}; +#endif + + + +#ifdef __GXX_CONCEPTS__ + template <typename Value, typename Parameters> + concept_map OrientedCollection<mtl::matrix::dense2D<Value, Parameters> > + { + typedef Value value_type; + typedef const Value& const_reference; + typedef typename mtl::matrix::dense2D<Value, Parameters>::size_type size_type; + + typedef typename mtl::matrix::dense2D<Value, Parameters>::orientation orientation; + }; +#else + template <typename Value, typename Parameters> + struct OrientedCollection<mtl::matrix::dense2D<Value, Parameters> > + : public Collection<mtl::matrix::dense2D<Value, Parameters> > + { + typedef typename mtl::matrix::dense2D<Value, Parameters>::orientation orientation; + }; +#endif + +#ifdef __GXX_CONCEPTS__ + + template <typename Value, unsigned long Mask, typename Parameters> + concept_map OrientedCollection<mtl::matrix::morton_dense<Value, Mask, Parameters> > + { + typedef Value value_type; + typedef const Value& const_reference; + typedef typename mtl::matrix::morton_dense<Value, Mask, Parameters>::size_type size_type; + + typedef typename mtl::matrix::morton_dense<Value, Mask, Parameters>::orientation orientation; + }; + +#else + + template <typename Value, unsigned long Mask, typename Parameters> + struct OrientedCollection<mtl::matrix::morton_dense<Value, Mask, Parameters> > + : public Collection<mtl::matrix::morton_dense<Value, Mask, Parameters> > + { + typedef typename mtl::matrix::morton_dense<Value, Mask, Parameters>::orientation orientation; + }; + +#endif + +#ifdef __GXX_CONCEPTS__ + template <typename Value, typename Parameters> + concept_map OrientedCollection<mtl::matrix::compressed2D<Value, Parameters> > + { + typedef Value value_type; + typedef const Value& const_reference; + typedef typename mtl::matrix::compressed2D<Value, Parameters>::size_type size_type; + + typedef typename mtl::matrix::compressed2D<Value, Parameters>::orientation orientation; + }; +#else + template <typename Value, typename Parameters> + struct OrientedCollection<mtl::matrix::compressed2D<Value, Parameters> > + : public Collection<mtl::matrix::compressed2D<Value, Parameters> > + { + typedef typename mtl::matrix::compressed2D<Value, Parameters>::orientation orientation; + }; +#endif + +#ifdef __GXX_CONCEPTS__ +#else + template <typename Matrix> + struct OrientedCollection<mtl::matrix::indirect<Matrix> > + : public Collection<mtl::matrix::indirect<Matrix> > + { + typedef row_major orientation; + }; +#endif + +#ifdef __GXX_CONCEPTS__ + template <typename Value, typename Parameters> + concept_map OrientedCollection<mtl::vector::dense_vector<Value, Parameters> > + { + typedef Value value_type; + typedef const Value& const_reference; + typedef typename mtl::vector::dense_vector<Value, Parameters>::size_type size_type; + + typedef typename mtl::vector::dense_vector<Value, Parameters>::orientation orientation; + }; +#else + template <typename Value, typename Parameters> + struct OrientedCollection<mtl::vector::dense_vector<Value, Parameters> > + : public Collection<mtl::vector::dense_vector<Value, Parameters> > + { + typedef typename mtl::vector::dense_vector<Value, Parameters>::orientation orientation; + }; +#endif + +#ifdef __GXX_CONCEPTS__ + template <typename Value, typename Parameters> + concept_map OrientedCollection<mtl::vector::strided_vector_ref<Value, Parameters> > + { + typedef typename boost::remove_const<Value>::type value_type; + typedef const Value& const_reference; + typedef typename mtl::vector::strided_vector_ref<Value, Parameters>::size_type size_type; + + typedef typename mtl::vector::strided_vector_ref<Value, Parameters>::orientation orientation; + }; +#else + template <typename Value, typename Parameters> + struct OrientedCollection<mtl::vector::strided_vector_ref<Value, Parameters> > + : public Collection<mtl::vector::strided_vector_ref<Value, Parameters> > + { + typedef typename mtl::vector::strided_vector_ref<Value, Parameters>::orientation orientation; + }; +#endif + + + +#ifdef __GXX_CONCEPTS__ + template <typename Value> + concept_map OrientedCollection<std::vector<Value> > + { + typedef Value value_type; + typedef const Value& const_reference; + typedef typename std::vector<Value>::size_type size_type; + + typedef mtl::tag::col_major orientation; + }; +#else + template <typename Value> + struct OrientedCollection<std::vector<Value> > + : public Collection<std::vector<Value> > + { + typedef mtl::tag::col_major orientation; + }; +#endif + + +#ifdef __GXX_CONCEPTS__ + template <typename Scaling, typename Coll> + concept_map OrientedCollection< matrix::scaled_view<Scaling, Coll> > + { + typedef typename matrix::scaled_view<Scaling, Coll>::value_type value_type; + typedef typename matrix::scaled_view<Scaling, Coll>::const_reference const_reference; + typedef typename matrix::scaled_view<Scaling, Coll>::size_type size_type; + + typedef typename OrientedCollection<Coll>::orientation orientation; + }; +#else + template <typename Scaling, typename Coll> + struct OrientedCollection< matrix::scaled_view<Scaling, Coll> > + : public Collection< matrix::scaled_view<Scaling, Coll> > + { + typedef typename OrientedCollection<Coll>::orientation orientation; + }; +#endif + +// added by Hui Li +#ifdef __GXX_CONCEPTS__ + template <typename Coll, typename RScaling> + concept_map OrientedCollection< matrix::rscaled_view<Coll,RScaling> > + { + typedef typename matrix::rscaled_view<Coll,RScaling>::value_type value_type; + typedef typename matrix::rscaled_view<Coll,RScaling>::const_reference const_reference; + typedef typename matrix::rscaled_view<Coll,RScaling>::size_type size_type; + + typedef typename OrientedCollection<Coll>::orientation orientation; + }; +#else + template <typename Coll, typename RScaling> + struct OrientedCollection< matrix::rscaled_view<Coll,RScaling> > + : public Collection< matrix::rscaled_view<Coll,RScaling> > + { + typedef typename OrientedCollection<Coll>::orientation orientation; + }; +#endif + + +#ifdef __GXX_CONCEPTS__ + template <typename Scaling, typename Coll> + concept_map OrientedCollection< mtl::vector::scaled_view<Scaling, Coll> > + { + typedef typename mtl::vector::scaled_view<Scaling, Coll>::value_type value_type; + typedef typename mtl::vector::scaled_view<Scaling, Coll>::const_reference const_reference; + typedef typename mtl::vector::scaled_view<Scaling, Coll>::size_type size_type; + + typedef typename OrientedCollection<Coll>::orientation orientation; + }; +#else + template <typename Scaling, typename Coll> + struct OrientedCollection< mtl::vector::scaled_view<Scaling, Coll> > + : public Collection< mtl::vector::scaled_view<Scaling, Coll> > + { + typedef typename OrientedCollection<Coll>::orientation orientation; + }; +#endif + +//added by Hui Li +#ifdef __GXX_CONCEPTS__ + template <typename Coll, typename RScaling> + concept_map OrientedCollection< mtl::vector::rscaled_view<Coll,RScaling> > + { + typedef typename mtl::vector::rscaled_view<Coll,RScaling>::value_type value_type; + typedef typename mtl::vector::rscaled_view<Coll,RScaling>::const_reference const_reference; + typedef typename mtl::vector::rscaled_view<Coll,RScaling>::size_type size_type; + + typedef typename OrientedCollection<Coll>::orientation orientation; + }; +#else + template <typename Coll, typename RScaling> + struct OrientedCollection< mtl::vector::rscaled_view<Coll,RScaling> > + : public Collection< mtl::vector::rscaled_view<Coll,RScaling> > + { + typedef typename OrientedCollection<Coll>::orientation orientation; + }; +#endif + + +#ifdef __GXX_CONCEPTS__ + template <typename Coll> + concept_map OrientedCollection<matrix::conj_view<Coll> > + { + typedef typename matrix::conj_view<Coll>::value_type value_type; + typedef typename matrix::conj_view<Coll>::const_reference const_reference; + typedef typename matrix::conj_view<Coll>::size_type size_type; + + typedef typename OrientedCollection<Coll>::orientation orientation; + }; +#else + template <typename Coll> + struct OrientedCollection<matrix::conj_view<Coll> > + : public Collection<matrix::conj_view<Coll> > + { + typedef typename OrientedCollection<Coll>::orientation orientation; + }; +#endif + + +#ifdef __GXX_CONCEPTS__ + template <typename Coll> + concept_map OrientedCollection<mtl::vector::conj_view<Coll> > + { + typedef typename mtl::vector::conj_view<Coll>::value_type value_type; + typedef typename mtl::vector::conj_view<Coll>::const_reference const_reference; + typedef typename mtl::vector::conj_view<Coll>::size_type size_type; + + typedef typename OrientedCollection<Coll>::orientation orientation; + }; +#else + template <typename Coll> + struct OrientedCollection<mtl::vector::conj_view<Coll> > + : public Collection<mtl::vector::conj_view<Coll> > + { + typedef typename OrientedCollection<Coll>::orientation orientation; + }; +#endif + + +#ifdef __GXX_CONCEPTS__ + template <typename Functor, typename Coll> + concept_map OrientedCollection< mtl::vector::map_view<Functor, Coll> > + { + typedef typename mtl::vector::map_view<Functor, Coll>::value_type value_type; + typedef typename mtl::vector::map_view<Functor, Coll>::const_reference const_reference; + typedef typename mtl::vector::map_view<Functor, Coll>::size_type size_type; + + typedef typename OrientedCollection<Coll>::orientation orientation; + }; +#else + template <typename Functor, typename Coll> + struct OrientedCollection< mtl::vector::map_view<Functor, Coll> > + : public Collection< mtl::vector::map_view<Functor, Coll> > + { + typedef typename OrientedCollection<Coll>::orientation orientation; + }; +#endif + + +#ifdef __GXX_CONCEPTS__ + template <typename Coll> + concept_map OrientedCollection<mtl::matrix::transposed_view<Coll> > + { + typedef typename mtl::matrix::transposed_view<Coll>::value_type value_type; + typedef typename mtl::matrix::transposed_view<Coll>::const_reference const_reference; + typedef typename mtl::matrix::transposed_view<Coll>::size_type size_type; + + typedef typename mtl::traits::transposed_orientation<typename OrientedCollection<Coll>::orientation>::type orientation; + }; +#else + template <typename Coll> + struct OrientedCollection<mtl::matrix::transposed_view<Coll> > + : public Collection<mtl::matrix::transposed_view<Coll> > + { + typedef typename mtl::traits::transposed_orientation<typename OrientedCollection<Coll>::orientation>::type orientation; + }; +#endif + +#ifdef __GXX_CONCEPTS__ + template <typename Coll> + concept_map OrientedCollection<matrix::hermitian_view<Coll> > + { + typedef typename matrix::hermitian_view<Coll>::value_type value_type; + typedef typename matrix::hermitian_view<Coll>::const_reference const_reference; + typedef typename matrix::hermitian_view<Coll>::size_type size_type; + + typedef typename mtl::traits::transposed_orientation<typename OrientedCollection<Coll>::orientation>::type orientation; + }; +#else + template <typename Coll> + struct OrientedCollection<matrix::hermitian_view<Coll> > + : public Collection<matrix::hermitian_view<Coll> > + { + typedef typename mtl::traits::transposed_orientation<typename OrientedCollection<Coll>::orientation>::type orientation; + }; +#endif + + + +/*@}*/ // end of group Concepts + +} // namespace mtl + +#endif // MTL_COLLECTION_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/concept/magnitude.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/concept/magnitude.hpp new file mode 100644 index 0000000000000000000000000000000000000000..ba432ca1426900f0e8ac3094b86557bc6830a97a --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/concept/magnitude.hpp @@ -0,0 +1,88 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MAGNITUDE_INCLUDE +#define MTL_MAGNITUDE_INCLUDE + +#include <complex> + +namespace mtl { + +// ================================================= +// Concept to specify return type of abs (and norms) +// ================================================= + + +#ifdef __GXX_CONCEPTS__ + +// Concept to specify to specify projection of scalar value to comparable type +// For instance as return type of abs +// Minimalist definition for maximal applicability +auto concept Magnitude<typename T> +{ + typename type = T; +}; + +template <typename T> +concept_map Magnitude<std::complex<T> > +{ + typedef T type; +} + + +// Concept for norms etc., which are real values in mathematical definitions +auto concept RealMagnitude<typename T> + : Magnitude<T> +{ + requires std::EqualityComparable<type>; + requires std::LessThanComparable<type>; + +#ifndef CONCEPTS_WITHOUT_OVERLOADED_REQUIREMENTS + requires Field<type>; +#endif + + type sqrt(type); + + type abs(T); +} + +#else // now without concepts + +/// Concept/Type-trait for magnitudes of scalar values +/** This name is overloaded: when MTL4 is compiled with a concept-compiler + Magnitude is a concept otherwise a type-trait. + It is used for instance in norms. +**/ +template <typename T> +struct Magnitude +{ + /// Associated type; the default is T; must be specialized appropriately + typedef T type; +}; + +/// Specialization for complex numbers +template <typename T> +struct Magnitude<std::complex<T> > +{ + /// The associated type is defined to the complex's value type + typedef T type; +}; + +template <typename T> struct RealMagnitude + : public Magnitude<T> +{}; + +#endif // __GXX_CONCEPTS__ + +} // namespace mtl + +#endif // MTL_MAGNITUDE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/concept/matrix.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/concept/matrix.hpp new file mode 100644 index 0000000000000000000000000000000000000000..e701b21f49366aeefd74018670c29fc115bed9f9 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/concept/matrix.hpp @@ -0,0 +1,468 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_CONCEPT_INCLUDE +#define MTL_MATRIX_CONCEPT_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> + +#ifdef __GXX_CONCEPTS__ +# include <concepts> +#else +# include <boost/numeric/linear_algebra/pseudo_concept.hpp> +#endif + +namespace mtl { + +/** @addtogroup Concepts + * @{ + */ + +#ifdef __GXX_CONCEPTS__ + concept Matrix<typename T> + : AlgebraicCollection<T> + { + const_reference T::operator() (size_type row, size_type col) const; + + size_type nnz(T); + + // A[r][c] equivalent to A(r, c) + }; +#else + /// Concept Matrix + /** + \par Refinement of: + - AlgebraicCollection < T > + \par Notation: + - X is a type that models Matrix + - A is an object of type X + - r, c are objects of size_type + \par Valid expressions: + - Element access: \n A(r, c) \n Return Type: const_reference + \n Semantics: Element in row \p r and column \p c + - Element access: \n A[r][c] \n Equivalent to A(r, c) + \par Models: + - dense2D + - morton_dense + - compressed2D + \note + -# The access via A[r][c] is supposed to be implemented by means of A(r, c) (typically via CRTP and proxies). + If it would become (extremely) important to support 2D C arrays, it might be necessary to drop the requirement + of element access by A(r, c). + -# The name const_reference does not imply that the return type is necessarily referrable. For instance compressed2D + returns value_type. + */ + template <typename T> + struct Matrix + : public AlgebraicCollection<T> + { + /// Element access + const_reference T::operator() (size_type row, size_type col) const; + }; +#endif + + + +#ifdef __GXX_CONCEPTS__ + concept MatrixInserter<typename T> + { + typename matrix_type; + // typename T::matrix_type; + + requires Matrix<matrix_type>; + + typename proxy_type; + proxy_type operator() (Matrix<matrix_type>::size_type row, Matrix<matrix_type>::size_type col); + + T operator<< (proxy_type, Matrix<matrix_type>::value_type>); + }; +#else + /// Concept MatrixInserter: classes that enable efficient insertion into matrices, esp. compressed sparse. + /** + Used to fill non-mutable matrices like compressed2D. Matrix inserters might be parametrizable with + update functor. This allow to perform different operations when entry already exist, e.g. overwriting, + incrementing, minimum, ... The most important updates are certainly overwrite and increment (add). + + \par Associated types + - matrix_type + + \par Requires: + - Matrix<matrix_type> + + \par Notation: + - X is a type that models MatrixInserter + - A is an object of type X + - r, c are objects of type Matrix<matrix_type>::size_type + - v is an object of type Matrix<matrix_type>::value_type + + \par Valid expressions: + - Insertion with shift operator: \n + A(r, c) << v \n + Return type: T + \par Models: + - mtl::matrix::inserter < T > + \note + -# Used in concept InsertableMatrix + */ + template <typename T> + struct MatrixInserter + { + /// Type of matrix into which is inserted + typedef associated_type matrix_type; + + /// Return type of element access; only proxy + typedef associated_type proxy_type; + /// Element access; returns a proxy that handles insertion + proxy_type operator() (Matrix<matrix_type>::size_type row, Matrix<matrix_type>::size_type col); + }; +#endif + +#ifdef __GXX_CONCEPTS__ + concept InsertableMatrix<typename T> + : Matrix<T> + { + requires MatrixInserter<mtl::matrix::inserter<T> >; + }; +#else + /// Concept InsertableMatrix: %matrix that can be filled by means of inserter + /** + \par Requires: + - MatrixInserter < mtl::matrix::inserter< T > > + \par Models: + - dense2D + - morton_dense + - compressed2D + \note + -# All matrices in MTL model this concept in order and all future matrices are supposed to. + */ + template <typename T> + struct InsertableMatrix + : Matrix < T > + {}; +#endif + + +#ifdef __GXX_CONCEPTS__ + concept MutableMatrix<typename T> + : Matrix<T>, + MutableCollection<T> + { + reference T::operator() (size_type row, size_type col); + + // A[r][c] equivalent to A(r, c) + }; +#else + /// Concept MutableMatrix + /** + \par Refinement of: + - Matrix < T > + - MutableCollection < T > + \par Notation: + - X is a type that models MutableMatrix + - A is an object of type X + - r, c are objects of size_type + \par Valid expressions: + - Element access: \n A(r, c) \n Return Type: reference + \n Semantics: Element in row \p r and column \p c + - Element access: \n A[r][c] \n Equivalent to A(r, c) + \par Models: + - dense2D + - morton_dense + \note + -# The access via A[r][c] is supposed to be implemented by means of A(r, c) (typically via CRTP and proxies). + If it would become (extremely) important to support 2D C arrays, it might be necessary to drop the requirement + of element access by A(r, c). + */ + template <typename T> + struct MutableMatrix + : public Matrix<T>, + public MutableCollection<T> + { + /// Element access (in addition to const access) + reference T::operator() (size_type row, size_type col); + }; +#endif + + +#ifdef __GXX_CONCEPTS__ + concept ConstantSizeMatrix<typename T> + : Matrix<T>, + ConstantSizeAlgebraicCollection<T> + {}; +#else + /// Concept ConstantSizeMatrix + /** + \par Refinement of: + - Matrix < T > + - ConstantSizeAlgebraicCollection < T > + */ + template <typename T> + struct ConstantSizeMatrix + : public Matrix<T>, + public ConstantSizeAlgebraicCollection<T> + {}; +#endif + + +#ifdef __GXX_CONCEPTS__ + concept ResizeableMatrix<typename T> + : Matrix<T> + { + void T::resize(size_type r, size_type c); + }; +#else + /// Concept ResizeableMatrix + /** + \par Refinement of: + - Matrix < T > + */ + template <typename T> + struct ResizeableMatrix + : public Matrix<T> + { + /// Resize function + /** If new memory should be allocated only if total size changes */ + void resize(size_type r, size_type c); + }; +#endif + + +#ifdef __GXX_CONCEPTS__ + concept RowTraversableMatrix<typename M> + : Matrix<M>, + TraversableCollection<mtl::tag::row, M> + {}; +#else + /// Concept RowTraversableMatrix: provides begin and end cursor to traverse rows + /** + \par Refinement of: + - Matrix < M > + - TraversableCollection <mtl::tag::row, M> + */ + template <typename M> + struct RowTraversableMatrix + : public Matrix<M>, + public TraversableCollection<mtl::tag::row, M> + {}; +#endif + + +#ifdef __GXX_CONCEPTS__ + concept ColumnTraversableMatrix<typename M> + : Matrix<M>, + TraversableCollection<mtl::tag::col, M> + {}; +#else + /// Concept ColumnTraversableMatrix: provides begin and end cursor to traverse columns + /** + \par Refinement of: + - Matrix < M > + - TraversableCollection <mtl::tag::col, M> + */ + template <typename M> + struct ColumnTraversableMatrix + : public Matrix<M>, + public TraversableCollection<mtl::tag::col, M> + {}; +#endif + + +#ifdef __GXX_CONCEPTS__ + concept MajorTraversableMatrix<typename M> + : Matrix<M>, + TraversableCollection<mtl::tag::major, M> + {}; +#else + /// Concept MajorTraversableMatrix: traversable on major dimension + /** + Concept for matrices that are traversable along the major dimension, i.e. + traversing the rows of a row-major matrix and the columns of a column-major matrices. + The cursors begin and end are provided. + \par Refinement of: + - Matrix < M > + - TraversableCollection <mtl::tag::major, M> + \note + -# This traversal corresponds to the iterator design in MTL 2. + */ + template <typename M> + struct MajorTraversableMatrix + : public Matrix<M>, + public TraversableCollection<mtl::tag::major, M> + {}; +#endif + + +#ifdef __GXX_CONCEPTS__ + concept MinorTraversableMatrix<typename M> + : Matrix<M>, + TraversableCollection<mtl::tag::minor, M> + {}; +#else + /// Concept MinorTraversableMatrix: traversable on minor dimension + /** + Concept for matrices that are traversable along the minor dimension, i.e. + traversing the columns of a row-major matrix and the rows of a column-major matrices. + The cursors begin and end are provided. + \par Refinement of: + - Matrix < M > + - TraversableCollection <mtl::tag::minor, M> + \note + -# This traversal corresponds to the iterator design in MTL 2. + */ + template <typename M> + struct MinorTraversableMatrix + : public Matrix<M>, + public TraversableCollection<mtl::tag::minor, M> + {}; +#endif + + +#ifdef __GXX_CONCEPTS__ + concept AllTraversableMatrix<typename M> + : Matrix<M>, + TraversableCollection<mtl::tag::all, M> + {}; +#else + /// Concept AllTraversableMatrix: provides traversion over all elements + /** + All elements of a matrix are traversed, including structural zeros. Can be used, e.g., + for printing. + The cursors begin and end are provided. + \par Refinement of: + - Matrix < M > + - TraversableCollection <mtl::tag::all, M> + \note + -# For dense matrices the concept is equivalent to NonZeroTraversableMatrix. + */ + template <typename M> + struct AllTraversableMatrix + : public Matrix<M>, + public TraversableCollection<mtl::tag::all, M> + {}; +#endif + + +#ifdef __GXX_CONCEPTS__ + concept NonZeroTraversableMatrix<typename M> + : Matrix<M>, + TraversableCollection<mtl::tag::nz, M> + {}; +#else + /// Concept NonZeroTraversableMatrix: provides traversion over all structural non-zeros + /** + All structural non-zero elements of a matrix are traversed. Can be used, e.g., + for copying. + The cursors begin and end are provided. + \par Refinement of: + - Matrix < M > + - TraversableCollection <mtl::tag::all, M> + \note + -# For dense matrices the concept is equivalent to AllTraversableMatrix. + */ + template <typename M> + struct AllTraversableMatrix + : public Matrix<M>, + public TraversableCollection<mtl::tag::all, M> + {}; +#endif + + +#ifdef __GXX_CONCEPTS__ + concept AllTraversableSubMatrix<typename Tag, typename M> + : Matrix<M>, + TraversableCollection<Tag, M>, + TraversableCollection<mtl::tag::all, TraversableCollection<Tag, M>::result_type> + {}; +#else + /// Concept AllTraversableSubMatrix: provides traversion of rows, columns of matrices + /** + All elements of a row or a column, according to the Tag, are traversed. + The cursors begin and end are provided. + \par Refinement of: + - Matrix < M > + - TraversableCollection<Tag, M>, + - TraversableCollection<mtl::tag::all, TraversableCollection<Tag, M>::result_type> + */ + template <typename Tag, typename M> + struct AllTraversableMatrix + : public Matrix<M>, + public TraversableCollection<Tag, M>, + public TraversableCollection<mtl::tag::all, TraversableCollection<Tag, M>::result_type> + {}; +#endif + + + +#ifdef __GXX_CONCEPTS__ + concept NonZeroTraversableSubMatrix<typename Tag, typename M> + : Matrix<M>, + TraversableCollection<Tag, M>, + TraversableCollection<mtl::tag::nz, TraversableCollection<Tag, M>::result_type> + {}; +#else + /// Concept NonZeroTraversableSubMatrix: provides traversion of non-zero in rows or columns of matrices + /** + All structural non-zero elements of a row or a column, according to the Tag, are traversed. + The cursors begin and end are provided. + \par Refinement of: + - Matrix < M > + - TraversableCollection<Tag, M>, + - TraversableCollection<mtl::tag::nz, TraversableCollection<Tag, M>::result_type> + */ + template <typename Tag, typename M> + struct NonZeroTraversableSubMatrix + : public Matrix<M>, + public TraversableCollection<Tag, M>, + public TraversableCollection<mtl::tag::nz, TraversableCollection<Tag, M>::result_type> + {}; +#endif + + +#ifdef __GXX_CONCEPTS__ + concept IteratableSubMatrix<typename Tag, typename ITag, typename M> + : Matrix<M>, + TraversableCollection<Tag, M>, + TraversableCollection<ITag, TraversableCollection<Tag, M>::result_type> + {}; +#else + /// Concept IteratableSubMatrix: provides iteration over elements within rows or columns of matrices + /** + This concepts actually combines four sub-concepts. The iteration can be either performed over + all elements or only over structural non-zero elements whereby the iterator can be a const-iterator + or a mutable iterator. These four combinations are specified by the tags mtl::tag::iter::all, + mtl::tag::iter::nz, mtl::tag::const_iter::all, and + mtl::tag::const_iter::nz for ITag. The template parameter Tag can be mtl::tag::major or mtl::tag::column. + The cursors begin and end are provided. + \par Refinement of: + - Matrix < M > + - TraversableCollection<Tag, M>, + - TraversableCollection<ITag, TraversableCollection<Tag, M>::result_type> + */ + template <typename Tag, typename ITag, typename M> + struct IteratableSubMatrix + : public Matrix<M>, + public TraversableCollection<Tag, M>, + public TraversableCollection<ITag, TraversableCollection<Tag, M>::result_type> + {}; +#endif + + + + + + +/*@}*/ // end of group Concepts + +} // namespace mtl + +#endif // MTL_MATRIX_CONCEPT_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/concept/static_functor.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/concept/static_functor.hpp new file mode 100644 index 0000000000000000000000000000000000000000..e1a549f690a31949f97daec42bc51c849a2b8346 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/concept/static_functor.hpp @@ -0,0 +1,76 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_STATIC_FUNCTOR_INCLUDE +#define MTL_STATIC_FUNCTOR_INCLUDE + +#include <complex> + +namespace mtl { + +#ifdef __GXX_CONCEPTS__ + +// Concept to specify static unary functors +auto concept StaticUnaryFunctor<typename T> +{ + typename argument_type = T::argument_type; + typename result_type = T::result_type; + + static result_type apply(argument_type); + result_type T::operator()(argument_type); +}; + +auto concept StaticBinaryFunctor<typename T> +{ + typename first_argument_type = T::first_argument_type; + typename second_argument_type = T::second_argument_type; + typename result_type = T::result_type; + + static result_type apply(first_argument_type, second_argument_type); + result_type T::operator()(first_argument_type, second_argument_type); +}; + +#else // now without concepts + +/// Concept/Type-trait for static unary functors +/** This name is overloaded: when MTL4 is compiled with a concept-compiler + StaticUnaryFunctor is a concept otherwise a type-trait. +**/ +template <typename T> +struct StaticUnaryFunctor +{ + /// Associated type for argument, by default set to class's internal typedef (specialize if not present) + typedef typename T::argument_type argument_type; + /// Associated type for result, by default set to class's internal typedef (specialize if not present) + typedef typename T::result_type result_type; +}; + +/// Concept/Type-trait for static binary functors +/** This name is overloaded: when MTL4 is compiled with a concept-compiler + StaticBinaryFunctor is a concept otherwise a type-trait. +**/ +template <typename T> +struct StaticBinaryFunctor +{ + /// Associated type for 1st argument, by default set to class's internal typedef (specialize if not present) + typedef typename T::first_argument_type first_argument_type; + /// Associated type for 2nd argument, by default set to class's internal typedef (specialize if not present) + typedef typename T::second_argument_type second_argument_type; + /// Associated type for result, by default set to class's internal typedef (specialize if not present) + typedef typename T::result_type result_type; +}; + +#endif // __GXX_CONCEPTS__ + +} // namespace mtl + +#endif // MTL_STATIC_FUNCTOR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/concept/std_concept.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/concept/std_concept.hpp new file mode 100644 index 0000000000000000000000000000000000000000..0a8f091fb31f216e9161ec29c46a937b3f35c179 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/concept/std_concept.hpp @@ -0,0 +1,286 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_STD_CONCEPT_INCLUDE +#define MTL_STD_CONCEPT_INCLUDE + +#ifdef __GXX_CONCEPTS__ +# include <concepts> +#else +// Use Joel de Guzman's return type deduction +# include <boost/numeric/ublas/detail/returntype_deduction.hpp> +# include <boost/mpl/at.hpp> +# include <boost/numeric/linear_algebra/pseudo_concept.hpp> +#endif + +// #include <boost/numeric/mtl/utility/is_what.hpp> -> leads to cyclic inclusions +// #include <boost/numeric/mtl/operation/mult_result.hpp> + +namespace mtl { + +/** + * \defgroup Concepts Concepts + */ +/*@{*/ + +#ifdef __GXX_CONCEPTS__ + + // Stay with the old names (for the moment) + + auto concept Addable<typename T, typename U = T> : std::HasPlus<T, U> {} + auto concept Subtractable<typename T, typename U = T> : std::HasMinus<T, U> {} + auto concept Multiplicable<typename T, typename U = T> : std::HasMultiply<T, U> {} + auto concept Divisible<typename T, typename U = T> : std::HasDivide<T, U> {} + +#if 0 + using std::Addable; + using std::Subtractable; + using std::Multiplicable; + + auto concept Divisible<typename T, typename U = T> + { + typename result_type; + result_type operator/(const T& t, const U& u); + }; +#endif + +#else // without concepts + + // Use Joel de Guzman's return type deduction + // Adapted from uBLAS + // Differences: + // - Separate types for all operations + // - result_type like in concept + + /// Concept Addable: Binary operation + /** In concept-free compilations also used for return type deduction */ + template<class X, class Y> + class Addable + { + typedef boost::numeric::ublas::type_deduction_detail::base_result_of<X, Y> base_type; + static typename base_type::x_type x; + static typename base_type::y_type y; + static const std::size_t size = sizeof ( + boost::numeric::ublas::type_deduction_detail::test< + typename base_type::x_type + , typename base_type::y_type + >(x + y) + ); + + static const std::size_t index = (size / sizeof (char)) - 1; + typedef typename boost::mpl::at_c< + typename base_type::types, index>::type id; + public: + /// Result of addition + typedef typename id::type result_type; + }; + + + /// Concept Subtractable: Binary operation + /** In concept-free compilations also used for return type deduction */ + template<class X, class Y> + class Subtractable + { + typedef boost::numeric::ublas::type_deduction_detail::base_result_of<X, Y> base_type; + static typename base_type::x_type x; + static typename base_type::y_type y; + static const std::size_t size = sizeof ( + boost::numeric::ublas::type_deduction_detail::test< + typename base_type::x_type + , typename base_type::y_type + >(x - y) + ); + + static const std::size_t index = (size / sizeof (char)) - 1; + typedef typename boost::mpl::at_c< + typename base_type::types, index>::type id; + public: + /// Result of subtraction + typedef typename id::type result_type; + }; + +#if 0 // doesn't work + template<class X, class Y> + class Multiplicable_aux<X, Y, true> + { + typedef typename mtl::traits::mult_result<X, Y>::type type; + }; + + /// Concept Multiplicable: Binary operation + /** In concept-free compilations also used for return type deduction */ + template<class X, class Y, bool B> + class Multiplicable_aux + { + typedef boost::numeric::ublas::type_deduction_detail::base_result_of<X, Y> base_type; + static typename base_type::x_type x; + static typename base_type::y_type y; + static const std::size_t size = sizeof ( + boost::numeric::ublas::type_deduction_detail::test< + typename base_type::x_type + , typename base_type::y_type + >(x * y) + ); + + static const std::size_t index = (size / sizeof (char)) - 1; + typedef typename boost::mpl::at_c< + typename base_type::types, index>::type id; + public: + /// Result of multiplication + typedef typename id::type result_type; + }; + + /// Concept Multiplicable: Binary operation + /** In concept-free compilations also used for return type deduction */ + template<class X, class Y> + class Multiplicable + : Multiplicable_aux<X, Y, mtl::traits::is_scalar<X>::value && mtl::traits::is_scalar<Y>::value> + {}; +#endif + + /// Concept Multiplicable: Binary operation + /** In concept-free compilations also used for return type deduction */ + template<class X, class Y> + class Multiplicable + { + typedef boost::numeric::ublas::type_deduction_detail::base_result_of<X, Y> base_type; + static typename base_type::x_type x; + static typename base_type::y_type y; + static const std::size_t size = sizeof ( + boost::numeric::ublas::type_deduction_detail::test< + typename base_type::x_type + , typename base_type::y_type + >(x * y) + ); + + static const std::size_t index = (size / sizeof (char)) - 1; + typedef typename boost::mpl::at_c< + typename base_type::types, index>::type id; + public: + /// Result of multiplication + typedef typename id::type result_type; + }; + + /// Concept Divisible: Binary operation + /** In concept-free compilations also used for return type deduction */ + template<class X, class Y> + class Divisible + { + typedef boost::numeric::ublas::type_deduction_detail::base_result_of<X, Y> base_type; + static typename base_type::x_type x; + static typename base_type::y_type y; + static const std::size_t size = sizeof ( + boost::numeric::ublas::type_deduction_detail::test< + typename base_type::x_type + , typename base_type::y_type + >(x * y) + ); + + static const std::size_t index = (size / sizeof (char)) - 1; + typedef typename boost::mpl::at_c< + typename base_type::types, index>::type id; + public: + /// Result of division + typedef typename id::type result_type; + }; + +#endif + + +#ifdef __GXX_CONCEPTS__ + concept UnaryStaticFunctor<typename F, typename T> + : std::Callable1<F, T> + { + typename result_type; + + static result_type F::apply(T); + }; +#else + /// Concept UnaryFunctor + /** With concept corresponds to std::Callable1 */ + template <typename T> + struct UnaryFunctor + { + /// Result type of operator() + typedef associated_type result_type; + + /// The unary function + result_type operator()(T); + }; + + + /// Concept UnaryStaticFunctor + /** + \par Refinement of: + - std::Callable1 < T > + */ + template <typename T> + struct UnaryStaticFunctor + : public UnaryFunctor<T> + { + /// Result type of apply + typedef associated_type result_type; + + /// The unary static function + static result_type apply(T); + + /// The application operator behaves like apply. Exists for compatibility with UnaryFunctor + result_type operator()(T); + }; +#endif + + +#ifdef __GXX_CONCEPTS__ + auto concept BinaryStaticFunctor<typename F, typename T, typename U> + : std::Callable2<F, T, U> + { + typename result_type; + + static result_type F::apply(T, U); + }; +#else + /// Concept BinaryFunctor + /** With concept corresponds to std::Callable2 */ + template <typename T, typename U> + struct BinaryFunctor + { + /// Result type of operator() + typedef associated_type result_type; + + /// The unary function + result_type operator()(T, U); + }; + + /// Concept BinaryStaticFunctor + /** + \par Refinement of: + - BinaryFunctor <T, U> + */ + template <typename T, typename U> + struct BinaryStaticFunctor + : public BinaryFunctor <T, U> + { + /// Result type of apply + typedef associated_type result_type; + + /// The unary static function + static result_type apply(T, U); + + /// The application operator behaves like apply. Exists for compatibility with BinaryFunctor + result_type operator()(T, U); + }; +#endif + +/*@}*/ // end of group Concepts + +} // namespace mtl + +#endif // MTL_STD_CONCEPT_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/concept/vector.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/concept/vector.hpp new file mode 100644 index 0000000000000000000000000000000000000000..a9c632096f5e0f2e72cf7da0cf3c2f672b0bc4af --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/concept/vector.hpp @@ -0,0 +1,142 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_VECTOR_CONCEPTS_INCLUDE +#define MTL_VECTOR_CONCEPTS_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> + +#ifdef __GXX_CONCEPTS__ +# include <concepts> +#else +# include <boost/numeric/linear_algebra/pseudo_concept.hpp> +#endif + +namespace mtl { + +/** @addtogroup Concepts + * @{ + */ + +#ifdef __GXX_CONCEPTS__ + concept Vector<typename T> + : AlgebraicCollection<T> + { + const_reference T::operator() (size_type index) const; + + const_reference T::operator[] (size_type index) const; + + size_type nnz(T); // maybe into AlgebraicCollection? + }; +#else + /// Concept Vector + /** + \par Refinement of: + - AlgebraicCollection < T > + \par Notation: + - X is a type that models Vector + - v is an object of type X + - r are objects of size_type + \par Valid expressions: + - Element access: \n v(r) \n Return Type: const_reference + \n Semantics: Element in row \p r and column \p c + - Element access: \n v[r] \n Equivalent to v(r) + \invariant + - Either num_cols(v), in case of a column vector, or num_rows(v), + in case of a row vector, must be 1! Otherwise it would be + a matrix. + \par Models: + - dense_vector + \note + -# If it would become (extremely) important to support 1D C arrays as Vector, + it might be necessary to drop the requirement + of element access by v(r). + */ + template <typename T> + struct Vector + : public AlgebraicCollection<T> + { + /// Element access + const_reference T::operator() (size_type index) const; + + /// Element access + const_reference T::operator[] (size_type index) const; + }; +#endif + + +#ifdef __GXX_CONCEPTS__ + concept MutableVector<typename T> + : Vector<T>, + MutableCollection<T> + { + reference T::operator() (size_type index); + + reference T::operator[] (size_type index); + }; +#else + /// Concept MutableVector + /** + \par Refinement of: + - Vector < T > + - MutableCollection < T > + \par Notation: + - X is a type that models Vector + - v is an object of type X + - r are objects of size_type + \par Valid expressions: + - Element access: \n v(r) \n Return Type: reference + \n Semantics: Element in row \p r for a column vector or in column \p c for a row vector + - Element access: \n v[r] \n Equivalent to v(r) + \par Models: + - dense_vector + \note + -# If it would become (extremely) important to support 1D C arrays as Vector, + it might be necessary to drop the requirement + of element access by v(r). + */ + template <typename T> + struct MutableVector + : public Vector<T>, + public MutableCollection<T> + {}; +#endif + + +#ifdef __GXX_CONCEPTS__ + concept ConstantSizeVector<typename T> + : Vector<T>, + ConstantSizeAlgebraicCollection<T> + {}; +#else + /// Concept ConstantSizeVector + /** + \par Refinement of: + - Vector < T > + - ConstantSizeAlgebraicCollection < T > + */ + template <typename T> + struct ConstantSizeVector + : public Vector<T>, + public ConstantSizeAlgebraicCollection<T> + {}; +#endif + + + +/*@}*/ // end of group Concepts + + +} // namespace mtl + +#endif // MTL_VECTOR_CONCEPTS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/config.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/config.hpp new file mode 100644 index 0000000000000000000000000000000000000000..336a8d79519bdc5b535117265a27cea8b55686e8 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/config.hpp @@ -0,0 +1,97 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_CONFIG_INCLUDE +#define MTL_CONFIG_INCLUDE + +namespace mtl { + + + namespace matrix { + + // parameters for dense operations + + +# ifdef MTL_MATRIX_DENSE_NON_RECURSIVE_PRODUCT_LIMIT + const std::size_t dense_non_recursive_product_limit= MTL_MATRIX_DENSE_NON_RECURSIVE_PRODUCT_LIMIT; +# else + /// Maximal matrix size of dense matrices that is multiplied without recursion + /** Can be reset with a macro definition or corresponding compiler flag, + e.g. {-D|/D}MTL_MATRIX_DENSE_NON_RECURSIVE_PRODUCT_LIMIT=4000 **/ + const std::size_t dense_non_recursive_product_limit= 10000; +# endif + + +# ifdef MTL_STRAIGHT_DMAT_DMAT_MULT_LIMIT + const std::size_t straight_dmat_dmat_mult_limit= MTL_STRAIGHT_DMAT_DMAT_MULT_LIMIT; +# else + /// Defines the maximal number of entries in each matrix for which the dense matrix product is computed in C++. + /** Above this limit the computation is performed with BLAS if available. + Can be reset with a macro definition or corresponding compiler flag, + e.g. {-D|/D}MTL_STRAIGHT_DMAT_DMAT_MULT_LIMIT=4000 **/ + const std::size_t straight_dmat_dmat_mult_limit= 1000; +# endif + +# ifdef MTL_FULLY_UNROLL_DMAT_DMAT_MULT_LIMIT + const std::size_t fully_unroll_dmat_dmat_mult_limit= MTL_FULLY_UNROLL_DMAT_DMAT_MULT_LIMIT; +# else + /// Defines the maximal number of entries in each matrix for which the dense matrix product is fully unrolled. + /** Above this limit the computation is performed with a tiled loop implementation. + Applies only to statically sized matrices. + Can be reset with a macro definition or corresponding compiler flag, + e.g. {-D|/D}MTL_FULLY_UNROLL_DMAT_DMAT_MULT_LIMIT=40 **/ + const std::size_t fully_unroll_dmat_dmat_mult_limit= 10; +# endif + + // parameters for sparse operations + +# ifdef MTL_MATRIX_COMPRESSED_LINEAR_SEARCH_LIMIT + const std::size_t compressed_linear_search_limit= MTL_MATRIX_COMPRESSED_LINEAR_SEARCH_LIMIT; +# else + /// Maximal number of entries that is searched linearly within a row/column of a CRS/CCS matrix + /** Above this std::lower_bound is used. + Can be reset with a macro definition or corresponding compiler flag, + e.g. {-D|/D}MTL_MATRIX_COMPRESSED_LINEAR_SEARCH_LIMIT=16 **/ + const std::size_t compressed_linear_search_limit= 10; +# endif + +# ifdef MTL_SORTED_BLOCK_INSERTION_LIMIT + const std::size_t sorted_block_insertion_limit= MTL_SORTED_BLOCK_INSERTION_LIMIT; +# else + /// Maximal number of columns in block that is inserted separately; above this the block is presorted (only row-major sparse matrices). + /** Can be reset with a macro definition or corresponding compiler flag, + e.g. {-D|/D}MTL_SORTED_BLOCK_INSERTION_LIMIT=8 + Default is 5. **/ + const std::size_t sorted_block_insertion_limit= 5; +# endif + +# ifdef MTL_CRS_CVEC_MULT_BLOCK_SIZE + const std::size_t crs_cvec_mult_block_size= MTL_CRS_CVEC_MULT_BLOCK_SIZE; +# else + /// Number of rows that are handled independently in each iteration of CRS times vector product + /** The independent treatment of multiple matrix rows enables concurrency + (although we do not explicit parallelize the matrix product here). + The default is treating 4 rows in each iteration. + This default can be changed with a macro definition or corresponding compiler flag, + e.g. {-D|/D}MTL_CRS_CVEC_MULT_BLOCK_SIZE=8 + At the same the macro MTL_CRS_CVEC_MULT_TUNING must be defined. **/ + const std::size_t crs_cvec_mult_block_size= 4; +# endif + + + } + + + +} // namespace mtl + +#endif // MTL_CONFIG_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/detail/base_cursor.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/detail/base_cursor.hpp new file mode 100644 index 0000000000000000000000000000000000000000..11cc95e9ff7ae7c999f19ce24fe75aa975e2324c --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/detail/base_cursor.hpp @@ -0,0 +1,105 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_BASE_CURSOR_INCLUDE +#define MTL_BASE_CURSOR_INCLUDE + +namespace mtl { namespace detail { + +// base class for different cursors, works with pointers and integers +template <class Key> class base_cursor +{ + public: + typedef Key key_type; + typedef base_cursor self; + + base_cursor () {} + base_cursor (key_type key) : key(key) {} + + key_type operator*() const + { + return key; + } + + key_type value() const + { + return key; + } + + self& operator++ () + { + ++key; return *this; + } + self operator++ (int) + { + self tmp = *this; + ++key; + return tmp; + } + self& operator-- () + { + --key; + return *this; + } + self operator-- (int) + { + self tmp = *this; + --key; + return tmp; + } + self& operator+=(int n) + { + key += n; + return *this; + } + + self operator+(int n) const + { + self tmp = *this; + tmp+= n; + return tmp; + } + + self& operator-=(int n) + { + key -= n; + return *this; + } + + int operator-(const self& cc) const + { + return this->key - cc.key; + } + + bool operator==(const self& cc) const + { + return key == cc.key; + } + + bool operator!=(const self& cc) const + { + return !(*this == cc); + } + + + + + key_type key; +}; // base_cursor + + + +}} // namespace mtl::detail + +#endif // MTL_BASE_CURSOR_INCLUDE + + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/detail/contiguous_memory_block.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/detail/contiguous_memory_block.hpp new file mode 100644 index 0000000000000000000000000000000000000000..816fe1b33aaa43ab965d83cd96c50e94bd16d06d --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/detail/contiguous_memory_block.hpp @@ -0,0 +1,493 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_CONTIGUOUS_MEMORY_BLOCK_INCLUDE +#define MTL_CONTIGUOUS_MEMORY_BLOCK_INCLUDE + +#include <cassert> +#include <algorithm> +#include <boost/static_assert.hpp> +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/matrix/dimension.hpp> +#include <boost/numeric/mtl/detail/index.hpp> +#include <boost/numeric/mtl/operation/clone.hpp> + + + +namespace mtl { namespace detail { +using std::size_t; + +// Macro MTL_ENABLE_ALIGNMENT is by default not set + +// Minimal size of memory allocation using alignment +#ifndef MTL_ALIGNMENT_LIMIT +# define MTL_ALIGNMENT_LIMIT 1024 +#endif + +// Alignment in memory +#ifndef MTL_ALIGNMENT +# define MTL_ALIGNMENT 128 +#endif + + +// Size helper for static size +template <unsigned Size> +struct size_helper +{ + typedef size_helper self; + + size_helper() {} + explicit size_helper(std::size_t size) + { + set_size(size); + } + +# ifndef MTL_IGNORE_STATIC_SIZE_VIOLATION + void set_size(std::size_t MTL_DEBUG_ARG(size)) + { MTL_DEBUG_THROW_IF(Size != size, change_static_size()); } +# else + void set_size(std::size_t) {} +# endif + + std::size_t used_memory() const { return Size; } + friend void swap(self&, self&) {} +}; + +// Manage size only if template parameter is 0, i.e. dynamic size +template <> +struct size_helper<0> +{ + typedef size_helper self; + + size_helper(std::size_t size= 0) : my_used_memory(size) {} + + void set_size(std::size_t size) + { + my_used_memory= size; + } + + std::size_t used_memory() const + { + return my_used_memory; + } + + friend void swap(self& x, self& y) + { + std::swap(x.my_used_memory, y.my_used_memory); + } + + protected: + std::size_t my_used_memory; +}; + + +// Encapsulate behavior of alignment + +# ifdef MTL_ENABLE_ALIGNMENT + + template <typename Value> + struct alignment_helper + { + typedef alignment_helper self; + + alignment_helper() : malloc_address(0) {} + + Value* alligned_alloc(std::size_t size) + { + if (size == 0) + return 0; + + bool align= size * sizeof(value_type) >= MTL_ALIGNMENT_LIMIT; + std::size_t bytes= size * sizeof(value_type); + + if (align) + bytes+= MTL_ALIGNMENT - 1; + + char* p= malloc_address= new char[bytes]; + if (align) + while ((long int)(p) % MTL_ALIGNMENT) p++; + // p+= MTL_ALIGNMENT - (long int)(p) % MTL_ALIGNMENT; + + return reinterpret_cast<value_type*>(p); + } + + void aligned_delete(bool is_own, Value*& data) + { + if (is_own && malloc_address) delete[] malloc_address; + data= 0; + } + + friend void swap(self& x, self& y) + { + using std::swap + swap(x.malloc_address, y.malloc_address); + } + + private: + char* malloc_address; + }; + +# else + + template <typename Value> + struct alignment_helper + { + typedef alignment_helper self; + + Value* alligned_alloc(std::size_t size) { return size > 0 ? new Value[size] : (Value*)(0); } + + void aligned_delete(bool is_own, Value*& data) + { + if (is_own && data != 0) // std::cout << "Delete " << data << '\n', + delete[] data, data= 0; + } + + friend void swap(self&, self&) {} + }; + +# endif + + +template <typename Value, bool OnStack, unsigned Size> +struct memory_crtp +// : public contiguous_memory_block<Value, OnStack, Size> +{ + typedef contiguous_memory_block<Value, OnStack, Size> base; + + static bool const on_stack= OnStack; + + typedef Value value_type; + typedef value_type* pointer_type; + typedef const value_type* const_pointer_type; + + // offset of key (pointer) w.r.t. data + // values must be stored consecutively + size_t offset(const Value* p) const + { + return p - static_cast<const base&>(*this).data; + } + + // returns pointer to data + pointer_type elements() + { + return static_cast<base&>(*this).data; + } + + // returns const pointer to data + const_pointer_type elements() const + { + return static_cast<const base&>(*this).data; + } + + // returns n-th value in consecutive memory + // (whatever this means in the corr. matrix format) + value_type& value_n(size_t offset) + { + return static_cast<base&>(*this).data[offset]; + } + + // returns n-th value in consecutive memory + // (whatever this means in the corr. matrix format) + const value_type& value_n(size_t offset) const + { + return static_cast<const base&>(*this).data[offset]; + } + +}; + +// OnStack == false -> data on heap +template <typename Value, bool OnStack, unsigned Size> +struct contiguous_memory_block + : public size_helper<Size>, + public alignment_helper<Value>, + public memory_crtp<Value, OnStack, Size> +{ + typedef Value value_type; + typedef contiguous_memory_block self; + typedef size_helper<Size> size_base; + typedef alignment_helper<Value> alignment_base; + typedef memory_crtp<Value, OnStack, Size> crtp_base; + + /// Category of memory, determines behaviour + enum c_t {own, //< My own memory: allocate and free it + external, //< Memory, complete memory block of other item, only reference + view //< View of other's memory (e.g. sub-matrix), different construction than external + }; + + private: + + void alloc(std::size_t size) + { + category= own; + this->set_size(size); + data= this->alligned_alloc(this->used_memory()); + } + + void delete_it() + { + this->aligned_delete(category == own, data); + } + + template <typename Other> + void copy_construction(const Other& other) + { + using std::copy; + category= own; + // std::cout << "Copied in copy constructor.\n"; + alloc(other.used_memory()); + // std::cout << "My address: " << data << ", other address: " << other.data << '\n'; + copy(other.data, other.data + other.used_memory(), data); + } + + void move_construction(self& other) + { + // std::cout << "Data moved in constructor.\n"; + category= own; data= 0; + swap(*this, other); + } + + // Copy the arguments of a view (shallowly) and leave original as it is + void copy_view(const self& other) + { + // std::cout << "View copied (shallowly).\n"; + assert(other.category == view); + category= view; + this->set_size(other.used_memory()); + data= other.data; + } + + template <typename Other> + void copy_assignment(const Other& other) + { + // std::cout << "Copied in assignment.\n"; + if (this->used_memory() == 0) + alloc(other.used_memory()); + MTL_DEBUG_THROW_IF(this->used_memory() != other.used_memory(), incompatible_size()); + std::copy(other.data, other.data + other.used_memory(), data); + } + + public: + contiguous_memory_block() : category(own), data(0) {} + + explicit contiguous_memory_block(Value *data, std::size_t size, bool is_view= false) + : size_base(size), category(is_view ? view : external), data(data) + {} + + explicit contiguous_memory_block(std::size_t size) : category(own) + { + // std::cout << "Constructor with size.\n"; + alloc(size); + // std::cout << "New block at " << data << '\n'; + } + + // Default copy constructor + contiguous_memory_block(const self& other) : size_base(other) + { + // std::cout << "Copy constructor (same type).\n"; + if (other.category == view) + copy_view(other); + else + copy_construction(other); + } + + // Force copy construction + contiguous_memory_block(const self& other, clone_ctor) + { + // std::cout << "(Forced) Copy constructor (same type).\n"; + copy_construction(other); + } + + // Other types must be copied always + template<typename Value2, bool OnStack2, unsigned Size2> + explicit contiguous_memory_block(const contiguous_memory_block<Value2, OnStack2, Size2>& other) + { + std::cout << "Copy constructor (different type).\n"; + copy_construction(other); + } + +#ifdef MTL_WITH_MOVE + self& operator=(self&& other) + { + move_assignment(other); + return *this; + } + + self& operator=(const self& other) + { + copy_assignment(other); + return *this; + } +#elif defined(MTL_MEMORY_BLOCK_MOVE_EMULATION) + // Operator takes parameter by value and consumes it + self& operator=(self other) + { + move_assignment(other); + return *this; + } +#else + self& operator=(self other) + { + copy_assignment(other); + return *this; + } +#endif + + // Same behavior as consuming assignment, to be used by derived classes +protected: + void move_assignment(self& other) + { + // std::cout << "Consuming assignment operator (if same type).\n"; + if (category == own && other.category == own) + swap(*this, other); + else + copy_assignment(other); + } + +public: + template<typename Value2, bool OnStack2, unsigned Size2> + self& operator=(const contiguous_memory_block<Value2, OnStack2, Size2>& other) + { + // std::cout << "Assignment from different array type -> Copy.\n"; + copy_assignment(other); + return *this; + } + + + void set_view() { category= view; } + + void realloc(std::size_t size) + { + if (Size == 0) { + + // If already have memory of the right size we can keep it + if (size == this->used_memory()) + return; + MTL_DEBUG_THROW_IF(category != own, + logic_error("Can't change the size of collections with external memory")); + delete_it(); + alloc(size); + } else { + MTL_DEBUG_THROW_IF(size != Size, logic_error("Can't change static size")); + } + } + + ~contiguous_memory_block() + { + //std::cout << "Delete block with address " << data << '\n'; + delete_it(); + } + + friend void swap(self& x, self& y) + { + using std::swap; + swap(x.category, y.category); + std::swap(x.data, y.data); + swap(static_cast<size_base&>(x), static_cast<size_base&>(y)); + swap(static_cast<alignment_base&>(x), static_cast<alignment_base&>(y)); + } + +protected: + enum c_t category; +public: + Value *data; +}; + +// OnStack == true +template <typename Value, unsigned Size> +struct contiguous_memory_block<Value, true, Size> + : public alignment_helper<Value>, + public memory_crtp<Value, true, Size> +{ + typedef Value value_type; + typedef contiguous_memory_block self; + //static bool const on_stack= true; + + Value data[Size]; + +# ifdef NDEBUG + contiguous_memory_block() {} // default constructor in release mode + explicit contiguous_memory_block(std::size_t) {} +# else + explicit contiguous_memory_block(std::size_t size= Size) + { + MTL_DEBUG_THROW_IF(Size != size, incompatible_size()); + } +# endif + + // Move-semantics ignored for arrays on stack + contiguous_memory_block(const self& other) + { + // std::cout << "Copied in copy constructor (same type).\n"; + std::copy(other.data, other.data+Size, data); + } + + + template<typename Value2, bool OnStack2, unsigned Size2> + explicit contiguous_memory_block(const contiguous_memory_block<Value2, OnStack2, Size2>& other) + { + // std::cout << "Copied in copy constructor (different type).\n"; + MTL_DEBUG_THROW_IF(Size != other.used_memory(), incompatible_size()); + std::copy(other.data, other.data + other.used_memory(), data); + } + + self& operator=(const self& other) + { + // std::cout << "Assignment from same type.\n"; + std::copy(other.data, other.data+Size, data); + return *this; + } + + // For consistency with non-static blocks, to be used by derived classes +protected: + void move_assignment(self& other) + { + std::copy(other.data, other.data+Size, data); + } + +public: + template<typename Value2, bool OnStack2, unsigned Size2> + self& operator=(const contiguous_memory_block<Value2, OnStack2, Size2>& other) + { + // std::cout << "Assignment from different type.\n"; + MTL_DEBUG_THROW_IF(Size != other.used_memory(), incompatible_size()); + std::copy(other.data, other.data + other.used_memory(), data); + return *this; + } + + + void realloc(std::size_t MTL_DEBUG_ARG(s)) + { + // Arrays on stack cannot be reallocated but if the size isn't changed we are fine + assert(s == Size); + } + + std::size_t used_memory() const + { + return Size; + } + + protected: + enum c_t {own}; + static const c_t category= own; +}; + + +}} // namespace mtl::detail + +namespace mtl { + template <typename Value, bool OnStack, unsigned Size> + struct is_clonable< detail::contiguous_memory_block<Value, OnStack, Size> > : boost::mpl::bool_<!OnStack> {}; +} + +#endif // MTL_CONTIGUOUS_MEMORY_BLOCK_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/detail/dilated_int.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/detail/dilated_int.hpp new file mode 100644 index 0000000000000000000000000000000000000000..dff44a1e5c4bb7b36b15d37ab9e34cd5ccea5ff8 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/detail/dilated_int.hpp @@ -0,0 +1,255 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. +// +// Written by Jiahu Deng and Peter Gottschling + +#ifndef MTL_DILATED_INT_INCLUDE +#define MTL_DILATED_INT_INCLUDE + +#include <boost/numeric/mtl/detail/masked_dilation_tables.hpp> +#include <iostream> + +namespace mtl { namespace dilated { + +template <typename T> +struct even_bits +{ + static T const value = T(-1) / T(3); +}; + +template <typename T> +struct odd_bits +{ + static T const value = ~even_bits<T>::value; +}; + +// And is mostly used with original mask +template <typename T, T BitMask, bool Normalized> +struct masking +{ + inline void operator() (T& x) const + { + x &= BitMask; + } +}; + +// Or is mostly used with complementary mask +template <typename T, T BitMask> +struct masking<T, BitMask, false> +{ + inline void operator() (T& x) const + { + static T const anti_mask = ~BitMask; + x |= anti_mask; + } +}; + +template <typename T, T BitMask> +struct last_bit; + +template <typename T, T BitMask, bool IsZero> +struct last_bit_helper { + static T const tmp = BitMask >> 1; + static T const value = BitMask & 1 ? 1 : last_bit_helper<T, tmp, tmp == 0>::value << 1; +}; + +template <typename T, T BitMask> +struct last_bit_helper<T, BitMask, true> { + static T const value = 0; +}; + +template <typename T, T BitMask> +struct last_bit +{ + static T const value = last_bit_helper<T, BitMask, BitMask == 0>::value; +}; + + +template <typename T, T BitMask, bool Normalized> +struct dilated_int +{ + typedef T value_type; + typedef dilated_int<T, BitMask, Normalized> self; + + typedef masking<T, BitMask, Normalized> clean_carry; + typedef masking<T, BitMask, !Normalized> init_carry; + + static T const bit_mask = BitMask, + anti_mask = ~BitMask, + dilated_zero = Normalized ? 0 : anti_mask, + dilated_one = dilated_zero + last_bit<T, bit_mask>::value; +protected: + // masked_dilation_tables<T, bit_mask> mask_tables; + // masked_dilation_tables<T, anti_mask> anti_tables; probably not needed + +// will be protected later +public: + T i; + + void dilate(T x) + { + static const T to_switch_on = Normalized ? 0 : anti_mask; + i = mask<bit_mask>(x) | to_switch_on; + } + +public: + + // Default constructor + dilated_int() + { + i = Normalized ? 0 : anti_mask; + } + + // Only works for odd and even bits and 4-byte-int at this point !!!!!!!!!!!!!!!!!!! + explicit dilated_int(T x) + { + dilate(x); + } + + // Only works for odd and even bits and 4-byte-int at this point !!!!!!!!!!!!!!!!!!! + T undilate() + { + return unmask<bit_mask>(i); + } + + T dilated_value() const + { + return i; + } + + self& operator= (self const& x) + { + i = x.i; + return *this; + } + + self& operator= (T x) + { + dilate(x); + return *this; + } + + self& operator++ () + { + static T const x = Normalized ? bit_mask : T(-1); + i -= x; + clean_carry()(i); + return *this; + } + + self operator++ (int) + { + self tmp(*this); + ++*this; + return tmp; + } + + self& operator+= (self const& x) + { + init_carry()(i); + i+= x.i; + clean_carry()(i); + return *this; + } + + self operator+ (self const& x) + { + self tmp(*this); + return tmp += x; + } + + self& operator-- () + { + i -= dilated_one; + clean_carry()(i); + return *this; + } + + self operator-- (int) + { + self tmp(*this); + --*this; + return tmp; + } + + self& operator-= (self const& x) + { + i -= x.i; + clean_carry()(i); + return *this; + } + + self operator- (self const& x) const + { + self tmp(*this); + return tmp -= x; + } + + // advance in both directions, special care is needed for negative values + self& advance(int inc) + { + value_type incv(inc >= 0 ? inc : -inc); + self incd(incv); + if (inc >= 0) + operator+=(incd); + else + operator-=(incd); + return *this; + } + + bool operator== (self const& x) const + { + return i == x.i; + } + + bool operator!= (self const& x) const + { + return i != x.i; + } + + bool operator<= (self const& x) const + { + return i <= x.i; + } + + bool operator< (self const& x) const + { + return i < x.i; + } + + bool operator>= (self const& x) const + { + return i >= x.i; + } + + bool operator> (self const& x) const + { + return i > x.i; + } + + +}; + +} // namespace mtl::dilated + +using dilated::dilated_int; + +} // namespace mtl + +template <typename T, T BitMask, bool Normalized> +inline std::ostream& operator<< (std::ostream& os, mtl::dilated::dilated_int<T, BitMask, Normalized> d) +{ + os.setf(std::ios_base::hex, std::ios_base::basefield); + return os << d.i; +} + +#endif // MTL_DILATED_INT_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/detail/dilation_table.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/detail/dilation_table.hpp new file mode 100644 index 0000000000000000000000000000000000000000..cffe40beae5b56a444e5722039c261ed9191f15d --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/detail/dilation_table.hpp @@ -0,0 +1,143 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. +// +// Written by Jiahu Deng and Peter Gottschling + +/* This is designed for 16-bit undilated integers and 32-bit dilated + * integers. If we want to scale that up, it's an easy change but you will + * need to make it. - Greg 00/05/12 + */ + +/* Rewrote by Jiahu Deng 06/08/2005 + modified the undilated-lookup table, use the algorithms from + Prof.Wise's paper, Converting to and from Dilated Integers. + Added supports for anti-dilated integers. +*/ + +#ifndef MTL_DILATION_TABLE_INCLUDE +#define MTL_DILATION_TABLE_INCLUDE + +namespace mtl { namespace dilated { + + +static const unsigned short int dilate_lut[256] = { + 0x0000, 0x0001, 0x0004, 0x0005, 0x0010, 0x0011, 0x0014, 0x0015, + 0x0040, 0x0041, 0x0044, 0x0045, 0x0050, 0x0051, 0x0054, 0x0055, + 0x0100, 0x0101, 0x0104, 0x0105, 0x0110, 0x0111, 0x0114, 0x0115, + 0x0140, 0x0141, 0x0144, 0x0145, 0x0150, 0x0151, 0x0154, 0x0155, + 0x0400, 0x0401, 0x0404, 0x0405, 0x0410, 0x0411, 0x0414, 0x0415, + 0x0440, 0x0441, 0x0444, 0x0445, 0x0450, 0x0451, 0x0454, 0x0455, + 0x0500, 0x0501, 0x0504, 0x0505, 0x0510, 0x0511, 0x0514, 0x0515, + 0x0540, 0x0541, 0x0544, 0x0545, 0x0550, 0x0551, 0x0554, 0x0555, + 0x1000, 0x1001, 0x1004, 0x1005, 0x1010, 0x1011, 0x1014, 0x1015, + 0x1040, 0x1041, 0x1044, 0x1045, 0x1050, 0x1051, 0x1054, 0x1055, + 0x1100, 0x1101, 0x1104, 0x1105, 0x1110, 0x1111, 0x1114, 0x1115, + 0x1140, 0x1141, 0x1144, 0x1145, 0x1150, 0x1151, 0x1154, 0x1155, + 0x1400, 0x1401, 0x1404, 0x1405, 0x1410, 0x1411, 0x1414, 0x1415, + 0x1440, 0x1441, 0x1444, 0x1445, 0x1450, 0x1451, 0x1454, 0x1455, + 0x1500, 0x1501, 0x1504, 0x1505, 0x1510, 0x1511, 0x1514, 0x1515, + 0x1540, 0x1541, 0x1544, 0x1545, 0x1550, 0x1551, 0x1554, 0x1555, + 0x4000, 0x4001, 0x4004, 0x4005, 0x4010, 0x4011, 0x4014, 0x4015, + 0x4040, 0x4041, 0x4044, 0x4045, 0x4050, 0x4051, 0x4054, 0x4055, + 0x4100, 0x4101, 0x4104, 0x4105, 0x4110, 0x4111, 0x4114, 0x4115, + 0x4140, 0x4141, 0x4144, 0x4145, 0x4150, 0x4151, 0x4154, 0x4155, + 0x4400, 0x4401, 0x4404, 0x4405, 0x4410, 0x4411, 0x4414, 0x4415, + 0x4440, 0x4441, 0x4444, 0x4445, 0x4450, 0x4451, 0x4454, 0x4455, + 0x4500, 0x4501, 0x4504, 0x4505, 0x4510, 0x4511, 0x4514, 0x4515, + 0x4540, 0x4541, 0x4544, 0x4545, 0x4550, 0x4551, 0x4554, 0x4555, + 0x5000, 0x5001, 0x5004, 0x5005, 0x5010, 0x5011, 0x5014, 0x5015, + 0x5040, 0x5041, 0x5044, 0x5045, 0x5050, 0x5051, 0x5054, 0x5055, + 0x5100, 0x5101, 0x5104, 0x5105, 0x5110, 0x5111, 0x5114, 0x5115, + 0x5140, 0x5141, 0x5144, 0x5145, 0x5150, 0x5151, 0x5154, 0x5155, + 0x5400, 0x5401, 0x5404, 0x5405, 0x5410, 0x5411, 0x5414, 0x5415, + 0x5440, 0x5441, 0x5444, 0x5445, 0x5450, 0x5451, 0x5454, 0x5455, + 0x5500, 0x5501, 0x5504, 0x5505, 0x5510, 0x5511, 0x5514, 0x5515, + 0x5540, 0x5541, 0x5544, 0x5545, 0x5550, 0x5551, 0x5554, 0x5555, +}; + + +static const unsigned short int anti_dilate_lut[256] = { + 0xaaaa,0xaaab,0xaaae,0xaaaf,0xaaba,0xaabb,0xaabe,0xaabf, + 0xaaea,0xaaeb,0xaaee,0xaaef,0xaafa,0xaafb,0xaafe,0xaaff, + 0xabaa,0xabab,0xabae,0xabaf,0xabba,0xabbb,0xabbe,0xabbf, + 0xabea,0xabeb,0xabee,0xabef,0xabfa,0xabfb,0xabfe,0xabff, + 0xaeaa,0xaeab,0xaeae,0xaeaf,0xaeba,0xaebb,0xaebe,0xaebf, + 0xaeea,0xaeeb,0xaeee,0xaeef,0xaefa,0xaefb,0xaefe,0xaeff, + 0xafaa,0xafab,0xafae,0xafaf,0xafba,0xafbb,0xafbe,0xafbf, + 0xafea,0xafeb,0xafee,0xafef,0xaffa,0xaffb,0xaffe,0xafff, + 0xbaaa,0xbaab,0xbaae,0xbaaf,0xbaba,0xbabb,0xbabe,0xbabf, + 0xbaea,0xbaeb,0xbaee,0xbaef,0xbafa,0xbafb,0xbafe,0xbaff, + 0xbbaa,0xbbab,0xbbae,0xbbaf,0xbbba,0xbbbb,0xbbbe,0xbbbf, + 0xbbea,0xbbeb,0xbbee,0xbbef,0xbbfa,0xbbfb,0xbbfe,0xbbff, + 0xbeaa,0xbeab,0xbeae,0xbeaf,0xbeba,0xbebb,0xbebe,0xbebf, + 0xbeea,0xbeeb,0xbeee,0xbeef,0xbefa,0xbefb,0xbefe,0xbeff, + 0xbfaa,0xbfab,0xbfae,0xbfaf,0xbfba,0xbfbb,0xbfbe,0xbfbf, + 0xbfea,0xbfeb,0xbfee,0xbfef,0xbffa,0xbffb,0xbffe,0xbfff, + 0xeaaa,0xeaab,0xeaae,0xeaaf,0xeaba,0xeabb,0xeabe,0xeabf, + 0xeaea,0xeaeb,0xeaee,0xeaef,0xeafa,0xeafb,0xeafe,0xeaff, + 0xebaa,0xebab,0xebae,0xebaf,0xebba,0xebbb,0xebbe,0xebbf, + 0xebea,0xebeb,0xebee,0xebef,0xebfa,0xebfb,0xebfe,0xebff, + 0xeeaa,0xeeab,0xeeae,0xeeaf,0xeeba,0xeebb,0xeebe,0xeebf, + 0xeeea,0xeeeb,0xeeee,0xeeef,0xeefa,0xeefb,0xeefe,0xeeff, + 0xefaa,0xefab,0xefae,0xefaf,0xefba,0xefbb,0xefbe,0xefbf, + 0xefea,0xefeb,0xefee,0xefef,0xeffa,0xeffb,0xeffe,0xefff, + 0xfaaa,0xfaab,0xfaae,0xfaaf,0xfaba,0xfabb,0xfabe,0xfabf, + 0xfaea,0xfaeb,0xfaee,0xfaef,0xfafa,0xfafb,0xfafe,0xfaff, + 0xfbaa,0xfbab,0xfbae,0xfbaf,0xfbba,0xfbbb,0xfbbe,0xfbbf, + 0xfbea,0xfbeb,0xfbee,0xfbef,0xfbfa,0xfbfb,0xfbfe,0xfbff, + 0xfeaa,0xfeab,0xfeae,0xfeaf,0xfeba,0xfebb,0xfebe,0xfebf, + 0xfeea,0xfeeb,0xfeee,0xfeef,0xfefa,0xfefb,0xfefe,0xfeff, + 0xffaa,0xffab,0xffae,0xffaf,0xffba,0xffbb,0xffbe,0xffbf, + 0xffea,0xffeb,0xffee,0xffef,0xfffa,0xfffb,0xfffe,0xffff, + +}; + +static const unsigned short int undilate_lut[256] = { + 0x00, 0x01, 0x10, 0x11, 0x02, 0x03, 0x12, 0x13, + 0x20, 0x21, 0x30, 0x31, 0x22, 0x23, 0x32, 0x33, + 0x04, 0x05, 0x14, 0x15, 0x06, 0x07, 0x16, 0x17, + 0x24, 0x25, 0x34, 0x35, 0x26, 0x27, 0x36, 0x37, + 0x40, 0x41, 0x50, 0x51, 0x42, 0x43, 0x52, 0x53, + 0x60, 0x61, 0x70, 0x71, 0x62, 0x63, 0x72, 0x73, + 0x44, 0x45, 0x54, 0x55, 0x46, 0x47, 0x56, 0x57, + 0x64, 0x65, 0x74, 0x75, 0x66, 0x67, 0x76, 0x77, + 0x08, 0x09, 0x18, 0x19, 0x0a, 0x0b, 0x1a, 0x1b, + 0x28, 0x29, 0x38, 0x39, 0x2a, 0x2b, 0x3a, 0x3b, + 0x0c, 0x0d, 0x1c, 0x1d, 0x0e, 0x0f, 0x1e, 0x1f, + 0x2c, 0x2d, 0x3c, 0x3d, 0x2e, 0x2f, 0x3e, 0x3f, + 0x48, 0x49, 0x58, 0x59, 0x4a, 0x4b, 0x5a, 0x5b, + 0x68, 0x69, 0x78, 0x79, 0x6a, 0x6b, 0x7a, 0x7b, + 0x4c, 0x4d, 0x5c, 0x5d, 0x4e, 0x4f, 0x5e, 0x5f, + 0x6c, 0x6d, 0x7c, 0x7d, 0x6e, 0x6f, 0x7e, 0x7f, + 0x80, 0x81, 0x90, 0x91, 0x82, 0x83, 0x92, 0x93, + 0xa0, 0xa1, 0xb0, 0xb1, 0xa2, 0xa3, 0xb2, 0xb3, + 0x84, 0x85, 0x94, 0x95, 0x86, 0x87, 0x96, 0x97, + 0xa4, 0xa5, 0xb4, 0xb5, 0xa6, 0xa7, 0xb6, 0xb7, + 0xc0, 0xc1, 0xd0, 0xd1, 0xc2, 0xc3, 0xd2, 0xd3, + 0xe0, 0xe1, 0xf0, 0xf1, 0xe2, 0xe3, 0xf2, 0xf3, + 0xc4, 0xc5, 0xd4, 0xd5, 0xc6, 0xc7, 0xd6, 0xd7, + 0xe4, 0xe5, 0xf4, 0xf5, 0xe6, 0xe7, 0xf6, 0xf7, + 0x88, 0x89, 0x98, 0x99, 0x8a, 0x8b, 0x9a, 0x9b, + 0xa8, 0xa9, 0xb8, 0xb9, 0xaa, 0xab, 0xba, 0xbb, + 0x8c, 0x8d, 0x9c, 0x9d, 0x8e, 0x8f, 0x9e, 0x9f, + 0xac, 0xad, 0xbc, 0xbd, 0xae, 0xaf, 0xbe, 0xbf, + 0xc8, 0xc9, 0xd8, 0xd9, 0xca, 0xcb, 0xda, 0xdb, + 0xe8, 0xe9, 0xf8, 0xf9, 0xea, 0xeb, 0xfa, 0xfb, + 0xcc, 0xcd, 0xdc, 0xdd, 0xce, 0xcf, 0xde, 0xdf, + 0xec, 0xed, 0xfc, 0xfd, 0xee, 0xef, 0xfe, 0xff, +}; + + + +}} // namespace mtl::dilated + +#endif // MTL_DILATION_TABLE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/detail/index.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/detail/index.hpp new file mode 100644 index 0000000000000000000000000000000000000000..62de2d71b567606a1a919f7d2f8bac7431f1fd6a --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/detail/index.hpp @@ -0,0 +1,72 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_INDEX_INCLUDE +#define MTL_INDEX_INCLUDE + +// The whole idea of changing indices is insane! +// Thus, the file shouldn't exist at all. + +#include <boost/mpl/if.hpp> + +namespace mtl { namespace index { + +// Index like in C (identical with internal representation) +struct c_index {}; + +// Index like Fortran +struct f_index {}; + + +#if 0 +// Which index has type T +template <class T> struct which_index +{ + typedef typename boost::mpl::if_c< + traits::is_mtl_type<T>::value + , typename T::index_type // mtl data shall know their type + , c_index // others are by default c + >::type type; +}; +#endif + + +template <class T> struct which_index +{ + typedef typename T::index_type type; +}; + +// Change from internal representation to requested index type +template <class T> inline T change_to(c_index, T i) +{ + return i; +} + +template <class T> inline T change_to(f_index, T i) +{ + return i + 1; +} + +// Change from requested index type to internal representation +template <class T> inline T change_from(c_index, T i) +{ + return i; +} + +template <class T> inline T change_from(f_index, T i) +{ + return i - 1; +} + +}} // namespace mtl::index + +#endif // MTL_INDEX_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/detail/masked_dilation_tables.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/detail/masked_dilation_tables.hpp new file mode 100644 index 0000000000000000000000000000000000000000..ef693c6333e99dc5cd5e71a10008a35ff1bb476e --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/detail/masked_dilation_tables.hpp @@ -0,0 +1,290 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MASKED_DILATION_TABLES_INCLUDE +#define MTL_MASKED_DILATION_TABLES_INCLUDE + +#include <iostream> +#include <iomanip> +#include <cassert> + +namespace mtl { namespace dilated { + +template <class T, T Mask> +struct masked_dilation_tables +{ + typedef masked_dilation_tables self; + typedef T value_type; + const static T mask= Mask; + + static const T n_bytes= sizeof(T); // number of bytes of the unmasked value of this type + typedef T lookup_type[n_bytes][256]; + typedef T mp_type[n_bytes]; + typedef T it_type[n_bytes]; // why int ??? switch to T + + protected: + static lookup_type* my_mask_lut, *my_unmask_lut; + static mp_type* my_mask_piece; + static it_type* my_mask_size, *my_mask_shift_table, *my_unmask_shift_table; + static int n_valid_table, instances; + public: + + masked_dilation_tables() + { + if (instances++ == 0) + compute_tables(); + } + + ~masked_dilation_tables() + { + if (--instances == 0) { + delete[] my_mask_lut; + delete[] my_unmask_lut; + delete[] my_mask_piece; + delete[] my_mask_size; + delete[] my_mask_shift_table; + delete[] my_unmask_shift_table; + } + } + + lookup_type& mask_lut() { return *my_mask_lut; } + lookup_type& unmask_lut() { return *my_unmask_lut; } + mp_type& mask_piece() { return *my_mask_piece; } + it_type& mask_size() { return *my_mask_size; } + it_type& mask_shift_table() { return *my_mask_shift_table; } + it_type& unmask_shift_table() { return *my_unmask_shift_table; } + +private: + + // get mask of the style 0xfff... + static T get_f_mask(int n_bits) { return (1 << n_bits) - 1; } + + T inc(T i, T mask) { return ((i - mask) & mask); } + + void compute_tables() + { + // std::cout << "computing tables! " << std::endl; + init(); + + // compute the mask table + for (int j = 0; j < n_valid_table; ++j) { + T f_mask = get_f_mask(mask_size()[j]), i, ii; + for (i = 0, ii = 0; i < 256; ++i, ii = inc(ii, mask_piece()[j])) + mask_lut()[j][i] = (ii & f_mask) << mask_shift_table()[j]; // need to shift + } + + // compute the unmask table + T f_mask = get_f_mask(8); + for (T j = 0; j < sizeof(T); ++j) { + T t_mask = (Mask >> (8*j)) & f_mask, i, ii; + for(i = 0, ii = 0; ii < t_mask; ii = inc(ii, t_mask), ++i) + unmask_lut()[j][ii] = i << unmask_shift_table()[j]; + // set the value for the last one + unmask_lut()[j][t_mask] = i << unmask_shift_table()[j]; + } + } + + void allocate() + { + my_mask_lut= new lookup_type[1]; + my_unmask_lut= new lookup_type[1]; + my_mask_piece= new mp_type[1]; + my_mask_size= new it_type[1]; + my_mask_shift_table= new it_type[1]; + my_unmask_shift_table= new it_type[1]; + } + + + // initialize needed parameters + void init() + { + allocate(); + assert(count_n_ones(Mask) > 0); + n_valid_table= (count_n_ones(Mask) + 7) / 8; // calculate the number of valid table + set_mask(); + } + + // return the number of 1's in the mask + int count_n_ones(T t) + { + int n_ones = 0; + for (; t; t>>= 1) + if(t & 1) ++n_ones; + return n_ones; + } + + // return the number of valid bits in the mask + int count_bits(T t) + { + int bits = 0; + for (; t; t>>= 1) + ++bits; + return bits; + } + + + // set mask pieces + void set_mask() + { + // set the unmask shift table + unmask_shift_table()[0] = 0; + T t_mask = Mask, tmp, count; + for (T i = 1; i < n_bytes; ++i) { + tmp = t_mask & get_f_mask(8); + count = count_n_ones(tmp); + unmask_shift_table()[i] = count + unmask_shift_table()[i - 1]; + t_mask >>= 8; + } + + mask_shift_table()[0] = 0; // don't need shift for the first table + // if there is only 8 or less 1's in the mask, + // only one table is needed + if (n_valid_table == 1) { + mask_piece()[0] = Mask; + mask_size()[0] = count_bits(Mask); + return; + } + + t_mask = Mask; + for (int i = 0; i < n_valid_table - 1; ++i) { + T n_bits = 0, tmp = t_mask; + for (T n_ones= 0; n_ones < 8; ++n_bits) { + if ((t_mask & 0x01) == 1) ++n_ones; + t_mask = t_mask >>1; + } + // set the ith piece of mask, which must contains 8 1's + mask_piece()[i] = get_f_mask(n_bits) & tmp; + + // set the mask size table + mask_size()[i] = n_bits; + + // set shift table + mask_shift_table()[i + 1] = n_bits + mask_shift_table()[i]; + } + + // set the last piece of mask, which may contain less than 8 1's + // set the number of bits of the last mask + mask_piece()[n_valid_table - 1 ] = t_mask; + mask_size()[n_valid_table - 1] = count_bits(t_mask); + } + +public: + + // convert to masked integer + T to_masked(T x) + { + T result = 0; + for (int i = 0; i < n_valid_table; ++i) + result += mask_lut()[i][0xff & (x >> (8*i)) ]; + return result; + } + + + // convert to unmasked integer + T to_unmasked(T x) + { + T result = 0; + x &= Mask; + for (T i = 0; i < n_bytes; ++i) { + result += unmask_lut()[i][0xff & (x >> (8*i)) ]; + } + return result; + } +}; + +template <class T, T Mask> +typename masked_dilation_tables<T, Mask>::lookup_type* masked_dilation_tables<T, Mask>::my_mask_lut= 0; + +template <class T, T Mask> +typename masked_dilation_tables<T, Mask>::lookup_type* masked_dilation_tables<T, Mask>::my_unmask_lut= 0; + +template <class T, T Mask> +typename masked_dilation_tables<T, Mask>::mp_type* masked_dilation_tables<T, Mask>::my_mask_piece= 0; + +template <class T, T Mask> +typename masked_dilation_tables<T, Mask>::it_type* masked_dilation_tables<T, Mask>::my_mask_size= 0; + +template <class T, T Mask> +typename masked_dilation_tables<T, Mask>::it_type* masked_dilation_tables<T, Mask>::my_mask_shift_table= 0; + +template <class T, T Mask> +typename masked_dilation_tables<T, Mask>::it_type* masked_dilation_tables<T, Mask>::my_unmask_shift_table= 0; + +template <class T, T Mask> +int masked_dilation_tables<T, Mask>::n_valid_table= 0; + +template <class T, T Mask> +int masked_dilation_tables<T, Mask>::instances= 0; + + +// Masking: syntax e.g. mask<0x55555555>(7); +// Mask must be in front of T -> need casting :-( +template <long unsigned Mask, typename T> +inline T mask(T const& value) +{ + static masked_dilation_tables<T, T(Mask)> tables; + return tables.to_masked(value); +} + + +// Masking: syntax e.g. mask(7, table_object); +template <typename T, T Mask> +inline T mask(T const& value, masked_dilation_tables<T, Mask> tables) +{ + return tables.to_masked(value); +} + + +// Unmasking: syntax e.g. unmask<0x55555555>(7); +// Mask must be in front of T -> need casting :-( +template <long unsigned Mask, typename T> +inline T unmask(T const& value) +{ + static masked_dilation_tables<T, T(Mask)> tables; + return tables.to_unmasked(value); +} + + +// Unmasking: syntax e.g. unmask(7, table_object); +template <typename T, T Mask> +inline T unmask(T const& value, masked_dilation_tables<T, Mask> tables) +{ + return tables.to_unmasked(value); +} + + +// Conversion from Mask1 to Mask2 +// syntax e.g. from Morton to Doppler convert<0x55555555, 0x5555ff00>(7); +// Mask must be in front of T -> need casting :-( +template <long unsigned Mask1, long unsigned Mask2, typename T> +inline T convert(T const& value) +{ + return mask<Mask2>(unmask<Mask1>(value)); +} + +// Conversion from Mask1 to Mask2 +template <long unsigned Mask1, long unsigned Mask2, typename T> +inline T convert(T const& value, masked_dilation_tables<T, Mask1> const& tables1, + masked_dilation_tables<T, Mask2> const& tables2) +{ + return tables2.to_masked(tables1.to_unmasked(value)); +} + + + +} // namespace mtl::dilated + + //using dilated::dilated_int; + +} // namespace mtl + +#endif // MTL_MASKED_DILATION_TABLES_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/detail/range_generator.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/detail/range_generator.hpp new file mode 100644 index 0000000000000000000000000000000000000000..0c789ba774b3ace872610eec917f5bf3160dd3a9 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/detail/range_generator.hpp @@ -0,0 +1,307 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_DETAIL_RANGE_GENERATOR_INCLUDE +#define MTL_DETAIL_RANGE_GENERATOR_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/glas_tag.hpp> +#include <boost/numeric/mtl/utility/complexity.hpp> +#include <boost/numeric/mtl/detail/base_cursor.hpp> +#include <boost/mpl/less.hpp> + +namespace mtl { namespace traits { namespace detail { + + /// Range generator that traverses all elements of some densely stored collection + /** - Or contiguous parts of such collection + - Works for matrices and vectors when derived from contiguous_memory_block + **/ + template <typename Collection, typename Cursor, typename Complexity> + struct dense_element_range_generator + { + typedef Complexity complexity; + typedef Cursor type; + static int const level = 1; + + type begin(Collection const& collection) + { + return collection.elements(); + } + type end(Collection const& collection) + { + return collection.elements() + collection.used_memory(); + } + }; + + /// Range generator that traverses all elements of some collection stored in strides + template <typename Collection, typename Ref, typename Traversor> + struct strided_element_range_generator + { + typedef complexity_classes::linear complexity; + typedef Traversor type; + static int const level = 1; + + type begin(Ref& c) + { + return type(c.address_data(), c.stride()); + } + type end(Ref& c) + { + using mtl::size; + return type(c.address_data() + size(c) + c.stride(), c.stride()); + } + }; + + + // Like above over all elements but in terms of offsets + // Also with reference to collection in cursor + template <typename Matrix, typename Cursor, typename Complexity> + struct all_offsets_range_generator + { + typedef Complexity complexity; + typedef Cursor type; + static int const level = 1; + + type begin(Matrix const& matrix) const + { + return type(matrix, 0); + } + type end(Matrix const& matrix) const + { + return type(matrix, matrix.nnz()); + } + }; + + + // Cursor to some submatrix (e.g. row, column, block matrix, block row) + // This cursor is intended to be used by range generators to iterate + // over subsets of the submatrix this cursor refers to. + // For instance if this cursor refers to a row then a range + // can iterate over the elements in this row. + // If this cursor refers to a block then a range can iterate over the rows in this block. + // The level of a generated cursor must be of course at least one level less + // The tag serves to dispatching between row and column cursors + template <typename Matrix, typename Tag, int Level> + struct sub_matrix_cursor + : mtl::detail::base_cursor<int> + { + typedef sub_matrix_cursor self; + typedef mtl::detail::base_cursor<int> base; + typedef Matrix ref_type; + static int const level = Level; + + sub_matrix_cursor(int i, Matrix const& c) + : base(i), ref(c) + {} + + self operator+(int offset) const + { + return self(key + offset, ref); + } + + // otherwise base_cursor returns an int and ranged for doesn't work + // for getting the key of base_cursor use this->value() + self operator*() const { return *this; } + + Matrix const& ref; + }; + + // Key for canonically referring to its elements with row and column index + template <typename Matrix> + struct matrix_element_key + { + typedef typename Collection<Matrix>::size_type size_type; + typedef matrix_element_key self; + + matrix_element_key(Matrix const& ref, size_type r, size_type c) : ref(ref) + { + indices[0]= r; indices[1]= c; + } + + bool operator==(const self& cc) const { return &ref == &cc.ref && indices[0] == cc.indices[0] && indices[1] == cc.indices[1]; } + bool operator!=(const self& cc) const { return !(*this == cc); } + + size_type indices[2]; + Matrix const& ref; + }; + + // Cursor for canonically referring to its elements with row and column index + // Increments row for pos==0 and column for pos==1 + // Referring operator returns matrix_element_key + template <typename Matrix, int pos> + struct matrix_element_cursor + { + typedef typename Collection<Matrix>::size_type size_type; + typedef matrix_element_cursor self; + typedef matrix_element_key<Matrix> key_type; + static int const level = 2; + + matrix_element_cursor(Matrix const& ref, size_type r, size_type c) : ref(ref) + { + indices[0]= r; indices[1]= c; + } + + key_type operator*() const { return key_type(ref, indices[0], indices[1]); } + + self& operator++() { ++indices[pos]; return *this; } + self operator++(int) { self tmp(*this); ++indices[pos]; return tmp; } + self& operator+=(int n) { indices[pos]+= n; return *this; } + self& operator+(int n) const { self tmp = *this; tmp+= n; return tmp; } + + self& operator--() { indices[pos]--; return *this; } + self operator--(int) { self tmp(*this); indices[pos]--; return tmp; } + self& operator-=(int n) { indices[pos]-= n; return *this; } + self& operator-(int n) const { self tmp = *this; tmp-= n; return tmp; } + + bool operator==(const self& cc) const { return &ref == &cc.ref && indices[0] == cc.indices[0] && indices[1] == cc.indices[1]; } + bool operator!=(const self& cc) const { return !(*this == cc); } + + size_type indices[2]; + Matrix const& ref; + }; + + + template <typename Matrix, typename Complexity, int Level> + struct all_rows_range_generator + { + typedef Complexity complexity; + static int const level = Level; + typedef Matrix ref_type; + typedef sub_matrix_cursor<Matrix, glas::tag::row, Level> type; + typedef typename Collection<Matrix>::size_type size_type; + + type begin(Matrix const& c) const + { + return type(0, c); // return type(c.begin_row(), c); get rid of obsolete stuff + } + type end(Matrix const& c) const + { + using mtl::num_rows; using mtl::matrix::num_rows; + return type(num_rows(c), c); //return type(c.end_row(), c); + } + type lower_bound(Matrix const& c, size_type position) const + { + using mtl::num_rows; + return type(std::min(num_rows(c), position), c); + } + }; + + template <typename Cursor> + struct all_cols_in_row_range_generator + { + typedef complexity_classes::linear complexity; + static int const level = 1; + typedef typename Cursor::ref_type ref_type; + typedef typename Collection<ref_type>::size_type size_type; + + + typedef matrix_element_cursor<ref_type, 1> type; + + type begin(Cursor const& c) const { return type(c.ref, c.value(), size_type(0)); } + type end(Cursor const& c) const { using mtl::num_cols; return type(c.ref, c.value(), num_cols(c.ref)); } + type lower_bound(Cursor const& c, size_type position) const + { + using mtl::num_cols; + return type(c.ref, c.value, std::min(num_cols(c.ref), position)); + } + }; + + + template <typename Matrix, typename Complexity, int Level> + struct all_cols_range_generator + { + typedef Complexity complexity; + static int const level = Level; + typedef sub_matrix_cursor<Matrix, glas::tag::col, Level> type; + typedef typename Collection<Matrix>::size_type size_type; + + type begin(Matrix const& c) const + { + return type(0, c); // return type(c.begin_col(), c); + } + type end(Matrix const& c) const + { + using mtl::num_cols; + return type(num_cols(c), c); // return type(c.end_col(), c); + } + type lower_bound(Matrix const& c, size_type position) const + { + using mtl::num_cols; + return type(std::min(num_cols(c), position), c); + } + }; + + template <typename Cursor> + struct all_rows_in_col_range_generator + { + typedef complexity_classes::linear complexity; + static int const level = 1; + typedef typename Cursor::ref_type ref_type; + typedef typename Collection<ref_type>::size_type size_type; + + + typedef matrix_element_cursor<ref_type, 0> type; + + type begin(Cursor const& c) const { return type(c.ref, 0, c.value()); } + type end(Cursor const& c) const { using mtl::num_rows; return type(c.ref, num_rows(c.ref), c.value()); } + type lower_bound(Cursor const& c, size_type position) const + { + using mtl::num_rows; + return type(c.ref, std::min(num_rows(c.ref), position), c.value()); + } + }; + + + // Use RangeGenerator for Collection by applying to .ref + template <typename Coll, typename RangeGenerator> + struct referred_range_generator + { + typedef typename RangeGenerator::complexity complexity; + static int const level = RangeGenerator::level; + typedef typename RangeGenerator::type type; + typedef typename Collection<Coll>::size_type size_type; + + type begin(const Coll& c) + { + return RangeGenerator().begin(c.ref); + } + + type end(const Coll& c) + { + return RangeGenerator().end(c.ref); + } + type lower_bound(const Coll& c, size_type position) + { + return RangeGenerator().lower_bound(c.ref, position); + } + }; + +} // namespace detail + + namespace range { + + template <typename Range1, typename Range2> + struct min + : public boost::mpl::if_< + boost::mpl::less< + typename Range1::complexity, + typename Range2::complexity> + , Range1 + , Range2 + > + {}; + } + +}} // namespace mtl::traits + +#endif // MTL_DETAIL_RANGE_GENERATOR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/detail/strided_base_cursor.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/detail/strided_base_cursor.hpp new file mode 100644 index 0000000000000000000000000000000000000000..0465e9eefc8ac02f03419b346d724b915a1a1fbe --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/detail/strided_base_cursor.hpp @@ -0,0 +1,80 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_STRIDED_BASE_CURSOR_INCLUDE +#define MTL_STRIDED_BASE_CURSOR_INCLUDE + +#include <boost/numeric/mtl/detail/base_cursor.hpp> + +namespace mtl { namespace detail { + +template <class Key> struct strided_base_cursor + : base_cursor<Key> +{ + typedef Key key_type; + typedef base_cursor<Key> base; + typedef strided_base_cursor self; + + strided_base_cursor () {} + strided_base_cursor (key_type key, std::size_t stride) + : base(key), stride(stride) + {} + + self& operator++ () + { + this->key+= stride; return *this; + } + self operator++ (int) + { + self tmp = *this; + this->key+= stride; + return tmp; + } + self& operator-- () + { + this->key-= stride; + return *this; + } + self operator-- (int) + { + self tmp = *this; + this->key-= stride; + return tmp; + } + self& operator+=(int n) + { + this->key += stride * n; + return *this; + } + self operator+(int n) const + { + self tmp(*this); + tmp+= n; + return tmp; + } + self& operator-=(int n) + { + this->key -= stride * n; + return *this; + } + + int operator-(const self& cc) const + { + return (this->key - cc.key) / stride; + } + + std::size_t stride; +}; + +}} // namespace mtl::detail + +#endif // MTL_STRIDED_BASE_CURSOR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/detail/trivial_inserter.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/detail/trivial_inserter.hpp new file mode 100644 index 0000000000000000000000000000000000000000..1e16adefc0d68f2c9bc58505236d7f818239c0fe --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/detail/trivial_inserter.hpp @@ -0,0 +1,103 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_TRIVIAL_INSERTER_INCLUDE +#define MTL_TRIVIAL_INSERTER_INCLUDE + +#include <boost/numeric/mtl/operation/update.hpp> +#include <boost/numeric/mtl/operation/size.hpp> +#include <boost/numeric/mtl/matrix/element_matrix.hpp> +#include <boost/numeric/mtl/matrix/element_array.hpp> + +namespace mtl { namespace detail { + + +// Matrix must have direct write access, i.e. matrix(row, col) must return a non-const reference +template <typename Matrix, typename Updater = mtl::operations::update_store<typename Matrix::value_type> > +struct trivial_inserter +{ + typedef trivial_inserter self; + typedef Matrix matrix_type; + typedef typename matrix_type::size_type size_type; + typedef typename matrix_type::value_type value_type; + typedef operations::update_proxy<self, size_type> proxy_type; + + explicit trivial_inserter(matrix_type& matrix, size_type) : matrix(matrix) {} + + proxy_type operator() (size_type row, size_type col) + { + return proxy_type(*this, row, col); + } + + + private: + + struct bracket_proxy + { + bracket_proxy(self& ref, size_type row) : ref(ref), row(row) {} + + proxy_type operator[](size_type col) + { + return proxy_type(ref, row, col); + } + + self& ref; + size_type row; + }; + + public: + + bracket_proxy operator[] (size_type row) + { + return bracket_proxy(*this, row); + } + + template <typename Value> + void update(size_type row, size_type col, Value val) + { + Updater() (matrix(row, col), val); + } + + template <typename Modifier, typename Value> + void modify(size_type row, size_type col, Value val) + { + Modifier() (matrix(row, col), val); + } + + + template <typename EMatrix, typename Rows, typename Cols> + self& operator<< (const matrix::element_matrix_t<EMatrix, Rows, Cols>& elements) + { + using mtl::size; + for (unsigned ri= 0; ri < size(elements.rows); ri++) + for (unsigned ci= 0; ci < size(elements.cols); ci++) + update (elements.rows[ri], elements.cols[ci], elements.matrix(ri, ci)); + return *this; + } + + template <typename EMatrix, typename Rows, typename Cols> + self& operator<< (const matrix::element_array_t<EMatrix, Rows, Cols>& elements) + { + using mtl::size; + for (unsigned ri= 0; ri < size(elements.rows); ri++) + for (unsigned ci= 0; ci < size(elements.cols); ci++) + update (elements.rows[ri], elements.cols[ci], elements.array[ri][ci]); + return *this; + } + + protected: + matrix_type& matrix; +}; + +}} // namespace mtl::detail + +#endif // MTL_TRIVIAL_INSERTER_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/interface/arprec.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/interface/arprec.hpp new file mode 100644 index 0000000000000000000000000000000000000000..dd1726113338fed552f21e09224f6454afbbff37 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/interface/arprec.hpp @@ -0,0 +1,61 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_ARPREC_INCLUDE +#define MTL_ARPREC_INCLUDE + +#ifdef MTL_HAS_ARPREC + +#include <arprec/mp_real.h> +#include <arprec/mp_complex.h> + +#include <boost/numeric/mtl/concept/magnitude.hpp> +#include <boost/numeric/mtl/utility/true_copy.hpp> +#include <boost/numeric/linear_algebra/identity.hpp> + +namespace mtl { + + /// Specialization for ARPREC complex numbers + template <> + struct Magnitude<mp_complex> + { + /// The associated type is ARPREC real + typedef mp_real type; + }; + + namespace traits { + + template <> + struct true_copy<mp_real_temp> + { + typedef mp_real type; + }; + } +} // namespace mtl + +namespace math { + + template <> + struct identity_t< add<mp_complex>, mp_complex > + : public std::binary_function<add<mp_complex>, mp_complex, mp_complex> + { + mp_complex operator() (const add<mp_complex>&, const mp_complex& /*ref*/) const + { + return mp_complex("0", "0"); + } + }; + +} // math + +#endif // MTL_HAS_ARPREC + +#endif // MTL_ARPREC_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/interface/blas.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/interface/blas.hpp new file mode 100644 index 0000000000000000000000000000000000000000..13e8222a17aa8744f6c6e2903948b2d6d164e04d --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/interface/blas.hpp @@ -0,0 +1,165 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + + +#ifndef MTL_BLAS_INCLUDE +#define MTL_BLAS_INCLUDE + + +#ifdef MTL_HAS_BLAS + +// #include "mtl/mtl_config.h" + +#if 0 +#include "mtl/mtl_complex.h" +using std::complex; +#endif + +/*-------------------------------------------------------- + Basic Linear Algebra Subprograms for C/C++ + Version 1.0 + Matthew E. Gaston + May 6, 1998 +----------------------------------------------------------*/ + +#define MTL_BLAS_NAME(name) name##_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*--------------------------------------------------------- + Level 1 BLAS +-----------------------------------------------------------*/ + +/* +// Dot product functions +*/ +float MTL_BLAS_NAME(sdot)(int*, float*, int*, float*, int*); +double MTL_BLAS_NAME(dsdot)(int*, float*, int*, float*, int*); +float MTL_BLAS_NAME(sdsdot)(int*, float*, float*, int*, float*, int*); +double MTL_BLAS_NAME(ddot)(int*, double*, int*, double*, int*); + +/* + AXPY +*/ +void MTL_BLAS_NAME(saxpy)(int*, float*, float*, int*, float*, int*); +void MTL_BLAS_NAME(daxpy)(int*, double*, double*, int*, double*, int*); + +/* + Copy +*/ +void MTL_BLAS_NAME(scopy)(int*, float*, int*, float*, int*); +void MTL_BLAS_NAME(dcopy)(int*, double*, int*, double*, int*); + +/* + Swap +*/ +void MTL_BLAS_NAME(sswap)(int*, float*, int*, float*, int*); +void MTL_BLAS_NAME(dswap)(int*, double*, int*, double*, int*); + +/* + 2 Norm +*/ +float MTL_BLAS_NAME(snrm2)(int *, float*, int*); +double MTL_BLAS_NAME(dnrm2)(int *, double*, int*); + +/* + Sum of Absolute Values +*/ +float MTL_BLAS_NAME(sasum)(int *, float*, int*); +double MTL_BLAS_NAME(dasum)(int *, double*, int*); + +/* + Scale +*/ +void MTL_BLAS_NAME(sscal)(int*, float*, float*, int*); +void MTL_BLAS_NAME(dscal)(int*, double*, double*, int*); + +/* + Maximum absolute value +*/ +int MTL_BLAS_NAME(isamax)(int *, float*, int*); +int MTL_BLAS_NAME(idamax)(int *, double*, int*); + + +/* + Givens Plane Rotation +*/ +void MTL_BLAS_NAME(srotg)(float*, float*, float*, float*); +void MTL_BLAS_NAME(drotg)(double*, double*, double*, double*); +#if 0 +void MTL_BLAS_NAME(crotg)(complex<float>*,complex<float>*,float*,complex<float>*); +void MTL_BLAS_NAME(zrotg)(complex<double>*,complex<double>*,double*,complex<double>*); +#endif +void MTL_BLAS_NAME(srot)(int*, float*, int*, float*, int*, float*, float*); +void MTL_BLAS_NAME(drot)(int*, double*, int*, double*, int*, double*, double*); +#if 0 +/* MTL implements ccrot and zzrot */ +void MTL_BLAS_NAME(csrot)(int*, complex<float>*, int*, complex<float>*, int*, + complex<float>*, complex<float>*); +void MTL_BLAS_NAME(zdrot)(int*, complex<double>*, int*, complex<double>*, int*, + double*, double*); +#endif + +/*--------------------------------------------------------- + Level 2 BLAS +-----------------------------------------------------------*/ + +void MTL_BLAS_NAME(dgemv)(char*, int*, int*, double*, double*, int*, + double*, int*, double*, double*, int*); + +void MTL_BLAS_NAME(dger)(int*, int*, double*, double*, int*, double*, + int*, double*, int*); + +void MTL_BLAS_NAME(dgbmv)(char*, int*, int*, int*, int*, double*, double*, int*, + double*, int*, double*, double*, int*); + + +void MTL_BLAS_NAME(dtrsv)(char* uplo, char* trans, char* diag, int* n, double *da, + int* lda, double *dx, int* incx); + +/*--------------------------------------------------------- + Level 3 BLAS +-----------------------------------------------------------*/ + +void MTL_BLAS_NAME(sgemm)(const char* transa, const char* transb, + const int* m, const int* n, const int* k, + const float* alpha, const float *da, const int* lda, + const float *db, const int* ldb, const float* dbeta, + float *dc, const int* ldc); + +void MTL_BLAS_NAME(dgemm)(const char* transa, const char* transb, + const int* m, const int* n, const int* k, + const double* alpha, const double *da, const int* lda, + const double *db, const int* ldb, const double* dbeta, + double *dc, const int* ldc); + +void MTL_BLAS_NAME(cgemm)(const char* transa, const char* transb, + const int* m, const int* n, const int* k, + const std::complex<float>* alpha, const std::complex<float> *da, const int* lda, + const std::complex<float> *db, const int* ldb, const std::complex<float>* dbeta, + std::complex<float> *dc, const int* ldc); + +void MTL_BLAS_NAME(zgemm)(const char* transa, const char* transb, + const int* m, const int* n, const int* k, + const std::complex<double>* alpha, const std::complex<double> *da, const int* lda, + const std::complex<double> *db, const int* ldb, const std::complex<double>* dbeta, + std::complex<double> *dc, const int* ldc); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // MTL_HAS_BLAS + +#endif // MTL_BLAS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/interface/lapack.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/interface/lapack.hpp new file mode 100644 index 0000000000000000000000000000000000000000..502314f41dfd1b6ff2faf7c7c57a6c84d9137bc3 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/interface/lapack.hpp @@ -0,0 +1,48 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_LAPACK_INCLUDE +#define MTL_LAPACK_INCLUDE + +#include <complex> + + +#ifdef __cplusplus +extern "C" { +#endif + + + // Cholesky Factorization + void spotrf_(const char* uplo, const int* n, float *a, const int* ld, int* info); + void dpotrf_(const char* uplo, const int* n, double *a, const int* ld, int* info); + void cpotrf_(const char* uplo, const int* n, std::complex<float> *a, const int* ld, int* info); + void zpotrf_(const char* uplo, const int* n, std::complex<double> *a, const int* ld, int* info); + + + + + + + + + + + + + + +#ifdef __cplusplus +} // extern "C" +#endif + + +#endif // MTL_LAPACK_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/interface/umfpack_solve.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/interface/umfpack_solve.hpp new file mode 100644 index 0000000000000000000000000000000000000000..878d60ad4a3271c19dd164aa0e66885264c80de3 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/interface/umfpack_solve.hpp @@ -0,0 +1,567 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_UMFPACK_SOLVE_INCLUDE +#define MTL_MATRIX_UMFPACK_SOLVE_INCLUDE + +#ifdef MTL_HAS_UMFPACK + +#include <iostream> + + +#include <cassert> +#include <algorithm> +#include <boost/mpl/bool.hpp> +#include <boost/numeric/mtl/matrix/compressed2D.hpp> +#include <boost/numeric/mtl/matrix/parameter.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/make_copy_or_reference.hpp> +#include <boost/numeric/mtl/operation/merge_complex_vector.hpp> +#include <boost/numeric/mtl/operation/split_complex_vector.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +extern "C" { +# include <umfpack.h> +} + +namespace mtl { namespace matrix { + + /// Namespace for Umfpack solver + namespace umfpack { + + // conversion for value_type needed if not double or complex<double> (where possible) + template <typename Value> struct value {}; + template<> struct value<long double> { typedef double type; }; + template<> struct value<double> { typedef double type; }; + template<> struct value<float> { typedef double type; }; + template<> struct value<std::complex<long double> > { typedef std::complex<double> type; }; + template<> struct value<std::complex<double> > { typedef std::complex<double> type; }; + template<> struct value<std::complex<float> > { typedef std::complex<double> type; }; + + template <typename Value> struct use_long { static const bool value= sizeof(Value) > sizeof(int); }; + + template <bool Larger> struct index_aux { typedef int type; }; +#if defined(UF_long) + template<> struct index_aux<true> { typedef UF_long type; }; +#elif defined(SuiteSparse_long) + template<> struct index_aux<true> { typedef SuiteSparse_long type; }; +#else + template<> struct index_aux<true> { typedef long type; }; +#endif + + template <typename Value> struct index + : index_aux<use_long<Value>::value> {}; + + template <typename Matrix, typename Value, typename Orientation> + struct matrix_copy {}; + + // If arbitrary compressed matrix -> copy + template <typename Value, typename Parameters, typename Orientation> + struct matrix_copy<compressed2D<Value, Parameters>, Value, Orientation> + { + typedef typename value<Value>::type value_type; + typedef compressed2D<value_type, parameters<col_major> > matrix_type; + typedef compressed2D<Value, Parameters> in_matrix_type; + + matrix_copy(const in_matrix_type& A) : matrix(A) {} + matrix_type matrix; + }; + + struct error : public domain_error + { + error(const char *s, int code) : domain_error(s), code(code) {} + int code; + }; + + inline void check(int res, const char* s) + { + MTL_THROW_IF(res != UMFPACK_OK, error(s, res)); + } + + /// Class for repeated Umfpack solutions + /** Keeps symbolic and numeric preprocessing. Numeric part can be updated. + Only defined for compressed2D<double> and compressed2D<complex<double> >. **/ + template <typename T> + class solver { + public: + /// Constructor referring to matrix \p A (not changed) and optionally Umfpack's strategy and alloc_init (look for the specializations) + // \ref solver<compressed2D<double, Parameters> > and \ref solver<compressed2D<std::complex<double>, Parameters> >) + explicit solver(const T& A) {} + + /// Update numeric part, for matrices that kept the sparsity and changed the values + void update_numeric() {} + + /// Update symbolic and numeric part + void update() {} + + /// Solve system A*x == b with matrix passed in constructor + /** Please note that the order of b and x is different than in solve() !!! **/ + template <typename VectorX, typename VectorB> + int operator()(VectorX& x, const VectorB& b) const {return 0;} + + /// Solve system A*x == b with matrix passed in constructor + /** Please note that the order of b and x is different than in operator() !!! **/ + template <typename VectorB, typename VectorX> + int operator()(const VectorB& b, VectorX& x) const {return 0;} + }; + + /// Speciatization of solver for \ref matrix::compressed2D with double values + template <typename Parameters> + class solver<compressed2D<double, Parameters> > + { + typedef double value_type; + typedef compressed2D<value_type, Parameters> matrix_type; + typedef typename matrix_type::size_type size_type; + typedef typename index<size_type>::type index_type; + + static const bool copy_indices= sizeof(index_type) != sizeof(size_type), + long_indices= use_long<size_type>::value; + typedef boost::mpl::bool_<long_indices> blong; + typedef boost::mpl::true_ true_; + typedef boost::mpl::false_ false_; + + // typedef parameters<col_major> Parameters; + + void assign_pointers() + { + if (copy_indices) { + if (Apc == 0) Apc= new index_type[n + 1]; + if (my_nnz != A.nnz() && Aic) { delete[] Aic; Aic= 0; } + if (Aic == 0) Aic= new index_type[A.nnz()]; + std::copy(A.address_major(), A.address_major() + n + 1, Apc); + std::copy(A.address_minor(), A.address_minor() + A.nnz(), Aic); + Ap= Apc; + Ai= Aic; + } else { + Ap= reinterpret_cast<const index_type*>(A.address_major()); + Ai= reinterpret_cast<const index_type*>(A.address_minor()); + } + Ax= A.address_data(); + } + + void init_aux(true_) + { + check(umfpack_dl_symbolic(n, n, Ap, Ai, Ax, &Symbolic, Control, Info), "Error in dl_symbolic"); + check(umfpack_dl_numeric(Ap, Ai, Ax, Symbolic, &Numeric, Control, Info), "Error in dl_numeric"); + } + + void init_aux(false_) + { + check(umfpack_di_symbolic(n, n, Ap, Ai, Ax, &Symbolic, Control, Info), "Error in di_symbolic"); +#if 0 + std::cout << "=== INFO of umfpack_*_symbolic ===\n"; + std::cout << " UMFPACK_STATUS: " << (Info[UMFPACK_STATUS] == UMFPACK_OK ? "OK" : "ERROR") << "\n"; + std::cout << " UMFPACK_NROW: " << Info[UMFPACK_NROW] << "\n"; + std::cout << " UMFPACK_NCOL: " << Info[UMFPACK_NCOL] << "\n"; + std::cout << " UMFPACK_NZ: " << Info[UMFPACK_NZ] << "\n"; + std::cout << " UMFPACK_SIZE_OF_UNIT: " << Info[UMFPACK_SIZE_OF_UNIT] << "\n"; + std::cout << " UMFPACK_NDENSE_ROW: " << Info[UMFPACK_NDENSE_ROW] << "\n"; + std::cout << " UMFPACK_NEMPTY_ROW: " << Info[UMFPACK_NEMPTY_ROW] << "\n"; + std::cout << " UMFPACK_NDENSE_COL: " << Info[UMFPACK_NDENSE_COL] << "\n"; + std::cout << " UMFPACK_NEMPTY_COL: " << Info[UMFPACK_NEMPTY_COL] << "\n"; + std::cout << " UMFPACK_SYMBOLIC_DEFRAG: " << Info[UMFPACK_SYMBOLIC_DEFRAG] << "\n"; + std::cout << " UMFPACK_SYMBOLIC_PEAK_MEMORY: " << Info[UMFPACK_SYMBOLIC_PEAK_MEMORY] << "\n"; + std::cout << " UMFPACK_SYMBOLIC_SIZE: " << Info[UMFPACK_SYMBOLIC_SIZE] << "\n"; + std::cout << " UMFPACK_VARIABLE_PEAK_ESTIMATE: " << Info[UMFPACK_VARIABLE_PEAK_ESTIMATE] << "\n"; + std::cout << " UMFPACK_NUMERIC_SIZE_ESTIMATE: " << Info[UMFPACK_NUMERIC_SIZE_ESTIMATE] << "\n"; + std::cout << " UMFPACK_PEAK_MEMORY_ESTIMATE: " << Info[UMFPACK_PEAK_MEMORY_ESTIMATE] << "\n"; + std::cout << " UMFPACK_FLOPS_ESTIMATE: " << Info[UMFPACK_FLOPS_ESTIMATE] << "\n"; + std::cout << " UMFPACK_LNZ_ESTIMATE: " << Info[UMFPACK_LNZ_ESTIMATE] << "\n"; + std::cout << " UMFPACK_UNZ_ESTIMATE: " << Info[UMFPACK_UNZ_ESTIMATE] << "\n"; + std::cout << " UMFPACK_MAX_FRONT_SIZE_ESTIMATE: " << Info[UMFPACK_MAX_FRONT_SIZE_ESTIMATE] << "\n"; + std::cout << " UMFPACK_SYMBOLIC_TIME: " << Info[UMFPACK_SYMBOLIC_TIME] << "\n"; + std::cout << " UMFPACK_SYMBOLIC_WALLTIME: " << Info[UMFPACK_SYMBOLIC_WALLTIME] << "\n"; + + if (Info[UMFPACK_STRATEGY_USED] == UMFPACK_STRATEGY_SYMMETRIC) + std::cout << " UMFPACK_STRATEGY_USED: SYMMETRIC\n"; + else { + if(Info[UMFPACK_STRATEGY_USED] == UMFPACK_STRATEGY_UNSYMMETRIC) + std::cout << " UMFPACK_STRATEGY_USED: UNSYMMETRIC\n"; + else { + if (Info[UMFPACK_STRATEGY_USED] == UMFPACK_STRATEGY_2BY2) + std::cout << " UMFPACK_STRATEGY_USED: 2BY2\n"; + else + std::cout << " UMFPACK_STRATEGY_USED: UNKOWN STRATEGY " << Info[UMFPACK_STRATEGY_USED] << "\n"; + } + } + + std::cout << " UMFPACK_ORDERING_USED: " << Info[UMFPACK_ORDERING_USED] << "\n"; + std::cout << " UMFPACK_QFIXED: " << Info[UMFPACK_QFIXED] << "\n"; + std::cout << " UMFPACK_DIAG_PREFERRED: " << Info[UMFPACK_DIAG_PREFERRED] << "\n"; + std::cout << " UMFPACK_ROW_SINGLETONS: " << Info[UMFPACK_ROW_SINGLETONS] << "\n"; + std::cout << " UMFPACK_COL_SINGLETONS: " << Info[UMFPACK_COL_SINGLETONS] << "\n"; + std::cout << " UMFPACK_PATTERN_SYMMETRY: " << Info[UMFPACK_PATTERN_SYMMETRY] << "\n"; + std::cout << " UMFPACK_NZ_A_PLUS_AT: " << Info[UMFPACK_NZ_A_PLUS_AT] << "\n"; + std::cout << " UMFPACK_NZDIAG: " << Info[UMFPACK_NZDIAG] << "\n"; + std::cout << " UMFPACK_N2: " << Info[UMFPACK_N2] << "\n"; + std::cout << " UMFPACK_S_SYMMETRIC: " << Info[UMFPACK_S_SYMMETRIC] << "\n"; + std::cout << " UMFPACK_MAX_FRONT_NROWS_ESTIMATE: " << Info[UMFPACK_MAX_FRONT_NROWS_ESTIMATE] << "\n"; + std::cout << " UMFPACK_MAX_FRONT_NCOLS_ESTIMATE: " << Info[UMFPACK_MAX_FRONT_NCOLS_ESTIMATE] << "\n"; + std::cout << " UMFPACK_SYMMETRIC_LUNZ: " << Info[UMFPACK_SYMMETRIC_LUNZ] << "\n"; + std::cout << " UMFPACK_SYMMETRIC_FLOPS: " << Info[UMFPACK_SYMMETRIC_FLOPS] << "\n"; + std::cout << " UMFPACK_SYMMETRIC_NDENSE: " << Info[UMFPACK_SYMMETRIC_NDENSE] << "\n"; + std::cout << " UMFPACK_SYMMETRIC_DMAX: " << Info[UMFPACK_SYMMETRIC_DMAX] << "\n"; +#endif + + check(umfpack_di_numeric(Ap, Ai, Ax, Symbolic, &Numeric, Control, Info), "Error in di_numeric"); + +#if 0 + std::cout << "=== INFO of umfpack_*_numeric ===\n"; + std::cout << " UMFPACK_STATUS: " << (Info[UMFPACK_STATUS] == UMFPACK_OK ? "OK" : "ERROR") << "\n"; + std::cout << " UMFPACK_VARIABLE_PEAK: " << Info[UMFPACK_VARIABLE_PEAK] << "\n"; + std::cout << " UMFPACK_PEAK_MEMORY: " << Info[UMFPACK_PEAK_MEMORY] << "\n"; + std::cout << " UMFPACK_FLOPS: " << Info[UMFPACK_FLOPS] << "\n"; + std::cout << " UMFPACK_LNZ: " << Info[UMFPACK_LNZ] << "\n"; + std::cout << " UMFPACK_UNZ: " << Info[UMFPACK_UNZ] << "\n"; + std::cout << " UMFPACK_NUMERIC_DEFRAG: " << Info[UMFPACK_NUMERIC_DEFRAG] << "\n"; + std::cout << " UMFPACK_NUMERIC_REALLOC: " << Info[UMFPACK_NUMERIC_REALLOC] << "\n"; + std::cout << " UMFPACK_NUMERIC_COSTLY_REALLOC: " << Info[UMFPACK_NUMERIC_COSTLY_REALLOC] << "\n"; + std::cout << " UMFPACK_COMPRESSED_PATTERN: " << Info[UMFPACK_COMPRESSED_PATTERN] << "\n"; + std::cout << " UMFPACK_LU_ENTRIES: " << Info[UMFPACK_LU_ENTRIES] << "\n"; + std::cout << " UMFPACK_NUMERIC_TIME: " << Info[UMFPACK_NUMERIC_TIME] << "\n"; + std::cout << " UMFPACK_RCOND: " << Info[UMFPACK_RCOND] << "\n"; + std::cout << " UMFPACK_UDIAG_NZ: " << Info[UMFPACK_UDIAG_NZ] << "\n"; + std::cout << " UMFPACK_UMIN: " << Info[UMFPACK_UMIN] << "\n"; + std::cout << " UMFPACK_UMAX: " << Info[UMFPACK_UMAX] << "\n"; + std::cout << " UMFPACK_MAX_FRONT_NROWS: " << Info[UMFPACK_MAX_FRONT_NROWS] << "\n"; + std::cout << " UMFPACK_MAX_FRONT_NCOLS: " << Info[UMFPACK_MAX_FRONT_NCOLS] << "\n"; + std::cout << " UMFPACK_ALL_LNZ: " << Info[UMFPACK_ALL_LNZ] << "\n"; + std::cout << " UMFPACK_ALL_UNZ: " << Info[UMFPACK_ALL_UNZ] << "\n"; +#endif + } + + void init() + { + MTL_THROW_IF(num_rows(A) != num_cols(A), matrix_not_square()); + n= num_rows(A); + assign_pointers(); + init_aux(blong()); + } + + + + public: + /// Constructor referring to matrix \p A (not changed) and optionally Umfpack's strategy and alloc_init + solver(const matrix_type& A, int strategy = UMFPACK_STRATEGY_AUTO, double alloc_init = 0.7) + : A(A), Apc(0), Aic(0), my_nnz(0), Symbolic(0), Numeric(0) + { + vampir_trace<5060> trace; + // Use default setings. + if (long_indices) + umfpack_dl_defaults(Control); + else + umfpack_di_defaults(Control); + + Control[UMFPACK_STRATEGY] = strategy; + Control[UMFPACK_ALLOC_INIT] = alloc_init; + init(); + } + + ~solver() + { + vampir_trace<5061> trace; + if (long_indices) { + umfpack_dl_free_numeric(&Numeric); + umfpack_dl_free_symbolic(&Symbolic); + } else { + umfpack_di_free_numeric(&Numeric); + umfpack_di_free_symbolic(&Symbolic); + } + if (Apc) delete[] Apc; + if (Aic) delete[] Aic; + } + + void update_numeric_aux(true_) + { + umfpack_dl_free_numeric(&Numeric); + check(umfpack_dl_numeric(Ap, Ai, Ax, Symbolic, &Numeric, Control, Info), "Error in dl_numeric"); + } + + void update_numeric_aux(false_) + { + umfpack_di_free_numeric(&Numeric); + check(umfpack_di_numeric(Ap, Ai, Ax, Symbolic, &Numeric, Control, Info), "Error in di_numeric"); + } + + /// Update numeric part, for matrices that kept the sparsity and changed the values + void update_numeric() + { + assign_pointers(); + update_numeric_aux(blong()); + } + + /// Update symbolic and numeric part + void update() + { + if (long_indices) { + umfpack_dl_free_numeric(&Numeric); + umfpack_dl_free_symbolic(&Symbolic); + } else { + umfpack_di_free_numeric(&Numeric); + umfpack_di_free_symbolic(&Symbolic); + } + init(); + } + + template <typename VectorX, typename VectorB> + void solve_aux(int sys, VectorX& xx, const VectorB& bb, true_) + { + check(umfpack_dl_solve(sys, Ap, Ai, Ax, &xx.value[0], &bb.value[0], Numeric, Control, Info), "Error in dl_solve"); + } + + template <typename VectorX, typename VectorB> + void solve_aux(int sys, VectorX& xx, const VectorB& bb, false_) + { + check(umfpack_di_solve(sys, Ap, Ai, Ax, &xx.value[0], &bb.value[0], Numeric, Control, Info), "Error in di_solve"); + } + + /// Solve double system + template <typename VectorX, typename VectorB> + int operator()(VectorX& x, const VectorB& b) + { + vampir_trace<5062> trace; + MTL_THROW_IF(num_rows(A) != size(x) || num_rows(A) != size(b), incompatible_size()); + make_in_out_copy_or_reference<dense_vector<value_type>, VectorX> xx(x); + make_in_copy_or_reference<dense_vector<value_type>, VectorB> bb(b); + int sys= mtl::traits::is_row_major<Parameters>::value ? UMFPACK_At : UMFPACK_A; + solve_aux(sys, xx, bb, blong()); + return UMFPACK_OK; + } + + /// Solve double system + template <typename VectorB, typename VectorX> + int solve(const VectorB& b, VectorX& x) const + { + // return (*this)(x, b); + return const_cast<solver&>(*this)(x, b); // evil hack because Umfpack has no const + } + + private: + const matrix_type& A; + int n; + const index_type *Ap, *Ai; + index_type *Apc, *Aic; + size_type my_nnz; + const double *Ax; + double Control[UMFPACK_CONTROL], Info[UMFPACK_INFO]; + void *Symbolic, *Numeric; + }; + + /// Speciatization of solver for \ref matrix::compressed2D with double values + template <typename Parameters> + class solver<compressed2D<std::complex<double>, Parameters> > + { + typedef std::complex<double> value_type; + typedef compressed2D<value_type, Parameters> matrix_type; + typedef typename matrix_type::size_type size_type; + typedef typename index<size_type>::type index_type; + + static const bool copy_indices= sizeof(index_type) != sizeof(size_type), + long_indices= use_long<size_type>::value; + + typedef boost::mpl::bool_<long_indices> blong; + typedef boost::mpl::true_ true_; + typedef boost::mpl::false_ false_; + + + void assign_pointers() + { + if (copy_indices) { + if (Apc == 0) Apc= new index_type[n + 1]; + if (Aic == 0) Aic= new index_type[A.nnz()]; + std::copy(A.address_major(), A.address_major() + n + 1, Apc); + std::copy(A.address_minor(), A.address_minor() + A.nnz(), Aic); + Ap= Apc; + Ai= Aic; + } else { + Ap= reinterpret_cast<const index_type*>(A.address_major()); + Ai= reinterpret_cast<const index_type*>(A.address_minor()); + } + split_complex_vector(A.data, Ax, Az); + } + + void init_aux(true_) + { + check(umfpack_zl_symbolic(n, n, Ap, Ai, &Ax[0], &Az[0], &Symbolic, Control, Info), "Error in zl_symbolic"); + check(umfpack_zl_numeric(Ap, Ai, &Ax[0], &Az[0], Symbolic, &Numeric, Control, Info), "Error in zl_numeric"); + } + + void init_aux(false_) + { + check(umfpack_zi_symbolic(n, n, Ap, Ai, &Ax[0], &Az[0], &Symbolic, Control, Info), "Error in zi_symbolic"); + check(umfpack_zi_numeric(Ap, Ai, &Ax[0], &Az[0], Symbolic, &Numeric, Control, Info), "Error in zi_numeric"); + } + + void initialize() + { + MTL_THROW_IF(num_rows(A) != num_cols(A), matrix_not_square()); + n= num_rows(A); + assign_pointers(); + init_aux(blong()); + } + public: + /// Constructor referring to matrix \p A (not changed) and optionally Umfpack's strategy and alloc_init (look for the specializations) + explicit solver(const compressed2D<value_type, Parameters>& A, int strategy = UMFPACK_STRATEGY_AUTO, double alloc_init = 0.7) + : A(A), Apc(0), Aic(0) + { + vampir_trace<5060> trace; + // Use default setings. + if (long_indices) + umfpack_zl_defaults(Control); + else + umfpack_zi_defaults(Control); + // umfpack_zi_defaults(Control); + + Control[UMFPACK_STRATEGY] = strategy; + Control[UMFPACK_ALLOC_INIT] = alloc_init; + initialize(); + } + + ~solver() + { + vampir_trace<5061> trace; + if (long_indices) { + umfpack_zl_free_numeric(&Numeric); + umfpack_zl_free_symbolic(&Symbolic); + } else { + umfpack_zi_free_numeric(&Numeric); + umfpack_zi_free_symbolic(&Symbolic); + } + if (Apc) delete[] Apc; + if (Aic) delete[] Aic; + } + + void update_numeric_aux(true_) + { + umfpack_zl_free_numeric(&Numeric); + check(umfpack_zl_numeric(Ap, Ai, &Ax[0], &Az[0], Symbolic, &Numeric, Control, Info), "Error in dl_numeric D"); + } + + void update_numeric_aux(false_) + { + umfpack_zi_free_numeric(&Numeric); + check(umfpack_zi_numeric(Ap, Ai, &Ax[0], &Az[0], Symbolic, &Numeric, Control, Info), "Error in di_numeric"); + } + + /// Update numeric part, for matrices that kept the sparsity and changed the values + void update_numeric() + { + assign_pointers(); + update_numeric_aux(blong()); + } + + /// Update symbolic and numeric part + void update() + { + Ax.change_dim(0); Az.change_dim(0); + if (long_indices) { + umfpack_zl_free_numeric(&Numeric); + umfpack_zl_free_symbolic(&Symbolic); + } else { + umfpack_zi_free_numeric(&Numeric); + umfpack_zi_free_symbolic(&Symbolic); + } + initialize(); + } + + template <typename VectorX, typename VectorB> + void solve_aux(int sys, VectorX& Xx, VectorX& Xz, const VectorB& Bx, const VectorB& Bz, true_) + { + check(umfpack_zl_solve(sys, Ap, Ai, &Ax[0], &Az[0], &Xx[0], &Xz[0], &Bx[0], &Bz[0], Numeric, Control, Info), + "Error in zi_solve"); + } + + template <typename VectorX, typename VectorB> + void solve_aux(int sys, VectorX& Xx, VectorX& Xz, const VectorB& Bx, const VectorB& Bz, false_) + { + check(umfpack_zi_solve(sys, Ap, Ai, &Ax[0], &Az[0], &Xx[0], &Xz[0], &Bx[0], &Bz[0], Numeric, Control, Info), + "Error in zi_solve"); + } + + /// Solve complex system + template <typename VectorX, typename VectorB> + int operator()(VectorX& x, const VectorB& b) + { + vampir_trace<5062> trace; + MTL_THROW_IF(num_rows(A) != size(x) || num_rows(A) != size(b), incompatible_size()); + dense_vector<double> Xx(size(x)), Xz(size(x)), Bx, Bz; + split_complex_vector(b, Bx, Bz); + int sys= mtl::traits::is_row_major<Parameters>::value ? UMFPACK_Aat : UMFPACK_A; + solve_aux(sys, Xx, Xz, Bx, Bz, blong()); + merge_complex_vector(Xx, Xz, x); + return UMFPACK_OK; + } + + /// Solve complex system + template <typename VectorB, typename VectorX> + int solve(const VectorB& b, VectorX& x) + { + return (*this)(x, b); + } + + private: + const matrix_type& A; + int n; + const index_type *Ap, *Ai; + index_type *Apc, *Aic; + dense_vector<double> Ax, Az; + double Control[UMFPACK_CONTROL], Info[UMFPACK_INFO]; + void *Symbolic, *Numeric; + }; + + template <typename Value, typename Parameters> + class solver<compressed2D<Value, Parameters> > + : matrix_copy<compressed2D<Value, Parameters>, Value, typename Parameters::orientation>, + public solver<typename matrix_copy<compressed2D<Value, Parameters>, Value, typename Parameters::orientation>::matrix_type > + { + typedef matrix_copy<compressed2D<Value, Parameters>, Value, typename Parameters::orientation> copy_type; + typedef solver<typename matrix_copy<compressed2D<Value, Parameters>, Value, typename Parameters::orientation>::matrix_type > solver_type; + public: + explicit solver(const compressed2D<Value, Parameters>& A) + : copy_type(A), solver_type(copy_type::matrix), A(A) + {} + + void update() + { + copy_type::matrix= A; + solver_type::update(); + } + + void update_numeric() + { + copy_type::matrix= A; + solver_type::update_numeric(); + } + private: + const compressed2D<Value, Parameters>& A; + }; + } // umfpack + +/// Solve A*x == b with umfpack +/** Only available when compiled with enabled macro MTL_HAS_UMFPACK. + Uses classes umfpack::solver internally. + If you want more control on single operations or to keep umfpack's + internal factorization, use this class. + **/ +template <typename Value, typename Parameters, typename VectorX, typename VectorB> +int umfpack_solve(const compressed2D<Value, Parameters>& A, VectorX& x, const VectorB& b) +{ + umfpack::solver<compressed2D<Value, Parameters> > solver(A); + return solver(x, b); +} + +}} // namespace mtl::matrix + +#endif + +#endif // MTL_MATRIX_UMFPACK_SOLVE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/interface/vpt.cpp b/AMDiS/lib/mtl4/boost/numeric/mtl/interface/vpt.cpp new file mode 100644 index 0000000000000000000000000000000000000000..838596b29a70aa5da88f35a18a5522c517ff9b6b --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/interface/vpt.cpp @@ -0,0 +1,443 @@ +#include <boost/numeric/mtl/interface/vpt.hpp> + +#ifdef MTL_HAS_VPT +namespace mtl { + +/// Namespace for Vampir Trace interface +namespace vpt { + +// Categories: +// Utilities + very small functions: 0000 +// Static size operations: 1000 +// Vector operations: 2000 +// Matrix Vector & single matrix: 3000 +// Matrix matrix operations: 4000 +// Factorizations, preconditioners: 5000 +// Fused operations: 6000 +// Iterative solvers: 7000 +// Multigrid: 8000 + + +// Utilities: < 1000 +template <> std::string vampir_trace<1>::name("copysign"); +template <> std::string vampir_trace<2>::name("Elem_raw_copy"); +template <> std::string vampir_trace<3>::name("Get_real_part"); +template <> std::string vampir_trace<4>::name("Info_contruct_vector"); +template <> std::string vampir_trace<5>::name("right_scale_inplace"); +template <> std::string vampir_trace<6>::name("sign_real_part_of_complex"); +template <> std::string vampir_trace<7>::name("unrolling_expresion"); +template <> std::string vampir_trace<8>::name(""); +template <> std::string vampir_trace<9>::name(""); +template <> std::string vampir_trace<10>::name("squared_abs_magnitudes"); +template <> std::string vampir_trace<11>::name("squared_abs_complex"); +template <> std::string vampir_trace<12>::name("squared_abs_magnitudes_template"); +template <> std::string vampir_trace<13>::name("update_store"); +template <> std::string vampir_trace<14>::name("update_plus"); +template <> std::string vampir_trace<15>::name("update_minus"); +template <> std::string vampir_trace<16>::name("update_times"); +template <> std::string vampir_trace<17>::name("update_adapter"); +template <> std::string vampir_trace<18>::name(""); +template <> std::string vampir_trace<19>::name(""); +template <> std::string vampir_trace<20>::name("update_proxy_<<"); +template <> std::string vampir_trace<21>::name("update_proxy_="); +template <> std::string vampir_trace<22>::name("update_proxy_+="); +template <> std::string vampir_trace<23>::name("sfunctor::plus"); +template <> std::string vampir_trace<24>::name("sfunctor::minus"); +template <> std::string vampir_trace<25>::name("sfunctor::times"); +template <> std::string vampir_trace<26>::name("sfunctor::divide"); +template <> std::string vampir_trace<27>::name("sfunctor::assign"); +template <> std::string vampir_trace<28>::name("sfunctor::plus_assign"); +template <> std::string vampir_trace<29>::name("sfunctor::minus_assign"); +template <> std::string vampir_trace<30>::name("sfunctor::times_assign"); +template <> std::string vampir_trace<31>::name("sfunctor::divide_assign"); +template <> std::string vampir_trace<32>::name("sfunctor::identity"); +template <> std::string vampir_trace<33>::name("sfunctor::abs"); +template <> std::string vampir_trace<34>::name("sfunctor::sqrt"); +template <> std::string vampir_trace<35>::name("sfunctor::square"); +template <> std::string vampir_trace<36>::name("sfunctor::negate"); +template <> std::string vampir_trace<37>::name("sfunctor::compose"); +template <> std::string vampir_trace<38>::name("sfunctor::compose_first"); +template <> std::string vampir_trace<39>::name("sfunctor::compose_second"); +template <> std::string vampir_trace<40>::name("sfunctor::compose_both"); +template <> std::string vampir_trace<41>::name("sfunctor::compose_binary"); +template <> std::string vampir_trace<42>::name(""); +template <> std::string vampir_trace<43>::name(""); +template <> std::string vampir_trace<44>::name(""); +template <> std::string vampir_trace<45>::name(""); + +// Fine-grained vector operations +template <> std::string vampir_trace<236>::name("Vector_swapped_row"); + + +// Static size operations: 1000 +template <> std::string vampir_trace<1001>::name("stat_vec_expr"); +template <> std::string vampir_trace<1002>::name("fsize_dmat_dmat_mult"); +template <> std::string vampir_trace<1003>::name("vector_size_static"); +template <> std::string vampir_trace<1004>::name("static_dispatch"); // ?? row_in_matrix.hpp:74 +template <> std::string vampir_trace<1005>::name("copy_blocks_forward"); +template <> std::string vampir_trace<1006>::name("copy_blocks_backward"); +template <> std::string vampir_trace<1007>::name("Static_Size"); +template <> std::string vampir_trace<1008>::name("fsize_mat_vect_mult"); +template <> std::string vampir_trace<1009>::name(""); +template <> std::string vampir_trace<1010>::name(""); +template <> std::string vampir_trace<1011>::name(""); +template <> std::string vampir_trace<1012>::name(""); +template <> std::string vampir_trace<1013>::name(""); +template <> std::string vampir_trace<1014>::name(""); +template <> std::string vampir_trace<1015>::name(""); +template <> std::string vampir_trace<1016>::name(""); +template <> std::string vampir_trace<1017>::name(""); +template <> std::string vampir_trace<1018>::name(""); +template <> std::string vampir_trace<1019>::name(""); +template <> std::string vampir_trace<1020>::name(""); + + + + + +// Vector operations: 2000 +template <> std::string vampir_trace<2001>::name("gen_vector_copy"); +template <> std::string vampir_trace<2002>::name("cross"); +template <> std::string vampir_trace<2003>::name("dot"); +template <> std::string vampir_trace<2004>::name("householder"); +template <> std::string vampir_trace<2005>::name("householder_s"); +template <> std::string vampir_trace<2006>::name("vector::infinity_norm"); +template <> std::string vampir_trace<2007>::name("vector::look_at_each_nonzero"); +template <> std::string vampir_trace<2008>::name("vector::look_at_each_nonzero_pos"); +template <> std::string vampir_trace<2009>::name("vector::reduction"); +template <> std::string vampir_trace<2010>::name("vector::max"); +template <> std::string vampir_trace<2011>::name("vector::max_abs_pos"); +template <> std::string vampir_trace<2012>::name("max_of_sums"); +template <> std::string vampir_trace<2013>::name("vector::max_pos"); +template <> std::string vampir_trace<2014>::name("merge_complex_vector"); +template <> std::string vampir_trace<2015>::name("vector::one_norm"); +template <> std::string vampir_trace<2016>::name("vector::diagonal"); +template <> std::string vampir_trace<2017>::name("dyn_vec_expr"); +template <> std::string vampir_trace<2018>::name("Orthogonalize_Vectors"); +template <> std::string vampir_trace<2019>::name("Orthogonalize_Factors"); +template <> std::string vampir_trace<2020>::name("Vector_product"); +template <> std::string vampir_trace<2021>::name("Vector_random"); +template <> std::string vampir_trace<2022>::name("Vec_Vec_rank_update"); +template <> std::string vampir_trace<2023>::name("Vector_dispatch"); +template <> std::string vampir_trace<2024>::name("Vector_rscale"); +template <> std::string vampir_trace<2025>::name("Multi-vector_mult"); +template <> std::string vampir_trace<2026>::name("Transp_Multi-vector_mult"); +template <> std::string vampir_trace<2027>::name("Hermitian_Multi-vector_mult"); +template <> std::string vampir_trace<2028>::name("Vector_scal"); +template <> std::string vampir_trace<2029>::name("Vector_set_zero"); +template <> std::string vampir_trace<2030>::name("Vector_size1D"); +template <> std::string vampir_trace<2031>::name("Vector_size_runtime"); +template <> std::string vampir_trace<2032>::name("Vect_quicksort_lo_to_hi"); +template <> std::string vampir_trace<2033>::name("Vect_quicksort_permutaion_lo_to_hi"); +template <> std::string vampir_trace<2034>::name("split_complex_vector"); +template <> std::string vampir_trace<2035>::name("Vect_entries_sum"); +template <> std::string vampir_trace<2037>::name("Vector_const_trans"); +template <> std::string vampir_trace<2038>::name("Vector_trans"); +template <> std::string vampir_trace<2039>::name("vector::two_norm"); +template <> std::string vampir_trace<2040>::name("dot_simple"); +template <> std::string vampir_trace<2041>::name("unary_dot"); +template <> std::string vampir_trace<2042>::name("dense_vector::copy_ctor"); +template <> std::string vampir_trace<2043>::name("dense_vector::tpl_copy_ctor"); +template <> std::string vampir_trace<2044>::name(""); +template <> std::string vampir_trace<2045>::name(""); +template <> std::string vampir_trace<2046>::name(""); +template <> std::string vampir_trace<2047>::name(""); +template <> std::string vampir_trace<2048>::name(""); +template <> std::string vampir_trace<2049>::name(""); +template <> std::string vampir_trace<2050>::name(""); +template <> std::string vampir_trace<2051>::name(""); +template <> std::string vampir_trace<2052>::name(""); + + +// Matrix Vector & single matrix: 3000 +template <> std::string vampir_trace<3001>::name("matrix_copy_ele_times"); +template <> std::string vampir_trace<3002>::name("gen_matrix_copy"); +template <> std::string vampir_trace<3003>::name("copy"); +template <> std::string vampir_trace<3004>::name("clone"); +template <> std::string vampir_trace<3005>::name("compute_summand"); +template <> std::string vampir_trace<3006>::name("crop"); +template <> std::string vampir_trace<3007>::name("matrix::diagonal"); +template <> std::string vampir_trace<3008>::name("assign_each_nonzero"); +template <> std::string vampir_trace<3009>::name("fill"); +template <> std::string vampir_trace<3010>::name("frobenius_norm"); +template <> std::string vampir_trace<3011>::name("matrix::infinity_norm"); +template <> std::string vampir_trace<3012>::name("invert_diagonal"); +template <> std::string vampir_trace<3013>::name("iota"); +template <> std::string vampir_trace<3014>::name("left_scale_inplace"); +template <> std::string vampir_trace<3015>::name("matrix::look_at_each_nonzero"); +template <> std::string vampir_trace<3016>::name("matrix::look_at_each_nonzero_pos"); +template <> std::string vampir_trace<3017>::name("fsize_dense_mat_cvec_mult"); +template <> std::string vampir_trace<3018>::name("dense_mat_cvec_mult"); +template <> std::string vampir_trace<3019>::name("mvec_cvec_mult"); +template <> std::string vampir_trace<3020>::name("trans_mvec_cvec_mult"); +template <> std::string vampir_trace<3021>::name("herm_mvec_cvec_mult"); +template <> std::string vampir_trace<3022>::name("sparse_row_cvec_mult"); // generic row-major sparse +template <> std::string vampir_trace<3023>::name("ccs_cvec_mult"); +template <> std::string vampir_trace<3024>::name("matrix::max_abs_pos"); +template <> std::string vampir_trace<3025>::name("matrix::one_norm"); +template <> std::string vampir_trace<3026>::name("invert_diagonal(compressed)"); +template <> std::string vampir_trace<3027>::name("mat_vect_mult"); +template <> std::string vampir_trace<3028>::name("Vect_sparse_mat_mult"); +template <> std::string vampir_trace<3029>::name("Matrix_scal"); +template <> std::string vampir_trace<3030>::name("Vector_Secular_Equation"); +template <> std::string vampir_trace<3031>::name("Matrix_set_zero"); +template <> std::string vampir_trace<3032>::name("Matrix_size1D"); +template <> std::string vampir_trace<3033>::name("Matrix_size_runtime"); +template <> std::string vampir_trace<3034>::name("Matrix_LU"); +template <> std::string vampir_trace<3035>::name("Vector_Matrix_LU"); +template <> std::string vampir_trace<3036>::name("Sub_matrix_indices"); +template <> std::string vampir_trace<3037>::name("Matrix_svd_reference"); +template <> std::string vampir_trace<3038>::name("Matrix_svd_triplet"); +template <> std::string vampir_trace<3039>::name("Matrix_swapped"); +template <> std::string vampir_trace<3040>::name("Matrix_Trace"); +template <> std::string vampir_trace<3041>::name("Matrix_const_trans"); +template <> std::string vampir_trace<3042>::name("Matrix_trans"); +template <> std::string vampir_trace<3043>::name("Matrix_upper_trisolve"); +template <> std::string vampir_trace<3044>::name("Matrix_upper_trisolve_diagonal"); +template <> std::string vampir_trace<3045>::name("Matrix_upper_trisolve_invers_diag"); +template <> std::string vampir_trace<3046>::name("Matrix_upper_trisolve_DiaTag"); +template <> std::string vampir_trace<3047>::name("scalar_assign"); +template <> std::string vampir_trace<3048>::name("elest_cvec_mult"); +template <> std::string vampir_trace<3049>::name("crs_cvec_mult"); +template <> std::string vampir_trace<3050>::name("sparse_ins::ctor"); +template <> std::string vampir_trace<3051>::name("sparse_ins::dtor"); +template <> std::string vampir_trace<3052>::name("sparse_ins::stretch"); +template <> std::string vampir_trace<3053>::name("sparse_ins::final_place"); +template <> std::string vampir_trace<3054>::name("sparse_ins::insert_spare"); +template <> std::string vampir_trace<3055>::name("mat_crtp_scal_assign"); +template <> std::string vampir_trace<3056>::name("mat_crtp_mat_assign"); +template <> std::string vampir_trace<3057>::name("mat_crtp_sum_assign"); +template <> std::string vampir_trace<3058>::name("mat_crtp_diff_assign"); +template <> std::string vampir_trace<3059>::name("mat_crtp_array_assign"); +template <> std::string vampir_trace<3060>::name("mat_crtp_mvec_assign"); +template <> std::string vampir_trace<3061>::name("copy_band_to_sparse"); +template <> std::string vampir_trace<3062>::name("block_dia_times_cvec"); +template <> std::string vampir_trace<3063>::name("laplacian_setup"); +template <> std::string vampir_trace<3064>::name("vsmat_cvec_mult"); +template <> std::string vampir_trace<3065>::name("adapt_crs_cvec_mult"); +template <> std::string vampir_trace<3066>::name("dense2D_cvec_mult"); +template <> std::string vampir_trace<3067>::name("square_cvec_mult"); +template <> std::string vampir_trace<3068>::name("mat_cvec_multiplier"); +template <> std::string vampir_trace<3069>::name("sbanded_cvec_mult"); +template <> std::string vampir_trace<3070>::name(""); +template <> std::string vampir_trace<3071>::name(""); +template <> std::string vampir_trace<3072>::name(""); +template <> std::string vampir_trace<3073>::name(""); +template <> std::string vampir_trace<3074>::name(""); +template <> std::string vampir_trace<3075>::name(""); +template <> std::string vampir_trace<3076>::name(""); +template <> std::string vampir_trace<3077>::name(""); +template <> std::string vampir_trace<3078>::name(""); +template <> std::string vampir_trace<3079>::name(""); + + +// Matrix matrix operations: 4000 +template <> std::string vampir_trace<4001>::name("cursor_dmat_dmat_mult"); +template <> std::string vampir_trace<4002>::name("dmat_dmat_mult"); +template <> std::string vampir_trace<4003>::name("tiling_dmat_dmat_mult"); +template <> std::string vampir_trace<4004>::name("tiling_44_dmat_dmat_mult"); +template <> std::string vampir_trace<4005>::name("tiling_22_dmat_dmat_mult"); +template <> std::string vampir_trace<4006>::name("wrec_dmat_dmat_mult"); +template <> std::string vampir_trace<4007>::name("recursive_dmat_dmat_mult"); +template <> std::string vampir_trace<4008>::name("xgemm"); +template <> std::string vampir_trace<4009>::name(""); +template <> std::string vampir_trace<4010>::name("mult"); +template <> std::string vampir_trace<4011>::name("gen_mult"); +template <> std::string vampir_trace<4012>::name("mat_mat_mult"); +template <> std::string vampir_trace<4013>::name("matrix_qr"); +template <> std::string vampir_trace<4014>::name("matrix_qr_factors"); +template <> std::string vampir_trace<4015>::name("matrix_random"); +template <> std::string vampir_trace<4016>::name("matrix_scale_inplace"); +template <> std::string vampir_trace<4017>::name("matrix_rscale"); +template <> std::string vampir_trace<4018>::name("matrix_gen_smat_dmat_mult"); +template <> std::string vampir_trace<4019>::name("matrix_gen_tiling_smat_dmat_mult"); +template <> std::string vampir_trace<4020>::name("matrix_smat_smat_mult"); +template <> std::string vampir_trace<4021>::name(""); +template <> std::string vampir_trace<4022>::name(""); +template <> std::string vampir_trace<4023>::name(""); +template <> std::string vampir_trace<4024>::name(""); +template <> std::string vampir_trace<4025>::name(""); +template <> std::string vampir_trace<4026>::name(""); +template <> std::string vampir_trace<4027>::name(""); +template <> std::string vampir_trace<4028>::name(""); +template <> std::string vampir_trace<4029>::name(""); +template <> std::string vampir_trace<4030>::name(""); +template <> std::string vampir_trace<4031>::name(""); +template <> std::string vampir_trace<4032>::name(""); +template <> std::string vampir_trace<4033>::name(""); +template <> std::string vampir_trace<4034>::name(""); +template <> std::string vampir_trace<4035>::name(""); +template <> std::string vampir_trace<4036>::name("read_el_matrix"); +template <> std::string vampir_trace<4037>::name(""); +template <> std::string vampir_trace<4038>::name(""); +template <> std::string vampir_trace<4039>::name(""); +template <> std::string vampir_trace<4040>::name(""); +template <> std::string vampir_trace<4041>::name(""); + + +// Factorizations, preconditioners: 5000 +template <> std::string vampir_trace<5001>::name("cholesky_base"); +template <> std::string vampir_trace<5002>::name("cholesky_solve_base"); +template <> std::string vampir_trace<5003>::name("cholesky_schur_base"); +template <> std::string vampir_trace<5004>::name("cholesky_update_base"); +template <> std::string vampir_trace<5005>::name("cholesky_schur_update"); +template <> std::string vampir_trace<5006>::name("cholesky_tri_solve"); +template <> std::string vampir_trace<5007>::name("cholesky_tri_schur"); +template <> std::string vampir_trace<5008>::name("recursive cholesky"); +template <> std::string vampir_trace<5009>::name("fill_matrix_for_cholesky"); +template <> std::string vampir_trace<5010>::name("qr_sym_imp"); +template <> std::string vampir_trace<5011>::name("qr_algo"); +template <> std::string vampir_trace<5012>::name("eigenvalue_symmetric"); +template <> std::string vampir_trace<5013>::name("hessenberg_q"); +template <> std::string vampir_trace<5014>::name("hessenberg_factors"); +template <> std::string vampir_trace<5015>::name("extract_householder_hessenberg"); +template <> std::string vampir_trace<5016>::name("householder_hessenberg"); +template <> std::string vampir_trace<5017>::name("extract_hessenberg"); +template <> std::string vampir_trace<5018>::name("hessenberg"); +template <> std::string vampir_trace<5019>::name("inv_upper"); +template <> std::string vampir_trace<5020>::name("inv_lower"); +template <> std::string vampir_trace<5021>::name("inv"); +template <> std::string vampir_trace<5022>::name("lower_trisolve"); +template <> std::string vampir_trace<5023>::name("lu"); +template <> std::string vampir_trace<5024>::name("lu(pivot)"); +template <> std::string vampir_trace<5025>::name("lu_f"); +template <> std::string vampir_trace<5026>::name("lu_solve_straight"); +template <> std::string vampir_trace<5027>::name("lu_apply"); +template <> std::string vampir_trace<5028>::name("lu_solve"); +template <> std::string vampir_trace<5029>::name("lu_adjoint_apply"); +template <> std::string vampir_trace<5030>::name("lu_adjoint_solve"); +template <> std::string vampir_trace<5031>::name("pc::id::solve"); +template <> std::string vampir_trace<5032>::name("pc::id.solve"); +template <> std::string vampir_trace<5033>::name("pc::id::adjoint_solve"); +template <> std::string vampir_trace<5034>::name("pc::id.adjoint_solve"); +template <> std::string vampir_trace<5035>::name("ic_0::factorize"); +template <> std::string vampir_trace<5036>::name("ic_0::solve"); +template <> std::string vampir_trace<5037>::name("ic_0::solve_nocopy"); +template <> std::string vampir_trace<5038>::name("ilu_0::factorize"); +template <> std::string vampir_trace<5039>::name("ilu_0::solve"); +template <> std::string vampir_trace<5040>::name("ilu_0::adjoint_solve"); +template <> std::string vampir_trace<5041>::name("lower_trisolve_kernel"); +template <> std::string vampir_trace<5042>::name("upper_trisolve_row"); +template <> std::string vampir_trace<5043>::name("upper_trisolve_col"); +template <> std::string vampir_trace<5044>::name("ic_0::adjoint_solve"); +template <> std::string vampir_trace<5045>::name("ic_0::adjoint_solve_nocopy"); +template <> std::string vampir_trace<5046>::name("upper_trisolve_crs_compact"); +template <> std::string vampir_trace<5047>::name("lower_trisolve_crs_compact"); +template <> std::string vampir_trace<5048>::name("lower_unit_trisolve_crs_compact"); +template <> std::string vampir_trace<5049>::name("ilut::factorize"); +template <> std::string vampir_trace<5050>::name("diagonal::setup"); +template <> std::string vampir_trace<5051>::name("diagonal::solve"); +template <> std::string vampir_trace<5052>::name("imf::factor"); +template <> std::string vampir_trace<5053>::name("imf::ctor"); +template <> std::string vampir_trace<5054>::name("imf::solve"); +template <> std::string vampir_trace<5055>::name("pc::solver::assign_to"); +template <> std::string vampir_trace<5056>::name("sub_matrix_pc::solve"); +template <> std::string vampir_trace<5057>::name("sub_matrix_pc::adjoint_solve"); +template <> std::string vampir_trace<5058>::name("pc::concat::solve"); +template <> std::string vampir_trace<5059>::name("pc::concat::adjoint_solve"); +template <> std::string vampir_trace<5060>::name("umfpack::solver::ctor"); +template <> std::string vampir_trace<5061>::name("umfpack::solver::dtor"); +template <> std::string vampir_trace<5062>::name("umfpack::solve"); + + +// Fused operations: 6000 +template <> std::string vampir_trace<6001>::name("fused::fwd_eval_loop"); +template <> std::string vampir_trace<6002>::name("fused::fwd_eval_loop_unrolled"); +template <> std::string vampir_trace<6003>::name("fused::bwd_eval_loop"); +template <> std::string vampir_trace<6004>::name("fused::bwd_eval_loop_unrolled"); + + + +// Iterative solvers: 7000 +template <> std::string vampir_trace<7001>::name("cg_without_pc"); +template <> std::string vampir_trace<7002>::name("cg"); +template <> std::string vampir_trace<7003>::name("bicg"); +template <> std::string vampir_trace<7004>::name("bicgstab"); +template <> std::string vampir_trace<7005>::name("bicgstab_2"); +template <> std::string vampir_trace<7006>::name("bicgstab_ell"); +template <> std::string vampir_trace<7007>::name("cgs"); +template <> std::string vampir_trace<7008>::name("qmr"); +template <> std::string vampir_trace<7009>::name("tfqmr"); +template <> std::string vampir_trace<7010>::name("idr_s"); + + +// OpenMP +template <> std::string vampir_trace<8001>::name("omp::dot"); +template <> std::string vampir_trace<8002>::name("omp::reduction"); +template <> std::string vampir_trace<8003>::name("omp::dyn_vec_expr"); +template <> std::string vampir_trace<8004>::name("omp::crs_cvec_mult"); + + + +// multigrid +template <> std::string vampir_trace<8501>::name("mtl::mg::v_cycle"); +template <> std::string vampir_trace<8502>::name("mtl::mg::w_cycle"); +template <> std::string vampir_trace<8503>::name("mtl::mg::fmg"); +template <> std::string vampir_trace<8504>::name("mtl::mg::two_grid_cycle"); + +template <> std::string vampir_trace<8510>::name("mtl::mg::geometric_multigrid_solver_impl"); +template <> std::string vampir_trace<8511>::name("mtl::mg::geometric_multigrid_solver_solve1"); +template <> std::string vampir_trace<8512>::name("mtl::mg::geometric_multigrid_solver_solve2"); + +template <> std::string vampir_trace<8515>::name("mtl::mg::algebraic_multigrid_solver"); +template <> std::string vampir_trace<8516>::name("amg_pc::solve"); + +template <> std::string vampir_trace<8520>::name("mtl::mg::linear_restriction"); +template <> std::string vampir_trace<8521>::name("mtl::mg::linear_prolongation"); + +template <> std::string vampir_trace<8530>::name("mtl::mg::gauss_elimination"); +template <> std::string vampir_trace<8531>::name("mtl::mg::back_substitution"); + +template <> std::string vampir_trace<8550>::name("mtl::mg::jacobi"); +template <> std::string vampir_trace<8551>::name("mtl::mg::gauss_seidel"); +template <> std::string vampir_trace<8552>::name("mtl::mg::jor"); +template <> std::string vampir_trace<8553>::name("mtl::mg::sor"); + +template <> std::string vampir_trace<8572>::name("boundaries"); +template <> std::string vampir_trace<8573>::name("viscosity"); +template <> std::string vampir_trace<8574>::name("pressure_correction"); + +template <> std::string vampir_trace<8590>::name("mtl::mg::util::vtk_exporter"); +template <> std::string vampir_trace<8591>::name("mtl::mg::util::csv_exporter"); + +template <> std::string vampir_trace<8610>::name("amg::amg_matrix_hierarchy"); +template <> std::string vampir_trace<8611>::name("amg::compute_influence"); +template <> std::string vampir_trace<8612>::name("amg::default_coarse_grid_detection::compute_C"); +template <> std::string vampir_trace<8614>::name("amg::utils::compute_potentials"); +template <> std::string vampir_trace<8615>::name("amg::utils::find_max_pos"); + +template <> std::string vampir_trace<8617>::name("amg::amg_prolongation"); +template <> std::string vampir_trace<8618>::name("amg::compute_weight"); +template <> std::string vampir_trace<8619>::name("amg::compute_mfactors"); + +template <> std::string vampir_trace<8620>::name("amg::strongly_influenced_points"); +template <> std::string vampir_trace<8621>::name("amg::is_strongly_influenced"); +template <> std::string vampir_trace<8622>::name("amg::strongly_influencing_points"); + +template <> std::string vampir_trace<8630>::name("amg::amg_operators::amg_restriction"); +template <> std::string vampir_trace<8631>::name("amg::amg_operators::amg_prolongation"); +template <> std::string vampir_trace<8635>::name("amg::amg_operators::amg_weight"); + +template <> std::string vampir_trace<8900>::name("NaSto::solve()"); +template <> std::string vampir_trace<8910>::name("NaSto::computeGamma()"); +template <> std::string vampir_trace<8920>::name("NaSto::computeBoundaries()"); +template <> std::string vampir_trace<8930>::name("NaSto::computeImplViscosity()"); +template <> std::string vampir_trace<8940>::name("NaSto::computePressureCorr()"); + +// Test blocks for performance debugging +template <> std::string vampir_trace<9901>::name("tb1"); +template <> std::string vampir_trace<9902>::name("tb2"); +template <> std::string vampir_trace<9903>::name("tb3"); +template <> std::string vampir_trace<9904>::name("tb4"); +template <> std::string vampir_trace<9999>::name("main"); + + +// Only for testing +template <> std::string vampir_trace<9990>::name("helper_function"); +template <> std::string vampir_trace<9991>::name("function"); + + + +}} //mtl::vpt + +#endif //MTL_HAS_VPT diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/interface/vpt.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/interface/vpt.hpp new file mode 100644 index 0000000000000000000000000000000000000000..a1838bcc78baf23f0db65df01ccf4d3dbf464943 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/interface/vpt.hpp @@ -0,0 +1,94 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_VPT_VPT_INCLUDE +#define MTL_VPT_VPT_INCLUDE + +#ifdef MTL_HAS_VPT + #include <vt_user.h> + #include <boost/mpl/bool.hpp> +#endif + +#include <math.h> +#include <string> + +namespace mtl { + +/// Namespace for Vampir Trace interface +namespace vpt { + +#ifdef MTL_HAS_VPT + +#ifndef MTL_VPT_LEVEL +# define MTL_VPT_LEVEL 2 +#endif + +/// Class for Vampir Trace +template <int N> +class vampir_trace +{ + // Statically determine whether the event is traced; just in case you wanted to know how. + typedef boost::mpl::bool_<(MTL_VPT_LEVEL * 1000 < N)> to_print; + public: + /// Default constructor defines the start point of a trace + vampir_trace() { entry(to_print()); } + + void entry(boost::mpl::false_) {} + void entry(boost::mpl::true_) + { + VT_USER_START(name.c_str()); + // std::cout << "vpt_entry(" << N << ")\n"; + } + + /// Destructor defines the end point of a trace + ~vampir_trace() { end(to_print()); } + + void end(boost::mpl::false_) {} + void end(boost::mpl::true_) + { + VT_USER_END(name.c_str()); + // std::cout << "vpt_end(" << N << ")\n"; + } + + /// Function to check whether this event is traced with the current setting + bool is_traced() { return to_print::value; } + + private: + static std::string name; +}; + + +#else + +// Dummy when Vampir Trace is not supported +template <int N> +class vampir_trace +{ + public: + vampir_trace() {} + void show_vpt_level() {} + bool is_traced() { return false; } + private: + static std::string name; +}; +#endif + + // names defined in vpt.cpp !!! + +} // namespace vpt + +/// Import of vpt::vampir_trace +using vpt::vampir_trace; + +} // namespace mtl + +#endif // MTL_VPT_VPT_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/interfaces.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/interfaces.hpp new file mode 100644 index 0000000000000000000000000000000000000000..b709dda92d8fa4b97a2985adb95ffcf19491d4a6 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/interfaces.hpp @@ -0,0 +1,18 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_INTERFACES_INCLUDE +#define MTL_INTERFACES_INCLUDE + +#include <boost/numeric/mtl/interface/vpt.hpp> + +#endif // MTL_INTERFACES_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/io/functor_symbol.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/io/functor_symbol.hpp new file mode 100644 index 0000000000000000000000000000000000000000..b66fe3a6462859944c43e161888516d5eff23173 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/io/functor_symbol.hpp @@ -0,0 +1,90 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_IO_FUNCTOR_SYMBOL_INCLUDE +#define MTL_IO_FUNCTOR_SYMBOL_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> + +namespace mtl { namespace io { + +template <typename Value> +std::string functor_symbol(const sfunctor::conj<Value>&) +{ return "conj"; } + +template <typename Value> +std::string functor_symbol(const sfunctor::imag<Value>&) +{ return "imag"; } + +template <typename Value> +std::string functor_symbol(const sfunctor::real<Value>&) +{ return "real"; } + +template <typename Value> +std::string functor_symbol(const sfunctor::identity<Value>&) +{ return "identity"; } + +template <typename Value> +std::string functor_symbol(const sfunctor::abs<Value>&) +{ return "abs"; } + +template <typename Value> +std::string functor_symbol(const sfunctor::sqrt<Value>&) +{ return "sqrt"; } + +template <typename Value> +std::string functor_symbol(const sfunctor::square<Value>&) +{ return "square"; } + +template <typename Value> +std::string functor_symbol(const sfunctor::negate<Value>&) +{ return "-"; } + +template <typename Value1, typename Value2> +std::string functor_symbol(const sfunctor::minus<Value1, Value2>&) +{ return "-"; } + +template <typename Value1, typename Value2> +std::string functor_symbol(const sfunctor::plus<Value1, Value2>&) +{ return "+"; } + +template <typename Value1, typename Value2> +std::string functor_symbol(const sfunctor::times<Value1, Value2>&) +{ return "*"; } + +template <typename Value1, typename Value2> +std::string functor_symbol(const sfunctor::divide<Value1, Value2>&) +{ return "/"; } + +template <typename Value1, typename Value2> +std::string functor_symbol(const sfunctor::assign<Value1, Value2>&) +{ return "="; } + +template <typename Value1, typename Value2> +std::string functor_symbol(const sfunctor::plus_assign<Value1, Value2>&) +{ return "+="; } + +template <typename Value1, typename Value2> +std::string functor_symbol(const sfunctor::minus_assign<Value1, Value2>&) +{ return "-="; } + +template <typename Value1, typename Value2> +std::string functor_symbol(const sfunctor::times_assign<Value1, Value2>&) +{ return "*="; } + +template <typename Value1, typename Value2> +std::string functor_symbol(const sfunctor::divide_assign<Value1, Value2>&) +{ return "/="; } + +}} // namespace mtl::io + +#endif // MTL_IO_FUNCTOR_SYMBOL_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/io/matrix_file.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/io/matrix_file.hpp new file mode 100644 index 0000000000000000000000000000000000000000..cd0b2763d4c81ca51632bed3b62a455debff4ad6 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/io/matrix_file.hpp @@ -0,0 +1,41 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_IO_MATRIX_FILE_INCLUDE +#define MTL_IO_MATRIX_FILE_INCLUDE + +namespace mtl { namespace io { + +template <typename MatrixIFStream, typename MatrixOFStream> +class matrix_file +{ + public: + explicit matrix_file(const std::string& fname) : fname(fname) {} + explicit matrix_file(const char* fname) : fname(fname) {} + + std::string file_name() const { return fname; } + + template <typename Collection> + matrix_file& operator=(const Collection& c) + { + MatrixOFStream stream(fname); + stream << c; + return *this; + } + + protected: + std::string fname; +}; + +}} // namespace mtl::io + +#endif // MTL_IO_MATRIX_FILE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/io/matrix_market.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/io/matrix_market.hpp new file mode 100644 index 0000000000000000000000000000000000000000..6aa60fedb16aee7fefcea2f0093a9e3c3485138f --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/io/matrix_market.hpp @@ -0,0 +1,335 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_IO_MATRIX_MARKET_INCLUDE +#define MTL_IO_MATRIX_MARKET_INCLUDE + +#include <string> +#include <fstream> +#include <iostream> +#include <limits> +#include <locale> +#include <complex> + +#include <boost/utility/enable_if.hpp> +#include <boost/type_traits/is_floating_point.hpp> +#include <boost/type_traits/is_integral.hpp> +// #include <boost/algorithm/string/case_conv.hpp> +#include <boost/numeric/conversion/cast.hpp> + +#include <boost/numeric/mtl/io/matrix_file.hpp> +#include <boost/numeric/mtl/io/read_filter.hpp> +#include <boost/numeric/mtl/utility/property_map.hpp> +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/utility/string_to_enum.hpp> +#include <boost/numeric/mtl/matrix/inserter.hpp> +#include <boost/numeric/mtl/operation/set_to_zero.hpp> + +namespace mtl { namespace io { + + +/// Input file stream for files in matrix market format +class matrix_market_istream +{ + class pattern_type {}; + typedef matrix_market_istream self; + void check_stream(const std::string& file_name= std::string()) // not const to delete new_stream + { + if (!my_stream.good()) { + std::string message("matrix_market_istream: Error in input stream!\n"); + if (file_name != std::string()) + message+= "Probably file " + file_name + " not found.\n"; + std::cerr << message; + if (new_stream) + delete new_stream, new_stream= 0; // To get valgrind quite + throw(file_not_found(message.c_str())); + } + } + + public: + explicit matrix_market_istream(const char* p) : new_stream(new std::ifstream(p)), my_stream(*new_stream) { check_stream(p); } + explicit matrix_market_istream(const std::string& s) : new_stream(new std::ifstream(s.c_str())), my_stream(*new_stream) { check_stream(s); } + explicit matrix_market_istream(std::istream& s= std::cin) : new_stream(0), my_stream(s) { check_stream(); } + + ~matrix_market_istream() + { if (new_stream) delete new_stream; } + + template <typename Coll> + self& operator>>(Coll& c) + { return read(c, typename mtl::traits::category<Coll>::type()); } + + /// Close only my own file, i.e. if filename and not stream is passed in constructor + void close() { if (new_stream) new_stream->close(); } + + protected: + template <typename Matrix> self& read(Matrix& A, tag::matrix); + + void to_lower(std::string& s) const + { + using namespace std; + for (unsigned i= 0; i < s.size(); i++) + s[i]= tolower(s[i]); + } + + void set_symmetry(std::string& symmetry_text) + { + to_lower(symmetry_text); + const char* symmetry_options[]= {"general", "symmetric", "skew-symmetric", "hermitian"}; + my_symmetry= string_to_enum(symmetry_text, symmetry_options, symmetry()); + } + + void set_sparsity(std::string& sparsity_text) + { + to_lower(sparsity_text); + const char* sparsity_options[]= {"coordinate", "array"}; + my_sparsity= string_to_enum(sparsity_text, sparsity_options, sparsity()); + } + + template <typename Inserter, typename Value> + void read_matrix(Inserter& ins, Value) + { + typedef typename Collection<typename Inserter::matrix_type>::size_type size_type; + read_filter<Inserter> filter(ins); + if (my_sparsity == coordinate) // sparse + // while (my_stream) { // sometimes does an extra erroneous loop + for (std::size_t i= 0; i < nnz; i++) { + size_type r, c; + my_stream >> r >> c; + if (!my_stream) break; // in case while(my_stream) caught an empty line at the end + insert_value(ins, r-1, c-1, filter, Value()); + } + else // dense + for (std::size_t c= 0; c < ncols; c++) + for (std::size_t r= 0; r < nrows; r++) + insert_value(ins, r, c, filter, Value()); + } + + template <typename Inserter, typename Filter, typename Value> + void insert_value(Inserter& ins, std::size_t r, std::size_t c, const Filter& filter, Value) + { + using mtl::conj; + typedef typename Collection<typename Inserter::matrix_type>::value_type mvt; + Value v; + read_value(v); + // std::cout << "Going to insert at [" << r << "][" << c << "] value " << which_value(v, mvt()) << "\n"; + if (filter(r, c)) + ins[r][c] << which_value(v, mvt()); + if (r != c && filter(c, r)) + switch(my_symmetry) { + case symmetric: ins[c][r] << which_value(v, mvt()); break; + case skew: ins[c][r] << -which_value(v, mvt()); break; + case Hermitian: ins[c][r] << conj(which_value(v, mvt())); break; + default: ; // do nothing + } + } + + void read_value(pattern_type) {} + void read_value(double& v) { my_stream >> v;} + void read_value(long& v) { my_stream >> v;} + void read_value(std::complex<double>& v) + { + double r, i; my_stream >> r >> i; v= std::complex<double>(r, i); + } + + // Which value to be inserted? Itself if exist and 0 for pattern; complex are + template <typename Value, typename MValue> MValue which_value(Value v, MValue) { return boost::numeric_cast<MValue>(v); } + template <typename MValue> MValue which_value(pattern_type, MValue) { return boost::numeric_cast<MValue>(0.0); } + template <typename MValue> MValue which_value(std::complex<double>, MValue) { MTL_THROW(runtime_error("Cannot convert complex value in real\n")); return 1; } + std::complex<long double> which_value(std::complex<double> v, std::complex<long double>) { return boost::numeric_cast<std::complex<long double> >(v); } + std::complex<double> which_value(std::complex<double> v, std::complex<double>) { return v; } + std::complex<float> which_value(std::complex<double> v, std::complex<float>) { return std::complex<float>(float(real(v)), float(imag(v))); } + + std::ifstream *new_stream; + std::istream &my_stream; + enum symmetry {general, symmetric, skew, Hermitian} my_symmetry; + enum sparsity {coordinate, array} my_sparsity; + std::size_t nrows, ncols, nnz; +}; + + + +// Matrix version +template <typename Matrix> +matrix_market_istream& matrix_market_istream::read(Matrix& A, tag::matrix) +{ + std::string marker, type, sparsity_text, value_format, symmetry_text; + my_stream >> marker >> type >> sparsity_text >> value_format >> symmetry_text; +#if 0 + std::cout << marker << ", " << type << ", " << sparsity_text << ", " + << value_format << ", " << symmetry_text << "\n"; +#endif + MTL_THROW_IF(marker != std::string("%%MatrixMarket"), + runtime_error("File not in Matrix Market format")); + MTL_THROW_IF(type != std::string("matrix"), + runtime_error("Try to read matrix from non-matrix file")); + + set_symmetry(symmetry_text); + set_sparsity(sparsity_text); + + char first, comment[80]; + do { + my_stream >> first; + if (first == '%') // comments start with % -> ignore them + my_stream.getline(comment, 80, '\n'); // read rest of line + else + my_stream.putback(first); // if not commment we still need it + } while (first == '%'); + + my_stream >> nrows >> ncols; + // std::cout << nrows << "x" << ncols << ", " << nnz << " non-zeros\n"; + A.change_dim(nrows, ncols); + set_to_zero(A); + + std::size_t slot_size; + if (sparsity_text == std::string("coordinate")) { + my_stream >> nnz; slot_size= std::max(std::size_t(double(nnz) / double(A.dim1()) * 1.25), std::size_t(1)); + } else + slot_size= A.dim2(); // maximal value (if A is dense it does not matter anyway) + + // Create enough space in sparse matrices + matrix::inserter<Matrix> ins(A, slot_size); + + if (value_format == std::string("real")) + read_matrix(ins, double()); + else if (value_format == std::string("integer")) + read_matrix(ins, long()); + else if (value_format == std::string("complex")) + read_matrix(ins, std::complex<double>()); + else if (value_format == std::string("pattern")) + read_matrix(ins, pattern_type()); + else + MTL_THROW(runtime_error("Unknown tag for matrix value type in file")); + + return *this; +} + + +class matrix_market_ostream +{ + typedef matrix_market_ostream self; +public: + explicit matrix_market_ostream(const char* p) : new_stream(new std::ofstream(p)), my_stream(*new_stream) {} + explicit matrix_market_ostream(const std::string& s) : new_stream(new std::ofstream(s.c_str())), my_stream(*new_stream) {} + explicit matrix_market_ostream(std::ostream& s= std::cout) : new_stream(0), my_stream(s) {} + + ~matrix_market_ostream() { if (new_stream) delete new_stream; } + + template <typename Coll> + self& operator<<(const Coll& c) + { + return write(c, typename mtl::traits::category<Coll>::type()); + } + + /// Close only my own file, i.e. if filename and not stream is passed in constructor + void close() { if (new_stream) new_stream->close(); } + +private: + template <typename Matrix> self& write(const Matrix& A, tag::matrix) + { + matrix_status_line(A); + if (sparsity(A) == std::string("coordinate ")) + return write_sparse_matrix(A); + else + return write_dense_matrix(A); + } + + template <typename Matrix> self& write_sparse_matrix(const Matrix& A) + { + my_stream << num_rows(A) << " " << num_cols(A) << " " << A.nnz() << "\n"; + + typename mtl::traits::row<Matrix>::type row(A); + typename mtl::traits::col<Matrix>::type col(A); + typename mtl::traits::const_value<Matrix>::type value(A); + typedef typename mtl::traits::range_generator<tag::major, Matrix>::type cursor_type; + typedef typename mtl::traits::range_generator<tag::nz, cursor_type>::type icursor_type; + + for (cursor_type cursor = begin<tag::major>(A), cend = end<tag::major>(A); cursor != cend; ++cursor) + for (icursor_type icursor = begin<tag::nz>(cursor), icend = end<tag::nz>(cursor); icursor != icend; ++icursor) + my_stream << row(*icursor)+1 << " " << col(*icursor)+1 << " ", write_value(value(*icursor)), my_stream << "\n"; + return *this; + } + + template <typename Matrix> self& write_dense_matrix(const Matrix& A) + { + my_stream << num_rows(A) << " " << num_cols(A) << "\n"; + for (std::size_t c = 0; c < num_cols(A); ++c) + for (std::size_t r = 0; r < num_rows(A); ++r) { + write_value(A[r][c]), my_stream << " "; + my_stream << "\n"; + } + return *this; + } + + template <typename Value> + typename boost::enable_if<boost::is_integral<Value> >::type + write_value(const Value& v) { my_stream << v; } + + template <typename Value> + typename boost::enable_if<boost::is_floating_point<Value> >::type + write_value(const Value& v) + { + my_stream.precision(std::numeric_limits<Value>::digits10 + 1); + my_stream.setf(std::ios::scientific); + my_stream << v; + my_stream.unsetf(std::ios::scientific); + } + + template <typename Value> + void write_value(const std::complex<Value>& v) + { + my_stream.precision(std::numeric_limits<Value>::digits10 + 1); + my_stream.setf(std::ios::scientific); + my_stream << real(v) << " " << imag(v); + my_stream.unsetf(std::ios::scientific); + } + + // Will be generalized via traits::is_symmetric and alike + template <typename Matrix> + std::string symmetry(const Matrix&) const { return std::string("general\n"); } + + template <typename Matrix> + std::string sparsity(const Matrix&) const + { + return std::string( mtl::traits::is_sparse<Matrix>::value ? "coordinate " : "array " ); + } + + template <typename Value> + typename boost::enable_if<boost::is_integral<Value>, std::string>::type + value(const Value&) const { return std::string("integer "); } + + template <typename Value> + typename boost::enable_if<boost::is_floating_point<Value>, std::string>::type + value(const Value&) const { return std::string("real "); } + + template <typename Value> + std::string value(const std::complex<Value>&) const { return std::string("complex "); } + + template <typename Matrix> + void matrix_status_line(const Matrix& A) const + { + typedef typename Collection<Matrix>::value_type value_type; + std::string st(std::string("%%MatrixMarket matrix ") + sparsity(A) + value(value_type()) + symmetry(A)); + my_stream << st; + } + +protected: + std::ofstream *new_stream; + std::ostream &my_stream; +}; + + +}} // namespace mtl::io + +#endif // MTL_IO_MATRIX_MARKET_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/io/path.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/io/path.hpp new file mode 100644 index 0000000000000000000000000000000000000000..d0bedc07b3dc7d12d90ef7b6e218239552a8cbb8 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/io/path.hpp @@ -0,0 +1,54 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_IO_PATH_INCLUDE +#define MTL_IO_PATH_INCLUDE + +namespace mtl { namespace io { + +#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) + const static char delim = '\\'; +#else + const static char delim = '/'; +#endif + +/// Join the directory and file +/** It concatenates both with the os-specific slash unless directory is empty, then only file is returned **/ +std::string inline join(std::string directory, std::string file) +{ + return directory.empty() ? file : directory + delim + file; +} + +/// Directory name in s that is everything before last slash +std::string inline directory_name(std::string s) +{ + for (int i= s.size() - 1; i >= 0; i--) + if (s[i] == delim) + return s.substr(0, i); + return std::string(); +} + +/// File name in s that is everything after last slash +std::string inline file_name(std::string s) +{ + for (int i= s.size() - 1; i >= 0; i--) + if (s[i] == delim) + return s.substr(i + 1); + return s; +} + + + + +}} // namespace mtl::io + +#endif // MTL_IO_PATH_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/io/read_el_matrix.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/io/read_el_matrix.hpp new file mode 100644 index 0000000000000000000000000000000000000000..9ec4f186a33312a58c840d08d4ffcdcd9033b32d --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/io/read_el_matrix.hpp @@ -0,0 +1,165 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. +// +// Algorithm inspired by Nick Vannieuwenhoven, written by Cornelius Steinhardt + +#ifndef MTL_MATRIX_READ_EL_MATRIX +#define MTL_MATRIX_READ_EL_MATRIX + +#include <string> + +#include <iostream> +#include <istream> +#include <set> +#include <vector> +#include <valarray> + +#include <boost/numeric/mtl/interface/vpt.hpp> +#include <boost/numeric/mtl/matrix/element.hpp> +#include <boost/numeric/mtl/matrix/element_structure.hpp> + +namespace mtl { namespace matrix { + +// Read a value from the stream. The stream is advanced. +template <class T, class StreamType> +inline T read_value(StreamType& stream) +{ + T value; + stream >> value; + return value; +} + +// Reads the element structure from a given file. +// +// It is assumed the nodes are numbered consecutively, i.e. there are no unused +// node numbers. +template < typename StreamType, typename ValueType> +void read_el_matrix(StreamType& file, element_structure<ValueType>& A) +{ + // Type definitions + typedef element<ValueType> element_type; + // typedef typename element_type::value_type value_type; + typedef typename element_type::index_type indices; + typedef typename element_type::matrix_type matrix; + vampir_trace<4036> trace; + + // Read element type information. + int nb_elements = 0; + file >> nb_elements; + file.ignore(500,'\n'); + std::cout << "nb elements: " << nb_elements << "\n"; + + // Compatibility with older files + file.ignore(500,'\n'); + + assert(nb_elements >= 0); + + element_type* elements = new element_type[nb_elements]; + + // Read elements from file. + int el_nbr = 0; + int nb_total_vars = 0; + while( el_nbr < nb_elements ) { + + // Read the node numbers. + std::string line; + getline(file, line, '\n'); + std::stringstream node_line(line), read_node_line(line); + + int read_num=0, i=0; + while( !read_node_line.eof() ) { + int idx = 0; + read_node_line >> idx; + ++read_num; + } + read_num--; + mtl::vector::dense_vector<int> nodes(read_num, 0); + while( !node_line.eof() ) { + int idx = 0; + node_line >> idx; + if (i<read_num) + nodes[i]=idx; + if(idx > nb_total_vars) + nb_total_vars = idx; + i++; + } + indices index(nodes); + // Read the values. + const int nb_vars = int(size(nodes)); + matrix vals(nb_vars, nb_vars); + for(int i = 0; i < nb_vars*nb_vars; ++i) + vals(i / nb_vars, i % nb_vars) = read_value<ValueType>(file); + file.ignore(500,'\n'); + file.ignore(500,'\n'); + element_type elem(el_nbr, index, vals); + elements[el_nbr] = elem; + if(el_nbr == 0){ + std::cout<< "elem=" << elem << "\n"; + } + ++el_nbr; + } + + // Construct mapping. + ++nb_total_vars; + assert(nb_total_vars >= 0); + std::vector<int>* node_element_map = new std::vector<int>[nb_total_vars]; + for( int i = 0; i < nb_elements; ++i ) { + element_type& el = elements[i]; + indices& idx = el.get_indices(); + for(int j = 0; j < el.nb_vars(); ++j) + node_element_map[ idx(j) ].push_back(el.get_id()); + } + + // Construct neighborhood information. + for( int i = 0; i < nb_elements; ++i ) { + element_type& el = elements[i]; + indices& idx = el.get_indices(); + std::set<int> neighs; + for(int j = 0; j < el.nb_vars(); ++j) + neighs.insert(node_element_map[ idx(j) ].begin(), + node_element_map[ idx(j) ].end()); + + for(std::set<int>::iterator it = neighs.begin(); it != neighs.end(); ++it) + if( *it != el.get_id() ) + el.get_neighbors().push_back( elements+(*it) ); + + + // Sort data. + el.sort_indices(); + } + + delete[] node_element_map; + A.consume(nb_elements, nb_total_vars, elements); +} + +template <typename ValueType> +inline void read_el_matrix(std::string& mat_file, element_structure<ValueType>& A) +{ read_el_matrix(mat_file.c_str(), A); } + +template <typename ValueType> +void read_el_matrix(const char* mat_file, element_structure<ValueType>& A) +{ + std::ifstream file; + file.open( mat_file ); + if( !file.is_open() ) { + std::cout << "The file \"" << mat_file << "\" could not be opened." << + std::endl; + throw "File could not be opened"; + } + read_el_matrix(file, A); + + file.close(); +} + +}} // end namespace mtl::matrix + +#endif // MTL_MATRIX_READ_EL_MATRIX diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/io/read_filter.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/io/read_filter.hpp new file mode 100644 index 0000000000000000000000000000000000000000..960bc0529f044e60c2843039e5f6366090b4e61b --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/io/read_filter.hpp @@ -0,0 +1,42 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_IO_READ_FILTER_INCLUDE +#define MTL_IO_READ_FILTER_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> + +namespace mtl { namespace io { + +/// Utility to filter entries in the read process +/** Depending on type only certain entries are considered for insertion. + Particularly interesting for distributed collections (inserters). **/ +template <typename Inserter> +class read_filter +{ + public: + explicit read_filter(const Inserter& inserter) : inserter(inserter) {} + + /// Default for vectors is to consider every entry + bool operator()(std::size_t) const { return true; } + + /// Default for matrices is to consider every entry + bool operator()(std::size_t, std::size_t) const { return true; } + + private: + const Inserter& inserter; +}; + + +}} // namespace mtl::io + +#endif // MTL_IO_READ_FILTER_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/io/test_ostream.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/io/test_ostream.hpp new file mode 100644 index 0000000000000000000000000000000000000000..ec2b57ec589791150f13f24e5cb370d6a5620f6e --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/io/test_ostream.hpp @@ -0,0 +1,69 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_TEST_OSTREAM_INCLUDE +#define MTL_TEST_OSTREAM_INCLUDE + +#include <ostream> + +namespace mtl { namespace io { + +/// ostream class whose objects only write if MTL_VERBOSE_TEST is defined +struct test_ostream +{ +#ifdef MTL_VERBOSE_TEST + + /// Constructor for out or std::cout + test_ostream(std::ostream& out = std::cout) : out(out) {} + + + template <typename T> + test_ostream& operator<<(const T& v) + { + out << v; + return *this; + } + + test_ostream& operator<<(test_ostream& (*pf)(test_ostream&)) + { return pf(*this); } + + void flush() { out.flush(); } + +private: + std::ostream& out; + +#else + test_ostream() {} + test_ostream(std::ostream&) {} + + /// Print on outstream + template <typename T> test_ostream& operator<<(const T&) { return *this; } + + /// Interface for manipulators + test_ostream& operator<<(test_ostream& (*)(test_ostream&)) { return *this; } + + /// Flush output + void flush() {} +#endif +}; + +/// Output stream that writes if MTL_VERBOSE_TEST is defined +static test_ostream tout; + +}} // namespace mtl::io + +namespace std { + inline mtl::io::test_ostream& endl(mtl::io::test_ostream& os) { os << '\n'; os.flush(); return os; } +} + + +#endif // MTL_TEST_OSTREAM_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/io/write_ast.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/io/write_ast.hpp new file mode 100644 index 0000000000000000000000000000000000000000..6b30c89c3ba3ad00c826c18ab60b6f90ea36dcc5 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/io/write_ast.hpp @@ -0,0 +1,35 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_IO_WRITE_AST_INCLUDE +#define MTL_IO_WRITE_AST_INCLUDE + +#include <fstream> +#include <boost/numeric/mtl/io/write_ast_dispatch.hpp> + +namespace mtl { namespace io { + +/// write the abstract syntax tree (AST) to file name \p fname +template <typename Expr> +void write_ast(const Expr& expr, const char* fname) +{ + std::ofstream f(fname); + f << "digraph G {\n ordering = out;\n edge [arrowhead=none];\n\n"; + write_ast_dispatch(expr, "t", f); + + f << "}\n"; +} + + +}} // namespace mtl::io + +#endif // MTL_IO_WRITE_AST_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/io/write_ast_dispatch.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/io/write_ast_dispatch.hpp new file mode 100644 index 0000000000000000000000000000000000000000..ea3bc5487672522ce9f2c25eec9bc7704e2ebbe6 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/io/write_ast_dispatch.hpp @@ -0,0 +1,162 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_IO_WRITE_AST_DISPATCH_INCLUDE +#define MTL_IO_WRITE_AST_DISPATCH_INCLUDE + +#include <string> +#include <sstream> +#include <fstream> +#include <boost/utility/enable_if.hpp> +#include <boost/type_traits/is_integral.hpp> +#include <boost/type_traits/is_floating_point.hpp> +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/io/functor_symbol.hpp> +#include <boost/numeric/mtl/vector/vec_vec_aop_expr.hpp> + +namespace mtl { namespace io { + +template <typename Value, typename Parameters> +void write_ast_dispatch(const mtl::vector::dense_vector<Value, Parameters>& v, std::string s, std::ofstream& f); +template <typename E1, typename E2, typename SFunctor> +void write_ast_dispatch(const mtl::vector::vec_vec_aop_expr<E1, E2, SFunctor>& expr, std::string s, std::ofstream& f); +template <class E1, class E2, typename SFunctor> +void write_ast_dispatch(const mtl::vector::vec_vec_pmop_expr<E1, E2, SFunctor>& expr, std::string s, std::ofstream& f); +template <typename Functor, typename Vector> +void write_ast_dispatch(const mtl::vector::map_view<Functor, Vector>& expr, std::string s, std::ofstream& f); +template <typename Scaling, typename Vector> +void write_ast_dispatch(const mtl::vector::scaled_view<Scaling, Vector>& expr, std::string s, std::ofstream& f); +template <typename Matrix, typename Vector> +void write_ast_dispatch(const mtl::mat_cvec_times_expr<Matrix, Vector>& expr, std::string s, std::ofstream& f); +template <typename Expr> +void write_ast_dispatch(const mtl::operation::compute_summand<Expr>& expr, std::string s, std::ofstream& f); +template <typename Matrix, typename Vector> +void write_ast_dispatch(const mtl::operation::compute_summand<mtl::mat_cvec_times_expr<Matrix, Vector> >& expr, std::string s, std::ofstream& f); +template <typename Vector1, typename Vector2> +void write_ast_dispatch(const mtl::matrix::outer_product_matrix<Vector1, Vector2>& expr, std::string s, std::ofstream& f); + + + +template <typename Value> +typename boost::enable_if_c<boost::is_floating_point<Value>::value || boost::is_integral<Value>::value>::type +write_ast_dispatch(const Value& v, std::string s, std::ofstream& f) +{ + f << " " << s << "[shape=box,label=\"scalar\\n" << v << "\"]\n"; +} + + +template <typename Value, typename Parameters> +void write_ast_dispatch(const mtl::vector::dense_vector<Value, Parameters>& v, std::string s, std::ofstream& f) +{ + f << " " << s << "[shape=box,label=\"vector\\n" << &v << "\"]\n"; +} + +template <typename E1, typename E2, typename SFunctor> +void write_ast_dispatch(const mtl::vector::vec_vec_aop_expr<E1, E2, SFunctor>& expr, std::string s, std::ofstream& f) +{ + f << " " << s << "[label=\"" << functor_symbol(SFunctor()) << "\"]\n"; + std::string target= s + "t", source= s + "s"; + write_ast_dispatch(expr.first_argument(), target, f); + write_ast_dispatch(expr.second_argument(), source, f); + f << " " << s << "->" << target << '\n'; + f << " " << s << "->" << source << '\n'; +} + +template <class E1, class E2, typename SFunctor> +void write_ast_dispatch(const mtl::vector::vec_vec_pmop_expr<E1, E2, SFunctor>& expr, std::string s, std::ofstream& f) +{ + f << " " << s << "[label=\"" << functor_symbol(SFunctor()) << "\"]\n"; + std::string first= s + "f", second= s + "s"; + write_ast_dispatch(expr.first_argument(), first, f); + write_ast_dispatch(expr.second_argument(), second, f); + f << " " << s << "->" << first << '\n'; + f << " " << s << "->" << second << '\n'; +} + +template <typename Scaling, typename Vector> +void write_ast_dispatch(const mtl::vector::scaled_view<Scaling, Vector>& expr, std::string s, std::ofstream& f) +{ + f << " " << s << "[label=\"scaled_view\"]\n"; + std::string functor= s + "f", ref= s + "r"; + + write_ast_dispatch(expr.functor.value, functor, f); + write_ast_dispatch(expr.ref, ref, f); + + f << " " << s << "->" << functor << '\n'; + f << " " << s << "->" << ref << '\n'; +} + +template <typename Value1, typename Value2> +void write_ast_dispatch(const mtl::tfunctor::scale<Value1, Value2, mtl::tag::scalar>& expr, std::string s, std::ofstream& f) +{ + f << " " << s << "[label=\"scale\"]\n"; + std::string factor= s + "f", ref= s + "r"; + write_ast_dispatch(expr.value(), factor, f); + f << " " << ref << "[label=\".\"]\n"; + + f << " " << s << "->" << factor << '\n'; + f << " " << s << "->" << ref << '\n'; +} + +template <typename Functor, typename Vector> +void write_ast_dispatch(const mtl::vector::map_view<Functor, Vector>& expr, std::string s, std::ofstream& f) +{ + f << " " << s << "[label=\"map\"]\n"; + std::string functor= s + "f", ref= s + "r"; + + write_ast_dispatch(expr.functor, functor, f); + write_ast_dispatch(expr.ref, ref, f); + + f << " " << s << "->" << functor << '\n'; + f << " " << s << "->" << ref << '\n'; +} + +// template <typename Matrix, typename Vector> +// void write_ast_dispatch(const mtl::mat_cvec_times_expr<Matrix, Vector>& expr, std::string s, std::ofstream& f) +// { +// } + +template <typename Expr> +void write_ast_dispatch(const mtl::operation::compute_summand<Expr>& expr, std::string s, std::ofstream& f) +{ + write_ast_dispatch(expr.value, s, f); +} + +template <typename Matrix, typename Vector> +void write_ast_dispatch(const mtl::operation::compute_summand<mtl::mat_cvec_times_expr<Matrix, Vector> >& expr, std::string s, std::ofstream& f) +{ +# ifdef NDEBUG + write_ast_dispatch(expr.value, s, f); +# else + f << " " << s << "[label=\"*\"]\n"; + std::string first= s + "f", second= s + "s"; + write_ast_dispatch(expr.first, first, f); + write_ast_dispatch(expr.second, second, f); + f << " " << s << "->" << first << '\n'; + f << " " << s << "->" << second << '\n'; +# endif +} + +template <typename Vector1, typename Vector2> +void write_ast_dispatch(const mtl::matrix::outer_product_matrix<Vector1, Vector2>& expr, std::string s, std::ofstream& f) +{ + f << " " << s << "[label=\"outer product\"]\n"; + std::string first= s + "f", second= s + "s"; + write_ast_dispatch(expr.v1(), first, f); + write_ast_dispatch(expr.v2(), second, f); + f << " " << s << "->" << first << '\n'; + f << " " << s << "->" << second << '\n'; +} + +}} // namespace mtl::io + +#endif // MTL_IO_WRITE_AST_DISPATCH_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrices.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrices.hpp new file mode 100644 index 0000000000000000000000000000000000000000..d2d2bc1f15def1f8aab092842094e1957a149f79 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrices.hpp @@ -0,0 +1,46 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MATRICES_INCLUDE +#define MTL_MATRICES_INCLUDE + +#include <boost/numeric/mtl/matrix/dense2D.hpp> +#include <boost/numeric/mtl/matrix/morton_dense.hpp> +#include <boost/numeric/mtl/matrix/compressed2D.hpp> +#include <boost/numeric/mtl/matrix/sparse_banded.hpp> +#include <boost/numeric/mtl/matrix/multi_vector.hpp> +#include <boost/numeric/mtl/matrix/multi_vector_range.hpp> +#include <boost/numeric/mtl/matrix/element_matrix.hpp> +#include <boost/numeric/mtl/matrix/element.hpp> +#include <boost/numeric/mtl/matrix/implicit_dense.hpp> +#include <boost/numeric/mtl/matrix/block_diagonal2D.hpp> +#include <boost/numeric/mtl/matrix/ell_matrix.hpp> + +#include <boost/numeric/mtl/matrix/inserter.hpp> +#include <boost/numeric/mtl/matrix/shifted_inserter.hpp> +#include <boost/numeric/mtl/matrix/mapped_inserter.hpp> + +#include <boost/numeric/mtl/matrix/map_view.hpp> +#include <boost/numeric/mtl/matrix/transposed_view.hpp> +#include <boost/numeric/mtl/matrix/hermitian_view.hpp> +#include <boost/numeric/mtl/matrix/banded_view.hpp> +#include <boost/numeric/mtl/matrix/indirect.hpp> + +#include <boost/numeric/mtl/matrix/parameter.hpp> +#include <boost/numeric/mtl/matrix/laplacian_setup.hpp> +#include <boost/numeric/mtl/matrix/hessian_setup.hpp> +#include <boost/numeric/mtl/matrix/poisson2D_dirichlet.hpp> +#include <boost/numeric/mtl/matrix/identity2D.hpp> + +#include <boost/numeric/mtl/recursion/predefined_masks.hpp> + +#endif // MTL_MATRICES_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/all_mat_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/all_mat_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..6677d89ba92e9b87868804f23e7221369b587bd2 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/all_mat_expr.hpp @@ -0,0 +1,28 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_ALL_MAT_EXPR_INCLUDE +#define MTL_ALL_MAT_EXPR_INCLUDE + +#include <boost/numeric/mtl/matrix/mat_expr.hpp> +#include <boost/numeric/mtl/matrix/mat_mat_minus_expr.hpp> +#include <boost/numeric/mtl/matrix/mat_mat_plus_expr.hpp> +#include <boost/numeric/mtl/matrix/mat_mat_times_expr.hpp> +#include <boost/numeric/mtl/matrix/mat_mat_ele_times_expr.hpp> +#include <boost/numeric/mtl/matrix/mat_mat_asgn_expr.hpp> +#include <boost/numeric/mtl/matrix/mat_negate_expr.hpp> + +#if 0 +#include <boost/numeric/mtl/matrix/mat_mat_plus_asgn_expr.hpp> +#endif + +#endif // MTL_ALL_MAT_EXPR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/banded_view.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/banded_view.hpp new file mode 100644 index 0000000000000000000000000000000000000000..a548be24516175a8e72ef27565a9522d8eb251fa --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/banded_view.hpp @@ -0,0 +1,262 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_BANDED_VIEW_INCLUDE +#define MTL_MATRIX_BANDED_VIEW_INCLUDE + +#include <utility> +#include <boost/shared_ptr.hpp> +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/utility/property_map.hpp> +#include <boost/numeric/mtl/utility/parameters.hpp> +#include <boost/numeric/mtl/matrix/crtp_base_matrix.hpp> +#include <boost/numeric/mtl/matrix/base_matrix.hpp> +#include <boost/numeric/mtl/operation/sfunctor.hpp> +#include <boost/numeric/mtl/matrix/mat_expr.hpp> +#include <boost/numeric/mtl/matrix/map_view.hpp> +#include <boost/numeric/linear_algebra/identity.hpp> + + +// Is not mutable because masking out some values forbids returning references +// +// Arbitrary combinations with other views (using shared_ptr) is planned + +namespace mtl { namespace matrix { + +// Forward +namespace detail { + template <typename> struct banded_value; + template <typename, typename> struct mapped_value; +} + + +template <typename Matrix> +struct banded_view + : public const_crtp_base_matrix< banded_view<Matrix>, + typename Matrix::value_type, typename Matrix::size_type >, + public mat_expr< banded_view<Matrix> >, + public base_matrix<typename Matrix::value_type, + typename mtl::traits::parameters<Matrix>::type> +{ + typedef banded_view self; + typedef mat_expr< self > expr_base; + typedef typename mtl::traits::parameters<Matrix>::type parameters; + + typedef base_matrix<typename Matrix::value_type, parameters> base; + + typedef Matrix other; + typedef typename Matrix::orientation orientation; + typedef typename Matrix::index_type index_type; + // typedef typename Matrix::parameters parameters; + + typedef typename Matrix::value_type value_type; + typedef typename Matrix::const_reference const_reference; + + typedef typename Matrix::key_type key_type; + typedef typename Matrix::size_type size_type; + typedef typename Matrix::dim_type dim_type; + + typedef long int bsize_type; + + banded_view(const other& ref, bsize_type begin, bsize_type end) + : base(dim_type(mtl::matrix::num_rows(ref), mtl::matrix::num_cols(ref)), ref.nnz()), + ref(ref), begin(begin), end(end) + {} + + banded_view(const boost::shared_ptr<Matrix>& p, bsize_type begin, bsize_type end) + : base(dim_type(mtl::matrix::num_rows(*p), mtl::matrix::num_cols(*p)), p->nnz()), + my_copy(p), ref(*p), begin(begin), end(end) + {} + +#ifdef MTL_WITH_CPP11_MOVE + banded_view (self&& that) : my_copy(std::move(that.my_copy)), ref(that.ref), begin(that.begin), end(that.end) {} + banded_view (const self& that) : ref(that.ref), begin(that.begin), end(that.end) { assert(that.my_copy.use_count() == 0); } +#endif + + value_type operator() (size_type r, size_type c) const + { + using math::zero; + bsize_type bc= static_cast<bsize_type>(c), br= static_cast<bsize_type>(r), + band= bc - br; + // Need value to return correct zero as well (i.e. matrices itself) + value_type v= ref(r, c); + return begin <= band && band < end ? v : zero(v); + } + + // need const functions + bsize_type get_begin() const { return begin; } + bsize_type get_end() const { return end; } + + template <typename> friend struct detail::banded_value; + template <typename, typename> friend struct detail::map_value; + //template <typename> friend struct ::mtl::sub_matrix_t<self>; + + friend size_type inline num_rows(const self& A) + { using mtl::matrix::num_rows; return num_rows(A.ref); } + friend size_type inline num_cols(const self& A) + { using mtl::matrix::num_cols; return num_cols(A.ref); } + + protected: + boost::shared_ptr<Matrix> my_copy; + public: + const other& ref; + bsize_type begin, end; +}; + +template <typename Matrix> +inline std::size_t size(const banded_view<Matrix>& A) +{ + return num_rows(A) * num_rows(A); +} + +// ========== +// Sub matrix +// ========== + +template <typename Matrix> +struct sub_matrix_t< mtl::matrix::banded_view<Matrix> > +{ + typedef mtl::matrix::banded_view<Matrix> view_type; + + // Mapping of sub-matrix type + typedef typename sub_matrix_t<Matrix>::sub_matrix_type ref_sub_type; + typedef mtl::matrix::banded_view<ref_sub_type> const_sub_matrix_type; + typedef mtl::matrix::banded_view<ref_sub_type> sub_matrix_type; + typedef typename view_type::size_type size_type; + + sub_matrix_type operator()(view_type const& view, size_type begin_r, size_type end_r, + size_type begin_c, size_type end_c) + { + typedef boost::shared_ptr<ref_sub_type> pointer_type; + + // Submatrix of referred matrix (or view) + // Create a submatrix, whos address will be kept by banded_view + pointer_type p(new ref_sub_type(sub_matrix(view.ref, begin_r, end_r, begin_c, end_c))); + return sub_matrix_type(p, view.begin, view.end); + } +}; + + +}} // namespace mtl::matrix + + + + +namespace mtl { namespace traits { + + using mtl::matrix::banded_view; + + template <typename Matrix> + struct row<banded_view<Matrix> > + { + // from map_view + typedef detail::mapped_row<sfunctor::identity<typename Matrix::value_type>, Matrix> type; + }; + + template <typename Matrix> + struct col<banded_view<Matrix> > + { + // from map_view + typedef detail::mapped_col<sfunctor::identity<typename Matrix::value_type>, Matrix> type; + }; + + namespace detail { + + template <typename Matrix> + struct banded_value + { + typedef typename Matrix::key_type key_type; + typedef typename Matrix::value_type value_type; + typedef banded_view<Matrix> view_type; + + banded_value(view_type const& view) + : view(view), its_row(view.ref), its_col(view.ref), its_value(view.ref) + {} + + value_type operator() (key_type const& key) const + { + using math::zero; + typedef typename view_type::bsize_type bsize_type; + + bsize_type br= static_cast<bsize_type>(its_row(key)), + bc= static_cast<bsize_type>(its_col(key)), + band= bc - br; + // Need value to return correct zero as well (i.e. matrices itself) + const value_type v= its_value(key); + + return view.get_begin() <= band && band < view.get_end() ? v : zero(v); + } + + protected: + view_type const& view; + typename row<Matrix>::type its_row; + typename col<Matrix>::type its_col; + typename const_value<Matrix>::type its_value; + }; + + } // detail + + template <typename Matrix> + struct const_value<banded_view<Matrix> > + { + typedef detail::banded_value<Matrix> type; + }; + + // ================ + // Range generators + // ================ + + // Use range_generator of original matrix + template <typename Tag, typename Matrix> + struct range_generator<Tag, banded_view<Matrix> > + : public detail::referred_range_generator<banded_view<Matrix>, range_generator<Tag, Matrix> > + {}; + +#if 0 // It is more complicated than this because referred_range_generator returns Matrix's cursor and we + // cannot dispatch on this anymore + template <typename Matrix> + struct range_generator<glas::tag::nz, + typename detail::referred_range_generator<banded_view<Matrix>, range_generator<Tag, Matrix> >::type> + + detail::sub_matrix_cursor<banded_view<Matrix>, glas::tag::row, 2> > + { + typedef range_generator<glas::tag::row, banded_view<Matrix> > collection_type; + typedef range_generator<glas::tag::nz, range_generator<glas::tag::row, Matrix> > other_generator; + static int const level = other_generator::level; + typedef typename other_generator::type type; + + type begin(const collection_type& c) + { + return + + // + typedef typename range_generator<glas::tag::nz, detail::sub_matrix_cursor<Matrix>, glas::tag::row, 2>::type type; +#endif + + + // To disambiguate + template <typename Matrix> + struct range_generator<tag::major, banded_view<Matrix> > + : public detail::referred_range_generator<banded_view<Matrix>, range_generator<tag::major, Matrix> > + {}; + + + + + + +}} // mtl::traits + + +#endif // MTL_MATRIX_BANDED_VIEW_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/bands.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/bands.hpp new file mode 100644 index 0000000000000000000000000000000000000000..420b2f209645d3806ae702d8ff1a3f09ad9a25df --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/bands.hpp @@ -0,0 +1,48 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_BANDS_INCLUDE +#define MTL_MATRIX_BANDS_INCLUDE + +#include <boost/numeric/mtl/matrix/banded_view.hpp> + +namespace mtl { namespace matrix { + +namespace traits { + + template <typename Matrix> + struct bands + { + typedef banded_view<Matrix> type; + }; +} + +/// Returns a view of a matrix \p A from diagonal \p begin to \p end +/** The main diagonal is numbered 0; the off-diagonal below the main one is -1. + Accordingly, the off-diagonal above the main is 1. + The parameters \p begin and \p end specify a right-open interval. + For, instance bands(A, -1, 2) yields a tridiagonal matrix. **/ +template <typename Matrix> +typename traits::bands<Matrix>::type +inline bands(const Matrix& A, long begin, long end) +{ + typedef typename traits::bands<Matrix>::type result; + return result(A, begin, end); +} + +} // namespace matrix + + using matrix::bands; + +} // namespace mtl + +#endif // MTL_MATRIX_BANDS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/base_matrix.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/base_matrix.hpp new file mode 100644 index 0000000000000000000000000000000000000000..f3ad7db0a189647c2593d6c7370dae5da06bfdc8 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/base_matrix.hpp @@ -0,0 +1,190 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_BASE_MATRIX_INCLUDE +#define MTL_BASE_MATRIX_INCLUDE + +#include <algorithm> +#include <boost/static_assert.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/numeric/mtl/matrix/dimension.hpp> +#include <boost/numeric/mtl/detail/index.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/is_static.hpp> + +namespace mtl { namespace matrix { + +/// Base class for other matrices, contains only very simple functionality that is used in all matrices. +template <class Elt, class Parameters> +struct base_matrix +{ + typedef base_matrix self; + typedef Elt value_type; + typedef typename Parameters::orientation orientation; + typedef typename Parameters::index index_type; + typedef typename Parameters::dimensions dim_type; + static bool const on_stack= Parameters::on_stack; + typedef typename Parameters::size_type size_type; + protected: + dim_type dim; ///< # of rows and columns + size_type my_nnz; ///< # of non-zeros, to be set by derived matrix + typedef mtl::traits::is_static<dim_type> static_bool; + + public: + base_matrix(size_type n= 0) : my_nnz(n) {} + + /// Setting dimension + explicit base_matrix(mtl::non_fixed::dimensions d, size_type n= 0) : dim(d), my_nnz(n) {} + + /// Swap base matrix + friend void swap(self& x, self& y) + { + using std::swap; + swap(x.my_nnz, y.my_nnz); + swap(x.dim, y.dim); + } + + /// Either matrix to be changed is uninitialized (i.e. 0x0) or dimensions are equal + /** The matrices with dimension 0 x 0 are considered like stem cells: they can still + change into an arbitrary dimension and are compatible with any other matrix. Once a matrix has a non-trivial dimension + it can be only changed explicitly and is only compatible with matrices of the same dimensionality. **/ + void check_dim(size_type MTL_DEBUG_ARG(num_rows), size_type MTL_DEBUG_ARG(num_cols)) const + { + MTL_DEBUG_THROW_IF(this->num_rows() * this->num_cols() != 0 + && (this->num_rows() != num_rows || this->num_cols() != num_cols), + incompatible_size()); + } + +#if 0 + /** Will fail for fixed::dimension **/ + void change_dim(mtl::non_fixed::dimensions d) { dim= d; } + + template <std::size_t Rows, std::size_t Cols> + void change_dim(mtl::fixed::dimensions<Rows, Cols> d) {} +#endif + + void change_dim(size_type r, size_type c, boost::mpl::false_) { dim= dim_type(r, c); } + void change_dim(size_type r, size_type c, boost::mpl::true_) { check_dim(r, c); } + + void change_dim(size_type r, size_type c) { change_dim(r, c, static_bool()); } + +public: + /// Number of rows + size_type num_rows() const + { + return dim.num_rows(); + } + /// First row taking indexing into account + size_type begin_row() const + { + return index::change_to(index_type(), 0); + } + /// Past-end row taking indexing into account + size_type end_row() const + { + return index::change_to(index_type(), num_rows()); + } + + /// number of colums + size_type num_cols() const + { + return dim.num_cols(); + } + /// First column taking indexing into account + size_type begin_col() const + { + return index::change_to(index_type(), 0); + } + /// Past-end column taking indexing into account + size_type end_col() const + { + return index::change_to(index_type(), num_cols()); + } + + /// Number of non-zeros + size_type nnz() const + { + return my_nnz; + } + + protected: + // dispatched functions for major dimension + size_type dim1(row_major) const + { + return num_rows(); + } + size_type dim1(col_major) const + { + return num_cols(); + } + + // dispatched functions for minor dimension + size_type dim2(row_major) const + { + return num_cols(); + } + size_type dim2(col_major) const + { + return num_rows(); + } + + // Dispatched functions for major + // Trailing _ due to conflicts with macro major + size_type major_(size_type r, size_type, row_major) const + { + return r; + } + size_type major_(size_type, size_type c, col_major) const + { + return c; + } + + public: + /// Major dimension + size_type dim1() const + { + return dim1(orientation()); + } + + /// Minor dimension + size_type dim2() const + { + return dim2(orientation()); + } + + // Returns the row for row_major otherwise the column + // Trailing _ due to conflicts with macro major + size_type major_(size_type r, size_type c) const + { + return major_(r, c, orientation()); + } + + // Returns the row for col_major otherwise the column + // Trailing _ for consistency with major + size_type minor_(size_type r, size_type c) const + { + return major_(c, r, orientation()); + } + + // returns copy of dim + dim_type get_dimensions() const + { + return dim; + } +}; + + + +}} // namespace mtl::matrix + +#endif // MTL_BASE_MATRIX_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/base_sub_matrix.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/base_sub_matrix.hpp new file mode 100644 index 0000000000000000000000000000000000000000..8abfa125e6af193b775c83285880059bd33d39ff --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/base_sub_matrix.hpp @@ -0,0 +1,237 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_BASE_SUB_MATRIX_INCLUDE +#define MTL_BASE_SUB_MATRIX_INCLUDE + +#include <algorithm> +#include <boost/static_assert.hpp> +#include <boost/numeric/mtl/matrix/dimension.hpp> +#include <boost/numeric/mtl/detail/index.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> + +namespace mtl { namespace matrix { + +// Base class for sub-matrices +// Contains only very simple functionality that is used in all sub-matrices +// But also used in some complete matrices +template <class Elt, class Parameters> +struct base_sub_matrix +{ + typedef Elt value_type; + typedef typename Parameters::orientation orientation; + typedef typename Parameters::index index_type; + typedef typename Parameters::dimensions dim_type; + static bool const on_stack= Parameters::on_stack; + typedef std::size_t size_type; + typedef base_sub_matrix self; + + protected: + size_type my_nnz, // # of non-zeros, to be set by derived matrix (drop maybe?) + my_begin_row, my_end_row, + my_begin_col, my_end_col; + + void constructor_helper(const dim_type& dim) + { + my_begin_row= index::change_to(index_type(), 0); + my_end_row= index::change_to(index_type(), dim.num_rows()); + my_begin_col= index::change_to(index_type(), 0); + my_end_col= index::change_to(index_type(), dim.num_cols()); + my_nnz= 0; + } + + public: + // base_sub_matrix() : my_nnz(0), my_begin_row(0), my_end_row(0), my_begin_col(0), my_end_col(0) {} + + base_sub_matrix() + { + // With no static dimension information, it is by default 0 + constructor_helper(dim_type()); + } + + explicit base_sub_matrix(const dim_type& d) + //explicit base_sub_matrix(mtl::non_fixed::dimensions d) + { + constructor_helper(d); + } + + friend void swap(self& x, self& y) + { + std::swap(x.my_nnz, y.my_nnz); + std::swap(x.my_begin_row, y.my_begin_row); + std::swap(x.my_end_row, y.my_end_row); + std::swap(x.my_begin_col, y.my_begin_col); + std::swap(x.my_end_col, y.my_end_col); + } + + // Either changed matrix is uninitialized (i.e. 0x0) or dimensions are equal + void check_dim(size_type MTL_DEBUG_ARG(num_rows), size_type MTL_DEBUG_ARG(num_cols) ) const + { + MTL_DEBUG_THROW_IF(this->num_rows() * this->num_cols() != 0 + && (this->num_rows() != num_rows || this->num_cols() != num_cols), + incompatible_size()); + } + +protected: + void change_dim(non_fixed::dimensions d) { constructor_helper(d); } + template <std::size_t Rows, std::size_t Cols> + void change_dim(fixed::dimensions<Rows, Cols> d) { check_dim(d.num_rows(), d.num_cols()); } + + + + void change_dim(size_type r, size_type c) { change_dim(dim_type(r, c)); } + + void set_ranges(size_type br, size_type er, size_type bc, size_type ec) + { + MTL_DEBUG_THROW_IF(br > er, range_error("begin row > end row")); + MTL_DEBUG_THROW_IF(bc > ec, range_error("begin column > end column")); + my_begin_row= br; my_end_row= er; my_begin_col= bc; my_end_col= ec; + } + +public: + void check_ranges(size_type MTL_DEBUG_ARG(begin_r), size_type MTL_DEBUG_ARG(end_r), + size_type MTL_DEBUG_ARG(begin_c), size_type MTL_DEBUG_ARG(end_c) ) const + { + MTL_DEBUG_THROW_IF(begin_r < begin_row(), range_error("begin_row out of range")); + // if (end_r > end_row()) std::cout << "end_row out of range\n"; + MTL_DEBUG_THROW_IF(end_r > end_row(), range_error("end_row out of range")); + + MTL_DEBUG_THROW_IF(begin_c < begin_col(), range_error("begin_col out of range")); + MTL_DEBUG_THROW_IF(end_c > end_col(), range_error("end_col out of range")); + } + + explicit base_sub_matrix(size_type br, size_type er, size_type bc, size_type ec) : my_nnz(0) + { + set_ranges(br, er, bc, ec); + } + + // Number of rows + size_type num_rows() const + { + return my_end_row - my_begin_row; + } + + // First row taking indexing into account (already stored as such) + size_type begin_row() const + { + return my_begin_row; + } + + // Past-end row taking indexing into account (already stored as such) + size_type end_row() const + { + return my_end_row; + } + + // Number of columns + size_type num_cols() const + { + return my_end_col - my_begin_col; + } + + // First column taking indexing into account (already stored as such) + size_type begin_col() const + { + return my_begin_col; + } + + // Past-end column taking indexing into account (already stored as such) + size_type end_col() const + { + return my_end_col; + } + + // Number of non-zeros + size_type nnz() const + { + return my_nnz; + } + + protected: + // dispatched functions for major dimension + size_type dim1(row_major) const + { + return num_rows(); + } + + size_type dim1(col_major) const + { + return num_cols(); + } + + // dispatched functions for minor dimension + size_type dim2(row_major) const + { + return num_cols(); + } + + size_type dim2(col_major) const + { + return num_rows(); + } + + // Dispatched functions for major + // Trailing _ due to conflicts with macro major + size_type major_(size_type r, size_type, row_major) const + { + return r; + } + + size_type major_(size_type, size_type c, col_major) const + { + return c; + } + + public: + // return major dimension + size_type dim1() const + { + return dim1(orientation()); + } + + // return minor dimension + size_type dim2() const + { + return dim2(orientation()); + } + + // Returns the row for row_major otherwise the column + // Trailing _ due to conflicts with macro major + size_type major_(size_type r, size_type c) const + { + return major_(r, c, orientation()); + } + + // Returns the row for col_major otherwise the column + // Trailing _ for consistency with major + size_type minor_(size_type r, size_type c) const + { + return major_(c, r, orientation()); + } + + dim_type get_dimensions() const + { + return dim_type(num_rows(), num_cols()); + } + +}; + + +}} // namespace mtl::matrix + +#endif // MTL_BASE_SUB_MATRIX_INCLUDE + + +/* + Question: + - Shall we keep the position in the original matrix? +*/ diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/block_diagonal2D.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/block_diagonal2D.hpp new file mode 100644 index 0000000000000000000000000000000000000000..2a0b9482bbc6af2be8dcfb6db028cbe76545c48b --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/block_diagonal2D.hpp @@ -0,0 +1,255 @@ + +#ifndef MTL_DIST_BLOCK_DIAGONAL2D_INCLUDE +#define MTL_DIST_BLOCK_DIAGONAL2D_INCLUDE + + + +#include <vector> +#include <cassert> +#include <limits> +#include <boost/type_traits/is_same.hpp> +#include <boost/mpl/bool.hpp> + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/vector/dense_vector.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/irange.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> +#include <boost/numeric/mtl/matrix/mat_expr.hpp> + + +namespace mtl { + + namespace matrix { + + +/// Block diagonal matrix structure +/** Blocks can be any existing matrix_type in mtl4. **/ +template <typename Matrix> +class block_diagonal2D + : public mat_expr< block_diagonal2D<Matrix> > +{ + public: + + typedef unsigned int size_type; + typedef Matrix block_type; + typedef std::vector<Matrix> block_matrix_type; + typedef std::vector<size_type> index_vector_type; + typedef block_diagonal2D<Matrix> self; + typedef typename Collection<Matrix>::value_type value_type; + + /// Constructor: number or rows and columns and optionally estimated number of blocks + explicit block_diagonal2D(size_type rows, size_type cols, size_type init_size= 0) + : nrows(rows), ncols(cols), nb_blocks(0), my_nnz(0), + min_ind(std::numeric_limits<size_type>::max()), max_ind(std::numeric_limits<size_type>::min()), + compact_heap(0) + { + start_block.reserve(init_size); + end_block.reserve(init_size); + blocks.reserve(init_size); + } + + ~block_diagonal2D() { delete[] compact_heap; } + + /// Returns the global number of rows + size_type num_rows() const { + return nrows ; + } + /// Returns the global number of coluums + size_type num_cols() const { + return ncols ; + } + /// Returns the global number of blocks + size_type num_blocks() const { + return nb_blocks; + } + + /// Minimal index + size_type min_index() const { return min_ind; } + + /// Maximal index + size_type max_index() const { return max_ind; } + + + block_type const& block(size_type i) const + { + MTL_DEBUG_THROW_IF(is_negative(i) || i >= nb_blocks, index_out_of_range()); + return blocks[i]; + } + + /// Insert a block from start x start to end x end + void insert(size_type start, size_type end, const block_type& A) + { + MTL_DEBUG_THROW_IF(start > end, logic_error()); + MTL_DEBUG_THROW_IF(is_negative(start) || end > nrows || end > ncols, index_out_of_range()); + assert(compact_heap == 0); // insertion after make_compact; might be relaxed later + + start_block.push_back(start); + end_block.push_back(end); + blocks.push_back(A); + my_nnz+= A.nnz(); + nb_blocks++; + + if (start < min_ind) + min_ind= start; + if (end > max_ind) + max_ind= end; +#if 0 + boost::mpi::communicator world; + if (world.rank() == 0) { + std::cout << "block_diag.insert " << nb_blocks-1 << "th block: start == " + << start_block << ", end == " << end_block << "block is:\n" + << blocks.back(); + } +#endif + } + + /// Element A[i][j] by summing over all blocks, use only for debugging because it is very slow + value_type operator()(size_type i, size_type j) const + { + value_type s= value_type(0); + for (std::size_t b= 0; b < blocks.size(); ++b) { + size_type st= start_block[b], e= end_block[b]; + if (st <= i && st <= j && i < e && j < e) + s+= blocks[b][i - st][j - st]; + } + return s; + } + + /// Memory of inserted + void make_compact(boost::mpl::true_) + { + assert(compact_heap == 0); // might be relaxed later + + size_type entries= 0; + for (size_type i= 0; i < nb_blocks; i++) + entries+= size(blocks[i]); + compact_heap= new value_type[entries]; + + size_type pos= 0; + for (size_type i= 0; i < nb_blocks; i++) { + size_type s= end_block[i] - start_block[i]; + block_type tmp(s, s, compact_heap + pos); + tmp= blocks[i]; + pos+= size(blocks[i]); + swap(blocks[i], tmp); + } + assert(pos == entries); + } + void make_compact(boost::mpl::false_) {} + + void make_compact() { make_compact(boost::is_same<typename mtl::traits::category<block_type>::type, tag::dense2D>()); } + + /// Number of non-zeros (accumulated over blocks) + size_type nnz() const { return my_nnz; } + + template <typename VectorIn, typename VectorOut> + void add_mult(const VectorIn& x, VectorOut& y) const + { + mtl::vampir_trace<3062> tracer; + MTL_DEBUG_THROW_IF(ncols != size(x) || nrows != size(y), incompatible_size()); + + // set_to_zero(y); + for(size_type i= 0; i < nb_blocks; i++) { + mtl::irange r(start_block[i], end_block[i]); + y[r]+= blocks[i] * x[r]; + } + } + + ///block_diagonal-matrix times cvec + template <typename VectorIn, typename VectorOut> + void mult(const VectorIn& x, VectorOut& y) const + { + mtl::vampir_trace<3062> tracer; + MTL_DEBUG_THROW_IF(ncols != size(x) || nrows != size(y), incompatible_size()); + + set_to_zero(y); + for(size_type i= 0; i < nb_blocks; i++) { + mtl::irange r(start_block[i], end_block[i]); + y[r]= blocks[i] * x[r]; + } + } + + template <typename VectorIn> + struct multiplier + : mtl::vector::assigner<multiplier<VectorIn> > + { + explicit multiplier(const self& P, const VectorIn& x) : P(P), x(x) {} + + template <typename VectorOut> + void assign_to(VectorOut& y) const + { P.mult(x, y); } + + const self& P; + const VectorIn& x; + }; + + + template <typename VectorIn> + multiplier<VectorIn> operator*(const VectorIn& x) // const + { return multiplier<VectorIn>(*this, x); } + + + private: + size_type nrows, ncols, nb_blocks, my_nnz, min_ind, max_ind; + index_vector_type start_block, end_block; + block_matrix_type blocks; + value_type* compact_heap; +}; + +// ================ +// Free functions +// ================ + + +/// Number of rows +template <typename Value> +typename block_diagonal2D<Value>::size_type +inline num_rows(const block_diagonal2D<Value>& matrix) +{ + return matrix.num_rows(); +} + +/// Number of columns +template <typename Value> +typename block_diagonal2D<Value>::size_type +inline num_cols(const block_diagonal2D<Value>& matrix) +{ + return matrix.num_cols(); +} + +/// Size of the matrix, i.e. the number of row times columns +template <typename Value> +typename block_diagonal2D<Value>::size_type +inline size(const block_diagonal2D<Value>& matrix) +{ + return matrix.num_cols() * matrix.num_rows(); +} + +// /// Distributed Vector of start block entrys in the matrix +// template <typename Value> +// typename block_diagonal2D<Value>::index_type +// inline start(const block_diagonal2D<Value>& matrix) +// { +// return matrix.start(); +// } + +// /// Distributed Vector of en block entrys in the matrix +// template <typename Value> +// typename block_diagonal2D<Value>::index_type +// inline end(const block_diagonal2D<Value>& matrix) +// { +// return matrix.end(); +// } + + + + +} // namespace matrix +} // namespace mtl + +#endif // MTL_DIST_BLOCK_DIAGONAL2D_INCLUDE + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/compressed2D.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/compressed2D.hpp new file mode 100644 index 0000000000000000000000000000000000000000..7cef5c7dda308a7cde742c9021b70a1f3f4a1b0a --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/compressed2D.hpp @@ -0,0 +1,1336 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_COMPRESSED2D_INCLUDE +#define MTL_COMPRESSED2D_INCLUDE + +#include <algorithm> +#include <vector> +#include <map> +#include <cmath> +#include <boost/tuple/tuple.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/mpl/if.hpp> + +#include <boost/numeric/linear_algebra/identity.hpp> + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/config.hpp> +#include <boost/numeric/mtl/utility/common_include.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/maybe.hpp> +#include <boost/numeric/mtl/utility/shrink_stl_vector.hpp> +#include <boost/numeric/mtl/utility/zipped_sort.hpp> +#include <boost/numeric/mtl/detail/base_cursor.hpp> +#include <boost/numeric/mtl/operation/is_negative.hpp> +#include <boost/numeric/mtl/operation/update.hpp> +#include <boost/numeric/mtl/operation/shift_block.hpp> +#include <boost/numeric/mtl/matrix/parameter.hpp> +#include <boost/numeric/mtl/matrix/base_matrix.hpp> +#include <boost/numeric/mtl/matrix/crtp_base_matrix.hpp> +#include <boost/numeric/mtl/matrix/mat_expr.hpp> +#include <boost/numeric/mtl/matrix/element_matrix.hpp> +#include <boost/numeric/mtl/matrix/element_array.hpp> +#include <boost/numeric/mtl/vector/dense_vector.hpp> +#include <boost/numeric/mtl/operation/compute_factors.hpp> +#include <boost/numeric/mtl/operation/num_rows.hpp> +#include <boost/numeric/mtl/operation/num_cols.hpp> +#include <boost/numeric/mtl/operation/size.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +#ifdef MTL_WITH_INITLIST +# include <initializer_list> +#endif + +#undef major // fight namespace pollution + +namespace mtl { namespace matrix { + + +struct compressed_key +{ + typedef std::size_t size_t; + typedef compressed_key self; + + template <typename Elt, typename Parameters> + explicit compressed_key(compressed2D<Elt, Parameters> const& matrix, size_t offset) : offset(offset) + { + std::size_t my_major= matrix.indexer.find_major(matrix, offset); + major= my_major; + } + + template <typename Elt, typename Parameters> + explicit compressed_key(compressed2D<Elt, Parameters> const& matrix, size_t r, size_t c) + { + offset= matrix.indexer(matrix, r, c).value(); + major= matrix.indexer.major_minor_c(matrix, r, c).first; + } + + compressed_key(compressed_key const& other) { offset= other.offset; major= other.major; } + + self& operator= (self const& other) + { + offset= other.offset; major= other.major; + return *this; + } + + bool operator== (compressed_key const& other) const + { + //if (offset == other.offset && major != other.major) + // std::cout << offset << " " << other.offset << " " << major << " " << other.major << '\n'; + // The following tests doesn't hold everywhere (anymore) + // MTL_DEBUG_THROW_IF(offset == other.offset && major != other.major, logic_error("equal offsets imply equal major")); + return offset == other.offset; + } + + bool operator!= (compressed_key const& other) const { return !(*this == other); } + + size_t major; + size_t offset; +}; + + +// Cursor over every element +template <typename Elt, typename Parameters> +struct compressed_el_cursor + : public compressed_key +{ + typedef Elt value_type; + typedef compressed_key base; + typedef compressed_el_cursor self; + typedef std::size_t size_t; + + explicit compressed_el_cursor(compressed2D<Elt, Parameters> const& matrix, size_t r, size_t c) + : base(matrix, r, c), matrix(matrix) {} + + explicit compressed_el_cursor(compressed2D<Elt, Parameters> const& matrix, size_t offset) + : base(matrix, offset), matrix(matrix) {} + + compressed_el_cursor(const compressed_el_cursor<Elt, Parameters>& other) + : base(other), matrix(other.matrix) {} + + self& operator= (self const& other) { base::operator=(other); return *this; } + + self& operator++ () + { + ++offset; + MTL_DEBUG_THROW_IF(matrix.starts[major+1] < offset, runtime_error("Inconsistent incrementation!")); + while (major < matrix.starts.size()-1 && matrix.starts[major+1] == offset) + ++major; + return *this; + } + + base& operator* () { return *this; } + const base& operator* () const { return *this; } + + compressed2D<Elt, Parameters> const& matrix; +}; + + +// Cursor over every element +template <typename Elt, typename Parameters> +struct compressed_minor_cursor + : public compressed_key +{ + typedef Elt value_type; + typedef compressed_key base; + typedef compressed_minor_cursor self; + typedef std::size_t size_t; + + explicit compressed_minor_cursor(mtl::matrix::compressed2D<Elt, Parameters> const& matrix, size_t r, size_t c) + : base(matrix, r, c), matrix(matrix) + {} + + explicit compressed_minor_cursor(mtl::matrix::compressed2D<Elt, Parameters> const& matrix, size_t offset) + : base(matrix, offset), matrix(matrix) + {} + + compressed_minor_cursor(self const& other) : base(other), matrix(other.matrix) {} + + self& operator= (self const& other) + { base::operator=(other); return *this; } + + self& operator++() { ++offset; return *this; } + self& operator+=(size_t inc) { offset+= inc; return *this; } + self operator+(size_t inc) const { self tmp(*this); tmp+= inc; return tmp; } + + self& operator--() { --offset; return *this; } + base& operator* () { return *this; } + const base& operator* () const { return *this; } + + mtl::matrix::compressed2D<Elt, Parameters> const& matrix; +}; + + + + +// Indexing for compressed matrices +template <typename SizeType> +struct compressed2D_indexer +{ + typedef SizeType size_type; + typedef std::pair<size_type, size_type> size_pair; + private: + // helpers for public functions + template <class Matrix> + utilities::maybe<size_type> offset(const Matrix& ma, size_type major, size_type minor) const + { + typedef utilities::maybe<size_type> result_type; + assert(ma.starts[major] <= ma.starts[major+1]); // Check sortedness + assert(ma.starts[major+1] <= ma.my_nnz); // Check bounds of indices + // Now we are save to use past-end addresses as iterators + + // Empty matrices are special cases + if (ma.indices.empty()) + return result_type(0, false); + + const size_type *first = &ma.indices[0] + ma.starts[major], + *last = &ma.indices[0] + ma.starts[major+1]; + // if empty row (or column) return start of next one + if (first == last) + return result_type(first - &ma.indices[0], false); + + const size_type *index= first; + if (last - index <= int(compressed_linear_search_limit)) + while (index != last && *index < minor) ++index; + else + index = std::lower_bound(first, last, minor); + return result_type(index - &ma.indices[0], index != last && *index == minor); + } + + public: + // Returns major and minor index in C style (starting with 0) + template <class Matrix> + size_pair major_minor_c(const Matrix& ma, size_type row, size_type col) const + { + using std::make_pair; + // convert into c indices + typename Matrix::index_type my_index; + size_type my_row= index::change_from(my_index, row), + my_col= index::change_from(my_index, col); + return make_pair(ma.major_(my_row, my_col), ma.minor_(my_row, my_col)); + } + + // Returns the offset if found + // If not found it returns the position where it would be inserted + template <class Matrix> + utilities::maybe<size_type> operator() (const Matrix& ma, size_type row, size_type col) const + { + size_type major, minor; + boost::tie(major, minor) = major_minor_c(ma, row, col); + return offset(ma, major, minor); + } + + // Same as above if internal representation is already known + template <class Matrix> + utilities::maybe<size_type> operator() (const Matrix& ma, size_pair major_minor) const + { + return offset(ma, major_minor.first, major_minor.second); + } + + // For a given offset the minor can be accessed directly, the major dim has to be searched + // Returned in internal (c) representation + template <class Matrix> + size_type find_major(const Matrix& ma, size_type offset) const + { + MTL_DEBUG_THROW_IF(ma.starts.empty(), logic_error("Major vector can't be empty")); + size_type my_major= std::upper_bound(ma.starts.begin(), ma.starts.end(), offset) - ma.starts.begin(); + return --my_major; + } + + template <class Matrix> + size_type minor_from_offset(const Matrix& ma, size_type offset) const + { + typedef typename Matrix::index_type my_index; + return index::change_to(my_index(), ma.indices[offset]); + } + +}; // compressed2D_indexer + + +/// Compressed 2D matrix type +// For now no external data +template <typename Elt, typename Parameters = matrix::parameters<> > +class compressed2D + : public base_matrix<Elt, Parameters>, + public const_crtp_base_matrix< compressed2D<Elt, Parameters>, Elt, typename Parameters::size_type >, + public crtp_matrix_assign< compressed2D<Elt, Parameters>, Elt, typename Parameters::size_type >, + public mat_expr< compressed2D<Elt, Parameters> > +{ + typedef std::size_t size_t; + typedef base_matrix<Elt, Parameters> super; + typedef compressed2D self; + typedef mat_expr< compressed2D<Elt, Parameters> > expr_base; + + // Only allocation of new data, doesn't copy if already existent + void allocate(size_t new_nnz) + { + if (new_nnz) { + this->my_nnz = new_nnz; + data.resize(this->my_nnz); + indices.resize(this->my_nnz, 0); + } + } + + public: + typedef Parameters parameters; + typedef typename Parameters::orientation orientation; + typedef typename Parameters::index index_type; + typedef typename Parameters::dimensions dimensions; + typedef Elt value_type; + typedef compressed_key key_type; + // const value_type& isn't defined everywhere + typedef value_type const_reference; + + typedef typename Parameters::size_type size_type; + typedef crtp_matrix_assign<self, Elt, size_type> assign_base; + typedef compressed2D_indexer<size_type> indexer_type; + + void check() const { MTL_DEBUG_THROW_IF(inserting, access_during_insertion()); } + + /// Removes all values; e.g. for set_to_zero + void make_empty() + { + check(); + this->my_nnz = 0; + data.resize(0); + indices.resize(0); + std::fill(starts.begin(), starts.end(), 0); + } + + /// Change dimension of the matrix; data get lost. + void change_dim(size_type r, size_type c) + { + check(); + if (this->num_rows() != r || this->num_cols() != c) { + super::change_dim(r, c); + starts.resize(this->dim1()+1); + make_empty(); + } + } + + /// Sets nnz and resizes indices and data + void set_nnz(size_type n) + { + check(); + indices.resize(n); + data.resize(n); + this->my_nnz= n; + } + + // if compile time matrix size, we can set the start vector + /// Default constructor + explicit compressed2D () : inserting(false) + { + if (super::dim_type::is_static) starts.resize(super::dim1() + 1); + } + + + /// Setting dimension and allocate starting vector + explicit compressed2D (mtl::non_fixed::dimensions d, size_t nnz = 0) + : super(d), inserting(false) + { + starts.resize(super::dim1() + 1, 0); + allocate(nnz); + } + + /// Setting dimension and allocate starting vector + explicit compressed2D (size_type num_rows, size_type num_cols, size_t nnz = 0) + : super(non_fixed::dimensions(num_rows, num_cols)), inserting(false) + { + starts.resize(super::dim1() + 1, 0); + allocate(nnz); + } + + /// Initializing matrix from 3 arrays: \p Major, \p Minor,\p Entries. + /** For a row-major matrix Major shall contain the ranges of rows and Minor the column-indices. + This function is for advanced users only and should be used with care: + errors can lead to inconsistent matrices and segmentation faults. + **/ + compressed2D (size_type m, size_type n, size_type nnz, + size_type* Major, size_type* Minor, value_type* Entries) + : super(non_fixed::dimensions(m, n)), inserting(false) + { + allocate(nnz); + + data.assign(Entries, Entries + nnz); + starts.assign(Major, Major + super::dim1() + 1); + indices.assign(Minor, Minor + nnz); + } + + +#if 0 // Default is faster !!! + /// Copy constructor (just in case that is not generated by all compilers (generic matrix copy slower)) + compressed2D(const self& src) + : super(non_fixed::dimensions(src.num_rows(), src.num_cols())), data(src.data), + starts(src.starts), indices(src.indices), inserting(false) + {} +#endif + + /// Copy from other types + template <typename MatrixSrc> + explicit compressed2D (const MatrixSrc& src) : inserting(false) + { + if (super::dim_type::is_static) starts.resize(super::dim1() + 1); + *this= src; + } + + +#if defined(MTL_WITH_INITLIST) && defined(MTL_WITH_AUTO) && defined(MTL_WITH_RANGEDFOR) + /// Constructor for initializer list \p values + template <typename Value2> + compressed2D(std::initializer_list<std::initializer_list<Value2> > values) + : super(mtl::non_fixed::dimensions(values.size(), values.size()? values.begin()->size() : 0)), + inserting(false) + { + starts.resize(super::dim1() + 1, 0); + allocate(super::dim1() * super::dim2()); + *this= values; + } +#endif + +#ifdef MTL_WITH_DEFAULTIMPL + compressed2D(const compressed2D&) = default; +#endif + +#ifdef MTL_WITH_MOVE + self& operator=(self&& src) + { + std::cout << "I am moving !!!\n"; + check(); + this->checked_change_dim(src.num_rows(), src.num_cols()); + swap(*this, src); + return *this; + } + + self& operator=(const self& src) + { + if (this == &src) + return *this; + check(); + this->checked_change_dim(src.num_rows(), src.num_cols()); + set_nnz(src.nnz()); + + starts= src.starts; + indices= src.indices; + data= src.data; + return *this; + } +#else + /// Consuming assignment operator (without move semantics) + self& operator=(self src) + { + assert(this != &src); // Self-copy would be an indication of an error + + check(); + // TODO Check the following line + this->checked_change_dim(src.num_rows(), src.num_cols()); + swap(*this, src); + return *this; + } +#endif + + using assign_base::operator=; + +#if 0 + void self_copy(const self& src) + { + if (this == &src) + return; + change_dim(num_rows(src), num_cols(src)); + set_nnz(src.nnz()); + + #ifdef MTL_WITH_OPENMP + # pragma omp parallel for schedule(static, 16) + #endif + for (int i= 0; i < int(src.dim1()); i++) { + const size_type cj0= src.starts[i], cj1= src.starts[i+1]; + starts[i]= cj0; + for (size_type j0= cj0; j0 != cj1; ++j0) { + indices[j0]= src.indices[j0]; + data[j0]= src.data[j0]; + } + } + starts[src.dim1()]= src.starts[src.dim1()]; + } +#endif + + /// Copy the pattern of matrix \p src + /** Advanced feature. Not generic, i.e. does not exist for all matrix types. + value_type of \p src and target can be different. + Changes dimension of target to that of \p src. + Existing entries are deleted. **/ + template <typename Src> + void copy_pattern(const Src& src) + { + using std::copy; + change_dim(num_rows(src), num_cols(src)); + copy(src.ref_major().begin(), src.ref_major().end(), starts.begin()); + + set_nnz(src.ref_minor().size()); + copy(src.ref_minor().begin(), src.ref_minor().end(), indices.begin()); + } + + void make_symmetric_pattern() + { + MTL_THROW_IF(this->num_cols() != this->num_rows(), matrix_not_square()); + self A(*this); + { + using math::zero; + inserter<self> ins(A, 2 * this->nnz() / this->dim1()); + + typename traits::row<self>::type row(*this); + typename traits::col<self>::type col(*this); + typename traits::const_value<self>::type value(*this); + typedef typename traits::range_generator<mtl::tag::major, self>::type cursor_type; + for (cursor_type cursor = mtl::begin<mtl::tag::major>(*this), cend = mtl::end<mtl::tag::major>(*this); + cursor != cend; ++cursor) { + typedef mtl::tag::nz inner_tag; + typedef typename traits::range_generator<inner_tag, cursor_type>::type icursor_type; + for (icursor_type icursor = mtl::begin<inner_tag>(cursor), icend = mtl::end<inner_tag>(cursor); icursor != icend; ++icursor) { + size_type r= row(*icursor), c= col(*icursor); + if (!indexer(*this, c, r)) + ins[c][r] << zero(value(*icursor)); + } + } + } + swap(*this, A); + } + + + // Copies range of values and their coordinates into compressed matrix + // For brute force initialization, should be used with uttermost care + // Won't be suitable for distributed matrices, take care of this to this later + template <typename ValueIterator, typename StartIterator, typename IndexIterator> + void raw_copy(ValueIterator first_value, ValueIterator last_value, + StartIterator first_start, IndexIterator first_index) + { + using std::copy; + + // check if starts has right size + allocate(last_value - first_value); // ???? + // check if nnz and indices has right size + + copy(first_value, last_value, data.begin()); + copy(first_start, first_start + this->dim1() + 1, starts.begin()); + copy(first_index, first_index + this->nnz(), indices.begin()); + } + + /// Value of matrix entry + const_reference operator() (size_type row, size_type col) const + { + using math::zero; + check(); MTL_DEBUG_THROW_IF(is_negative(row) || row >= this->num_rows() || is_negative(col) || col >= this->num_cols(), index_out_of_range()); + utilities::maybe<size_type> pos = indexer(*this, row, col); + return pos ? data[pos.value()] : zero(value_type()); + } + + /// L-value reference of stored matrix entry + /** To be used with care; in debug mode, exception is thrown if entry is not found **/ + value_type& lvalue(size_type row, size_type col) + { + utilities::maybe<size_type> pos = indexer(*this, row, col); + check(); MTL_DEBUG_THROW_IF(!pos, logic_error("This entry does not exist in the matrix")); + return data[pos.value()]; + } + + // For internal use + const value_type& value_from_offset(size_type offset) const + { + check(); MTL_DEBUG_THROW_IF(offset >= this->my_nnz, index_out_of_range("Offset larger than matrix")); + return data[offset]; + } + + value_type& value_from_offset(size_type offset) + { + check(); MTL_DEBUG_THROW_IF(offset >= this->my_nnz, index_out_of_range("Offset larger than matrix")); + return data[offset]; + } + + /// Swap matrices + friend void swap(self& matrix1, self& matrix2) + { + using std::swap; + swap(static_cast<super&>(matrix1), static_cast<super&>(matrix2)); + + swap(matrix1.data, matrix2.data); + swap(matrix1.starts, matrix2.starts); + swap(matrix1.indices, matrix2.indices); + swap(matrix1.inserting, matrix2.inserting); + } + + /// Remove zero entries + void crop() + { + check(); + if (data.empty()) return; + + using math::zero; + value_type z= zero(data[0]); + size_type nzi= 0; // Where to copy next non-zero + + std::vector<size_type> new_starts(this->dim1() + 1); + new_starts[0] = 0; + + for (size_type i = 0; i < this->dim1(); i++) { + for (size_type j= starts[i], end= starts[i+1]; j != end; ++j) + if (data[j] != z) + indices[nzi]= indices[j], data[nzi++]= data[j]; + new_starts[i+1]= nzi; + } + this->my_nnz= nzi; + data.resize(nzi); + indices.resize(nzi); + swap(starts, new_starts); + } + + + /// Address of first major index; to be used with care. [advanced] + size_type* address_major() { check(); return &starts[0]; } + /// Address of first major index; to be used with care. [advanced] + const size_type* address_major() const { check(); return &starts[0]; } + /// Address of first minor index; to be used with care. [advanced] + size_type* address_minor() { check(); return &indices[0]; } + /// Address of first minor index; to be used with care. [advanced] + const size_type* address_minor() const { check(); return &indices[0]; } + /// Address of first data entry; to be used with care. [advanced] + value_type* address_data() { check(); return &data[0]; } + /// Address of first data entry; to be used with care. [advanced] + const value_type* address_data() const { check(); return &data[0]; } + + const std::vector<size_type>& ref_major() const { return starts; } ///< Refer start vector [advanced] + std::vector<size_type>& ref_major() { return starts; } ///< Refer start vector [advanced] + const std::vector<size_type>& ref_minor() const { return indices; } ///< Refer index vector [advanced] + std::vector<size_type>& ref_minor() { return indices; } ///< Refer index vector [advanced] + + /// Release unused space in STL vectors + void shrink() + { + shrink_stl_vector(data); + shrink_stl_vector(starts); + shrink_stl_vector(indices); + } + + /// Number of non-zeros in row/column \p r_or_c when matrix is row-/column-major + size_type nnz_local(size_type r_or_c) const + { + MTL_DEBUG_THROW_IF(r_or_c >= this->dim1(), index_out_of_range()); + return starts[r_or_c+1] - starts[r_or_c]; + } + + template <typename> friend struct compressed2D_indexer; + template <typename, typename, typename> friend struct compressed2D_inserter; + template <typename, typename> friend struct compressed_el_cursor; + template <typename, typename> friend struct compressed_minor_cursor; + + indexer_type indexer; + std::vector<value_type> data; + protected: + std::vector<size_type> starts; + std::vector<size_type> indices; + bool inserting; +}; + + + +// ======== +// Inserter +// ======== + +/// Additional data structure to insert entries into a compressed2D matrix +template <typename Elt, typename Parameters, typename Updater = mtl::operations::update_store<Elt> > +struct compressed2D_inserter +{ + typedef compressed2D_inserter self; + typedef compressed2D<Elt, Parameters> matrix_type; + typedef typename matrix_type::size_type size_type; + typedef typename matrix_type::value_type value_type; + typedef std::pair<size_type, size_type> size_pair; + typedef std::map<size_pair, value_type> map_type; + typedef operations::update_proxy<self, size_type> proxy_type; + + private: + // stretch matrix rows or columns to slot size (or leave it if equal or greater) + void stretch(); + + struct bracket_proxy + { + bracket_proxy(self& ref, size_type row) : ref(ref), row(row) {} + + proxy_type operator[](size_type col) { return proxy_type(ref, row, col); } + + self& ref; + size_type row; + }; + + protected: + void finish() + { + // std::cout << "~compressed2D_inserter: " << matrix.my_nnz << " entries in matrix already (reserved for " << elements.size() + // << ") and " << spare.size() << " entries in map.\n"; + vampir_trace<3051> tracer; + if (num_rows(matrix) > 0 && num_cols(matrix) > 0) { + final_place(); + insert_spare(); + } + matrix.inserting = false; + } + + public: + /// Construction with matrix reference and optional slot size, see \ref matrix_insertion + explicit compressed2D_inserter(matrix_type& matrix, size_type slot_size = 5) + : matrix(matrix), elements(matrix.data), starts(matrix.starts), indices(matrix.indices), + slot_size(std::min(slot_size, matrix.dim2())), slot_ends(matrix.dim1()+1) + { + vampir_trace<3050> tracer; + MTL_THROW_IF(matrix.inserting, runtime_error("Two inserters on same matrix")); + matrix.inserting = true; + if (size(matrix) > 0) + stretch(); + } + + ~compressed2D_inserter() + { + // Check if finish wasn't called explicitly before + if (matrix.inserting) + finish(); + } + + /// Proxy to insert into A[row][col] + bracket_proxy operator[] (size_type row) + { + return bracket_proxy(*this, row); + } + + /// Proxy to insert into A[row][col] + proxy_type operator() (size_type row, size_type col) + { + return proxy_type(*this, row, col); + } + + /// Modify A[row][col] with \p val using \p Modifier + template <typename Modifier> + void modify(size_type row, size_type col, value_type val); + + /// Modify A[row][col] with \p val using the class' updater + void update(size_type row, size_type col, value_type val) + { + using math::zero; + modify<Updater>(row, col, val); + } + + /// For debugging only; print entries in all slots; ignores entries in spare map [advanced] + void print() const + { + for (size_type j= 0; j < matrix.dim1(); j++) + print(j); + } + + /// For debugging only; print entries in slot; ignores entries in spare map [advanced] + void print(size_type i) const + { + std::cout << "in slot " << i << ": "; + for (size_type j= starts[i]; j < slot_ends[i]; ++j) + std::cout << "[" << indices[j] << ": " << elements[j] << "]"; + std::cout << "\n"; + } + + /// Empties slot i (row or column according to orientation); for experts only [advanced] + /** Does not work if entries are in spare map !!!! **/ + void make_empty(size_type i) + { slot_ends[i]= starts[i]; } + + /// Value in A[r][c] + value_type value(size_type r, size_type c) const + { + size_pair mm= matrix.indexer.major_minor_c(matrix, r, c); + utilities::maybe<size_type> offset= matrix_offset(mm); + return offset ? matrix.data[offset.value()] : value_type(0); + } + + /// Insert \p elements into %matrix with pre-sorting + /** It should be faster for sufficiently large element matrices but our benchmarks showed the opposite. **/ + template <typename Matrix, typename Rows, typename Cols> + self& sorted_block_insertion(const element_matrix_t<Matrix, Rows, Cols>& elements); + + /// Insert \p elements into %matrix + template <typename Matrix, typename Rows, typename Cols> + self& operator<< (const element_matrix_t<Matrix, Rows, Cols>& elements) + { + using mtl::size; +#if 0 // shouldn't be slower now + if (size(elements.cols) > sorted_block_insertion_limit + && boost::is_same<typename Parameters::orientation, row_major>::value) + return sorted_block_insertion(elements); +#endif + + for (unsigned ri= 0; ri < size(elements.rows); ri++) + for (unsigned ci= 0; ci < size(elements.cols); ci++) + update (elements.rows[ri], elements.cols[ci], elements.matrix(ri, ci)); + return *this; + } + + /// Insert \p elements into %matrix + template <typename Matrix, typename Rows, typename Cols> + self& operator<< (const element_array_t<Matrix, Rows, Cols>& elements) + { + using mtl::size; + for (unsigned ri= 0; ri < size(elements.rows); ri++) + for (unsigned ci= 0; ci < size(elements.cols); ci++) + update (elements.rows[ri], elements.cols[ci], elements.array[ri][ci]); + return *this; + } + + // not so nice functions needed for direct access, e.g. in factorizations + std::vector<size_type> const& ref_major() const { return starts; } ///< Refer start vector [advanced] + std::vector<size_type> const& ref_minor() const { return indices; } ///< Refer index vector [advanced] + std::vector<size_type> const& ref_slot_ends() const { return slot_ends; } ///< Refer slot-end vector [advanced] + std::vector<value_type> const& ref_elements() const { return elements; } ///< Refer element vector [advanced] + + private: + utilities::maybe<typename self::size_type> matrix_offset(size_pair) const; + void final_place(); + void insert_spare(); + + // Show ith row/column + void display(size_type i) + { + std::cout << "slot " << i << " is ["; + for (size_type j= starts[i]; j < slot_ends[i]; ++j) + std::cout << '(' << indices[j] << ": " << elements[j] << ")" + << (j < slot_ends[i] - 1 ? ", " : ""); + std::cout << "]\n"; + } + + // eliminate double entries in a slot by using the updater + // indices are supposed to be sorted + void reduce_slot(size_type i) + { + size_type tgt= starts[i], src= tgt + 1, end= slot_ends[i]; + for (; src < end;) { + while (src < end && indices[tgt] == indices[src]) + Updater()(elements[tgt], elements[src++]); + ++tgt; + if (tgt == src) + ++src; + else if (src < end && indices[tgt] != indices[src]) { + indices[tgt]= indices[src]; + elements[tgt]= elements[src++]; + if (src >= end) ++tgt; // correction to not remain on the last entry + } + } + slot_ends[i]= tgt; + } + + protected: + compressed2D<Elt, Parameters>& matrix; + std::vector<value_type>& elements; + std::vector<size_type>& starts; + std::vector<size_type>& indices; + size_type slot_size; + std::vector<size_type> slot_ends; + map_type spare; +}; + +template <typename Elt, typename Parameters, typename Updater> +void compressed2D_inserter<Elt, Parameters, Updater>::stretch() +{ + using std::copy; + using std::copy_backward; + using std::swap; + + vampir_trace<3052> tracer; + // Stretching is much simpler for empty matrices + if (elements.empty()) { + for (size_type i= 0, s= 0; i <= matrix.dim1(); i++, s+= slot_size) + slot_ends[i]= starts[i]= s; + size_type new_total= (slot_ends[matrix.dim1()]= starts[matrix.dim1()]) + slot_size; + elements.reserve(new_total); indices.reserve(new_total); + elements.resize(new_total); indices.resize(new_total); + return; + } + + + + // If there are enough existing entries then skip the stretching (expensive) + if (elements.size() + matrix.dim1()/2 > std::size_t(slot_size * matrix.dim1())) { + // Use start of next row/col as slot_ends + copy(starts.begin() + 1, starts.end(), slot_ends.begin()); + slot_ends[matrix.dim1()]= starts[matrix.dim1()]; + return; + } + + std::vector<size_type> new_starts(matrix.dim1() + 1); + new_starts[0] = 0; + for (size_type i = 0; i < matrix.dim1(); i++) { + size_type entries = starts[i+1] - starts[i]; + slot_ends[i] = new_starts[i] + entries; + new_starts[i+1] = new_starts[i] + std::max(entries, slot_size); + } + // Add an additional slot for temporaries + size_type new_total= (slot_ends[matrix.dim1()]= new_starts[matrix.dim1()]) + slot_size; + elements.resize(new_total); + indices.resize(new_total); + // for (int i= 0; i < matrix.dim1()+1; i++) std::cout << "Slot " << i << " is [" << new_starts[i] << ", " << slot_ends[i] << ")\n"; + + // copy normally if not overlapping and backward if overlapping + // i goes down to 1 (not to 0) because i >= 0 never stops for unsigned ;-) + // &v[i] is replaced by &v[0]+i to enable past-end addresses for STL copy + for (size_type i = matrix.dim1(); i > 0; i--) + if (starts[i] <= new_starts[i-1]) { + // std::cout << "Kopiere vorwaerts von " << starts[i-1] << " bis " << starts[i] << " nach " << new_starts[i-1] << "\n"; + copy(&elements[0] + starts[i-1], &elements[0] + starts[i], &elements[0] + new_starts[i-1]); + copy(&indices[0] + starts[i-1], &indices[0] + starts[i], &indices[0] + new_starts[i-1]); + } else { + // std::cout << "Kopiere rueckwaerts von " << starts[i-1] << " bis " << starts[i] << " nach " << slot_ends[i-1] << "\n"; + copy_backward(&elements[0] + starts[i-1], &elements[0] + starts[i], &elements[0] + slot_ends[i-1]); + copy_backward(&indices[0] + starts[i-1], &indices[0] + starts[i], &indices[0] + slot_ends[i-1]); + } + swap(starts, new_starts); +} + +template <typename Elt, typename Parameters, typename Updater> +inline utilities::maybe<typename compressed2D_inserter<Elt, Parameters, Updater>::size_type> +compressed2D_inserter<Elt, Parameters, Updater>::matrix_offset(size_pair mm) const +{ + size_type major, minor; + boost::tie(major, minor) = mm; + + if (indices.empty()) + return utilities::maybe<size_type> (0, false); + + // &v[i] isn't liked by all libs -> &v[0]+i circumvents complaints + const size_type *first = &indices[0] + starts[major], + *last = &indices[0] + slot_ends[major]; + if (first == last) + return utilities::maybe<size_type> (first - &indices[0], false); + + const size_type *index= first; + if (last - index < 10) + while (index != last && *index < minor) ++index; + else + index = std::lower_bound(first, last, minor); + return utilities::maybe<size_type>(index - &indices[0], index != last && *index == minor); +} + + +template <typename Elt, typename Parameters, typename Updater> +template <typename Modifier> +inline void compressed2D_inserter<Elt, Parameters, Updater>::modify(size_type row, size_type col, value_type val) +{ + using std::copy_backward; + MTL_DEBUG_THROW_IF(is_negative(row) || row >= num_rows(matrix) || is_negative(col) || col >= num_cols(matrix), index_out_of_range()); + + Modifier modifier; + compressed2D_indexer<size_type> indexer; + size_pair mm = indexer.major_minor_c(matrix, row, col); + size_type major, minor; + boost::tie(major, minor) = mm; + + utilities::maybe<size_type> pos = matrix_offset(mm); + // Check if already in matrix and update it + if (pos) + modifier (elements[pos.value()], val); + else { + size_type& my_end = slot_ends[major]; + // Check if place in matrix to insert there + if (my_end != starts[major+1]) { + if (pos.value() != my_end) { + copy_backward(&elements[0] + pos.value(), &elements[0] + my_end, &elements[0] + (my_end+1)); + copy_backward(&indices[0] + pos.value(), &indices[0] + my_end, &indices[0] + (my_end+1)); + } + elements[pos.value()] = modifier.init(val); indices[pos.value()] = minor; + my_end++; + matrix.my_nnz++; // new entry + } else { + typename map_type::iterator it = spare.find(mm); + // If not in map insert it, otherwise update the value + if (it == spare.end()) { + spare.insert(std::make_pair(mm, modifier.init(val))); + matrix.my_nnz++; // new entry + } else + modifier(it->second, val); + } + } + // std::cout << "inserter update: " << matrix.my_nnz << " non-zero elements, new value is " << elements[pos] << "\n"; +} + +namespace detail { + + struct cmp_first + { + template <typename F, typename S> + bool operator()(const std::pair<F, S>& x, const std::pair<F, S>& y) const + { + return x.first < y.first; + } + }; +} + +template <typename Elt, typename Parameters, typename Updater> +template <typename Matrix, typename Rows, typename Cols> +compressed2D_inserter<Elt, Parameters, Updater>& +compressed2D_inserter<Elt, Parameters, Updater>::sorted_block_insertion(const element_matrix_t<Matrix, Rows, Cols>& iblock) +{ + using std::copy; using std::copy_backward; using std::min; + using mtl::size; using mtl::num_rows; using mtl::num_cols; + using namespace mtl::utility; + typedef zip_it<size_type, value_type> it_type; + + size_type m= size(iblock.rows), n= size(iblock.cols); + MTL_THROW_IF(m != num_rows(iblock.matrix) || n != num_cols(iblock.matrix), incompatible_size()); + MTL_THROW_IF(&iblock.matrix[0][1] - &iblock.matrix[0][0] != 1, logic_error("Rows must be consecutive")); + + size_type rmax= matrix.dim1(), &index_max0= indices[starts[rmax]]; + value_type& value_max0= elements[starts[rmax]]; + for (size_type i= 0; i < m; i++) { + size_type r= iblock.rows[i], &index_0= indices[starts[r]]; + value_type& value_0= elements[starts[r]]; + if (slot_ends[r] == starts[r]) { + size_type to_copy= min(starts[r+1] - starts[r], n); + copy(&iblock.cols[0], &iblock.cols[0]+to_copy, &index_0); + copy(&iblock.matrix[i][0], &iblock.matrix[i][0]+to_copy, &value_0); + slot_ends[r]= starts[r] + to_copy; + std::sort(it_type(&index_0, &value_0, 0), it_type(&index_0, &value_0, to_copy), less_0()); + reduce_slot(r); + // display(r); + matrix.my_nnz+= slot_ends[r] - starts[r]; + for (size_type j= to_copy; j < n; ++j) + update(r, iblock.cols[j], iblock.matrix[i][j]); + } else { + size_type to_copy= min(slot_size, n); + copy(&iblock.cols[0], &iblock.cols[0]+to_copy, &index_max0); + copy(&iblock.matrix[i][0], &iblock.matrix[i][0]+to_copy, &value_max0); + slot_ends[rmax]= starts[rmax] + to_copy; + std::sort(it_type(&index_max0, &value_max0, 0), it_type(&index_max0, &value_max0, to_copy), less_0()); + size_type tgt= starts[r], tend= slot_ends[r], later= starts[rmax], src= later, end= slot_ends[rmax]; + for (; src < end; ) { + // search for next equal entry in slot r + while (tgt < tend && indices[src] > indices[tgt]) ++tgt; + // reduce equal entries (they are consecutive) + if (tgt < tend) + while (src < end && indices[src] == indices[tgt]) + Updater()(elements[tgt], elements[src++]); + else { // all new entries are larger than the largest existing + for (; src < end && tgt < starts[r+1]; ++src) { // copy at the end of slot + indices[tgt]= indices[src]; + elements[tgt]= elements[src]; + slot_ends[r]= ++tgt; + ++matrix.my_nnz; + } + for (; src < end; ++src) // remainder goes into spare + update(r, indices[src], elements[src]); + later= starts[rmax]; // we're done, avoid postponed loop + } + // collect indices not found in r to deal with later + while (src < end && indices[src] < indices[tgt]) { + if (later != src) { + indices[later]= indices[src]; + elements[later]= elements[src]; + } + ++src; ++later; + } + } + for (size_type j= starts[rmax]; j < later; ++j) + update(r, indices[j], elements[j]); + } + } + return *this; +} + + +template <typename Elt, typename Parameters, typename Updater> +void compressed2D_inserter<Elt, Parameters, Updater>::final_place() +{ + using std::swap; + vampir_trace<3053> tracer; + + size_type dim1 = matrix.dim1(); + std::vector<size_type> new_starts(dim1 + 1); + new_starts[0] = 0; + + if (spare.empty()) { + // Check if everything is already in place + if (slot_ends[dim1-1] == matrix.my_nnz) { + starts[dim1]= slot_ends[dim1-1]; + if (std::size_t(matrix.my_nnz) < elements.size()) + elements.resize(matrix.my_nnz), + indices.resize(matrix.my_nnz); + return; + } + size_type pos= 0; + for (size_type i= 0; i < dim1; ++i) { + new_starts[i]= pos; + for (size_type j= starts[i], je= slot_ends[i]; j < je; ++j, ++pos) { + elements[pos]= elements[j]; + indices[pos]= indices[j]; + } + } + new_starts[dim1]= pos; + swap(new_starts, starts); + if (std::size_t(matrix.my_nnz) < elements.size()) + elements.resize(matrix.my_nnz), + indices.resize(matrix.my_nnz); + return; + } + + typename map_type::iterator it = spare.begin(); + for (size_type i = 0; i < dim1; i++) { + size_type entries = slot_ends[i] - starts[i]; + while (it != spare.end() && it->first.first == i) + entries++, it++; + new_starts[i+1] = new_starts[i] + entries; + } + + size_type new_total = new_starts[dim1], old_total = starts[dim1]; + if (new_total > old_total) { + elements.resize(new_total); + indices.resize(new_total); } + + operations::shift_blocks(dim1, starts, new_starts, slot_ends, elements); + operations::shift_blocks(dim1, starts, new_starts, slot_ends, indices); + + if (std::size_t(new_total) < elements.size()) { + elements.resize(new_total); + indices.resize(new_total); } + + for (size_type i = 0; i < dim1; i++) + slot_ends[i] = new_starts[i] + slot_ends[i] - starts[i]; + + swap(starts, new_starts); +} + +template <typename Elt, typename Parameters, typename Updater> +void compressed2D_inserter<Elt, Parameters, Updater>::insert_spare() +{ + vampir_trace<3054> tracer; + using std::copy_backward; + + for (typename map_type::iterator it = spare.begin(); it != spare.end(); ++it) { + size_pair mm = it->first; + size_type major = mm.first, minor = mm.second; + utilities::maybe<size_type> pos = matrix_offset(mm); + size_type& my_end = slot_ends[major]; + + // &v[i] see above + copy_backward(&elements[0] + pos.value(), &elements[0] + my_end, &elements[0] + (my_end+1)); + copy_backward(&indices[0] + pos.value(), &indices[0] + my_end, &indices[0] + (my_end+1)); + elements[pos.value()] = it->second; indices[pos.value()] = minor; + my_end++; + } +} + +// ================ +// Free functions +// ================ + +template <typename Value, typename Parameters> +typename compressed2D<Value, Parameters>::size_type +inline num_rows(const compressed2D<Value, Parameters>& matrix) +{ + return matrix.num_rows(); +} + +template <typename Value, typename Parameters> +typename compressed2D<Value, Parameters>::size_type +inline num_cols(const compressed2D<Value, Parameters>& matrix) +{ + return matrix.num_cols(); +} + +template <typename Value, typename Parameters> +// typename compressed2D<Value, Parameters>::size_type risks overflow +std::size_t +inline size(const compressed2D<Value, Parameters>& matrix) +{ + return std::size_t(matrix.num_cols()) * std::size_t(matrix.num_rows()); +} + + +}} // namespace mtl::matrix + +namespace mtl { + using matrix::compressed2D; +} + +// ================ +// Range generators +// ================ + +namespace mtl { namespace traits { + + // VC 8.0 finds ambiguity with mtl::tag::morton_dense (I wonder why, especially here) + using mtl::matrix::compressed2D; + using mtl::matrix::compressed_el_cursor; + using mtl::matrix::compressed_minor_cursor; + + // =========== + // For cursors + // =========== + + template <class Elt, class Parameters> + struct range_generator<glas::tag::nz, compressed2D<Elt, Parameters> > + : detail::all_offsets_range_generator<compressed2D<Elt, Parameters>, + compressed_el_cursor<Elt, Parameters>, + complexity_classes::linear_cached> + {}; + + // Cursor over all rows + // Supported if row major matrix + template <typename Elt, typename Parameters> + struct range_generator<glas::tag::row, compressed2D<Elt, Parameters> > + : boost::mpl::if_< + boost::is_same<typename Parameters::orientation, row_major> + , detail::all_rows_range_generator<compressed2D<Elt, Parameters>, complexity_classes::linear_cached> + , range_generator<tag::unsupported, compressed2D<Elt, Parameters> > + >::type {}; + + + template <class Elt, class Parameters> + struct range_generator<glas::tag::nz, + detail::sub_matrix_cursor<compressed2D<Elt, Parameters>, glas::tag::row, 2> > + { + typedef typename Collection<compressed2D<Elt, Parameters> >::size_type size_type; + typedef detail::sub_matrix_cursor<compressed2D<Elt, Parameters>, glas::tag::row, 2> cursor_type; + typedef complexity_classes::linear_cached complexity; + typedef compressed_minor_cursor<Elt, Parameters> type; + static int const level = 1; + + type begin(cursor_type const& cursor) const + { + return type(cursor.ref, cursor.key, cursor.ref.begin_col()); + } + type end(cursor_type const& cursor) const + { + return type(cursor.ref, cursor.key, cursor.ref.end_col()); + } + type lower_bound(cursor_type const& cursor, size_type position) const + { + return type(cursor.ref, cursor.key, std::min(position, cursor.ref.end_col())); + } + }; + + // Cursor over all columns + // Supported if column major matrix + template <typename Elt, typename Parameters> + struct range_generator<glas::tag::col, compressed2D<Elt, Parameters> > + : boost::mpl::if_< + boost::is_same<typename Parameters::orientation, col_major> + , detail::all_cols_range_generator<compressed2D<Elt, Parameters>, complexity_classes::linear_cached> + , range_generator<tag::unsupported, compressed2D<Elt, Parameters> > + >::type {}; + + + template <class Elt, class Parameters> + struct range_generator<glas::tag::nz, + detail::sub_matrix_cursor<compressed2D<Elt, Parameters>, glas::tag::col, 2> > + { + typedef typename Collection<compressed2D<Elt, Parameters> >::size_type size_type; + typedef detail::sub_matrix_cursor<compressed2D<Elt, Parameters>, glas::tag::col, 2> cursor_type; + typedef complexity_classes::linear_cached complexity; + typedef compressed_minor_cursor<Elt, Parameters> type; + static int const level = 1; + + type begin(cursor_type const& cursor) const + { + return type(cursor.ref, cursor.ref.begin_row(), cursor.key); + } + type end(cursor_type const& cursor) const + { + return type(cursor.ref, cursor.ref.end_row(), cursor.key); + } + type lower_bound(cursor_type const& cursor, size_type position) const + { + return type(cursor.ref, std::min(position, cursor.ref.end_row()), cursor.key); + } + }; + + // Cursor over all rows or columns, depending which one is major + template <typename Elt, typename Parameters> + struct range_generator<glas::tag::major, compressed2D<Elt, Parameters> > + : boost::mpl::if_< + boost::is_same<typename Parameters::orientation, row_major> + , range_generator<glas::tag::row, compressed2D<Elt, Parameters> > + , range_generator<glas::tag::col, compressed2D<Elt, Parameters> > + >::type {}; + + +// ============= +// For iterators +// ============= + + + template <class Elt, class Parameters> + struct range_generator<tag::const_iter::nz, + detail::sub_matrix_cursor<compressed2D<Elt, Parameters>, glas::tag::row, 2> > + { + typedef compressed2D<Elt, Parameters> matrix_type; + typedef typename matrix_type::size_type size_type; + typedef typename matrix_type::value_type value_type; + typedef detail::sub_matrix_cursor<matrix_type, glas::tag::row, 2> cursor; + + typedef complexity_classes::linear_cached complexity; + static int const level = 1; + typedef const value_type* type; + + type begin(cursor const& c) + { + const matrix_type& matrix= c.ref; + size_type offset= matrix.indexer(matrix, c.key, matrix.begin_col()); + return &matrix.data[0] + offset; + } + + // returned pointer can pass the end and must only be used for comparison + type end(cursor const& c) + { + const matrix_type& matrix= c.ref; + size_type offset= matrix.indexer(matrix, c.key, matrix.end_col()); + return &matrix.data[0] + offset; + } + }; + + + template <class Elt, class Parameters> + struct range_generator<tag::const_iter::nz, + detail::sub_matrix_cursor<compressed2D<Elt, Parameters>, glas::tag::col, 2> > + { + typedef compressed2D<Elt, Parameters> matrix_type; + typedef typename matrix_type::size_type size_type; + typedef typename matrix_type::value_type value_type; + typedef detail::sub_matrix_cursor<matrix_type, glas::tag::col, 2> cursor; + + typedef complexity_classes::linear_cached complexity; + static int const level = 1; + typedef const value_type* type; + + type begin(cursor const& c) + { + const matrix_type& matrix= c.ref; + size_type offset= matrix.indexer(matrix, matrix.begin_row(), c.key); + return &matrix.data[0] + offset; + } + + // returned pointer can pass the end and must only be used for comparison + type end(cursor const& c) + { + const matrix_type& matrix= c.ref; + size_type offset= matrix.indexer(matrix, matrix.end_row(), c.key); + return &matrix.data[0] + offset; + } + }; + + +}} // namespace mtl::traits + + + +#endif // MTL_COMPRESSED2D_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/coordinate2D.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/coordinate2D.hpp new file mode 100644 index 0000000000000000000000000000000000000000..d70051e6f139e3bcf4b5dcfa8bdcb63cecadc3cd --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/coordinate2D.hpp @@ -0,0 +1,484 @@ + +#ifndef MTL_COORDINATE2D_INCLUDE +#define MTL_COORDINATE2D_INCLUDE + +#include <vector> +#include <cassert> +#include <boost/mpl/bool.hpp> + + +#include <boost/numeric/mtl/operation/is_negative.hpp> +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/operation/sort.hpp> +#include <boost/numeric/mtl/operation/iota.hpp> +#include <boost/numeric/mtl/matrix/parameter.hpp> +#include <boost/numeric/mtl/vector/dense_vector.hpp> +#include <boost/numeric/mtl/utility/is_row_major.hpp> +#include <boost/numeric/mtl/utility/static_assert.hpp> + +namespace mtl { namespace matrix { + + +/// Sparse matrix structure in coordinate format +template <typename Value, typename Parameters = matrix::parameters<> > +class coordinate2D + : public base_matrix<Value, Parameters>, + public const_crtp_base_matrix< coordinate2D<Value, Parameters>, Value, typename Parameters::size_type >, + public crtp_matrix_assign< coordinate2D<Value, Parameters>, Value, typename Parameters::size_type >, + public mat_expr< coordinate2D<Value, Parameters> > +{ + public: + + typedef Value value_type ; + typedef Value& reference ; + typedef Value const& const_reference ; + typedef typename Parameters::size_type size_type ; + typedef typename Parameters::dimensions dim_type; + typedef typename Parameters::orientation orientation; + + typedef base_matrix<Value, Parameters> super; + + typedef std::vector< size_type > row_index_array_type ; + typedef std::vector< size_type > column_index_array_type ; + typedef std::vector< value_type > value_array_type ; + + /// Common constructor + explicit coordinate2D(size_type nrows, size_type ncols, size_type expected= 0) + : super(dim_type(nrows, ncols)) + { + if (expected > 0) { + rows.reserve(expected); + cols.reserve(expected); + values.reserve(expected); + } + } + + size_type nnz() const { return rows.size(); } ///< Number of non-zeros + + value_array_type const& value_array() const { return values; } ///< Array of values (const) + value_array_type& value_array() { return values; } ///< Array of values (mutable) + + row_index_array_type const& row_index_array() const { return rows; } ///< Array of rows (const) + column_index_array_type const& column_index_array() const { return cols; } ///< Array of columns (const) + + row_index_array_type& row_index_array() { return rows; } ///< Array of rows (mutable) + column_index_array_type& column_index_array() { return cols; } ///< Array of columns (mutable) + + /// Insert an entry at the end of the row-,col- and value-array + void push_back(size_type r, size_type c, const_reference v) + { + rows.push_back(r); cols.push_back(c); values.push_back(v); my_is_sorted= false; + } + + /// Insert an entry at the end of the row-,col- and value-array, like push_back + void insert(size_type r, size_type c, const_reference v) { push_back(r, c, v); } + + /// Whether the entries are sorted + bool is_sorted() const { return my_is_sorted; } + + /// sorting standard by rows + void sort() + { + if (nnz() > 0) + sort(mtl::traits::is_row_major<Parameters>()); + my_is_sorted= true; + } + + private: + // sorting by rows + void sort(boost::mpl::true_) + { + mtl::vector::sort_xy(rows, cols, values); + } + + // sorting by columns + void sort(boost::mpl::false_) + { + mtl::vector::sort_xy(cols, rows, values); + } + + template <typename OStream, typename Vector> + void print_stl_vector(OStream& os, const Vector& v) const + { + os << "["; + for (unsigned i= 0; i < v.size(); i++) + os << v[i] << (i+1 < v.size() ? "," : ""); + os << "]\n"; + } + + public: + template <typename OStream> + void print_internal(OStream& os) const + { + os << "rows = "; print_stl_vector(os, rows); + os << "cols = "; print_stl_vector(os, cols); + os << "values = "; print_stl_vector(os, values); + } + + void print_internal() const { print(std::cout); } + + ///operator * for vector= coordinaten-matrix * vector + template <typename Vector > + Vector operator*(const Vector& x) + { + + Vector res(this->num_rows()); + res= 0; + for (size_type i= 0; i < nnz(); i++) + res[rows[i]]+= values[i] * x[cols[i]]; + return res; + } + + value_type operator() (const size_type r, const size_type c) const + { + MTL_DEBUG_THROW_IF(is_negative(r) || r >= this->num_rows() + || is_negative(c) || c >= this->num_cols(), index_out_of_range()); + +#if 0 + if (my_is_sorted) + return find(r, c, mtl::traits::is_row_major<Parameters>()); +#endif + + for (size_type i= 0; i < nnz(); i++) + if (rows[i] == r && cols[i] == c) + return values[i]; + return value_type(0); + } + + template <typename Updater> + void compress(Updater up) + { + if (!my_is_sorted) + sort(); + + size_type i= 0, j= 1, end= rows.size(); + for (; j < end; ++j) + if (rows[i] == rows[j] && cols[i] == cols[j]) { + up(values[i], values[j]); + } else { + i++; + if (i != j) { + rows[i]= rows[j]; + cols[i]= cols[j]; + values[i]= values[j]; + } + } + if (end > 0) i++; + rows.resize(i); + cols.resize(i); + values.resize(i); + } + + template <typename Matrix, typename Updater> friend struct coordinate2D_inserter; + + private: + row_index_array_type rows; + column_index_array_type cols; + value_array_type values; + bool my_is_sorted; +}; + +// ================ +// Free functions +// ================ + + +/// Number of rows +template <typename Value, typename Parameters> +typename coordinate2D<Value, Parameters>::size_type +inline num_rows(const coordinate2D<Value, Parameters>& matrix) +{ + return matrix.num_rows(); +} + +/// Number of columns +template <typename Value, typename Parameters> +typename coordinate2D<Value, Parameters>::size_type +inline num_cols(const coordinate2D<Value, Parameters>& matrix) +{ + return matrix.num_cols(); +} + +/// Size of the matrix, i.e. the number of row times columns +template <typename Value, typename Parameters> +typename coordinate2D<Value, Parameters>::size_type +inline size(const coordinate2D<Value, Parameters>& matrix) +{ + return matrix.num_cols() * matrix.num_rows(); +} + +/// Number of NoZeros of the matrix +template <typename Value, typename Parameters> +typename coordinate2D<Value, Parameters>::size_type +inline nnz(const coordinate2D<Value, Parameters>& matrix) +{ + return matrix.nnz(); +} + + +template <typename Matrix, + typename Updater = mtl::operations::update_store<typename Matrix::value_type> > +struct coordinate2D_inserter +{ + typedef coordinate2D_inserter self; + typedef Matrix matrix_type; + typedef typename matrix_type::size_type size_type; + typedef typename matrix_type::value_type value_type; + typedef operations::update_proxy<self, size_type> proxy_type; + + // We only support storing so far !!! + // STATIC_ASSERT((boost::is_same<Updater, mtl::operations::update_store<value_type> >::value), "We only support storing so far"); + + coordinate2D_inserter(matrix_type& matrix, size_type slot_size= 1) + : matrix(matrix) + { + std::size_t ns= slot_size * matrix.dim1(); + if (ns > matrix.nnz()) { + matrix.rows.reserve(ns); + matrix.cols.reserve(ns); + matrix.values.reserve(ns); + } + } + + ~coordinate2D_inserter() { matrix.compress(Updater()); } + + private: + + struct update_proxy + { + // self is type of inserter not update_proxy !!! + update_proxy(self& ref, size_type row, size_type col) : ref(ref), row(row), col(col) {} + + template <typename Value> + update_proxy& operator<< (Value const& val) + { + ref.matrix.push_back(row, col, val); + return *this; + } + self& ref; + size_type row, col; + }; + + proxy_type operator() (size_type row, size_type col) + { + return proxy_type(*this, row, col); + } + + + struct bracket_proxy + { + bracket_proxy(self& ref, size_type row) : ref(ref), row(row) {} + + proxy_type operator[](size_type col) + { + return proxy_type(ref, row, col); + } + + self& ref; + size_type row; + }; + + public: + + bracket_proxy operator[] (size_type row) + { + return bracket_proxy(*this, row); + } + + template <typename Value> + void update(size_type row, size_type col, Value val) + { + matrix.push_back(row, col, val); + } + + template <typename Modifier, typename Value> + void modify(size_type row, size_type col, Value val) + { + matrix.push_back(row, col, val); + } + + template <typename EMatrix, typename Rows, typename Cols> + self& operator<< (const matrix::element_matrix_t<EMatrix, Rows, Cols>& elements) + { + using mtl::size; + for (unsigned ri= 0; ri < size(elements.rows); ri++) + for (unsigned ci= 0; ci < size(elements.cols); ci++) + update (elements.rows[ri], elements.cols[ci], elements.matrix(ri, ci)); + return *this; + } + + template <typename EMatrix, typename Rows, typename Cols> + self& operator<< (const matrix::element_array_t<EMatrix, Rows, Cols>& elements) + { + using mtl::size; + for (unsigned ri= 0; ri < size(elements.rows); ri++) + for (unsigned ci= 0; ci < size(elements.cols); ci++) + update (elements.rows[ri], elements.cols[ci], elements.array[ri][ci]); + return *this; + } + + protected: + matrix_type& matrix; +}; + +struct coordinate_key +{ + typedef std::size_t size_t; + + explicit coordinate_key(size_t offset) : offset(offset) {} + + bool operator== (coordinate_key const& other) const { return offset == other.offset; } + bool operator!= (coordinate_key const& other) const { return offset != other.offset; } + + size_t offset; +}; + + +// Cursor over every element +template <typename Value, typename Parameters> +struct coordinate_minor_cursor + : public coordinate_key +{ + typedef coordinate_minor_cursor<Value, Parameters> self; + typedef typename Parameters::size_type size_type; + typedef const coordinate2D<Value, Parameters>& matrix_ref_type; + static const int level= 2; + + coordinate_minor_cursor(matrix_ref_type ref, size_type offset) + : coordinate_key(offset), ref(ref) {} + + bool operator!=(const self& that) const + { + assert(&ref == &that.ref); + return this->offset != that.offset; + } + + self& operator++() { this->offset++; return *this; } + coordinate_key operator*() const { return *this; } + + matrix_ref_type ref; +}; + + +template <typename Value, typename Parameters> +struct coordinate_major_cursor +{ + typedef coordinate_major_cursor<Value, Parameters> self; + typedef typename Parameters::size_type size_type; + typedef const coordinate2D<Value, Parameters>& matrix_ref_type; + typedef coordinate_minor_cursor<Value, Parameters> inner_cursor; + static const int level= 2; + + void find_next_offset(boost::mpl::true_) + { + size_type i= offset; + for ( ; i < nnz(ref) && ref.row_index_array()[i] <= major; i++) ; + next_offset= i; + } + + void find_next_offset(boost::mpl::false_) + { + size_type i= offset; + for ( ; i < nnz(ref) && ref.col_index_array()[i] <= major; i++) ; + next_offset= i; + } + + void find_next_offset() { find_next_offset(mtl::traits::is_row_major<Parameters>()); } + + coordinate_major_cursor(matrix_ref_type ref, size_type major, size_type offset) + : ref(ref), major(major), offset(offset) + { + find_next_offset(); + } + + bool operator!=(const self& that) const + { + assert(&ref == &that.ref); + return this->offset != that.offset; + } + + self& operator++() + { + offset= next_offset; + major++; + find_next_offset(); + return *this; + } + + matrix_ref_type ref; + size_type major, offset, next_offset; +}; + +template <typename Value, typename Parameters> +struct coordinate_minor_range_generator +{ + typedef coordinate_major_cursor<Value, Parameters> outer_cursor_type; + typedef coordinate_minor_cursor<Value, Parameters> type; + static const int level= 2; + + type begin(outer_cursor_type c) const { return type(c.ref, c.offset); } + type end(outer_cursor_type c) const { return type(c.ref, c.next_offset); } +}; + +template <typename Value, typename Parameters> +struct coordinate_row_range_generator +{ + typedef const coordinate2D<Value, Parameters>& matrix_ref_type; + typedef coordinate_major_cursor<Value, Parameters> type; + typedef complexity_classes::linear_cached complexity; + static const int level= 1; + + type begin(matrix_ref_type A) const { return type(A, 0, 0); } + type end(matrix_ref_type A) const { return type(A, num_rows(A), nnz(A)); } +}; + +template <typename Value, typename Parameters> +struct coordinate_col_range_generator +{ + typedef const coordinate2D<Value, Parameters>& matrix_ref_type; + typedef coordinate_major_cursor<Value, Parameters> type; + typedef complexity_classes::linear_cached complexity; + static const int level= 1; + + type begin(matrix_ref_type A) const { return type(A, 0, 0); } + type end(matrix_ref_type A) const { return type(A, num_cols(A), nnz(A)); } +}; + + +}} // namespace mtl::matrix + + +namespace mtl { namespace traits { + + // Cursor over all rows + // Supported if row major matrix + template <typename Value, typename Parameters> + struct range_generator<glas::tag::row, matrix::coordinate2D<Value, Parameters> > + : boost::mpl::if_< + boost::is_same<typename Parameters::orientation, row_major> + , matrix::coordinate_row_range_generator<Value, Parameters> + , range_generator<tag::unsupported, matrix::coordinate2D<Value, Parameters> > + >::type {}; + + template <typename Value, typename Parameters> + struct range_generator<glas::tag::col, matrix::coordinate2D<Value, Parameters> > + : boost::mpl::if_< + boost::is_same<typename Parameters::orientation, col_major> + , matrix::coordinate_col_range_generator<Value, Parameters> + , range_generator<tag::unsupported, matrix::coordinate2D<Value, Parameters> > + >::type {}; + + template <class Value, class Parameters> + struct range_generator<glas::tag::nz, matrix::coordinate_major_cursor<Value, Parameters> > + : matrix::coordinate_minor_range_generator<Value, Parameters> + {}; + + +}} // namespace mtl::traits + +namespace mtl { + using matrix::coordinate2D; +} + +#endif // MTL_COORDINATE2D_INCLUDE + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/crtp_base_matrix.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/crtp_base_matrix.hpp new file mode 100644 index 0000000000000000000000000000000000000000..b8436d73f75d64d69e1166673053c22216c390b9 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/crtp_base_matrix.hpp @@ -0,0 +1,737 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_CRTP_BASE_MATRIX_INCLUDE +#define MTL_CRTP_BASE_MATRIX_INCLUDE + +#include <iostream> +#include <algorithm> +#include <boost/mpl/bool.hpp> +#include <boost/utility/enable_if.hpp> +#include <boost/numeric/mtl/operation/print.hpp> + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/operation/matrix_bracket.hpp> +#include <boost/numeric/mtl/operation/copy.hpp> +#include <boost/numeric/mtl/operation/mult.hpp> +#include <boost/numeric/mtl/operation/right_scale_inplace.hpp> +#include <boost/numeric/mtl/operation/divide_by_inplace.hpp> +#include <boost/numeric/mtl/matrix/all_mat_expr.hpp> +#include <boost/numeric/mtl/matrix/diagonal_setup.hpp> +#include <boost/numeric/mtl/matrix/inserter.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/ashape.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/eval_dense.hpp> +#include <boost/numeric/mtl/utility/irange.hpp> +#include <boost/numeric/mtl/utility/iset.hpp> +#include <boost/numeric/mtl/operation/mult_assign_mode.hpp> +#include <boost/numeric/mtl/operation/compute_factors.hpp> +#include <boost/numeric/mtl/operation/column_in_matrix.hpp> +#include <boost/numeric/mtl/operation/row_in_matrix.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +#ifdef MTL_WITH_INITLIST +# include <initializer_list> +#endif + +namespace mtl { namespace matrix { + +template <typename Source, typename Matrix> +struct crtp_assign +{ + Matrix& operator()(const Source& source, Matrix& matrix) + { + return assign(source, matrix, typename ashape::ashape<Source>::type()); + } +private: + /// Assign scalar to a matrix by setting the matrix to a multiple of unity matrix + /** Uses internally \sa diagonal_setup, for details see there. **/ + Matrix& assign(const Source& source, Matrix& matrix, ashape::scal) + { + vampir_trace<3055> tracer; + MTL_DEBUG_THROW_IF(num_rows(matrix) * num_cols(matrix) == 0, + range_error("Trying to initialize a 0 by 0 matrix with a value")); + diagonal_setup(matrix, source); + return matrix; + } + + /// Assign matrix expressions by copying except for some special expressions + Matrix& assign(const Source& source, Matrix& matrix, typename ashape::ashape<Matrix>::type) + { + vampir_trace<3056> tracer; + // Self-assignment between different types shouldn't happen. + matrix.checked_change_resource(source); + matrix_copy(source, matrix); + return matrix; + } +}; + + + +/// Assign sum by assigning first argument and adding second +/* Note that this is more special then assigning arbitrary expressions including matrices itself + because mat_mat_plus_expr <E1, E2> is a derived class from mat_expr < MatrixSrc >. **/ +template <typename E1, typename E2, typename Matrix> +struct crtp_assign<mat_mat_plus_expr<E1, E2>, Matrix> +{ + Matrix& operator()(const mat_mat_plus_expr<E1, E2>& src, Matrix& matrix) + { + vampir_trace<3056> tracer; + matrix.checked_change_resource(src.first); + matrix= src.first; + return matrix+= src.second; + } +}; + +/// Assign difference by assigning first argument and subtracting second +/* Note that this is more special then assigning arbitrary expressions including matrices itself + because mat_mat_minus_expr <E1, E2> is a derived class from mat_expr < MatrixSrc >. **/ +template <typename E1, typename E2, typename Matrix> +struct crtp_assign<mat_mat_minus_expr<E1, E2>, Matrix> +{ + Matrix& operator()(const mat_mat_minus_expr<E1, E2>& src, Matrix& matrix) + { + vampir_trace<3057> tracer; + matrix.checked_change_resource(src.first); + matrix= src.first; + return matrix-= src.second; + } +}; + +/// Assign product by calling mult +template <typename E1, typename E2, typename Matrix> +struct crtp_assign<mat_mat_times_expr<E1, E2>, Matrix> +{ + Matrix& operator()(const mat_mat_times_expr<E1, E2>& src, Matrix& matrix) + { + vampir_trace<4012> tracer; + operation::compute_factors<Matrix, mat_mat_times_expr<E1, E2> > factors(src); + matrix.checked_change_resource(factors.first, factors.second); + mult(factors.first, factors.second, matrix); + return matrix; + } +}; + + +/// Assign element-wise product +template <typename E1, typename E2, typename Matrix> +struct crtp_assign<mat_mat_ele_times_expr<E1, E2>, Matrix> +{ + Matrix& operator()(const mat_mat_ele_times_expr<E1, E2>& src, Matrix& matrix) + { + vampir_trace<3028> tracer; + operation::compute_factors<Matrix, mat_mat_ele_times_expr<E1, E2> > factors(src); + matrix.checked_change_resource(factors.first); + matrix= factors.first; + return matrix.ele_rscale(factors.second); + } +}; + + + +/// Assign c-style 2D-array, because it's easier to initialize. +template <typename Value, unsigned Rows, unsigned Cols, typename Matrix> +struct crtp_assign<Value[Rows][Cols], Matrix> +{ + Matrix& operator()(const Value src[Rows][Cols], Matrix& matrix) + { + vampir_trace<3059> tracer; + typedef typename Collection<Matrix>::size_type size_type; + + matrix.checked_change_dim(Rows, Cols); + inserter<Matrix> ins(matrix, matrix.dim2()); + + for (size_type r= 0; r < Rows; ++r) + for (size_type c= 0; c < Cols; ++c) + ins(r, c) << src[r][c]; + return matrix; + } +}; + +#if defined(MTL_WITH_INITLIST) && defined(MTL_WITH_AUTO) && defined(MTL_WITH_RANGEDFOR) + /// Constructor for initializer list \p values + template <typename Value2, typename Matrix> + struct crtp_assign<std::initializer_list<std::initializer_list<Value2> >, Matrix> + { + Matrix& operator()(std::initializer_list<std::initializer_list<Value2> > values, Matrix& matrix) + { + typedef typename Collection<Matrix>::size_type size_type; + size_type nr= values.size(), nc= nr > 0? values.begin()->size() : 0; + matrix.checked_change_dim(nr, nc); + inserter<Matrix> ins(matrix, matrix.dim2()); + + size_t r= 0; + for (auto l : values) { + size_t c= 0; + MTL_THROW_IF(l.size() != nc, logic_error("All sub-lists must have same size!")); + for (auto v : l) + ins(r, c++) << v; + r++; + } + return matrix; + } + }; +#endif + + +template <typename Vector, typename Matrix> +struct crtp_assign<multi_vector<Vector>, Matrix> +{ + Matrix& operator()(const multi_vector<Vector>& src, Matrix& matrix) + { + vampir_trace<3060> tracer; + typedef typename Collection<Matrix>::size_type size_type; + + matrix.checked_change_resource(src); + // del checked_change_dim(num_rows(src), num_cols(src)); + inserter<Matrix> ins(matrix); + + for (size_type r= 0; r < num_rows(src); ++r) + for (size_type c= 0; c < num_cols(src); ++c) + ins(r, c) << src[r][c]; + return matrix; + } +}; + + +/// Assign content of a file to the matrix +template <typename IFStream, typename OFStream, typename Matrix> +struct crtp_assign<io::matrix_file<IFStream, OFStream>, Matrix> +{ + Matrix& operator()(const io::matrix_file<IFStream, OFStream>& file, Matrix& matrix) + { + vampir_trace<3029> tracer; + IFStream stream(file.file_name().c_str()); + stream >> matrix; + return matrix; + } +}; + +/// Assign-add matrix expressions by incrementally copying except for some special expressions +template <typename Source, typename Matrix> +struct crtp_plus_assign +{ + Matrix& operator()(const Source& source, Matrix& matrix) + { + vampir_trace<3030> tracer; + return assign(source, matrix, typename ashape::ashape<Source>::type()); + } + private: + Matrix& assign(const Source& source, Matrix& matrix, typename ashape::ashape<Matrix>::type) + { + matrix_copy_plus(source, matrix); + return matrix; + } +}; + +/// Assign-add sum by adding both arguments +/** Note that this is more special then assigning arbitrary expressions including matrices itself + because mat_mat_plus_expr <E1, E2> is a derived class from + mat_expr < MatrixSrc >. **/ +template <typename E1, typename E2, typename Matrix> +struct crtp_plus_assign<mat_mat_plus_expr<E1, E2>, Matrix> +{ + Matrix& operator()(const mat_mat_plus_expr<E1, E2>& src, Matrix& matrix) + { + vampir_trace<3030> tracer; + matrix+= src.first; + return matrix+= src.second; + } +}; + +template <typename E1, typename E2, typename Matrix> +struct crtp_plus_assign<mat_mat_minus_expr<E1, E2>, Matrix> +{ + Matrix& operator()(const mat_mat_minus_expr<E1, E2>& src, Matrix& matrix) + { + vampir_trace<3030> tracer; + matrix+= src.first; + return matrix-= src.second; + } +}; + +template <typename E1, typename E2, typename Matrix> +struct crtp_plus_assign<mat_mat_ele_times_expr<E1, E2>, Matrix> +{ + Matrix& operator()(const mat_mat_ele_times_expr<E1, E2>& src, Matrix& matrix) + { + vampir_trace<3030> tracer; + Matrix Prod(ele_prod(src.first, src.second)); + return matrix+= Prod; + } +}; + +template <typename E1, typename E2, typename Matrix> +struct crtp_plus_assign<mat_mat_times_expr<E1, E2>, Matrix> +{ + Matrix& operator()(const mat_mat_times_expr<E1, E2>& src, Matrix& matrix) + { + vampir_trace<3030> tracer; + operation::compute_factors<Matrix, mat_mat_times_expr<E1, E2> > factors(src); + gen_mult(factors.first, factors.second, matrix, assign::plus_sum(), + tag::flat<tag::matrix>(), tag::flat<tag::matrix>(), tag::flat<tag::matrix>()); + return matrix; + } +}; + + +/// Assign-subtract matrix expressions by decrementally copying except for some special expressions +template <typename Source, typename Matrix> +struct crtp_minus_assign +{ + Matrix& operator()(const Source& source, Matrix& matrix) + { + vampir_trace<3031> tracer; + return assign(source, matrix, typename ashape::ashape<Source>::type()); + } +private: + Matrix& assign(const Source& source, Matrix& matrix, typename ashape::ashape<Matrix>::type) + { + matrix_copy_minus(source, matrix); + return matrix; + } +}; + +/// Assign-subtract sum by adding both arguments +/** Note that this is more special then assigning arbitrary expressions including matrices itself + because mat_mat_plus_expr <E1, E2> is a derived class from + mat_expr < MatrixSrc >. **/ +template <typename E1, typename E2, typename Matrix> +struct crtp_minus_assign<mat_mat_plus_expr<E1, E2>, Matrix> +{ + Matrix& operator()(const mat_mat_plus_expr<E1, E2>& src, Matrix& matrix) + { + vampir_trace<3031> tracer; + matrix-= src.first; + return matrix-= src.second; + } +}; + +/// Assign-subtracting difference by subtracting first argument and adding the second one +/** Note that this is more special then assigning arbitrary expressions including matrices itself + because mat_mat_minus_expr <E1, E2> is a derived class from + mat_expr < MatrixSrc >. **/ +template <typename E1, typename E2, typename Matrix> +struct crtp_minus_assign<mat_mat_minus_expr<E1, E2>, Matrix> +{ + Matrix& operator()(const mat_mat_minus_expr<E1, E2>& src, Matrix& matrix) + { + vampir_trace<3031> tracer; + matrix-= src.first; + return matrix+= src.second; + } +}; + +template <typename E1, typename E2, typename Matrix> +struct crtp_minus_assign<mat_mat_ele_times_expr<E1, E2>, Matrix> +{ + Matrix& operator()(const mat_mat_ele_times_expr<E1, E2>& src, Matrix& matrix) + { + vampir_trace<3031> tracer; + Matrix Prod(ele_prod(src.first, src.second)); + return matrix-= Prod; + } +}; + +/// Assign-subtract product by calling gen_mult +/** Note that this does not work for arbitrary expressions. **/ +template <typename E1, typename E2, typename Matrix> +struct crtp_minus_assign<mat_mat_times_expr<E1, E2>, Matrix> +{ + Matrix& operator()(const mat_mat_times_expr<E1, E2>& src, Matrix& matrix) + { + vampir_trace<3031> tracer; + operation::compute_factors<Matrix, mat_mat_times_expr<E1, E2> > factors(src); + gen_mult(factors.first, factors.second, matrix, assign::minus_sum(), tag::flat<tag::matrix>(), tag::flat<tag::matrix>(), tag::flat<tag::matrix>()); + return matrix; + } +}; + + + +/// Base class to provide matrix assignment operators generically +template <typename Matrix, typename ValueType, typename SizeType> +struct crtp_matrix_assign +{ +private: + + // For (compatible) dense matrices do a loop over all entries + template <typename Source> + Matrix& density_assign(const Source& src, boost::mpl::true_) + { + vampir_trace<3032> tracer; + // typedef typename Collection<Source>::size_type size_type; + typedef unsigned size_type; + + // std::cout << "Dense assignment\n"; + checked_change_resource(src); + + Matrix& matrix= static_cast<Matrix&>(*this); + for (size_type r= 0; r < num_rows(matrix); ++r) + for (size_type c= 0; c < num_cols(matrix); ++c) + matrix[r][c]= src[r][c]; + return matrix; + } + + // If sparse matrices are involved evaluate step-wise (or assignment from scalar) + template <typename Source> + Matrix& density_assign(const Source& src, boost::mpl::false_) + { + // std::cout << "Sparse assignment\n"; + return crtp_assign<Source, Matrix>()(src, static_cast<Matrix&>(*this)); + } + + + // For (compatible) dense matrices do a loop over all entries + template <typename Source> + Matrix& density_plus_assign(const Source& src, boost::mpl::true_) + { + vampir_trace<3033> tracer; + // typedef typename Collection<Source>::size_type size_type; + typedef unsigned size_type; + + // std::cout << "Dense assignment\n"; + checked_change_resource(src); + // del checked_change_dim(num_rows(src), num_cols(src)); + + Matrix& matrix= static_cast<Matrix&>(*this); + for (size_type r= 0; r < num_rows(matrix); ++r) + for (size_type c= 0; c < num_cols(matrix); ++c) + matrix[r][c]+= src[r][c]; + return matrix; + } + + // If sparse matrices are involved evaluate step-wise (or assignment from scalar) + template <typename Source> + Matrix& density_plus_assign(const Source& src, boost::mpl::false_) + { + // std::cout << "Sparse assignment\n"; + return crtp_plus_assign<Source, Matrix>()(src, static_cast<Matrix&>(*this)); + } + + // For (compatible) dense matrices do a loop over all entries + template <typename Source> + Matrix& density_minus_assign(const Source& src, boost::mpl::true_) + { + vampir_trace<3034> tracer; + // typedef typename Collection<Source>::size_type size_type; + typedef unsigned size_type; + + // std::cout << "Dense assignment\n"; + checked_change_resource(src); + + Matrix& matrix= static_cast<Matrix&>(*this); + for (size_type r= 0; r < num_rows(matrix); ++r) + for (size_type c= 0; c < num_cols(matrix); ++c) + matrix[r][c]-= src[r][c]; + return matrix; + } + + // If sparse matrices are involved evaluate step-wise (or assignment from scalar) + template <typename Source> + Matrix& density_minus_assign(const Source& src, boost::mpl::false_) + { + // std::cout << "Sparse assignment\n"; + return crtp_minus_assign<Source, Matrix>()(src, static_cast<Matrix&>(*this)); + } + + // For (compatible) dense matrices do a loop over all entries + template <typename Source> + Matrix& density_ele_rscale(const Source& src, boost::mpl::true_) + { + vampir_trace<3035> tracer; + // typedef typename Collection<Source>::size_type size_type; + typedef unsigned size_type; + + // std::cout << "Dense assignment\n"; + checked_change_resource(src); + // del checked_change_dim(num_rows(src), num_cols(src)); + + Matrix& matrix= static_cast<Matrix&>(*this); + for (size_type r= 0; r < num_rows(matrix); ++r) + for (size_type c= 0; c < num_cols(matrix); ++c) + matrix[r][c]*= src[r][c]; + return matrix; + } + + // If sparse matrices are involved evaluate step-wise (or assignment from scalar) + template <typename Factor> + Matrix& density_ele_rscale(const Factor& alpha, boost::mpl::false_) + { + // std::cout << "Sparse assignment\n"; + matrix_copy_ele_times(alpha, static_cast<Matrix&>(*this)); + return static_cast<Matrix&>(*this); + } + + public: + + /// Check wether source and target have compatible resources, generalization of check_dim + /** For expressions like A= B + C, A can be set to the size of B and C if still is 0 by 0. **/ + template <typename Src> + void check_resource(const Src& src) const + { check_resource(src, typename mtl::traits::category<Matrix>::type()); } + + // Default case just check_dim + template <typename Src> + void check_resource(const Src& src, tag::universe) const + { check_dim(num_rows(src), num_cols(src)); } + + /// Check wether source and target have compatible resources and wether target has already resources + /** For expressions like A+= B + C, A must be already larger then 0 by 0 and compatible to B and C. **/ + // Generalization with 2 arguments might be needed (check rows from first and columns from second) + template <typename Src> + void check_ready_resource(const Src& src) const + { + MTL_DEBUG_THROW_IF(num_rows(src) * num_cols(src) == 0, need_nonempty()); + check_resource(src); + } + + /// Check wether source and target have compatible resources and adapt empty target + /** For expressions like A= B + C, A can be set to the size of B and C if still is 0 by 0. **/ + template <typename Src> + void checked_change_resource(const Src& src) + { checked_change_resource(src, src); } + + /// Check whether source and target have compatible resources and adapt empty target + /** For expressions like A= B + C, A can be set to the size of B and C if still is 0 by 0. **/ + template <typename Src1, typename Src2> + void checked_change_resource(const Src1& src1, const Src2& src2) + { checked_change_resource_aux(src1, src2, typename mtl::traits::category<Matrix>::type()); } + + template <typename Src1, typename Src2> + void checked_change_resource_aux(const Src1& src1, const Src2& src2, tag::universe) + { checked_change_dim(num_rows(src1), num_cols(src2)); } + + + /// Check whether matrix sizes are compatible or if matrix is 0 by 0 change it to r by c. + /** Deprecated, superseded by checked_change_resource. **/ + void checked_change_dim(SizeType r, SizeType c) + { + Matrix& matrix= static_cast<Matrix&>(*this); + matrix.check_dim(r, c); + matrix.change_dim(r, c); + } + + /// Templated assignment implemented by functor to allow for partial specialization + // Despite there is only an untemplated assignment and despite the disable_if MSVC whines about ambiguity :-! + // Scalar assignment is also taking out because it has another return type + template <typename Source> + typename boost::disable_if_c<boost::is_same<Matrix, Source>::value + || boost::is_same<typename ashape::ashape<Source>::type, ashape::scal>::value, + Matrix&>::type + operator=(const Source& src) + { + return density_assign(src, boost::mpl::bool_< boost::is_same<typename ashape::ashape<Matrix>::type, + typename ashape::ashape<Source>::type>::value + && mtl::traits::eval_dense< mat_mat_asgn_expr<Matrix, Source> >::value >()); + } + + // Helper type for assigning scalars to handle both A= a; and A= a, b, c; + template <typename Source> + struct scalar_assign + { + scalar_assign(Source src, Matrix& matrix) + : src(src), with_comma(false), r(0), c(0), matrix(matrix), ins(matrix, 1) {} + + ~scalar_assign() + { + vampir_trace<3047> tracer; + if (with_comma) { + MTL_DEBUG_THROW_IF(r != num_rows(matrix), incompatible_size("Not all matrix entries initialized!")); + } else { + using std::min; + if (src == math::zero(src)) // it is already set to zero + return; + // Otherwise set diagonal (if square) + for (SizeType i= 0, n= min(num_rows(matrix), num_cols(matrix)); i < n; i++) + ins[i][i] << src; + } + } + + template <typename ValueSource> + scalar_assign& operator, (ValueSource val) + { + if (!with_comma) { + with_comma= true; + assert(r == 0 && c == 0); + ins[r][c++] << src; // We haven't set v[0] yet + if (c == num_cols(matrix)) + c= 0, r++; + } + ins[r][c++] << val; + if (c == num_cols(matrix)) + c= 0, r++; + return *this; + } + + Source src; + bool with_comma; + SizeType r, c; + Matrix& matrix; + inserter<Matrix> ins; + }; + + template <typename Source> + typename boost::enable_if<boost::is_same<typename ashape::ashape<Source>::type, ashape::scal>, + scalar_assign<Source> >::type + operator=(Source src) + { + Matrix& matrix= static_cast<Matrix&>(*this); + MTL_DEBUG_THROW_IF(num_rows(matrix) * num_cols(matrix) == 0, + range_error("Trying to initialize a 0 by 0 matrix with a value")); + set_to_zero(matrix); + return scalar_assign<Source>(src, static_cast<Matrix&>(*this)); + } + + template <typename Source> + Matrix& operator+=(const Source& src) + { + return density_plus_assign(src, mtl::traits::eval_dense< mat_mat_asgn_expr<Matrix, Source> >()); + } + + template <typename Source> + Matrix& operator-=(const Source& src) + { + return density_minus_assign(src, mtl::traits::eval_dense< mat_mat_asgn_expr<Matrix, Source> >()); + } + + /// Scale matrix (in place) with scalar value or other matrix + template <typename Factor> + Matrix& operator*=(const Factor& alpha) + { + right_scale_inplace(static_cast<Matrix&>(*this), alpha); + return static_cast<Matrix&>(*this); + } + + // Element-wise scaling from right (i.e. like *= as elementwise) + template <typename Factor> + Matrix& ele_rscale(const Factor& alpha) + { + return density_ele_rscale(alpha, mtl::traits::eval_dense< mat_mat_asgn_expr<Matrix, Factor> >()); + } + + /// Divide matrix (in place) by scalar value + // added by Hui Li + template <typename Factor> + Matrix& operator/=(const Factor& alpha) + { + divide_by_inplace(static_cast<Matrix&>(*this), alpha); + return static_cast<Matrix&>(*this); + } +}; + + + +template <typename Matrix, typename ValueType, typename SizeType> +struct const_crtp_matrix_bracket +{ + template <typename T> + typename boost::disable_if_c<boost::is_same<T, mtl::irange>::value || boost::is_same<T, mtl::iset>::value, + operations::bracket_proxy<Matrix, const Matrix&, ValueType> >::type + operator[] (const T& row) const + { + return operations::bracket_proxy<Matrix, const Matrix&, ValueType>(static_cast<const Matrix&>(*this), row); + } + + // Compiler error (later) if no sub_matrix function (or row vector resp.) available + template <typename T> + typename boost::enable_if<boost::is_same<T, mtl::irange>, operations::range_bracket_proxy<Matrix, const Matrix&, const Matrix> >::type + operator[] (const T& row_range) const + { + return operations::range_bracket_proxy<Matrix, const Matrix&, const Matrix>(static_cast<const Matrix&>(*this), row_range); + } + + operations::set_bracket_proxy<Matrix, const Matrix&, const Matrix> + operator[] (const iset& row_set) const + { + return operations::set_bracket_proxy<Matrix, const Matrix&, const Matrix>(static_cast<const Matrix&>(*this), row_set); + } +}; + +template <typename Matrix, typename ValueType, typename SizeType> +struct crtp_matrix_bracket +{ + operations::bracket_proxy<Matrix, const Matrix&, const ValueType&> + operator[] (SizeType row) const + { + return operations::bracket_proxy<Matrix, const Matrix&, const ValueType&>(static_cast<const Matrix&>(*this), row); + } + + template <typename T> + typename boost::disable_if_c<boost::is_same<T, mtl::irange>::value || boost::is_same<T, mtl::iset>::value, + operations::bracket_proxy<Matrix, Matrix&, ValueType&> >::type + // operations::bracket_proxy<Matrix, Matrix&, ValueType&> + operator[] (const T& row) + { + return operations::bracket_proxy<Matrix, Matrix&, ValueType&>(static_cast<Matrix&>(*this), row); + } + + // Compiler error (later) if no sub_matrix function available + operations::range_bracket_proxy<Matrix, const Matrix&, const Matrix> + operator[] (const irange& row_range) const + { + return operations::range_bracket_proxy<Matrix, const Matrix&, const Matrix>(static_cast<const Matrix&>(*this), row_range); + } + + // Compiler error (later) if no sub_matrix function available + template <typename T> + typename boost::enable_if<boost::is_same<T, mtl::irange>, operations::range_bracket_proxy<Matrix, Matrix&, Matrix> >::type + // operations::range_bracket_proxy<Matrix, Matrix&, Matrix> + operator[] (const T& row_range) + { + return operations::range_bracket_proxy<Matrix, Matrix&, Matrix>(static_cast<Matrix&>(*this), row_range); + } + + operations::set_bracket_proxy<Matrix, const Matrix&, const Matrix> + operator[] (const iset& row_set) const + { + return operations::set_bracket_proxy<Matrix, const Matrix&, const Matrix>(static_cast<const Matrix&>(*this), row_set); + } +}; + +template <typename Matrix, typename ValueType, typename SizeType> +struct crtp_matrix_lvalue +{ + // Function must be overwritten by Matrix if m(row, col) does not return a reference + ValueType& lvalue(SizeType row, SizeType col) + { + return static_cast<Matrix&>(*this)(row, col); + } +}; + +template <typename Matrix, typename ValueType, typename SizeType> +struct const_crtp_base_matrix + : public const_crtp_matrix_bracket<Matrix, ValueType, SizeType> +{}; + +template <typename Matrix, typename ValueType, typename SizeType> +struct mutable_crtp_base_matrix + : public crtp_matrix_bracket<Matrix, ValueType, SizeType>, + public crtp_matrix_assign<Matrix, ValueType, SizeType> +{}; + +template <typename Matrix, typename ValueType, typename SizeType> +struct crtp_base_matrix + : boost::mpl::if_<boost::is_const<Matrix>, + const_crtp_base_matrix<Matrix, ValueType, SizeType>, + mutable_crtp_base_matrix<Matrix, ValueType, SizeType> + >::type +{}; + + + +}} // namespace mtl::matrix + +#endif // MTL_CRTP_BASE_MATRIX_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/dense2D.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/dense2D.hpp new file mode 100644 index 0000000000000000000000000000000000000000..3028ea050b7f0574658f645382e6f776869d1a2d --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/dense2D.hpp @@ -0,0 +1,909 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_DENSE2D_INCLUDE +#define MTL_DENSE2D_INCLUDE + + +#include <algorithm> +#include <boost/mpl/bool.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/mpl/if.hpp> +#include <boost/utility/enable_if.hpp> + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/matrix/crtp_base_matrix.hpp> +#include <boost/numeric/mtl/matrix/base_sub_matrix.hpp> +#include <boost/numeric/mtl/matrix/all_mat_expr.hpp> +#include <boost/numeric/mtl/matrix/operators.hpp> +#include <boost/numeric/mtl/detail/contiguous_memory_block.hpp> +#include <boost/numeric/mtl/operation/set_to_zero.hpp> +#include <boost/numeric/mtl/operation/compute_factors.hpp> +#include <boost/numeric/mtl/operation/clone.hpp> +#include <boost/numeric/mtl/operation/is_negative.hpp> +#include <boost/numeric/mtl/utility/common_include.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/is_static.hpp> +#include <boost/numeric/mtl/utility/irange.hpp> +#include <boost/numeric/mtl/utility/dense_el_cursor.hpp> +#include <boost/numeric/mtl/utility/static_assert.hpp> +#include <boost/numeric/mtl/utility/strided_dense_el_cursor.hpp> +#include <boost/numeric/mtl/utility/strided_dense_el_iterator.hpp> +#include <boost/numeric/mtl/utility/transposed_orientation.hpp> +#include <boost/numeric/linear_algebra/identity.hpp> + +#ifdef MTL_WITH_INITLIST +# include <initializer_list> +#endif + +// Forward declaration (for friend declaration) +namespace mtl { namespace traits { namespace detail { + template <typename, typename, bool> struct dense2D_iterator_range_generator; +}}} + +namespace mtl { namespace matrix { + + +using std::size_t; + +// Forward declarations +template <typename Value, typename Parameters> class dense2D; +class dense2D_indexer; + +// Helper type +struct dense2D_sub_ctor {}; + +// Indexing for dense matrices +class dense2D_indexer +{ + // helpers for public functions + size_t offset(size_t ldim, size_t r, size_t c, row_major) const + { + return r * ldim + c; + } + size_t offset(size_t ldim, size_t r, size_t c, col_major) const + { + return c * ldim + r; + } + + size_t row(size_t offset, size_t ldim, row_major) const + { + return offset / ldim; + } + size_t row(size_t offset, size_t ldim, col_major) const + { + return offset % ldim; + } + + size_t col(size_t offset, size_t ldim, row_major) const + { + return offset % ldim; + } + size_t col(size_t offset, size_t ldim, col_major) const + { + return offset / ldim; + } + + public: + template <typename Value, class Parameters> + size_t operator() (const dense2D<Value, Parameters>& ma, size_t r, size_t c) const + { + typedef dense2D<Value, Parameters> matrix_type; + // convert into c indices + typename matrix_type::index_type my_index; + size_t my_r= index::change_from(my_index, r); + size_t my_c= index::change_from(my_index, c); + return offset(ma.ldim, my_r, my_c, typename matrix_type::orientation()); + } + + template <typename Value, class Parameters> + size_t row(const dense2D<Value, Parameters>& ma, + typename dense2D<Value, Parameters>::key_type key) const + { + typedef dense2D<Value, Parameters> matrix_type; + // row with c-index for my orientation + size_t r= row(ma.offset(key), ma.ldim, typename matrix_type::orientation()); + return index::change_to(typename matrix_type::index_type(), r); + } + + template <typename Value, class Parameters> + size_t col(const dense2D<Value, Parameters>& ma, + typename dense2D<Value, Parameters>::key_type key) const + { + typedef dense2D<Value, Parameters> matrix_type; + // column with c-index for my orientation + size_t c= col(ma.offset(key), ma.ldim, typename matrix_type::orientation()); + return index::change_to(typename matrix_type::index_type(), c); + } + template <typename, typename> friend class dense2D; +}; // dense2D_indexer + + +namespace detail +{ + + // Compute required memory + // Enabling mechanism to make sure that computation is valid + template <typename Parameters, bool Enable> + struct dense2D_array_size { + static std::size_t const value= 0; + }; + + template <typename Parameters> + struct dense2D_array_size<Parameters, true> + { + typedef typename Parameters::dimensions dimensions; + MTL_STATIC_ASSERT((dimensions::is_static), "Size must be known at compile time."); + static std::size_t const value= dimensions::Num_Rows * dimensions::Num_Cols; + }; + + // return const-ref if matrix on stack and type itself if on heap + template <typename Matrix, bool on_stack> + struct ref_on_stack + { + typedef Matrix type; + }; + + template <typename Matrix> + struct ref_on_stack<Matrix, true> + { + typedef const Matrix& type; + }; + +} // namespace detail + + +/// Dense matrix type +template <typename Value, typename Parameters = parameters<> > +class dense2D + : public base_sub_matrix<Value, Parameters>, + public mtl::detail::contiguous_memory_block< Value, Parameters::on_stack, + detail::dense2D_array_size<Parameters, Parameters::on_stack>::value >, + public crtp_base_matrix< dense2D<Value, Parameters>, Value, std::size_t >, + public mat_expr< dense2D<Value, Parameters> > +{ + typedef dense2D self; + typedef base_sub_matrix<Value, Parameters> super; + typedef mtl::detail::contiguous_memory_block<Value, Parameters::on_stack, + detail::dense2D_array_size<Parameters, Parameters::on_stack>::value> memory_base; + typedef mat_expr< dense2D<Value, Parameters> > expr_base; + typedef crtp_base_matrix< self, Value, std::size_t > crtp_base; + typedef crtp_matrix_assign< self, Value, std::size_t > assign_base; + public: + typedef Parameters parameters; + typedef typename Parameters::orientation orientation; + typedef typename Parameters::index index_type; + typedef typename Parameters::dimensions dim_type; + typedef Value value_type; + typedef const value_type& const_reference; + typedef value_type& reference; + + typedef const value_type* const_pointer_type; + typedef const_pointer_type key_type; + typedef std::size_t size_type; + typedef dense_el_cursor<Value> el_cursor_type; + typedef dense2D_indexer indexer_type; + + // Self-similar type unless dimension is fixed + // Not supported for the moment + typedef self sub_matrix_type; + + protected: + // Obviously, the next 3 functions must be called after setting dimensions + void set_nnz() { this->my_nnz = this->num_rows() * this->num_cols(); } + void set_ldim(row_major) { ldim= this->num_cols(); } + void set_ldim(col_major) { ldim= this->num_rows(); } + void set_ldim() { set_ldim(orientation()); } + + void init() + { + set_nnz(); set_ldim(); // set_to_zero(*this); + } + + public: + /// Default constructor, if compile time matrix size allocate memory + dense2D() : super(), memory_base(dim_type().num_rows() * dim_type().num_cols()) + { init(); } + + /// Constructor that only sets dimensions, only for run-time dimensions + explicit dense2D(mtl::non_fixed::dimensions d) + : super(d), memory_base(d.num_rows() * d.num_cols()) + { init(); } + + /// Most common constructor from number of rows and columns + explicit dense2D(size_type num_rows, size_type num_cols) + : super(dim_type(num_rows, num_cols)), + memory_base(num_rows * num_cols) + { init(); } + + /// Constructor that sets dimensions and pointer to external data + explicit dense2D(mtl::non_fixed::dimensions d, value_type* a) + : super(d), memory_base(a, d.num_rows() * d.num_cols()) + { init(); } + + /// Constructor that sets dimensions and pointer to external data + explicit dense2D(size_type num_rows, size_type num_cols, value_type* a) + : super(mtl::non_fixed::dimensions(num_rows, num_cols)), memory_base(a, num_rows * num_cols) + { init(); } + + /// Constructor for compile time matrix size + /** sets dimensions and pointer to external data **/ + explicit dense2D(value_type* a) + : super(), memory_base(a, dim_type().num_rows() * dim_type().num_cols()) + { + MTL_STATIC_ASSERT((dim_type::is_static), "Size must be known at compile time."); + init(); + } + + /// Default copy constructor + dense2D(const self& m) + : super(dim_type(m.num_rows(), m.num_cols())), + memory_base(m) + { + // In case of sub-matrices we need m's ldim -> init doesn't work + this->my_nnz= m.my_nnz; ldim= m.ldim; + } + + /// Clone constructor, copies every source including sub-matrices and other matrices with references + explicit dense2D(const self& m, clone_ctor) + : super(mtl::non_fixed::dimensions(m.num_rows(), m.num_cols())), + memory_base(m, clone_ctor()) + { + init(); + *this= m; + } + + /// General copy constructor, uses functionality from CRTP base + template <typename MatrixSrc> + explicit dense2D(const MatrixSrc& src) + : super(), memory_base(dim_type().num_rows() * dim_type().num_cols()) + { + init(); + *this= src; + } + + /// Constructor for creating sub-matrices + template <typename MatrixSrc> + dense2D(MatrixSrc& matrix, dense2D_sub_ctor, + size_type begin_r, size_type end_r, size_type begin_c, size_type end_c) + : super(mtl::non_fixed::dimensions(matrix.num_rows(), matrix.num_cols())), + memory_base(matrix.data, (end_r - begin_r) * (end_c - begin_c), true) + { + sub_matrix_constructor(matrix, begin_r, end_r, begin_c, end_c, boost::mpl::bool_<memory_base::on_stack>()); + } + +#if defined(MTL_WITH_INITLIST) && defined(MTL_WITH_AUTO) && defined(MTL_WITH_RANGEDFOR) + /// Constructor for initializer list \p values + template <typename Value2> + dense2D(std::initializer_list<std::initializer_list<Value2> > values) + : super(mtl::non_fixed::dimensions(values.size(), values.size()? values.begin()->size() : 0)), + memory_base(this->num_rows() * this->num_cols()) + { + init(); + *this= values; + } +#endif + + private: + template <typename MatrixSrc> + void sub_matrix_constructor(MatrixSrc& matrix, size_type begin_r, size_type end_r, + size_type begin_c, size_type end_c, boost::mpl::false_) + { + matrix.check_ranges(begin_r, end_r, begin_c, end_c); + + if(end_r <= begin_r || end_c <= begin_c) + set_ranges(0, 0); + else { + // Leading dimension doesn't change + this->data += matrix.indexer(matrix, begin_r, begin_c); // Takes care of indexing + set_ranges(end_r - begin_r, end_c - begin_c); + } + this->my_nnz= matrix.nnz(); ldim= matrix.get_ldim(); + } + + template <typename MatrixSrc> + void sub_matrix_constructor(MatrixSrc&, size_type, size_type, + size_type, size_type, boost::mpl::true_) + { + MTL_THROW(logic_error("Matrices cannot be used as sub-matrices!")); + } + + public: + +#ifdef MTL_WITH_MOVE + /// Move assignment for data on heap + self& operator=(self&& src) + { return self_assign(src, boost::mpl::bool_<memory_base::on_stack>()); } + + // { + // swap(*this, src); + // std::cout << "In dense2D::move_assignment\n"; + // return *this; + // } + + /// (Copy) Assignment + self& operator=(const self& src) + { return self_assign(src, boost::mpl::true_()); } + +#else + /// (Copy) Assignment + self& operator=(typename detail::ref_on_stack<self, memory_base::on_stack>::type src) + { + return self_assign(src, boost::mpl::bool_<memory_base::on_stack>()); + } +#endif + + private: + // Already copied for lvalues -> data can be stolen (need non-const ref) + self& self_assign(self& src, boost::mpl::false_) + { + // Self-copy would be an indication of an error + assert(this != &src); + // std::cout << "In move assignment: this* = \n" << *this << "src = \n" << src; + + this->checked_change_dim(src.num_rows(), src.num_cols()); + if (this->category == memory_base::view || src.category == memory_base::view) + matrix_copy(src, *this); + else { + if (this->num_rows() != src.num_rows() || this->num_cols() != src.num_cols()) { + super::change_dim(src.num_rows(), src.num_cols()); + init(); + } + memory_base::move_assignment(src); + } + // std::cout << "End of move assignment: this* = \n" << *this; + return *this; + } + + // For matrices with data on stack (or lvalues in C++11) + self& self_assign(const self& src, boost::mpl::true_) + { + if (this != &src) { + this->checked_change_dim(src.num_rows(), src.num_cols()); + matrix_copy(src, *this); + } + return *this; + } + public: + + // import operators from CRTP base class +#if 0 // def __PGI + using crtp_base::operator=; +#else + using assign_base::operator=; +#endif + + /// Change dimension, can keep old data + void change_dim(size_type r, size_type c, bool keep_data = false) + { + change_dim(r, c, keep_data, mtl::traits::is_static<self>()); + } + + private: + void change_dim(size_type r, size_type c, bool keep_data, boost::mpl::false_) + { + if (r == this->num_rows() && c == this->num_cols()) + return; + + self temp; + if (keep_data) { + temp.super::change_dim(this->num_rows(), this->num_cols()); + temp.init(); + temp.memory_base::move_assignment(*this); + } + memory_base::realloc(r*c); + super::change_dim(r, c); + init(); + if (keep_data) { + if (r > temp.num_rows() || c > temp.num_cols()){ + set_to_zero(*this); +#if 0 + irange rr(0, std::min(r,temp.num_rows())), cr(0, std::min(c,temp.num_cols())); + *this[rr][cr]= temp[rr][cr]; +#endif + sub_matrix(*this,0,std::min(r,temp.num_rows()),0,std::min(c,temp.num_cols())) + = sub_matrix(temp,0,std::min(r,temp.num_rows()),0,std::min(c,temp.num_cols())); + } else + *this = temp[irange(0, r)][irange(0, c)]; + } + } + + void change_dim(size_type MTL_DEBUG_ARG(r), size_type MTL_DEBUG_ARG(c), bool, boost::mpl::true_) + { assert(r == this->num_rows() && c == this->num_cols()); } + + public: + /// Check whether indices r and c are in range + bool check_indices(size_t r, size_t c) const + { return r >= this->begin_row() && r < this->end_row() && c >= this->begin_col() && c < this->end_col(); } + + /// Constant access to element + const_reference operator() (size_t r, size_t c) const + { + MTL_DEBUG_THROW_IF(is_negative(r) || r >= this->num_rows() || is_negative(c) || c >= this->num_cols(), index_out_of_range()); + return this->data[indexer(*this, r, c)]; + } + + /// Mutable access to element + value_type& operator() (size_t r, size_t c) + { + MTL_DEBUG_THROW_IF(is_negative(r) || r >= this->num_rows() || is_negative(c) || c >= this->num_cols(), index_out_of_range()); + return this->data[indexer(*this, r, c)]; + } + + // offset regarding c-style indices + size_t c_offset(size_t r, size_t c) const + { return indexer.offset(ldim, r, c, orientation()); } + + /// Get lower dimension [advanced] + size_type get_ldim() const + { return ldim; } + + /// Swap two matrices + friend void swap(self& matrix1, self& matrix2) + { + swap(static_cast<memory_base&>(matrix1), static_cast<memory_base&>(matrix2)); + swap(static_cast<super&>(matrix1), static_cast<super&>(matrix2)); + std::swap(matrix1.ldim, matrix2.ldim); + } + + void crop() {} ///< Delete structural zeros; only dummy here + + /// Address of first data entry (mutable); to be used with care. [advanced] + value_type* address_data() { return this->data; } + /// Address of first data entry (constant); to be used with care. [advanced] + const value_type* address_data() const { return this->data; } + + /// Whether data is stored in strides + bool has_strided_data() const { return this->category != this->own; } + + protected: + + // Set ranges from begin_r to end_r and begin_c to end_c + void set_ranges(size_type begin_r, size_type end_r, size_type begin_c, size_type end_c) + { + super::set_ranges(begin_r, end_r, begin_c, end_c); + set_nnz(); + } + + // Set ranges to a num_row x num_col matrix, keeps indexing + void set_ranges(size_type num_rows, size_type num_cols) + { + set_ranges(this->begin_row(), this->begin_row() + num_rows, + this->begin_col(), this->begin_col() + num_cols); + } + + public: + + indexer_type indexer; + + friend class dense2D_indexer; + +#if !defined(_MSC_VER) || _MSC_VER != 1400 // Bug in MSVC 2005 + template <typename> friend struct sub_matrix_t; + template <typename, typename> friend struct mtl::traits::range_generator; + template <typename, typename, bool> friend struct mtl::traits::detail::dense2D_iterator_range_generator; + + protected: +#endif + + // Leading dimension is minor dimension in original matrix + // Opposed to other dims doesn't change in sub-matrices + size_type ldim; + +}; // dense2D + + +// ================ +// Free functions +// ================ + + +/// Number of rows +template <typename Value, typename Parameters> +typename dense2D<Value, Parameters>::size_type +inline num_rows(const dense2D<Value, Parameters>& matrix) +{ + return matrix.num_rows(); +} + +/// Number of columns +template <typename Value, typename Parameters> +typename dense2D<Value, Parameters>::size_type +inline num_cols(const dense2D<Value, Parameters>& matrix) +{ + return matrix.num_cols(); +} + +/// Size of the matrix, i.e. the number of row times columns +template <typename Value, typename Parameters> +typename dense2D<Value, Parameters>::size_type +inline size(const dense2D<Value, Parameters>& matrix) +{ + return matrix.num_cols() * matrix.num_rows(); +} + + +} + +using matrix::dense2D; + +} // namespace mtl::matrix + + +namespace mtl { namespace traits { + + + // VC 8.0 finds ambiguity with mtl::tag::dense2D (I wonder why, especially here) + using mtl::matrix::dense2D; + + // ================ + // Range generators + // For cursors + // ================ + + template <typename Value, typename Parameters> + struct range_generator<glas::tag::all, dense2D<Value, Parameters> > + : detail::dense_element_range_generator<dense2D<Value, Parameters>, + dense_el_cursor<Value>, complexity_classes::linear_cached> + {}; + + template <typename Value, typename Parameters> + struct range_generator<glas::tag::nz, dense2D<Value, Parameters> > + : detail::dense_element_range_generator<dense2D<Value, Parameters>, + dense_el_cursor<Value>, complexity_classes::linear_cached> + {}; + + namespace detail + { + // complexity of dense row cursor depends on storage scheme + // if orientation is row_major then complexity is cached_linear, otherwise linear + template <typename Orientation> struct dense2D_rc {}; + template<> struct dense2D_rc<row_major> + { + typedef complexity_classes::linear_cached type; + }; + template<> struct dense2D_rc<col_major> + { + typedef complexity_classes::linear type; + }; + + // Complexity of column cursor is of course opposite + template <typename Orientation> struct dense2D_cc + : dense2D_rc<typename mtl::traits::transposed_orientation<Orientation>::type> + {}; + } + + template <typename Value, typename Parameters> + struct range_generator<glas::tag::row, dense2D<Value, Parameters> > + : detail::all_rows_range_generator<dense2D<Value, Parameters>, + typename detail::dense2D_rc<typename Parameters::orientation>::type> + {}; + + // For a cursor pointing to some row give the range of elements in this row + template <typename Value, typename Parameters> + struct range_generator<glas::tag::nz, + detail::sub_matrix_cursor<dense2D<Value, Parameters>, glas::tag::row, 2> > + { + typedef dense2D<Value, Parameters> matrix; + typedef typename matrix::size_type size_type; + typedef detail::sub_matrix_cursor<matrix, glas::tag::row, 2> cursor; + + // linear for col_major and linear_cached for row_major + typedef typename detail::dense2D_rc<typename Parameters::orientation>::type complexity; + static int const level = 1; + + typedef typename boost::mpl::if_< + boost::is_same<typename Parameters::orientation, row_major> + , dense_el_cursor<Value> + , strided_dense_el_cursor<Value> + >::type type; + + private: + + type dispatch(cursor const& c, size_type col, row_major) const + { + return type(c.ref, c.key, col); + } + type dispatch(cursor const& c, size_type col, col_major) const + { + return type(c.ref, c.key, col, c.ref.ldim); + } + + public: + + type begin(cursor const& c) const + { + return dispatch(c, c.ref.begin_col(), typename matrix::orientation()); + } + type end(cursor const& c) const + { + return dispatch(c, c.ref.end_col(), typename matrix::orientation()); + } + type lower_bound(cursor const& c, size_type position) const + { + return dispatch(c, std::min(c.ref.end_col(), position), typename matrix::orientation()); + } + }; + + template <typename Value, typename Parameters> + struct range_generator<glas::tag::all, + detail::sub_matrix_cursor<dense2D<Value, Parameters>, glas::tag::row, 2> > + : range_generator<glas::tag::nz, + detail::sub_matrix_cursor<dense2D<Value, Parameters>, glas::tag::row, 2> > + {}; + + + template <typename Value, typename Parameters> + struct range_generator<glas::tag::col, dense2D<Value, Parameters> > + : detail::all_cols_range_generator<dense2D<Value, Parameters>, + typename detail::dense2D_cc<typename Parameters::orientation>::type> + {}; + + // For a cursor pointing to some row give the range of elements in this row + template <typename Value, typename Parameters> + struct range_generator<glas::tag::nz, + detail::sub_matrix_cursor<dense2D<Value, Parameters>, glas::tag::col, 2> > + { + typedef dense2D<Value, Parameters> matrix; + typedef typename matrix::size_type size_type; + typedef detail::sub_matrix_cursor<matrix, glas::tag::col, 2> cursor; + typedef typename detail::dense2D_cc<typename Parameters::orientation>::type complexity; + static int const level = 1; + + typedef typename boost::mpl::if_< + boost::is_same<typename Parameters::orientation, col_major> + , dense_el_cursor<Value> + , strided_dense_el_cursor<Value> + >::type type; + + private: + type dispatch(cursor const& c, size_type row, col_major) const + { + return type(c.ref, row, c.key); + } + type dispatch(cursor const& c, size_type row, row_major) const + { + return type(c.ref, row, c.key, c.ref.ldim); + } + + public: + type begin(cursor const& c) const + { + return dispatch(c, c.ref.begin_row(), typename matrix::orientation()); + } + type end(cursor const& c) const + { + return dispatch(c, c.ref.end_row(), typename matrix::orientation()); + } + type lower_bound(cursor const& c, size_type position) const + { + return dispatch(c, std::min(c.ref.end_row(), position), typename matrix::orientation()); + } + }; + + template <typename Value, typename Parameters> + struct range_generator<glas::tag::all, + detail::sub_matrix_cursor<dense2D<Value, Parameters>, glas::tag::col, 2> > + : public range_generator<glas::tag::nz, + detail::sub_matrix_cursor<dense2D<Value, Parameters>, glas::tag::col, 2> > + {}; + +// ============= +// For iterators +// ============= + + + namespace detail { + + // Traversal along major dimension first and then along minor + template <typename OuterTag, typename Orientation> + struct major_traversal + { + static const bool value= false; + }; + + template <> struct major_traversal<glas::tag::row, row_major> + { + static const bool value= true; + }; + + template <> struct major_traversal<glas::tag::col, col_major> + { + static const bool value= true; + }; + + + template <typename OuterTag, typename Matrix, bool is_const> + struct dense2D_iterator_range_generator + { + typedef Matrix matrix_type; + typedef typename matrix_type::size_type size_type; + typedef typename matrix_type::value_type value_type; + typedef typename matrix_type::parameters parameters; + typedef detail::sub_matrix_cursor<matrix_type, OuterTag, 2> cursor; + + // if traverse first along major dimension then memory access is contiguous (otherwise strided) + typedef typename boost::mpl::if_< + major_traversal<OuterTag, typename parameters::orientation> + , complexity_classes::linear_cached + , complexity_classes::linear + >::type complexity; + static int const level = 1; + + // if traverse first along major dimension use pointer otherwise strided iterator + typedef typename boost::mpl::if_< + major_traversal<OuterTag, typename parameters::orientation> + , typename boost::mpl::if_c< + is_const + , const value_type* + , value_type* + >::type + , typename boost::mpl::if_c< + is_const + , strided_dense_el_const_iterator<value_type> + , strided_dense_el_iterator<value_type> + >::type + >::type type; + + private: + // if traverse first along major dim. then return address as pointer + type dispatch(cursor const& c, size_type row, size_type col, complexity_classes::linear_cached) const + { + matrix_type& ma= const_cast<matrix_type&>(c.ref); + return ma.elements() + ma.indexer(ma, row, col); // &ref[row][col]; + } + + // otherwise strided + type dispatch(cursor const& c, size_type row, size_type col, complexity_classes::linear) const + { + // cast const away (is dirty and should be improved later (cursors must distinct constness)) + matrix_type& ref= const_cast<matrix_type&>(c.ref); + return type(ref, row, col, ref.ldim); + } + + type begin_dispatch(cursor const& c, glas::tag::row) const + { + return dispatch(c, c.key, c.ref.begin_col(), complexity()); + } + + type end_dispatch(cursor const& c, glas::tag::row) const + { + return dispatch(c, c.key, c.ref.end_col(), complexity()); + } + + + type begin_dispatch(cursor const& c, glas::tag::col) const + { + return dispatch(c, c.ref.begin_row(), c.key, complexity()); + } + + type end_dispatch(cursor const& c, glas::tag::col) const + { + return dispatch(c, c.ref.end_row(), c.key, complexity()); + } + + public: + + type begin(cursor const& c) const + { + return begin_dispatch(c, OuterTag()); + } + + type end(cursor const& c) const + { + return end_dispatch(c, OuterTag()); + } + }; + + } // namespace detail + + + template <typename Value, typename Parameters, typename OuterTag> + struct range_generator<tag::iter::nz, + detail::sub_matrix_cursor<dense2D<Value, Parameters>, OuterTag, 2> > + : public detail::dense2D_iterator_range_generator<OuterTag, dense2D<Value, Parameters>, false> + {}; + + template <typename Value, typename Parameters, typename OuterTag> + struct range_generator<tag::iter::all, + detail::sub_matrix_cursor<dense2D<Value, Parameters>, OuterTag, 2> > + : public detail::dense2D_iterator_range_generator<OuterTag, dense2D<Value, Parameters>, false> + {}; + + template <typename Value, typename Parameters, typename OuterTag> + struct range_generator<tag::const_iter::nz, + detail::sub_matrix_cursor<dense2D<Value, Parameters>, OuterTag, 2> > + : public detail::dense2D_iterator_range_generator<OuterTag, dense2D<Value, Parameters>, true> + {}; + + template <typename Value, typename Parameters, typename OuterTag> + struct range_generator<tag::const_iter::all, + detail::sub_matrix_cursor<dense2D<Value, Parameters>, OuterTag, 2> > + : public detail::dense2D_iterator_range_generator<OuterTag, dense2D<Value, Parameters>, true> + {}; + + +}} // namespace mtl::traits + +namespace mtl { namespace matrix { + + // ========== + // Sub matrix + // ========== + + template <typename Value, typename Parameters> + struct sub_matrix_t<dense2D<Value, Parameters> > + { + typedef dense2D<Value, Parameters> matrix_type; + // copy orientation, ignore index, set dimension to non-fixed and on_stack to false + typedef parameters<typename Parameters::orientation> para_type; + + typedef dense2D<Value, para_type> sub_matrix_type; + typedef sub_matrix_type const const_sub_matrix_type; + typedef typename matrix_type::size_type size_type; + + sub_matrix_type operator()(matrix_type& matrix, size_type begin_r, size_type end_r, size_type begin_c, size_type end_c) + { + return sub_matrix_type(matrix, dense2D_sub_ctor(), begin_r, end_r, begin_c, end_c); + } + + const_sub_matrix_type + operator()(matrix_type const& matrix, size_type begin_r, size_type end_r, size_type begin_c, size_type end_c) + { + // To minimize code duplication, we use the non-const version + sub_matrix_type tmp((*this)(const_cast<matrix_type&>(matrix), begin_r, end_r, begin_c, end_c)); + return tmp; + } + }; + +}} // mtl::matrix + +namespace mtl { + + // Enable cloning of dense matrices + template <typename Value, typename Parameters> + struct is_clonable< mtl::matrix::dense2D<Value, Parameters> > : boost::mpl::true_ {}; + +} // namespace mtl + + + +namespace math { + + // Multiplicative identities of matrices + template <typename Value, typename Parameters> + struct identity_t< mult<mtl::matrix::dense2D<Value, Parameters> >, mtl::matrix::dense2D<Value, Parameters> > + : public std::binary_function< mult<mtl::matrix::dense2D<Value, Parameters> >, + mtl::matrix::dense2D<Value, Parameters>, + mtl::matrix::dense2D<Value, Parameters> > + { + typedef mtl::matrix::dense2D<Value, Parameters> matrix_type; + + matrix_type operator() (const mult<matrix_type>&, const matrix_type& ref) const + { + matrix_type tmp(ref); + tmp= one(typename matrix_type::value_type()); + return tmp; + } + }; + +} // namespace math + + +#endif // MTL_DENSE2D_INCLUDE + + +/* +Limitations: +- with compile-time constant dimension, submatrices are not supported (would violate self-similarity) +- Element cursor doesn't work for sub-matrices (not contiguous) +*/ diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/diagonal_setup.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/diagonal_setup.hpp new file mode 100644 index 0000000000000000000000000000000000000000..16142458cf109e603cb4660e110db764b06a4ff2 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/diagonal_setup.hpp @@ -0,0 +1,48 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_DIAGONAL_SETUP_INCLUDE +#define MTL_DIAGONAL_SETUP_INCLUDE + +#include <boost/numeric/mtl/matrix/inserter.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/operation/set_to_zero.hpp> +#include <boost/numeric/linear_algebra/identity.hpp> + +namespace mtl { namespace matrix { + +/// Setup a matrix to a multiple of the unity matrix +/** Intended for sparse matrices but works also with dense matrices. + If the value is 0 the matrix is only zeroed out, whereby + a sparse matrix will be empty after this operation, + i.e. the zeros on the diagonal are not explicitly stored. + The diagonal in its generalized form is the set of entries with equal row and column + index (since r6843, older revision considered it erroneous to store + a non-zero scalar to a non-square matrix). + **/ +template <typename Matrix, typename Value> +inline void diagonal_setup(Matrix& matrix, const Value& value) +{ + using std::min; + if (num_rows(matrix) == 0 || num_cols(matrix) == 0) + return; + + set_to_zero(matrix); + inserter<Matrix> ins(matrix, 1); + for (typename Collection<Matrix>::size_type i= 0, n= min(num_rows(matrix), num_cols(matrix)); i < n; ++i) + ins[i][i] << value; +} + +}} // namespace mtl::matrix + +#endif // MTL_DIAGONAL_SETUP_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/dimension.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/dimension.hpp new file mode 100644 index 0000000000000000000000000000000000000000..7acab0891ca44bef2fd5a662ecc94f824250aeb6 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/dimension.hpp @@ -0,0 +1,117 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_DIMENSIONS_INCLUDE +#define MTL_DIMENSIONS_INCLUDE + +#include <iostream> +#include <cassert> +#include <boost/mpl/if.hpp> +#include <boost/utility/enable_if.hpp> + +namespace mtl { + +// dimension is a type for declaring matrix dimensions +// num_rows() and num_cols() return the number or rows and columns +// is_static says whether it is declared at compile time or not + +// Compile time version +namespace fixed +{ + + /// Compile-time dimensions + template <std::size_t Rows, std::size_t Cols> + struct dimensions + { + typedef std::size_t size_type; + + static size_type const Num_Rows= Rows; + static size_type const Num_Cols= Cols; + + // To have the same interface as fixed +#ifndef NDEBUG + /// Constructor does not need arguments but if given they are compared against the template arguments in debug mode + explicit dimensions(size_type r= Rows, size_type c= Cols) + { + assert(r == Rows); assert(c == Cols); + } +#else + explicit dimensions(size_type, size_type) {} + explicit dimensions(size_type) {} + explicit dimensions() {} +#endif + + size_type num_rows() const { return Rows; } ///< Number of rows + size_type num_cols() const { return Cols; } ///< Number of columns + + /// To check whether dimensions are static + static bool const is_static= true; + + /// Transposed dimension (type) + typedef dimensions<Cols, Rows> transposed_type; + transposed_type transpose() const + { + return transposed_type(); + } + }; + + /// Output of dimensions + template <std::size_t R, std::size_t C> + inline std::ostream& operator<< (std::ostream& stream, dimensions<R, C>) + { + return stream << R << 'x' << C; + } + +} // namespace fixed + +namespace non_fixed +{ + /// Run-time dimensions + struct dimensions + { + typedef std::size_t size_type; + + /// Constructor + dimensions(size_type r= 0, size_type c= 0) : r(r), c(c) {} + + /// Assignment + dimensions& operator=(const dimensions& x) + { + r= x.r; c= x.c; return *this; + } + size_type num_rows() const { return r; } ///< Number of rows + size_type num_cols() const { return c; } ///< Number of columns + + /// Transposed dimension + typedef dimensions transposed_type; + transposed_type transpose() + { + return transposed_type(c, r); + } + + /// To check whether dimensions are static + static bool const is_static= false; + protected: + size_type r, c; + }; + + /// Output of dimensions + inline std::ostream& operator<< (std::ostream& stream, dimensions d) + { + return stream << d.num_rows() << 'x' << d.num_cols(); + } + +} // namespace non_fixed + +} // namespace mtl + +#endif // MTL_DIMENSIONS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/element.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/element.hpp new file mode 100644 index 0000000000000000000000000000000000000000..d88cfc2b68b4e471459e980497f2ac32752147c0 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/element.hpp @@ -0,0 +1,504 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. +// +// Algorithm inspired by Nick Vannieuwenhoven, written by Cornelius Steinhardt + + +#ifndef MTL_ELEMENT_INCLUDE +#define MTL_ELEMENT_INCLUDE + +#include <vector> +#include <set> +#include <algorithm> +#include <iostream> +#include <functional> + +#include <boost/unordered_set.hpp> + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/matrix/dense2D.hpp> +#include <boost/numeric/mtl/vector/dense_vector.hpp> +#include <boost/numeric/mtl/utility/make_copy_or_reference.hpp> +#include <boost/numeric/itl/pc/comparators.hpp> + + +namespace mtl { namespace matrix { + +/// A class representing an element with ValType equals the type of the numeric values +template <typename ValType> +class element +{ + +public: + /// The type of this element. + typedef element<ValType> element_type; + + /// The value type of the matrix and rhs elements. + typedef ValType value_type; + + /// The type of a set of neighbors. + typedef std::vector<element_type*, std::allocator<element_type*> > neighbor_collection_type; // trouble with Clang 4.2 w/o allocator + + /// An iterator over the neighbors of this element. + typedef typename neighbor_collection_type::iterator neighbor_iterator; + + /// The type of an unordered set of neighbors. + typedef typename boost::unordered_set< + element_type*, + compare::address_hasher<element_type>, + compare::address_compare_equal<element_type> + > neighbor_set_type; + + /// The type of the iterator over an unorderd set of neighbors. + typedef typename neighbor_set_type::iterator neighbor_set_iterator_type; + + /// The type of matrix. + typedef mtl::matrix::dense2D<value_type> matrix_type; + + /// The type of the index vector. + typedef mtl::vector::dense_vector<int> index_type; + + +/******************************************************************************* + * Constructors + ******************************************************************************/ + + + /** + * Constructs the element using the memory specified by the two references. + * + * p_indices: a reference to the memory where the indices may be stored. + * p_values: a reference to the memory where the values may be stored. + */ + public: + element(int p_sequence_number, const index_type& p_indices, const matrix_type& p_values) + : m_indices(p_indices), + m_values(p_values), + m_sequence_number(p_sequence_number) + {} + + element() + : m_sequence_number(-1) {} + + element(const element_type& other) + : m_sequence_number(-1) + { *this = other; } + + /// Deep copy the given element. + void operator=(const element_type& other) + { + m_sequence_number = other.m_sequence_number; + m_neighbors = other.m_neighbors; + + m_indices = other.m_indices; + m_values = other.m_values; + } + + /// Returns the unique identifier of this element. + inline int get_id() const { return m_sequence_number; } + inline int& get_id() {return m_sequence_number; } + + /// Returns the number of variables. + inline int nb_vars() const { return size(m_indices); } + + /// Returns the number of values. + inline int nb_values() const { return nb_vars()*nb_vars(); } + + /// Reference to the matrix of values. + inline matrix_type& get_values() { return m_values; } + + /// Constant reference to the matrix of values. + inline const matrix_type& get_values() const { return m_values; } + + /// Reference to the indices. + inline const index_type& get_indices() const { return m_indices; } + + /// Mutable reference to the indices. + inline index_type& get_indices() { return m_indices; } + + /// The actual number of non-zero values. + int nnz() const + { + const value_type zero= math::zero(value_type()); + int nbr_nz = 0; + for (int r = 0; r < nb_vars(); ++r) + for (int c = 0; c < nb_vars(); ++c) + nbr_nz += get_values()(r,c) != zero; + return nbr_nz; + } + + /// Reference to the set of neighbors. + neighbor_collection_type& get_neighbors() { return m_neighbors; } + + /// Reference to the set of neighbors. + const neighbor_collection_type& get_neighbors() const { return m_neighbors; } + + /// Number of neighbors this element is connected to. + int get_nb_neighbors() const { return int(m_neighbors.size()); } + + /// Add new neighbors, max 6 at the time + void add_neighbors(element* n1, element* n2= 0, element* n3= 0, + element* n4= 0, element* n5= 0, element* n6= 0) + { + m_neighbors.push_back(n1); + if (n2) { + m_neighbors.push_back(n2); + if (n3) m_neighbors.push_back(n3); + if (n4) m_neighbors.push_back(n4); + if (n5) m_neighbors.push_back(n5); + if (n6) m_neighbors.push_back(n6); + } + } + + +/******************************************************************************* + * Useful Inspector Methods + ******************************************************************************/ + + /// The set of nodes that is incident to the element. + boost::unordered_set<int> get_incident_nodes() const + { + boost::unordered_set<int> nodes(2 * get_nb_neighbors()); + for(typename neighbor_collection_type::const_iterator neigh_it = m_neighbors.begin(); + neigh_it != m_neighbors.end(); ++neigh_it) { + element_type& neigh = **neigh_it; + nodes.insert(neigh.get_indices().begin(), neigh.get_indices().end()); + } + // Remove the nodes of the element. + for( int i = 0; i < nb_vars(); ++i ) + nodes.erase( get_indices()(i) ); + return nodes; + } + + + /// Get the set of level-k neighbors, for a given k. + neighbor_set_type get_level_neighbors(const int level = 1) + { + neighbor_set_type result( get_nb_neighbors() * level ); + + if (level > 0) { + result.insert( m_neighbors.begin(), m_neighbors.end() ); + if (level > 1) { + for(int i = 0; i < get_nb_neighbors(); ++i) { + neighbor_set_type neighs(m_neighbors[i]->get_level_neighbors(level-1)); + result.insert( neighs.begin(), neighs.end() ); + } + result.erase( this ); + } + } + return result; + } + +/******************************************************************************* + * Manipulation + ******************************************************************************/ + public: + /// Permutes the rows and the columns of the element coefficient matrix along + /// with the indices such that the latter are sorted in ascending order. + void sort_indices() { + if(size(m_indices) == 0) { + assert(size(m_values) == 0); + return; + } + + bool sorted = true; + for(int i = 0; i < nb_vars()-1; ++i) { + sorted &= (get_indices()(i) < get_indices()(i+1)); + } + if(sorted) { + return; + } + + index_type orig_index( get_indices() ); + matrix_type orig_matrix( get_values() ); + + std::sort( + &(get_indices()(0)), + &(get_indices()(0))+nb_vars() + ); + + index_type orig_offset( nb_vars() ); + orig_offset = -1; + for(int i = 0; i < nb_vars(); ++i) { + int seek_idx = get_indices()(i); + int j = 0; + for(; (j < nb_vars()) && (orig_index(j) != seek_idx); ++j){}; + orig_offset(i) = j; + } + + matrix_type& values = get_values(); + for(int r = 0; r < nb_vars(); ++r) { + for(int c = 0; c < nb_vars(); ++c) { + values(r,c) = orig_matrix( orig_offset(r), orig_offset(c) ); + } + } + +#ifndef NDEBUG + sorted = true; + for(int i = 0; i < nb_vars()-1; ++i) { + sorted &= (get_indices()(i) < get_indices()(i+1)); + } + assert(sorted); +#endif + } + + + public: + /// Removes the given set of nodes from the element + template< class Vector > + void remove_nodes(const Vector& nodes, element_type& el) { + if(size(m_indices) == 0) { + assert(size(m_values) == 0); + return; + } + if(nb_vars() == 0) { + return; + } + +#ifndef NDEBUG + bool sorted = true; + for(unsigned int i = 1; i < mtl::size(nodes); ++i) { + sorted &= ( nodes[i-1] < nodes[i] ); + } + assert(sorted); +#endif + + const int nb_nodes = mtl::size(nodes); + + // Count number of remaining variables. + int new_nb_nodes = nb_vars(); + { + int i = 0, j = 0; + while( i < nb_vars() && j < nb_nodes ) { + const int diff = get_indices()(i) - nodes[j]; + if( diff < 0 ) { + ++i; + } else if( diff > 0 ) { + ++j; + } else { + --new_nb_nodes; + ++i; + ++j; + } + } + } + assert(new_nb_nodes >= 0); + + // Construct new index array. + index_type index; + index_type local_index(new_nb_nodes); + if(new_nb_nodes > 0) { + index.change_dim(new_nb_nodes); +// index = new index_type(new_nb_nodes); + int i = 0, j = 0, pos = 0; + while( i < nb_vars() && j < nb_nodes ) { + const int diff = get_indices()(i) - nodes[j]; + if( diff < 0 ) { + assert( pos < new_nb_nodes ); + // (*index)(pos) = get_indices()(i); + index[pos] = get_indices()(i); + local_index(pos) = i; + ++pos; + ++i; + } else if( diff > 0 ) { + ++j; + } else { + ++i; + ++j; + } + } + while( i < nb_vars() ) { + assert( pos < new_nb_nodes ); +// (*index)(pos) = get_indices()(i); + index[pos] = get_indices()(i); + local_index(pos) = i; + ++pos; + ++i; + } + } else { +// index = new index_type(0); + } + + matrix_type values; + if(new_nb_nodes > 0) { + values.change_dim( new_nb_nodes, new_nb_nodes ); + matrix_type tmp(get_values()), tmp2(new_nb_nodes, new_nb_nodes); + for(unsigned int i=0;i<size(local_index);i++){ + for(unsigned int j=0;j<size(local_index);j++){ + tmp2[i][j]=tmp[local_index(i)][local_index(j)]; + } + } + values = tmp2; + } else { +// std::cout<< "ELSE\n"; +// values = new matrix_type(0,0); + } + // Update the neighborhood. + std::set<int, std::less<int>, std::allocator<int> > remove_neighs; // trouble with Clang 4.2 w/o allocator + for( + neighbor_iterator neigh_it = m_neighbors.begin(); + neigh_it != m_neighbors.end(); + ++neigh_it + ) { + element_type& neigh = **neigh_it; + + // Search a matching index. + bool connected = false; + { + int i = 0, j = 0; + while( + (i < new_nb_nodes) && + (j < neigh.nb_vars()) && + !connected + ) { +// const int diff = (*index)(i) - neigh.get_indices()(j); + const int diff = index[i] - neigh.get_indices()(j); + if(diff < 0) { + ++i; + } else if(diff > 0) { + ++j; + } else { + connected = true; + } + } + } + + // If not found, then remove ourself from the neighbors and vice versa. + if(!connected) { + neighbor_iterator pos = std::find(neigh.get_neighbors().begin(), neigh.get_neighbors().end(), this ); + if( (pos != neigh.get_neighbors().end()) && (&neigh != &el) ) { + neigh.get_neighbors().erase(pos); + } + remove_neighs.insert( neigh.get_id() ); + } + } + + // Remove the neighbors we're no longer connected to. + for(std::set<int>::iterator it = remove_neighs.begin(); it != remove_neighs.end(); ++it) { + const int seek_seq_nbr = *it; + for (std::size_t j = 0; j < m_neighbors.size(); ++j) + if (m_neighbors[j] != 0 && m_neighbors[j]->get_id() == seek_seq_nbr) { + m_neighbors.erase( m_neighbors.begin()+j ); + break; + } + } + + if(new_nb_nodes == 0) { + m_neighbors.clear(); + } + + m_indices.change_dim(0); + m_values.change_dim(0, 0); + m_indices = index; + m_values = values; + } + + /// Absorbs the values of the given matrix with the given index. + template< class Matrix, class Vector > + void absorb(Matrix& other_values, Vector& other_indices) + { + const value_type zero= math::zero(value_type()); +#ifndef NDEBUG + bool sorted = true; + for(unsigned int i = 1; i < size(other_indices); ++i) { + sorted &= ( other_indices(i-1) < other_indices(i) ); + } + assert(sorted); +#endif + + const int other_idx_size = size( other_indices ); + + // Determine set of common indices. + const int max_common_idx = + (nb_vars() < other_idx_size) ? nb_vars() : other_idx_size; + mtl::vector::dense_vector<int> my_idx( max_common_idx ); + mtl::vector::dense_vector<int> ot_idx( max_common_idx ); + int offset = 0; + for(int i = 0, j = 0; i < nb_vars() && j < other_idx_size; ) { + int diff = (get_indices()(i) - other_indices(j)); + if(diff == 0) { + my_idx(offset) = i; + ot_idx(offset) = j; + ++offset; + ++i; + ++j; + } else if(diff < 0) { + ++i; + } else { + ++j; + } + } + + // Absorb the values. + for(int i = 0; i < offset; ++i) { + for(int j = i; j < offset; ++j) { + get_values()( my_idx(i), my_idx(j) ) += other_values( ot_idx(i), ot_idx(j) ); + other_values( ot_idx(i), ot_idx(j) ) = zero; + get_values()( my_idx(j), my_idx(i) ) += other_values( ot_idx(j), ot_idx(i) ); + other_values( ot_idx(j), ot_idx(i) ) = zero; + } + } + } + + /// Removes the numerical values from the element. + void clear() { + m_neighbors.clear(); + m_neighbors.resize(1); + matrix_type empty; + swap(m_values, empty); + m_indices.change_dim(0); + } + + template< class ValueType > friend class element_structure; + + private: + /// The set of neighbors of the element. + neighbor_collection_type m_neighbors; + + /// The set of indices of this element. + index_type m_indices; + + /// The [Size x Size] element matrix. + matrix_type m_values; + + /// A unique sequence number for the element, indicating it's order relative to other elements. + int m_sequence_number; + + int *dummy; +}; + + +/// Print an element to an output stream. +template<typename OStream, class ValueType> +OStream& operator<<(OStream& out, element<ValueType>& el) +{ + out << "ID: " << el.get_id() << "\n"; + if(el.nb_vars() > 0) { + out << "Indices: (" << el.get_indices()(0); + for(int i = 1; i < el.nb_vars(); ++i) { + out << ", " << el.get_indices()(i); + } + out << ")\n"; + } else { + out << "Indices: ()\n"; + } + out << "Neighbors: ("; + if (el.nb_vars() > 0) + for(int i = 0; i < el.get_nb_neighbors(); ++i) + out << el.get_neighbors()[i]->get_id() << (i+1 < el.get_nb_neighbors()? ", " : ")\n"); + out << "Values: \n" << el.get_values(); + return out; +} + + }} // mtl::matrix + +#endif // MTL_ELEMENT_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/element_array.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/element_array.hpp new file mode 100644 index 0000000000000000000000000000000000000000..d2d3326c64ff050d7b699b73c8d3899dea8d6d9d --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/element_array.hpp @@ -0,0 +1,51 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_ELEMENT_ARRAY_INCLUDE +#define MTL_ELEMENT_ARRAY_INCLUDE + +namespace mtl { namespace matrix { + +template <typename Array, typename Rows, typename Cols> +struct element_array_t +{ + explicit element_array_t(const Array& array, const Rows& rows, const Cols& cols) + : array(array), rows(rows), cols(cols) + {} + + const Array& array; + const Rows& rows; + const Cols& cols; +}; + + +template <typename Array, typename Rows, typename Cols> +element_array_t<Array, Rows, Cols> +inline element_array(const Array& array, const Rows& rows, const Cols& cols) +{ + return element_array_t<Array, Rows, Cols>(array, rows, cols); +} + +template <typename Array, typename Rows> +element_array_t<Array, Rows, Rows> +inline element_array(const Array& array, const Rows& rows) +{ + return element_array_t<Array, Rows, Rows>(array, rows, rows); +} + +} // namespace matrix + +using matrix::element_array; + +} // namespace mtl + +#endif // MTL_ELEMENT_ARRAY_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/element_matrix.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/element_matrix.hpp new file mode 100644 index 0000000000000000000000000000000000000000..fc21bff9c55aa43859ca350fa3c695c857f54b0c --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/element_matrix.hpp @@ -0,0 +1,49 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_ELEMENT_MATRIX_INCLUDE +#define MTL_ELEMENT_MATRIX_INCLUDE + +namespace mtl { namespace matrix { + + +template <typename Matrix, typename Rows, typename Cols> +struct element_matrix_t +{ + explicit element_matrix_t(const Matrix& matrix, const Rows& rows, const Cols& cols) + : matrix(matrix), rows(rows), cols(cols) + {} + + const Matrix& matrix; + const Rows& rows; + const Cols& cols; +}; + + +template <typename Matrix, typename Rows, typename Cols> +element_matrix_t<Matrix, Rows, Cols> +inline element_matrix(const Matrix& matrix, const Rows& rows, const Cols& cols) +{ + return element_matrix_t<Matrix, Rows, Cols>(matrix, rows, cols); +} + +template <typename Matrix, typename Rows> +element_matrix_t<Matrix, Rows, Rows> +inline element_matrix(const Matrix& matrix, const Rows& rows) +{ + return element_matrix_t<Matrix, Rows, Rows>(matrix, rows, rows); +} + + +}} // namespace mtl::matrix + +#endif // MTL_ELEMENT_MATRIX_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/element_structure.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/element_structure.hpp new file mode 100644 index 0000000000000000000000000000000000000000..9563d35a0bda6795f286c8cb47b096d23d815e2b --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/element_structure.hpp @@ -0,0 +1,300 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. +// +// Algorithm inspired by Nick Vannieuwenhoven, written by Cornelius Steinhardt + + + +#ifndef MTL_ELEMENT_STRUCTURE_INCLUDE +#define MTL_ELEMENT_STRUCTURE_INCLUDE + +#include <iostream> +#include <ostream> + +#include <boost/numeric/mtl/matrix/element.hpp> +#include <boost/numeric/mtl/utility/ashape.hpp> + +namespace mtl { namespace matrix { + +#if 0 ///TODO need for write elmement_structur +namespace print { + + template< class Type > + struct print_type { + template<class Stream> + static void print(Stream&); + }; + + template< > + struct print_type<double> { + template<class Stream> + static void print(Stream& str) { + str << "double\n"; + } + }; + + template< > + struct print_type<float> { + template<class Stream> + static void print(Stream& str) { + str << "double\n"; + } + }; + + template< > + struct print_type<std::complex<double> > { + template<class Stream> + static void print(Stream& str) { + str << "complex\n"; + } + }; + + template< class Type > + struct print_value { + template<class Stream> + static void print(Stream&); + }; + + template< > + struct print_value<double> { + template<class Stream> + static void print(Stream& str, double& val) { + str << std::scientific << std::setprecision(15); + str << val; + } + }; + + template< > + struct print_value<float> { + template<class Stream> + static void print(Stream& str, float& val) { + str << std::scientific << std::setprecision(15); + str << double(val); + } + }; + + template< > + struct print_value<std::complex<double> > { + template<class Stream> + static void print(Stream& str, std::complex<double>& val) { + str << std::scientific << std::setprecision(15); + str << val.real() << "\t" << val.imag() << "\t"; + } + }; +} + #endif + +/** + * A generic abstract base class for meshes. It describes the concept of a mesh. + */ +template< class ValueType > +class element_structure +{ + +public: + /// Type of the numerical values of the element coefficient matrices. + typedef ValueType value_type; + + /// Type of the element. + typedef element<value_type> element_type; + + /// Type of index arrays. + typedef typename element_type::index_type index_type; + // Type of the indices themselves + typedef typename Collection<index_type>::value_type ii_type; + + /// Type of the iterator over the elements of the mesh. + typedef element_type* element_iterator; + + /// Type of this class. + typedef element_structure<ValueType> this_type; + typedef this_type self; + + /// Standard constructor. + element_structure(int total_elements= 0, int total_vars= 0, element_type* elements= 0) + : m_total_elements(total_elements), m_total_vars(total_vars), + m_elements(elements), index_heap(0), value_heap(0) + { } + + /// consume elements into element_structure + void consume(int total_elements, int total_vars, element_type* elements) + { + m_total_elements= total_elements; + m_total_vars= total_vars; + delete[] m_elements; + m_elements= elements; + delete[] index_heap; index_heap= 0; + delete[] value_heap; value_heap= 0; + } + + + /// Copy the given mesh. + element_structure(this_type const& other) + : m_total_elements(other.m_total_elements), + m_total_vars(other.m_total_vars), + m_elements(m_total_elements == 0 ? 0 : new element_type[m_total_elements]), + index_heap(0), value_heap(0) + { + typedef typename element_type::neighbor_collection_type neigh_coll_type; + + int j = 0; + bool ordered = true; + for(element_iterator it = other.element_begin(); it != other.element_end(); ++it) { + // Deep copy the elements. + m_elements[j] = *it; + ordered &= (it->get_id() == j); + ++j; + } + assert( ordered ); + // Reconstruct the network of neighbors. + for(element_iterator it = this->element_begin(); it != this->element_end(); ++it) { + neigh_coll_type new_neighs; + neigh_coll_type& old_neighs = it->get_neighbors(); + for(int i = 0; i < it->get_nb_neighbors(); ++i) { + element_type& neigh = *(old_neighs[i]); + int pos = neigh.get_id(); + new_neighs.push_back( this->m_elements+pos ); + } + old_neighs.assign(new_neighs.begin(), new_neighs.end()); + } + } + + /// Destructor + ~element_structure() { delete[] m_elements; delete[] index_heap; delete[] value_heap; } + + /// make compakt memory block from elements + void make_compact() + { + assert(index_heap == 0); assert(value_heap == 0); // might be relaxed later + + int total_indices= 0, total_values= 0; + for (int i= 0; i < m_total_elements; i++) { + total_indices+= m_elements[i].nb_vars(); + total_values+= m_elements[i].nb_values(); + } + index_heap= new ii_type[total_indices]; + value_heap= new value_type[total_values]; + + int index_pos= 0, value_pos= 0; + for (int i= 0; i < m_total_elements; i++) { + element_type& element= m_elements[i]; + int s= element.nb_vars(); + index_type index_tmp(s, index_heap + index_pos); + index_tmp= element.get_indices(); + swap(index_tmp, element.get_indices()); + index_pos+= s; + + typename element_type::matrix_type value_tmp(s, s, value_heap + value_pos); + value_tmp= element.get_values(); + swap(value_tmp, element.get_values()); + value_pos+= s * s; + } + assert(total_indices == index_pos); + assert(total_values == value_pos); + } + + /******************************************************************************* + * Inspector Members + ******************************************************************************/ + + /// Total number of elements in the grid. + int get_total_elements() const { return m_total_elements; } + + /// Total number of variables. + int get_total_vars() const { return m_total_vars; } + + /// Total number of non-zero values. + int get_total_nnz() const + { + int nnz = 0; + for(element_iterator it = element_begin(); it != element_end(); ++it) { + nnz += it->nnz(); + } + return nnz; + } + + /// Iterator to the first element. + element_iterator element_begin() const { return m_elements + 0; } + + /// An iterator to the element past the last element. + element_iterator element_end() const { return m_elements + this->get_total_elements(); } + +#if 1 + /// Writes the elements to the specified file. TODO at the moment very slow + void write_to_file(const std::string& filename) + { + //using namespace print; + + std::ofstream file(filename.c_str()); + + // Write header information. + file << get_total_elements() << "\n"; + file << this->get_total_vars() << "\n"; + //print_type<value_type>::print(file); + + // Write element matrices. + for(element_iterator it = element_begin(); it != element_end(); ++it) { + // Write indices. + for(int i = 0; i < it->nb_vars()-1; ++i) { + file << it->get_indices()(i) << " "; + } + file << it->get_indices()(it->nb_vars()-1) << "\n"; + + // Write values. + for(int r = 0; r < it->nb_vars(); ++r) { + for(int c = 0; c < it->nb_vars()-1; ++c) { + //print_value<value_type>::print(file, it->get_values()(r,c)); + file << it->get_values()(r,c); file << " "; + } + //print_value<value_type>::print(file, it->get_values()(r,it->nb_vars()-1)); + file << it->get_values()(r,it->nb_vars()-1); + file << "\n"; + } + file << "\n"; + } + } +#endif + + int m_total_elements; ///< The total number of elements. + int m_total_vars; ///< The total number of variables. + element_type* m_elements; ///< The elements of the grid, stored consecutively. + + ii_type* index_heap; + value_type* value_heap; +}; + +template <typename ValueType> +inline std::size_t num_rows(const element_structure<ValueType>& A) +{ return A.get_total_vars(); } + +template <typename ValueType> +inline std::size_t num_cols(const element_structure<ValueType>& A) +{ return A.get_total_vars(); } + +template <typename ValueType> +inline std::size_t size(const element_structure<ValueType>& A) +{ return A.get_total_vars() * A.get_total_vars(); } + + +template <typename ValueType> +inline void swap(element_structure<ValueType>& x, element_structure<ValueType>& y) +{ + swap(x.m_total_elements, y.m_total_elements); + swap(x.m_total_vars, y.m_total_vars); + swap(x.m_elements, y.m_elements); +} + + +}} // mtl::matrix + + +#endif // MTL_ELEMENT_STRUCTURE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/ell_matrix.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/ell_matrix.hpp new file mode 100644 index 0000000000000000000000000000000000000000..d29557913623dfcf11039f8d64ff4f8ca3cfe771 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/ell_matrix.hpp @@ -0,0 +1,207 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_ELL_MATRIX_INCLUDE +#define MTL_MATRIX_ELL_MATRIX_INCLUDE + +#include <vector> +#include <cassert> + +#include <boost/static_assert.hpp> +#include <boost/numeric/mtl/matrix/parameter.hpp> +#include <boost/numeric/mtl/matrix/compressed2D.hpp> +#include <boost/numeric/mtl/utility/wrapped_object.hpp> +#include <boost/numeric/mtl/utility/is_row_major.hpp> +#include <boost/numeric/mtl/operation/std_output_operator.hpp> + + +namespace mtl { namespace matrix { + +/// Matrix in Ell-Pack format; still in early stage, to be used with care (if at all) +template <typename Value, typename Parameters = matrix::parameters<> > +class ell_matrix + : public base_matrix<Value, Parameters>, + public const_crtp_base_matrix< ell_matrix<Value, Parameters>, Value, typename Parameters::size_type >, + public crtp_matrix_assign< ell_matrix<Value, Parameters>, Value, typename Parameters::size_type >, + public mat_expr< ell_matrix<Value, Parameters> > +{ + BOOST_STATIC_ASSERT((mtl::traits::is_row_major<Parameters>::value)); + + typedef base_matrix<Value, Parameters> super; + typedef ell_matrix self; + typedef mat_expr< ell_matrix<Value, Parameters> > expr_base; + + void set_stride() + { my_stride= (this->dim1() + alignment - 1) / alignment * alignment; } + + public: + typedef Parameters parameters; + typedef typename Parameters::orientation orientation; + typedef typename Parameters::dimensions dimensions; + typedef Value value_type; + typedef value_type const_reference; + + typedef typename Parameters::size_type size_type; + typedef crtp_matrix_assign<self, Value, size_type> assign_base; + + static const unsigned alignment= 32; // TBD: make more flexible later + + /// Default constructor + explicit ell_matrix () + : super(non_fixed::dimensions(0, 0)), my_slots(0), inserting(false) + { set_stride(); } + + /// Construct matrix of size \p num_rows times \p num_cols + explicit ell_matrix (size_type num_rows, size_type num_cols) + : super(non_fixed::dimensions(num_rows, num_cols)), my_slots(0), inserting(false) + { set_stride(); } + + /// Print internal representation + template <typename OStream> + void print_internal(OStream& os) const + { +# ifdef MTL_HAS_STD_OUTPUT_OPERATOR + os << "indices = " << indices << '\n'; + os << "values = " << data << '\n'; +# endif + } + + /// Entry in row \p r and column \p c + value_type operator()(size_type r, size_type c) const + { + for (size_type k= r, i= 0; i < my_slots; ++i, k+= my_stride) + if (indices[k] == c) + return data[k]; + return value_type(0); + } + + const std::vector<size_type>& ref_minor() const { return indices; } ///< Refer index vector [advanced] + std::vector<size_type>& ref_minor() { return indices; } ///< Refer index vector [advanced] + const std::vector<value_type>& ref_data() const { return data; } ///< Refer data vector [advanced] + std::vector<value_type>& ref_data() { return data; } ///< Refer data vector [advanced] + + size_type stride() const { return my_stride; } /// Stride [advanced] + size_type slots() const { return my_slots; } /// Slots, i.e. maximum number of entries per row/column + + void make_empty() + { my_slots= 0; indices.resize(0); data.resize(0); } + + void change_dim(size_type r, size_type c) + { + if (this->num_rows() != r || this->num_cols() != c) { + super::change_dim(r, c); + set_stride(); + make_empty(); + } + } + + protected: + void allocate_slots(size_type s) + { + my_slots= s; + size_type size= my_stride * s; + indices.resize(size); data.resize(size); + } + + template <typename V, typename P, typename Updater> friend struct ell_matrix_inserter; + + std::vector<value_type> data; + std::vector<size_type> indices; + size_type my_stride, my_slots; + bool inserting; +}; + + +template <typename Value, typename Parameters, typename Updater = mtl::operations::update_store<Value> > +struct ell_matrix_inserter + : wrapped_object<compressed2D<Value, Parameters> >, + compressed2D_inserter<Value, Parameters, Updater> +{ + typedef typename Parameters::size_type size_type; + typedef Value value_type; + typedef ell_matrix<Value, Parameters> matrix_type; + typedef compressed2D<Value, Parameters> compressed_type; + typedef wrapped_object<compressed_type> wrapped_type; + typedef compressed2D_inserter<Value, Parameters, Updater> base_inserter; + + explicit ell_matrix_inserter(matrix_type& A, size_type slot_size = 5) + : wrapped_type(num_rows(A), num_cols(A)), + base_inserter(wrapped_type::wrapped_object_member, slot_size), + A(A) + { + A.inserting= true; + } + + ~ell_matrix_inserter() + { + this->finish(); + const compressed_type& B= this->wrapped_object_member; + // std::cout << "Finished insertion!\nA (compressed2D) is:\n" << B; + + size_type max_slots= 0; + for (size_type i= 0; i < B.dim1(); ++i) { + size_type s= this->starts[i+1] - this->starts[i]; + if (s > max_slots) + max_slots= s; + } + A.allocate_slots(max_slots); + + for (size_type i= 0; i < B.dim1(); ++i) { + size_type patch_entries= max_slots - (this->starts[i+1] - this->starts[i]), k= i, + patch_index= 0; + for (size_type j= this->starts[i]; j < this->starts[i+1]; ++j, k+= A.my_stride) { + patch_index= A.indices[k]= B.ref_minor()[j]; + A.data[k]= B.data[j]; + } + for (size_type j= 0; j < patch_entries; ++j, k+= A.my_stride) { + A.indices[k]= patch_index; + A.data[k]= value_type(0); + } + } + A.my_nnz= B.nnz(); + A.inserting= false; + } + + matrix_type& A; +}; + +// ================ +// Free functions +// ================ + +template <typename Value, typename Parameters> +typename ell_matrix<Value, Parameters>::size_type +inline num_rows(const ell_matrix<Value, Parameters>& matrix) +{ + return matrix.num_rows(); +} + +template <typename Value, typename Parameters> +typename ell_matrix<Value, Parameters>::size_type +inline num_cols(const ell_matrix<Value, Parameters>& matrix) +{ + return matrix.num_cols(); +} + +template <typename Value, typename Parameters> +// typename ell_matrix<Value, Parameters>::size_type risks overflow +std::size_t +inline size(const ell_matrix<Value, Parameters>& matrix) +{ + return std::size_t(matrix.num_cols()) * std::size_t(matrix.num_rows()); +} + + + +}} // namespace mtl::matrix + +#endif // MTL_MATRIX_ELL_MATRIX_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/hermitian_view.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/hermitian_view.hpp new file mode 100644 index 0000000000000000000000000000000000000000..1c503296740981b80168cbc056c13ab80ee235de --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/hermitian_view.hpp @@ -0,0 +1,127 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_HERMITIAN_VIEW_INCLUDE +#define MTL_HERMITIAN_VIEW_INCLUDE + +#include <iostream> +#include <boost/shared_ptr.hpp> +#include <boost/numeric/mtl/matrix/map_view.hpp> +#include <boost/numeric/mtl/matrix/transposed_view.hpp> +#include <boost/numeric/mtl/operation/conj.hpp> +#include <boost/numeric/mtl/operation/matrix_bracket.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> + + +namespace mtl { namespace matrix { + +template <class Matrix> +struct hermitian_view + : private transposed_view<Matrix>, + public map_view<mtl::sfunctor::conj<typename Matrix::value_type>, + transposed_view<Matrix> > +{ + typedef transposed_view<Matrix> trans_base; + typedef mtl::sfunctor::conj<typename Matrix::value_type> functor_type; + typedef map_view<functor_type, transposed_view<Matrix> > base; + typedef hermitian_view self; + typedef const Matrix& const_ref_type; + typedef typename Collection<Matrix>::size_type size_type; + typedef typename Collection<Matrix>::value_type value_type; + + typedef typename OrientedCollection<trans_base>::orientation orientation; // Should not be needed because defined in Collection (bug in g++???) + + hermitian_view(const Matrix& matrix) + : trans_base(const_cast<Matrix&>(matrix)), + base(functor_type(), static_cast<trans_base&>(*this)) + {} + +#if 0 + hermitian_view(boost::shared_ptr<Matrix> p) + : trans_base(p), base(functor_type(), static_cast<trans_base&>(*this)) + {} +#endif + + typename base::value_type operator()(size_type r, size_type c) const { return base::operator()(r, c); } + + operations::bracket_proxy<self, const self&, value_type> + operator[] (size_type r) const + { + return operations::bracket_proxy<self, const self&, value_type>(*this, r); + } + + friend size_type inline num_rows(const self& A) { return num_rows((const base&)(A)); } + friend size_type inline num_cols(const self& A) { return num_cols((const base&)(A)); } + + const_ref_type const_ref() const + { + // make two statements because nvcc cannot handle ref.ref + const transposed_view<Matrix>& r1= base::ref; + return r1.ref; + } + + size_type nnz() const { return base::nnz(); } + + friend inline std::ostream& operator<<(std::ostream& os, const self& A) { return os << (const base&)(A); } +}; + +// If not defined ambigous between map_view and transposed_view +template <class Matrix> +inline std::size_t size(const hermitian_view<Matrix>& A) +{ + return num_rows(A) * num_rows(A); +} + +// TBD submatrix of Hermitian (not trivial) + + +}} // namespace mtl::matrix + + + +// Traits for Hermitian views +namespace mtl { namespace traits { + +template <typename Matrix> +struct row< mtl::matrix::hermitian_view<Matrix> > + : public row< mtl::matrix::map_view<sfunctor::conj<typename Matrix::value_type>, + mtl::matrix::transposed_view<Matrix> > > +{}; + +template <typename Matrix> +struct col< mtl::matrix::hermitian_view<Matrix> > + : public col< mtl::matrix::map_view<sfunctor::conj<typename Matrix::value_type>, + mtl::matrix::transposed_view<Matrix> > > +{}; + +template <typename Matrix> +struct const_value< mtl::matrix::hermitian_view<Matrix> > + : public const_value< mtl::matrix::map_view<sfunctor::conj<typename Matrix::value_type>, + mtl::matrix::transposed_view<Matrix> > > +{}; + +template <typename Tag, typename Matrix> +struct range_generator< Tag, mtl::matrix::hermitian_view<Matrix> > + : public range_generator< Tag, mtl::matrix::map_view<sfunctor::conj<typename Matrix::value_type>, + mtl::matrix::transposed_view<Matrix> > > +{}; + +template <typename Matrix> +struct range_generator< tag::major, mtl::matrix::hermitian_view<Matrix> > + : public range_generator< tag::major, mtl::matrix::map_view<sfunctor::conj<typename Matrix::value_type>, + mtl::matrix::transposed_view<Matrix> > > +{}; + + +}} // mtl::traits + +#endif // MTL_HERMITIAN_VIEW_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/hessian_setup.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/hessian_setup.hpp new file mode 100644 index 0000000000000000000000000000000000000000..55ce0a53e52805f0d4d0e9d7bbd9b7accff6d102 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/hessian_setup.hpp @@ -0,0 +1,100 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_HESSIAN_MATRIX_UTILITIES_INCLUDE +#define MTL_HESSIAN_MATRIX_UTILITIES_INCLUDE + +#include <cmath> +#include <iostream> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/matrix/inserter.hpp> +#include <boost/numeric/mtl/operation/entry_similar.hpp> + +namespace mtl { namespace matrix { + +/// Fills a matrix A with A[i][j] = factor * (i + j) +/** Intended for dense matrices. + Works on sparse matrices with inserter but is very expensive. **/ +template <typename Matrix, typename Value> +void hessian_setup(Matrix& A, Value factor) +{ + typedef typename Collection<Matrix>::value_type value_type; + typedef typename Collection<Matrix>::size_type size_type; + + inserter<Matrix> ins(A, num_cols(A)); + + for (size_type r= 0; r < num_rows(A); r++) + for (size_type c= 0; c < num_cols(A); c++) + ins[r][c] << factor * (value_type(r) + value_type(c)); +} + +namespace impl { + + /* + - Check matrix product C = A * B with: + - A is MxN, B is NxL, C is MxL + - with matrices a_ij = i+j, b_ij = 2(i+j); + - c_ij = 1/3 N (1 - 3i - 3j + 6ij - 3N + 3iN + 3jN + 2N^2). + + */ + // Not really generic + template <typename Value> + double inline hessian_product_i_j (Value i, Value j, Value N) + { + return 1.0/3.0 * N * (1.0 - 3*i - 3*j + 6*i*j - 3*N + 3*i*N + 3*j*N + 2*N*N); + } + + template <typename Value> + inline bool similar_values(Value x, Value y) + { + using std::abs; using std::max; + return abs(x - y) / max(abs(x), abs(y)) < 0.000001; + } + + template <typename Matrix> + void inline check_entry(Matrix const& C, unsigned long r, unsigned long c, + unsigned long reduced_dim, double factor) + { + if (!entry_similar(C, r, c, factor * hessian_product_i_j(r, c, reduced_dim), 0.00001)) { + std::cerr << "Result in C[" << r << "][" << c << "] should be " + << factor * hessian_product_i_j(r, c, reduced_dim) + << " but is " << C[r][c] << "\n"; + MTL_THROW(unexpected_result()); + } + } + +} // impl + + +/// Check if matrix C is A * B with A and B set by hessian_setup +/** C has dimensions M x L and reduced_dim is N, see hessian_setup. **/ +template <typename Matrix> +void check_hessian_matrix_product(Matrix const& C, typename Matrix::size_type reduced_dim, double factor= 1.0) +{ + if (num_rows(C) * num_cols(C) == 0) return; // otherwise out of range + + impl::check_entry(C, 0, 0, reduced_dim, factor); + impl::check_entry(C, 0, num_cols(C)-1, reduced_dim, factor); + impl::check_entry(C, num_rows(C)-1, 0, reduced_dim, factor); + impl::check_entry(C, num_rows(C)-1, num_cols(C)-1, reduced_dim, factor); + impl::check_entry(C, num_rows(C)/2, num_cols(C)/2, reduced_dim, factor); +} + +} // namespace matrix; + +using matrix::hessian_setup; +using matrix::check_hessian_matrix_product; + +} // namespace mtl + +#endif // MTL_HESSIAN_MATRIX_UTILITIES_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/identity.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/identity.hpp new file mode 100644 index 0000000000000000000000000000000000000000..4380d5acae46409c1bf06159f027cd26d041a3f8 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/identity.hpp @@ -0,0 +1,38 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_IDENTITY_INCLUDE +#define MTL_MATRIX_IDENTITY_INCLUDE + +// #include <boost/numeric/linear_algebra/identity.hpp> +// #include <boost/numeric/mtl/mtl_fwd.hpp> +// #include <boost/numeric/mtl/matrix/parameter.hpp> +// #include <boost/numeric/mtl/matrix/diagonal_setup.hpp> + +#include <boost/numeric/mtl/matrix/identity2D.hpp> + +namespace mtl { namespace matrix { + +inline identity2D identity(std::size_t nrows, std::size_t ncols) +{ + return identity2D(nrows, ncols); +} + + +inline identity2D identity(std::size_t nrows) +{ + return identity2D(nrows, nrows); +} + +}} // namespace mtl::matrix + +#endif // MTL_MATRIX_IDENTITY_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/identity2D.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/identity2D.hpp new file mode 100644 index 0000000000000000000000000000000000000000..d1d226209a9a127d6669e223292d5fc80d0bd449 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/identity2D.hpp @@ -0,0 +1,83 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_IDENTITY2D_INCLUDE +#define MTL_MATRIX_IDENTITY2D_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/ashape.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/irange.hpp> +#include <boost/numeric/mtl/vector/mat_cvec_multiplier.hpp> + +namespace mtl { namespace matrix { + +/// Matrix-free linear operator for identity +struct identity2D +{ + /// Constructor for \p m by \p m matrix + identity2D(std::size_t m) : m(m), n(m) {} + + /// Constructor for \p m by \p n matrix + identity2D(std::size_t m, std::size_t n) : m(m), n(n) {} + + /// Member function that realizes the multiplication + template <typename VectorIn, typename VectorOut, typename Assign> + void mult(const VectorIn& v, VectorOut& w, Assign) const + { + MTL_DEBUG_THROW_IF(std::size_t(size(v)) != n, incompatible_size()); + MTL_DEBUG_THROW_IF(size(w) != 0 && std::size_t(size(w)) != m, incompatible_size()); + + if (size(w) == 0) + w.change_dim(m); + + if (m == n) + Assign::first_update(w, v); + else if (m < n) + Assign::first_update(w, v[irange(m)]); + else { + VectorOut w1(w[irange(n)]), w2(w[irange(n, imax)]); + Assign::first_update(w1, v); + Assign::init(w2); + } + } + + /// Multiplication is procastinated until we know where the product goes + template <typename VectorIn> + vector::mat_cvec_multiplier<identity2D, VectorIn> operator*(const VectorIn& v) const + { return vector::mat_cvec_multiplier<identity2D, VectorIn>(*this, v); } + + std::size_t m, n; +}; + +inline std::size_t size(const identity2D& A) { return A.m * A.n; } ///< Matrix size +inline std::size_t num_rows(const identity2D& A) { return A.m; } ///< Number of rows +inline std::size_t num_cols(const identity2D& A) { return A.n; } ///< Number of columns + +}} // namespace mtl::matrix + +namespace mtl { + + template <> + struct Collection<matrix::identity2D> + { + typedef double value_type; + typedef std::size_t size_type; + }; + + namespace ashape { + template <> struct ashape_aux<matrix::identity2D> + { typedef nonscal type; }; + } +} + +#endif // MTL_MATRIX_IDENTITY2D_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/implicit_dense.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/implicit_dense.hpp new file mode 100644 index 0000000000000000000000000000000000000000..c16c9ceba404cebe3c47502cb7893ee2d718d972 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/implicit_dense.hpp @@ -0,0 +1,279 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_IMPLICIT_DENSE_INCLUDE +#define MTL_MATRIX_IMPLICIT_DENSE_INCLUDE + +#include <vector> +#include <boost/numeric/linear_algebra/inverse.hpp> +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/matrix/crtp_base_matrix.hpp> +#include <boost/numeric/mtl/matrix/mat_expr.hpp> +#include <boost/numeric/mtl/concept/std_concept.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> + +#ifdef MTL_HAS_MPI +# include <boost/numeric/mtl/matrix/distributed.hpp> +# include <boost/numeric/mtl/matrix/inserter.hpp> +# include <boost/mpi/collectives.hpp> +#endif + +namespace mtl { namespace matrix { + +template <typename Functor> +class implicit_dense + : public const_crtp_base_matrix< implicit_dense<Functor>, + typename Functor::result_type, typename Functor::size_type >, + public mat_expr< implicit_dense<Functor> > +{ + typedef implicit_dense self; + public: + typedef mtl::tag::row_major orientation; // for completeness + typedef typename Functor::result_type value_type; + typedef typename Functor::result_type const_reference; + typedef typename Functor::size_type size_type; + + // Should not be needed, to be removed after transposed_view is cleaned up + typedef index::c_index index_type; + typedef mtl::traits::detail::matrix_element_key<self> key_type; + typedef mtl::non_fixed::dimensions dim_type; + + explicit implicit_dense (const Functor& functor) : my_functor(functor) {} + + value_type operator() (size_type r, size_type c) const { return my_functor(r, c); } + + size_type nnz() const { return dim1() * dim2(); } + size_type dim1() const { return num_rows(my_functor); } + size_type dim2() const { return num_cols(my_functor); } + + friend size_type inline num_rows(const self& A) { return num_rows(A.my_functor); } + friend size_type inline num_cols(const self& A) { return num_cols(A.my_functor); } + + Functor& functor() { return my_functor; } + Functor const& functor() const { return my_functor; } + + private: + Functor my_functor; +}; + +template <typename Functor> +typename Functor::size_type inline size(const implicit_dense<Functor>& A) +{ + return num_rows(A) * num_cols(A); +} + +// ========== +// Sub matrix +// ========== + +// To do later + +}} // namespace mtl::matrix + + +namespace mtl { namespace traits { + + // ================ + // Range generators + // For cursors + // ================ + + template <typename Functor> + struct range_generator<glas::tag::row, mtl::matrix::implicit_dense<Functor> > + : detail::all_rows_range_generator<mtl::matrix::implicit_dense<Functor>, complexity_classes::linear> + {}; + + template <typename Functor> + struct range_generator<glas::tag::major, mtl::matrix::implicit_dense<Functor> > + : range_generator<glas::tag::row, mtl::matrix::implicit_dense<Functor> > + {}; + + template <typename Functor> + struct range_generator<glas::tag::nz, + detail::sub_matrix_cursor<mtl::matrix::implicit_dense<Functor>, glas::tag::row, 2> > + : detail::all_cols_in_row_range_generator<detail::sub_matrix_cursor<mtl::matrix::implicit_dense<Functor>, glas::tag::row, 2> > + {}; + + template <typename Functor> + struct range_generator<glas::tag::col, mtl::matrix::implicit_dense<Functor> > + : detail::all_cols_range_generator<mtl::matrix::implicit_dense<Functor>, complexity_classes::linear> + {}; + + template <typename Functor> + struct range_generator<glas::tag::nz, + detail::sub_matrix_cursor<mtl::matrix::implicit_dense<Functor>, glas::tag::col, 2> > + : detail::all_rows_in_col_range_generator<detail::sub_matrix_cursor<mtl::matrix::implicit_dense<Functor>, glas::tag::col, 2> > + {}; + + + template <typename Tag, typename Value> + struct range_generator<Tag, mtl::matrix::ones_matrix<Value> > + : public range_generator<Tag, mtl::matrix::implicit_dense<mtl::matrix::ones_functor<Value> > > + {}; + + template <typename Value> + struct range_generator<glas::tag::major, mtl::matrix::ones_matrix<Value> > + : public range_generator<glas::tag::major, mtl::matrix::implicit_dense<mtl::matrix::ones_functor<Value> > > + {}; + + template <typename Tag, typename Value> + struct range_generator<Tag, mtl::matrix::hilbert_matrix<Value> > + : public range_generator<Tag, mtl::matrix::implicit_dense<mtl::matrix::hilbert_functor<Value> > > + {}; + + template <typename Value> + struct range_generator<glas::tag::major, mtl::matrix::hilbert_matrix<Value> > + : public range_generator<glas::tag::major, mtl::matrix::implicit_dense<mtl::matrix::hilbert_functor<Value> > > + {}; + + template <typename Tag, typename Vector1, typename Vector2> + struct range_generator<Tag, mtl::matrix::outer_product_matrix<Vector1, Vector2> > + : public range_generator<Tag, mtl::matrix::implicit_dense<mtl::matrix::outer_product_functor<Vector1, Vector2> > > + {}; + + template <typename Vector1, typename Vector2> + struct range_generator<glas::tag::major, mtl::matrix::outer_product_matrix<Vector1, Vector2> > + : public range_generator<glas::tag::major, mtl::matrix::implicit_dense<mtl::matrix::outer_product_functor<Vector1, Vector2> > > + {}; + +}} // mtl::traits + +// ============= +// Some functors +// ============= + + +namespace mtl { namespace matrix { + +template <typename Value= int> +class ones_functor +{ + typedef ones_functor self; + public: + typedef std::size_t size_type; + typedef Value result_type; + + ones_functor(size_type nr, size_type nc) : nr(nr), nc(nc) {} + + friend size_type inline num_rows(const self& A) { return A.nr; } + friend size_type inline num_cols(const self& A) { return A.nc; } + + result_type operator()(size_type, size_type) const { return Value(1); } + + private: + size_type nr, nc; +}; + + +template <typename Value= double> +class hilbert_functor +{ + typedef hilbert_functor self; + public: + typedef std::size_t size_type; + typedef Value result_type; + + hilbert_functor(size_type nr, size_type nc) : nr(nr), nc(nc) {} + + friend size_type inline num_rows(const self& A) { return A.nr; } + friend size_type inline num_cols(const self& A) { return A.nc; } + + result_type operator()(size_type r, size_type c) const + { + using math::reciprocal; + return reciprocal(Value(r + c + 1)); + } + private: + size_type nr, nc; +}; + + +template <typename Vector1, typename Vector2> +class outer_product_functor +{ + typedef outer_product_functor self; + public: + typedef std::size_t size_type; + typedef typename Multiplicable<typename Collection<Vector1>::value_type, + typename Collection<Vector2>::value_type>::result_type result_type; + + outer_product_functor(const Vector1& v1, const Vector2& v2) : my_v1(v1), my_v2(v2) {} + outer_product_functor(size_type r, size_type c) : my_v1(r), my_v2(c) {} + + friend size_type inline num_rows(const self& A) { return size(A.my_v1); } + friend size_type inline num_cols(const self& A) { return size(A.my_v2); } + + result_type operator()(size_type r, size_type c) const { return my_v1[r] * my_v2[c]; } + + Vector1& v1() { return my_v1; } + Vector1 const& v1() const { return my_v1; } + Vector2& v2() { return my_v2; } + Vector2 const& v2() const { return my_v2; } + + private: + Vector1 my_v1; // keeps copy + Vector2 my_v2; +}; + +// ====================== +// Some implicit matrices +// ====================== + + +template <typename Value= int> +class ones_matrix + : public implicit_dense<ones_functor<Value> > +{ + public: + typedef ones_functor<Value> functor_type; + typedef typename functor_type::size_type size_type; + typedef implicit_dense<functor_type> base; + + ones_matrix(size_type r, size_type c) : base(functor_type(r, c)) {} +}; + + +template <typename Value= double> +class hilbert_matrix + : public implicit_dense<hilbert_functor<Value> > +{ + public: + typedef hilbert_functor<Value> functor_type; + typedef typename functor_type::size_type size_type; + typedef implicit_dense<functor_type> base; + + hilbert_matrix(size_type r, size_type c) : base(functor_type(r, c)) {} +}; + + +template <typename Vector1, typename Vector2> +class outer_product_matrix + : public implicit_dense<outer_product_functor<Vector1, Vector2> > +{ + typedef outer_product_matrix self; + public: + typedef outer_product_functor<Vector1, Vector2> functor_type; + typedef typename functor_type::size_type size_type; + typedef implicit_dense<functor_type> base; + + outer_product_matrix(const Vector1& v1, const Vector2& v2) : base(functor_type(v1, v2)) {} + outer_product_matrix(size_type r, size_type c) : base(functor_type(r, c)) {} + + Vector1& v1() { return this->functor().v1(); } + Vector1 const& v1() const { return this->functor().v1(); } + Vector2& v2() { return this->functor().v2(); } + Vector2 const& v2() const { return this->functor().v2(); } +}; + +}} // namespace mtl::matrix + +#endif // MTL_MATRIX_IMPLICIT_DENSE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/indirect.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/indirect.hpp new file mode 100644 index 0000000000000000000000000000000000000000..2938e703bb20ea0df981602b2698602f0d911b52 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/indirect.hpp @@ -0,0 +1,69 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_INDIRECT_INCLUDE +#define MTL_MATRIX_INDIRECT_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/detail/range_generator.hpp> +#include <boost/numeric/mtl/utility/complexity.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/iset.hpp> +#include <boost/numeric/mtl/operation/is_negative.hpp> +#include <boost/numeric/mtl/matrix/mat_expr.hpp> + +namespace mtl { namespace matrix { + +/// Class for indirect access to matrix +/** So far only constant access, mutable access for appropriate matrices might be added later. **/ +template <typename Matrix> +struct indirect + : mat_expr<indirect<Matrix> >, + const_crtp_base_matrix<indirect<Matrix>, typename Collection<Matrix>::value_type, typename Collection<Matrix>::size_type> +{ + typedef indirect self; + typedef Matrix other; + typedef typename Collection<Matrix>::value_type value_type; + typedef typename Collection<Matrix>::size_type size_type; + // if implementation uses const_reference -> change collection accordingly + + + /// Construct from constant matrix reference and isets for rows and columns + indirect(const Matrix& ref, const iset& rows, const iset& cols) : ref(ref), rows(rows), cols(cols) {} + + friend size_type inline num_rows(const self& A) { return A.rows.size(); } ///< Number of rows + friend size_type inline num_cols(const self& A) { return A.cols.size(); } ///< Number of colums + size_type nnz() const { return num_rows(*this) * num_cols(*this); } ///< Number of non-zeros + + size_type dim1() const { return rows.size(); } ///< Dimension 1 is equal to number of rows + size_type dim2() const { return cols.size(); } ///< Dimension 2 is equal to number of columns + + value_type operator() (size_type r, size_type c) const + { return (ref(rows[r], cols[c])); } ///< Read A[r][c] + + private: + const Matrix& ref; + iset rows, cols; +}; + +template <typename Matrix> +inline std::size_t size(const indirect<Matrix>& A) +{ return num_rows(A) * num_rows(A); } + +}} // namespace mtl::matrix + + +// -- Range generators in utility/range_generator.hpp +// -- Property maps in utility/property_maps.hpp + + +#endif // MTL_MATRIX_INDIRECT_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/inserter.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/inserter.hpp new file mode 100644 index 0000000000000000000000000000000000000000..7e07895975514f5490242dd82f1be7e1db1433c1 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/inserter.hpp @@ -0,0 +1,90 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_INSERTER_INCLUDE +#define MTL_MATRIX_INSERTER_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/operation/update.hpp> +#include <boost/numeric/mtl/detail/trivial_inserter.hpp> + + + +namespace mtl { namespace matrix { + +/// Matrix inserter +/** The matrix inserter has two template arguments: the type of the target matrix and + an update functor. + The update functor determines how an existing entry is updated: overwritten, added, + subtracted... + The default is to overwrite existing entries. +**/ +template <typename Matrix, + typename Updater = mtl::operations::update_store<typename Matrix::value_type> > +struct inserter + : public mtl::detail::trivial_inserter<Matrix, Updater> +{ + typedef mtl::detail::trivial_inserter<Matrix, Updater> base; + typedef typename Matrix::size_type size_type; + + explicit inserter(Matrix& matrix, size_type slot_size = 0) : base(matrix, slot_size) {} +}; + + +template <typename Value, typename Parameters, typename Updater> +struct inserter<compressed2D<Value, Parameters>, Updater> + : compressed2D_inserter<Value, Parameters, Updater> +{ + typedef compressed2D<Value, Parameters> matrix_type; + typedef typename matrix_type::size_type size_type; + typedef compressed2D_inserter<Value, Parameters, Updater > base; + + explicit inserter(matrix_type& matrix, size_type slot_size = 5) : base(matrix, slot_size) {} +}; + +template <typename Value, typename Parameters, typename Updater> +struct inserter<coordinate2D<Value, Parameters>, Updater> + : coordinate2D_inserter<coordinate2D<Value, Parameters>, Updater> +{ + typedef coordinate2D<Value, Parameters> matrix_type; + typedef typename Parameters::size_type size_type; + typedef coordinate2D_inserter<coordinate2D<Value, Parameters>, Updater> base; + + explicit inserter(matrix_type& matrix, size_type slot_size= 1) : base(matrix, slot_size) {} +}; + +template <typename Value, typename Parameters, typename Updater> +struct inserter<sparse_banded<Value, Parameters>, Updater> + : sparse_banded_inserter<Value, Parameters, Updater> +{ + typedef sparse_banded<Value, Parameters> matrix_type; + typedef typename Parameters::size_type size_type; + typedef sparse_banded_inserter<Value, Parameters, Updater> base; + + explicit inserter(matrix_type& matrix, size_type slot_size= 1) : base(matrix, slot_size) {} +}; + +template <typename Value, typename Parameters, typename Updater> +struct inserter<ell_matrix<Value, Parameters>, Updater> + : ell_matrix_inserter<Value, Parameters, Updater> +{ + typedef ell_matrix<Value, Parameters> matrix_type; + typedef typename matrix_type::size_type size_type; + typedef ell_matrix_inserter<Value, Parameters, Updater > base; + + explicit inserter(matrix_type& matrix, size_type slot_size = 5) : base(matrix, slot_size) {} +}; + + +}} // namespace mtl::matrix + +#endif // MTL_MATRIX_INSERTER_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/laplacian_setup.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/laplacian_setup.hpp new file mode 100644 index 0000000000000000000000000000000000000000..1bb7f145e54405e54d02a65ab08e06bb98c72df1 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/laplacian_setup.hpp @@ -0,0 +1,47 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_LAPLACIAN_SETUP_INCLUDE +#define MTL_LAPLACIAN_SETUP_INCLUDE + +#include <boost/numeric/mtl/matrix/inserter.hpp> +#include <boost/numeric/mtl/operation/set_to_zero.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace mtl { namespace matrix { + +/// Setup a matrix according to a Laplacian equation on a 2D-grid using a five-point-stencil +/** Intended for sparse matrices but works also with dense matrices. Changes the size of + the matrix \f$m\cdot n\times m\cdot n\f$. **/ +template <typename Matrix> +inline void laplacian_setup(Matrix& A, unsigned m, unsigned n) +{ + vampir_trace<3063> tracer; + A.change_dim(m*n, m*n); + set_to_zero(A); + inserter<Matrix> ins(A, 5); + + for (unsigned i= 0; i < m; i++) + for (unsigned j= 0; j < n; j++) { + typename Collection<Matrix>::value_type four(4.0), minus_one(-1.0); + unsigned row= i * n + j; + ins(row, row) << four; + if (j < n-1) ins(row, row+1) << minus_one; + if (i < m-1) ins(row, row+n) << minus_one; + if (j > 0) ins(row, row-1) << minus_one; + if (i > 0) ins(row, row-n) << minus_one; + } +} + +}} // namespace mtl::matrix + +#endif // MTL_LAPLACIAN_SETUP_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/lower.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/lower.hpp new file mode 100644 index 0000000000000000000000000000000000000000..da6054850e4aa0d4fd8d21ffd4cc933bbf994338 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/lower.hpp @@ -0,0 +1,38 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_LOWER_INCLUDE +#define MTL_MATRIX_LOWER_INCLUDE + +namespace mtl { namespace matrix { + +namespace traits { + + template <typename Matrix> + struct lower + { + typedef typename traits::bands<Matrix>::type type; + }; +} + +/// Lower triangular matrix +template <typename Matrix> +typename traits::lower<Matrix>::type +inline lower(const Matrix& A) +{ + return bands(A, std::numeric_limits<long>::min(), 1); +} + + +}} // namespace mtl::matrix + +#endif // MTL_MATRIX_LOWER_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/make_fast_multi_vector_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/make_fast_multi_vector_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..1ea21773131af6057f57a9bed975d6b17f58e834 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/make_fast_multi_vector_expr.hpp @@ -0,0 +1,70 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_MAKE_FAST_MULTI_VECTOR_EXPR_INCLUDE +#define MTL_MATRIX_MAKE_FAST_MULTI_VECTOR_EXPR_INCLUDE + +#include <boost/numeric/mtl/utility/fast_multi_vector_expr.hpp> +#include <boost/numeric/mtl/matrix/mat_mat_plus_expr.hpp> +#include <boost/numeric/mtl/matrix/mat_mat_minus_expr.hpp> +#include <boost/numeric/mtl/matrix/map_view.hpp> +#include <boost/numeric/mtl/vector/vec_vec_plus_expr.hpp> +#include <boost/numeric/mtl/vector/vec_vec_minus_expr.hpp> +#include <boost/numeric/mtl/vector/map_view.hpp> + +namespace mtl { namespace matrix { + + +template <typename E1, typename E2> +typename mtl::traits::fast_multi_vector_expr< mv_mv_plus_expr<E1, E2> >::type +inline make_fast_multi_vector_expr(const mv_mv_plus_expr<E1, E2>& expr) +{ + typedef typename mtl::traits::fast_multi_vector_expr< mv_mv_plus_expr<E1, E2> >::type type; + return type(make_fast_multi_vector_expr(expr.first), make_fast_multi_vector_expr(expr.second)); +} + +template <typename E1, typename E2> +typename mtl::traits::fast_multi_vector_expr< mv_mv_minus_expr<E1, E2> >::type +inline make_fast_multi_vector_expr(const mv_mv_minus_expr<E1, E2>& expr) +{ + typedef typename mtl::traits::fast_multi_vector_expr< mv_mv_minus_expr<E1, E2> >::type type; + return type(make_fast_multi_vector_expr(expr.first), make_fast_multi_vector_expr(expr.second)); +} + +template <typename Functor, typename Matrix> +typename mtl::traits::fast_multi_vector_expr< map_view<Functor, Matrix> >::type +inline make_fast_multi_vector_expr(const map_view<Functor, Matrix>& expr) +{ + typedef typename mtl::traits::fast_multi_vector_expr< map_view<Functor, Matrix> >::type type; + return type(expr.functor, make_fast_multi_vector_expr(expr.ref)); +} + +template <typename Value1, typename Matrix> +typename mtl::traits::fast_multi_vector_expr< scaled_view<Value1, Matrix> >::type +inline make_fast_multi_vector_expr(const scaled_view<Value1, Matrix>& expr) +{ + typedef typename mtl::traits::fast_multi_vector_expr< scaled_view<Value1, Matrix> >::type type; + return type(expr.functor.value(), make_fast_multi_vector_expr(expr.ref)); +} + +template <typename Value1, typename Matrix> +typename mtl::traits::fast_multi_vector_expr< rscaled_view<Value1, Matrix> >::type +inline make_fast_multi_vector_expr(const rscaled_view<Value1, Matrix>& expr) +{ + typedef typename mtl::traits::fast_multi_vector_expr< rscaled_view<Value1, Matrix> >::type type; + return type(make_fast_multi_vector_expr(expr.ref), expr.functor.value()); +} + + +}} // namespace mtl::matrix + +#endif // MTL_MATRIX_MAKE_FAST_MULTI_VECTOR_EXPR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/map_view.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/map_view.hpp new file mode 100644 index 0000000000000000000000000000000000000000..bd4476ff9b1bafe9969de6453782d38942af2024 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/map_view.hpp @@ -0,0 +1,581 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MAP_VIEW_INCLUDE +#define MTL_MAP_VIEW_INCLUDE + +#include <utility> +#include <boost/utility/enable_if.hpp> +#include <boost/mpl/if.hpp> +#include <boost/type_traits/is_integral.hpp> +#include <boost/shared_ptr.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/utility/property_map.hpp> +#include <boost/numeric/mtl/utility/is_multi_vector_expr.hpp> +#include <boost/numeric/mtl/matrix/crtp_base_matrix.hpp> +#include <boost/numeric/mtl/operation/sub_matrix.hpp> +#include <boost/numeric/mtl/operation/sfunctor.hpp> +#include <boost/numeric/mtl/operation/tfunctor.hpp> +#include <boost/numeric/mtl/operation/conj.hpp> +#include <boost/numeric/mtl/operation/imag.hpp> +#include <boost/numeric/mtl/operation/real.hpp> +#include <boost/numeric/mtl/matrix/mat_expr.hpp> +#include <boost/numeric/mtl/vector/map_view.hpp> + + +namespace mtl { namespace matrix { namespace detail { + // Forward declaration for friend declaration + template <typename, typename> struct map_value; + + template <typename Functor, typename Matrix> struct map_vector {}; // not defined in general + template <typename Functor, typename Vector> + struct map_vector<Functor, mtl::matrix::multi_vector<Vector> > + { + typedef mtl::vector::map_view<Functor, Vector> type; + }; + +}}} + +namespace mtl { namespace matrix { + +template <typename Functor, typename Matrix> +struct map_view + : public const_crtp_base_matrix< map_view<Functor, Matrix>, + typename Functor::result_type, typename Matrix::size_type >, + public mat_expr< map_view<Functor, Matrix> > +{ + typedef map_view self; + typedef mat_expr< self > expr_base; + typedef Matrix other; + typedef const Matrix& const_ref_type; + typedef typename Matrix::orientation orientation; + + typedef typename Functor::result_type value_type; + typedef typename Functor::result_type const_reference; + + typedef typename Matrix::key_type key_type; + typedef typename Matrix::size_type size_type; + typedef typename Matrix::index_type index_type; + typedef typename Matrix::dim_type dim_type; + + struct dummy { typedef void type; }; + typedef typename boost::mpl::eval_if<mtl::traits::is_multi_vector_expr<Matrix>, detail::map_vector<Functor, Matrix>, dummy>::type vector_type; + + map_view (const Functor& functor, const other& ref) : functor(functor), ref(ref) {} + + map_view (const Functor& functor, boost::shared_ptr<Matrix> p) + : functor(functor), my_copy(p), ref(*p) {} + +#ifdef MTL_WITH_CPP11_MOVE + map_view (self&& that) : functor(that.functor), my_copy(std::move(that.my_copy)), ref(that.ref) {} + map_view (const self& that) : functor(that.functor), ref(that.ref) { assert(that.my_copy.use_count() == 0); } +#endif + + + value_type operator() (size_type r, size_type c) const + { + return functor(ref(r, c)); + } + // for multi_vector, needs enable_if since only defined for multi_vector + template <typename S> + typename boost::lazy_enable_if<boost::is_integral<S>, detail::map_vector<Functor, Matrix> >::type + vector(S c) const + { + return typename detail::map_vector<Functor, Matrix>::type(functor, ref.vector(c)); + } + + size_type dim1() const { return ref.dim1(); } + size_type dim2() const { return ref.dim2(); } + dim_type dimensions() const { return ref.dimensions(); } + + size_type begin_row() const { return ref.begin_row(); } + size_type end_row() const { return ref.end_row(); } + size_type begin_col() const { return ref.begin_col(); } + size_type end_col() const { return ref.end_col(); } + + size_type nnz() const { return ref.nnz(); } + + friend size_type inline num_rows(const self& A) + { using mtl::matrix::num_rows; return num_rows(A.ref); } + friend size_type inline num_cols(const self& A) + { using mtl::matrix::num_cols; return num_cols(A.ref); } + template <typename, typename> friend struct detail::map_value; + + protected: + boost::shared_ptr<Matrix> my_copy; + public: + Functor functor; + const other& ref; +}; + +template <typename Functor, typename Matrix> +inline std::size_t size(const map_view<Functor, Matrix>& A) +{ return num_rows(A) * num_rows(A); } + +// ========== +// Sub matrix +// ========== + +template <typename Functor, typename Matrix> +struct sub_matrix_t< mtl::matrix::map_view<Functor, Matrix> > +{ + typedef mtl::matrix::map_view<Functor, Matrix> view_type; + + // Mapping of sub-matrix type + typedef typename sub_matrix_t<Matrix>::const_sub_matrix_type ref_sub_type; + typedef mtl::matrix::map_view<Functor, ref_sub_type> const_sub_matrix_type; + typedef typename view_type::size_type size_type; + + const_sub_matrix_type operator()(view_type const& view, size_type begin_r, size_type end_r, + size_type begin_c, size_type end_c) + { + typedef boost::shared_ptr<ref_sub_type> pointer_type; + + // Submatrix of referred matrix (or view) + // Create a submatrix, whos address will be kept by map_view + // Functor is copied from view + pointer_type p(new ref_sub_type(sub_matrix(view.ref, begin_r, end_r, begin_c, end_c))); + return const_sub_matrix_type(view.functor, p); + } +}; + + +}} // namespace mtl::matrix + + +namespace mtl { namespace traits { + + namespace detail { + + + template <typename Functor, typename Matrix> + struct map_value + { + typedef typename Matrix::key_type key_type; + typedef typename mtl::matrix::map_view<Functor, Matrix>::value_type value_type; + + map_value(mtl::matrix::map_view<Functor, Matrix> const& map_matrix) + : map_matrix(map_matrix), its_value(map_matrix.ref) + {} + + value_type operator() (key_type const& key) const + { + return map_matrix.functor(its_value(key)); + } + + protected: + mtl::matrix::map_view<Functor, Matrix> const& map_matrix; + typename mtl::traits::const_value<Matrix>::type its_value; + }; + + + + template <typename Functor, typename Matrix> + struct mapped_row + { + typedef typename Matrix::key_type key_type; + typedef typename Matrix::size_type size_type; + + explicit mapped_row(const mtl::matrix::map_view<Functor, Matrix>& view) : its_row(view.ref) {} + explicit mapped_row(const mtl::matrix::banded_view<Matrix>& view) : its_row(view.ref) {} + + size_type operator() (key_type const& key) const + { + return its_row(key); + } + + protected: + typename row<Matrix>::type its_row; + }; + + + template <typename Functor, typename Matrix> + struct mapped_col + { + typedef typename Matrix::key_type key_type; + typedef typename Matrix::size_type size_type; + + mapped_col(const mtl::matrix::map_view<Functor, Matrix>& view) : its_col(view.ref) {} + mapped_col(const mtl::matrix::banded_view<Matrix>& view) : its_col(view.ref) {} + + size_type operator() (key_type const& key) const + { + return its_col(key); + } + + protected: + typename col<Matrix>::type its_col; + }; + + } // namespace detail + + template <typename Functor, typename Matrix> + struct row<mtl::matrix::map_view<Functor, Matrix> > + { + typedef detail::mapped_row<Functor, Matrix> type; + }; + + template <typename Functor, typename Matrix> + struct col<mtl::matrix::map_view<Functor, Matrix> > + { + typedef detail::mapped_col<Functor, Matrix> type; + }; + + template <typename Functor, typename Matrix> + struct const_value<mtl::matrix::map_view<Functor, Matrix> > + { + typedef detail::map_value<Functor, Matrix> type; + }; + + + // ================ + // Range generators + // ================ + + // Use range_generator of original matrix + template <typename Tag, typename Functor, typename Matrix> + struct range_generator<Tag, mtl::matrix::map_view<Functor, Matrix> > + : public detail::referred_range_generator<mtl::matrix::map_view<Functor, Matrix>, + range_generator<Tag, Matrix> > + {}; + + // To disambigue + template <typename Functor, typename Matrix> + struct range_generator<tag::major, mtl::matrix::map_view<Functor, Matrix> > + : public detail::referred_range_generator<mtl::matrix::map_view<Functor, Matrix>, + range_generator<tag::major, Matrix> > + {}; + + +}} // mtl::traits + + +namespace mtl { namespace matrix { + +template <typename Scaling, typename Matrix> +struct scaled_view + : public map_view<tfunctor::scale<Scaling, typename Matrix::value_type>, Matrix> +{ + typedef tfunctor::scale<Scaling, typename Matrix::value_type> functor_type; + typedef map_view<functor_type, Matrix> base; + typedef scaled_view self; + + scaled_view(const Scaling& scaling, const Matrix& matrix) + : base(functor_type(scaling), matrix) + {} + + scaled_view(const Scaling& scaling, boost::shared_ptr<Matrix> p) + : base(functor_type(scaling), p) + {} + +#ifdef MTL_WITH_CPP11_MOVE + scaled_view (self&& that) : base(that) {} + scaled_view (const self& that) : base(that) {} +#endif +}; + +// rscaled_view -- added by Hui Li +template <typename Matrix, typename RScaling> +struct rscaled_view + : public map_view<tfunctor::rscale<typename Matrix::value_type,RScaling>, Matrix> +{ + typedef tfunctor::rscale<typename Matrix::value_type, RScaling> functor_type; + typedef map_view<functor_type, Matrix> base; + typedef rscaled_view self; + + rscaled_view(const Matrix& matrix, const RScaling& rscaling) + : base(functor_type(rscaling),matrix) + {} + + rscaled_view(boost::shared_ptr<Matrix> p, const RScaling& rscaling) + : base(functor_type(rscaling), p) + {} + +#ifdef MTL_WITH_CPP11_MOVE + rscaled_view (self&& that) : base(that) {} + rscaled_view (const self& that) : base(that) {} +#endif +}; + +// divide_by_view -- added by Hui Li +template <typename Matrix, typename Divisor> +struct divide_by_view + : public map_view<tfunctor::divide_by<typename Matrix::value_type,Divisor>, Matrix> +{ + typedef tfunctor::divide_by<typename Matrix::value_type, Divisor> functor_type; + typedef map_view<functor_type, Matrix> base; + typedef divide_by_view self; + + divide_by_view(const Matrix& matrix,const Divisor& div) + : base(functor_type(div), matrix) + {} + + divide_by_view(boost::shared_ptr<Matrix> p, const Divisor& div) + : base(functor_type(div), p) + {} + +#ifdef MTL_WITH_CPP11_MOVE + divide_by_view (self&& that) : base(that) {} + divide_by_view (const self& that) : base(that) {} +#endif +}; + +template <typename Matrix> +struct conj_view + : public map_view<mtl::sfunctor::conj<typename Matrix::value_type>, Matrix> +{ + typedef mtl::sfunctor::conj<typename Matrix::value_type> functor_type; + typedef map_view<functor_type, Matrix> base; + typedef conj_view self; + + conj_view(const Matrix& matrix) : base(functor_type(), matrix) {} + conj_view(boost::shared_ptr<Matrix> p) : base(functor_type(), p) {} + +#ifdef MTL_WITH_CPP11_MOVE + conj_view (self&& that) : base(that) {} + conj_view (const self& that) : base(that) {} +#endif +}; + +template <typename Matrix> +struct imag_view + : public map_view<mtl::sfunctor::imag<typename Matrix::value_type>, Matrix> +{ + typedef mtl::sfunctor::imag<typename Matrix::value_type> functor_type; + typedef map_view<functor_type, Matrix> base; + typedef imag_view self; + + imag_view(const Matrix& matrix) : base(functor_type(), matrix) {} + imag_view(boost::shared_ptr<Matrix> p) : base(functor_type(), p) {} + +#ifdef MTL_WITH_CPP11_MOVE + imag_view (self&& that) : base(that) {} + imag_view (const self& that) : base(that) {} +#endif +}; + +template <typename Matrix> +struct negate_view + : public map_view<mtl::sfunctor::negate<typename Matrix::value_type>, Matrix> +{ + typedef mtl::sfunctor::negate<typename Matrix::value_type> functor_type; + typedef map_view<functor_type, Matrix> base; + typedef negate_view self; + + negate_view(const Matrix& matrix) : base(functor_type(), matrix) {} + negate_view(boost::shared_ptr<Matrix> p) : base(functor_type(), p) {} + +#ifdef MTL_WITH_CPP11_MOVE + negate_view (self&& that) : base(that) {} + negate_view (const self& that) : base(that) {} +#endif +}; + +template <typename Matrix> +struct real_view + : public map_view<mtl::sfunctor::real<typename Matrix::value_type>, Matrix> +{ + typedef mtl::sfunctor::real<typename Matrix::value_type> functor_type; + typedef map_view<functor_type, Matrix> base; + typedef real_view self; + + real_view(const Matrix& matrix) : base(functor_type(), matrix) {} + real_view(boost::shared_ptr<Matrix> p) : base(functor_type(), p) {} + +#ifdef MTL_WITH_CPP11_MOVE + real_view (self&& that) : base(that) {} + real_view (const self& that) : base(that) {} +#endif +}; + +template <typename Scaling, typename Matrix> +struct sub_matrix_t< mtl::matrix::scaled_view<Scaling, Matrix> > + : public sub_matrix_t< mtl::matrix::map_view<tfunctor::scale<Scaling, typename Matrix::value_type>, + Matrix> > +{}; + +template <typename Matrix> +struct sub_matrix_t< mtl::matrix::conj_view<Matrix> > + : public sub_matrix_t< mtl::matrix::map_view<sfunctor::conj<typename Matrix::value_type>, Matrix> > +{}; + +template <typename Matrix, typename RScaling> +struct sub_matrix_t< mtl::matrix::rscaled_view<Matrix, RScaling> > + : public sub_matrix_t< mtl::matrix::map_view<tfunctor::rscale<typename Matrix::value_type, RScaling>, + Matrix> > +{}; + +template <typename Matrix, typename Divisor> +struct sub_matrix_t< mtl::matrix::divide_by_view<Matrix, Divisor> > + : public sub_matrix_t< mtl::matrix::map_view<tfunctor::divide_by<typename Matrix::value_type, Divisor>, + Matrix> > +{}; + + +}} // namespace mtl::matrix + +namespace mtl { namespace sfunctor { + + template <typename Matrix> + struct conj_aux<Matrix, tag::matrix> + { + typedef matrix::conj_view<Matrix> result_type; + + static inline result_type apply(const Matrix& matrix) + { + return result_type(matrix); + } + + result_type operator() (const Matrix& matrix) const + { + return apply(matrix); + } + }; + +}} // namespace mtl::sfunctor + +// Traits for specific views +namespace mtl { namespace traits { + +template <typename Scaling, typename Matrix> +struct row< mtl::matrix::scaled_view<Scaling, Matrix> > + : public row< mtl::matrix::map_view<tfunctor::scale<Scaling, typename Matrix::value_type>, + Matrix> > +{}; + +template <typename Matrix> +struct row< mtl::matrix::conj_view<Matrix> > + : public row< mtl::matrix::map_view<sfunctor::conj<typename Matrix::value_type>, Matrix> > +{}; + +template <typename Matrix, typename RScaling> +struct row< mtl::matrix::rscaled_view<Matrix, RScaling> > + : public row< mtl::matrix::map_view<tfunctor::rscale<typename Matrix::value_type, RScaling>, + Matrix> > +{}; + +template <typename Matrix, typename Divisor> +struct row< mtl::matrix::divide_by_view<Matrix, Divisor> > + : public row< mtl::matrix::map_view<tfunctor::divide_by<typename Matrix::value_type, Divisor>, + Matrix> > +{}; + + +template <typename Scaling, typename Matrix> +struct col< mtl::matrix::scaled_view<Scaling, Matrix> > + : public col< mtl::matrix::map_view<tfunctor::scale<Scaling, typename Matrix::value_type>, + Matrix> > +{}; + +template <typename Matrix> +struct col< mtl::matrix::conj_view<Matrix> > + : public col< mtl::matrix::map_view<sfunctor::conj<typename Matrix::value_type>, Matrix> > +{}; + +template <typename Matrix, typename RScaling> +struct col< mtl::matrix::rscaled_view<Matrix, RScaling> > + : public col< mtl::matrix::map_view<tfunctor::rscale<typename Matrix::value_type, RScaling>, + Matrix> > +{}; + +template <typename Matrix, typename Divisor> +struct col< mtl::matrix::divide_by_view<Matrix, Divisor> > + : public col< mtl::matrix::map_view<tfunctor::divide_by<typename Matrix::value_type, Divisor>, + Matrix> > +{}; + + + + + +template <typename Scaling, typename Matrix> +struct const_value< mtl::matrix::scaled_view<Scaling, Matrix> > + : public const_value< mtl::matrix::map_view<tfunctor::scale<Scaling, typename Matrix::value_type>, + Matrix> > +{}; + +template <typename Matrix> +struct const_value< mtl::matrix::conj_view<Matrix> > + : public const_value< mtl::matrix::map_view<sfunctor::conj<typename Matrix::value_type>, Matrix> > +{}; + +template <typename Matrix, typename RScaling> +struct const_value< mtl::matrix::rscaled_view<Matrix, RScaling> > + : public const_value< mtl::matrix::map_view<tfunctor::rscale<typename Matrix::value_type, RScaling>, + Matrix> > +{}; + +template <typename Matrix, typename Divisor> +struct const_value< mtl::matrix::divide_by_view<Matrix, Divisor> > + : public const_value< mtl::matrix::map_view<tfunctor::divide_by<typename Matrix::value_type, Divisor>, + Matrix> > +{}; + + + + + +template <typename Tag, typename Scaling, typename Matrix> +struct range_generator< Tag, mtl::matrix::scaled_view<Scaling, Matrix> > + : public range_generator< Tag, mtl::matrix::map_view<tfunctor::scale<Scaling, typename Matrix::value_type>, + Matrix> > +{}; + +template <typename Tag, typename Matrix> +struct range_generator< Tag, mtl::matrix::conj_view<Matrix> > + : public range_generator< Tag, mtl::matrix::map_view<sfunctor::conj<typename Matrix::value_type>, Matrix> > +{}; + +template <typename Tag, typename Matrix, typename RScaling> +struct range_generator< Tag, mtl::matrix::rscaled_view<Matrix, RScaling> > + : public range_generator< Tag, mtl::matrix::map_view<tfunctor::rscale<typename Matrix::value_type, RScaling>, + Matrix> > +{}; + +template <typename Tag, typename Matrix, typename Divisor> +struct range_generator< Tag, mtl::matrix::divide_by_view<Matrix, Divisor> > + : public range_generator< Tag, mtl::matrix::map_view<tfunctor::divide_by<typename Matrix::value_type, Divisor>, + Matrix> > +{}; + + + +template <typename Scaling, typename Matrix> +struct range_generator< tag::major, mtl::matrix::scaled_view<Scaling, Matrix> > + : public range_generator< tag::major, mtl::matrix::map_view<tfunctor::scale<Scaling, typename Matrix::value_type>, + Matrix> > +{}; + +template <typename Matrix> +struct range_generator< tag::major, mtl::matrix::conj_view<Matrix> > + : public range_generator< tag::major, mtl::matrix::map_view<sfunctor::conj<typename Matrix::value_type>, Matrix> > +{}; + +template <typename Matrix, typename RScaling> +struct range_generator< tag::major, mtl::matrix::rscaled_view<Matrix, RScaling> > + : public range_generator< tag::major, mtl::matrix::map_view<tfunctor::rscale<typename Matrix::value_type, RScaling>, + Matrix> > +{}; + +template <typename Matrix, typename Divisor> +struct range_generator< tag::major, mtl::matrix::divide_by_view<Matrix, Divisor> > + : public range_generator< tag::major, mtl::matrix::map_view<tfunctor::divide_by<typename Matrix::value_type, Divisor>, + Matrix> > +{}; + + + +}} // mtl::traits + + +#endif // MTL_MAP_VIEW_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/mapped_inserter.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/mapped_inserter.hpp new file mode 100644 index 0000000000000000000000000000000000000000..eda40cdc2a78dde9578350fce6efa873c8ec0c0c --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/mapped_inserter.hpp @@ -0,0 +1,94 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_MAPPED_INSERTER_INCLUDE +#define MTL_MATRIX_MAPPED_INSERTER_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/operation/update.hpp> + +namespace mtl { namespace matrix { + +/// Inserter with shifted row and column indices +/** The main work is performed by the underlying base inserter whose type is given as template + argument. **/ +template <typename BaseInserter, typename Mapper > +class mapped_inserter +{ + public: + typedef mapped_inserter self; + typedef typename BaseInserter::matrix_type matrix_type; + typedef typename Collection<matrix_type>::size_type size_type; + typedef operations::update_proxy<BaseInserter, size_type> proxy_type; + + /// Constructor with matrix \p A, the mapping, and the slot size + mapped_inserter(matrix_type& A, Mapper& map, size_type slot_size= 0) + : ins(A, slot_size), map(map) {} + + private: + struct bracket_proxy + { + bracket_proxy(BaseInserter& ref, Mapper& map, size_type row) + : ref(ref),map(map), row(row) {} + + proxy_type operator[](size_type col) + { return proxy_type(ref, row, map.col(col)); } + + BaseInserter& ref; + Mapper& map; + size_type row; + }; + + public: + /// To be used in ins[r][c] << value; + bracket_proxy operator[] (size_type row) + { return bracket_proxy(ins, map, map.row(row)); } + + /// To be used in ins(r, c) << value; + proxy_type operator() (size_type row, size_type col) + { return proxy_type(ins, map.row(row),map.col(col)); } + + // update, modify and operator<< are used from BaseInserter + +private: + BaseInserter ins; + Mapper& map; +}; + +template< typename BaseInserter, typename Mapper, typename Elt, typename Parameters > +mapped_inserter< BaseInserter, Mapper >& operator<<(mapped_inserter< BaseInserter, Mapper >& minserter, + const compressed2D< Elt, Parameters >& rhs) +{ + + using mtl::tag::major; using mtl::tag::nz; using mtl::begin; using mtl::end; + namespace traits= mtl::traits; + typedef compressed2D< Elt, Parameters > Matrix; + + typename traits::row<Matrix>::type row(rhs); + typename traits::col<Matrix>::type col(rhs); + typename traits::const_value<Matrix>::type value(rhs); + + typedef typename traits::range_generator<major, Matrix>::type cursor_type; + typedef typename traits::range_generator<nz, cursor_type>::type icursor_type; + + for (cursor_type cursor = begin<major>(rhs), cend = end<major>(rhs); cursor != cend; ++cursor) + for (icursor_type icursor = begin<nz>(cursor), icend = end<nz>(cursor); icursor != icend; ++icursor) + minserter[row(*icursor)][col(*icursor)]<< value(*icursor); + + return minserter; +} + +} // namespace matrix + +} // namespace mtl + +#endif // MTL_MATRIX_MAPPED_INSERTER_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/mat_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/mat_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..0b9f26b46ed4e85c4630593977bd852f55861403 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/mat_expr.hpp @@ -0,0 +1,46 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MAT_EXPR_INCLUDE +#define MTL_MAT_EXPR_INCLUDE + +namespace mtl { namespace matrix { + +/// Base class for CRTP with matrices +template <typename Matrix> +struct mat_expr +{ + typedef Matrix ref_type; +}; + + +/// Base class for CRTP with dense matrices +template <typename Matrix> +struct dmat_expr + : public mat_expr<Matrix> +{ + typedef mat_expr<Matrix> base; +}; + + +/// Base class for CRTP with sparse matrices +template <typename Matrix> +struct smat_expr + : public mat_expr<Matrix> +{ + typedef mat_expr<Matrix> base; +}; + + +}} // namespace mtl::matrix + +#endif // MTL_MAT_EXPR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/mat_mat_asgn_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/mat_mat_asgn_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..22e366f52c9c09f8dd59c37d044c8b6d99a04205 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/mat_mat_asgn_expr.hpp @@ -0,0 +1,27 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_MAT_MAT_ASGN_EXPR_INCLUDE +#define MTL_MATRIX_MAT_MAT_ASGN_EXPR_INCLUDE + +namespace mtl { namespace matrix { + + +// Currently only dummy to be used in traits::eval_dense +template <typename E1, typename E2> +struct mat_mat_asgn_expr {}; + + + +}} // namespace mtl::matrix + +#endif // MTL_MATRIX_MAT_MAT_ASGN_EXPR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/mat_mat_ele_times_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/mat_mat_ele_times_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..e49e9ba548b0728d2048fa00733c63a465bb9c4d --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/mat_mat_ele_times_expr.hpp @@ -0,0 +1,62 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MAT_MAT_ELE_TIMES_EXPR_INCLUDE +#define MTL_MAT_MAT_ELE_TIMES_EXPR_INCLUDE + +#include <boost/shared_ptr.hpp> +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/matrix/mat_mat_op_expr.hpp> +#include <boost/numeric/mtl/operation/sfunctor.hpp> +#include <boost/numeric/linear_algebra/identity.hpp> + + +namespace mtl { namespace matrix { + +template <typename E1, typename E2> +struct mat_mat_ele_times_expr + : public mat_mat_op_expr< E1, E2, mtl::sfunctor::times<typename E1::value_type, typename E2::value_type> >, + public mat_expr< mat_mat_ele_times_expr<E1, E2> > +{ + typedef mat_mat_op_expr< E1, E2, mtl::sfunctor::times<typename E1::value_type, typename E2::value_type> > op_base; + typedef mat_expr< mat_mat_ele_times_expr<E1, E2> > crtp_base; + typedef mat_mat_ele_times_expr self; + typedef E1 first_argument_type ; + typedef E2 second_argument_type ; + typedef typename E1::orientation orientation; + typedef mtl::non_fixed::dimensions dim_type; + typedef typename E1::key_type key_type; + + + mat_mat_ele_times_expr( E1 const& v1, E2 const& v2 ) + : op_base( v1, v2 ), crtp_base(*this), first(v1), second(v2) + {} + + first_argument_type const& first ; + second_argument_type const& second ; +}; + +template <typename E1, typename E2> +std::size_t inline num_rows(const mat_mat_ele_times_expr<E1, E2>& expr) +{ return num_rows(expr.first); } + +template <typename E1, typename E2> +std::size_t inline num_cols(const mat_mat_ele_times_expr<E1, E2>& expr) +{ return num_cols(expr.second); } + +template <typename E1, typename E2> +std::size_t inline size(const mat_mat_ele_times_expr<E1, E2>& expr) +{ return num_rows(expr) * num_cols(expr); } + +}} // Namespace mtl::matrix + +#endif // MTL_MAT_MAT_ELE_TIMES_EXPR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/mat_mat_minus_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/mat_mat_minus_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..81600ac8ddd29dfa8cacd1d52f22fa458b8f0368 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/mat_mat_minus_expr.hpp @@ -0,0 +1,60 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MAT_MAT_MINUS_EXPR_INCLUDE +#define MTL_MAT_MAT_MINUS_EXPR_INCLUDE + + +#include <boost/numeric/mtl/matrix/mat_mat_op_expr.hpp> +#include <boost/numeric/mtl/vector/vec_vec_pmop_expr.hpp> +#include <boost/numeric/mtl/operation/sfunctor.hpp> + +namespace mtl {namespace matrix { + +template <typename E1, typename E2> +struct mat_mat_minus_expr + : public mat_mat_op_expr< E1, E2, mtl::sfunctor::minus<typename E1::value_type, typename E2::value_type> >, + public mat_expr< mat_mat_minus_expr<E1, E2> > +{ + typedef mat_mat_op_expr< E1, E2, mtl::sfunctor::minus<typename E1::value_type, typename E2::value_type> > op_base; + typedef mat_expr< mat_mat_minus_expr<E1, E2> > crtp_base; + typedef E1 first_argument_type ; + typedef E2 second_argument_type ; + + mat_mat_minus_expr( E1 const& v1, E2 const& v2 ) + : op_base( v1, v2 ), crtp_base(*this), first(v1), second(v2) + {} + + first_argument_type const& first ; + second_argument_type const& second ; +}; + +template <typename E1, typename E2> +struct mv_mv_minus_expr + : mat_mat_minus_expr<E1, E2> +{ + typedef mat_mat_minus_expr< E1, E2 > base; + typedef typename E1::vector_type V1; + typedef typename E2::vector_type V2; + typedef mtl::vector::vec_vec_pmop_expr< V1, V2, mtl::sfunctor::minus<typename V1::value_type, typename V2::value_type> > vector_type; + + mv_mv_minus_expr( E1 const& v1, E2 const& v2 ) + : base( v1, v2 ) + {} + + vector_type vector(std::size_t c) const { return vector_type(this->first.vector(c), this->second.vector(c)); } +}; + +}} // Namespace mtl::matrix + + +#endif // MTL_MAT_MAT_MINUS_EXPR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/mat_mat_op_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/mat_mat_op_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..737befe76fb5726ca7df7f27f5f42805555d4258 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/mat_mat_op_expr.hpp @@ -0,0 +1,100 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MAT_MAT_OP_EXPR_INCLUDE +#define MTL_MAT_MAT_OP_EXPR_INCLUDE + +#include <boost/numeric/mtl/matrix/mat_expr.hpp> +#include <boost/numeric/mtl/matrix/crtp_base_matrix.hpp> + +namespace mtl { namespace matrix { + + +template <typename E1, typename E2, typename SFunctor> +struct mat_mat_op_expr + : public const_crtp_matrix_bracket< mat_mat_op_expr<E1, E2, SFunctor>, + typename SFunctor::result_type, + typename E1::size_type > + // : public mat_expr< mat_mat_op_expr<E1, E2, SFunctor> > +{ + // typedef mat_expr< mat_mat_op_expr<E1, E2, SFunctor> > expr_base; + typedef mat_mat_op_expr self; + + typedef typename SFunctor::result_type value_type; + + // temporary solution + typedef typename E1::size_type size_type; + + typedef value_type const_dereference_type ; + + typedef E1 first_argument_type ; + typedef E2 second_argument_type ; + + mat_mat_op_expr( first_argument_type const& v1, second_argument_type const& v2 ) + : // expr_base( *this ), + first( v1 ), second( v2 ) + { +#if 0 + first.delay_assign(); + second.delay_assign(); +#endif + } + + void delay_assign() const {} + + void check_shape() const {} // consistency of shapes depend on operation + + const_dereference_type operator() (size_type row, size_type col) const + { + return SFunctor::apply( first(row, col), second(row, col) ) ; + // return SFunctor::apply( first[row][col], second[row][col] ) ; + } + +#if 0 + template <typename> friend size_type size(const self&); + template <typename> friend size_type num_rows(const self&); + template <typename> friend size_type num_cols(const self&); +#endif + + first_argument_type const& first ; + second_argument_type const& second ; +}; + + +template <typename E1, typename E2, typename SFunctor> +typename mat_mat_op_expr<E1, E2, SFunctor>::size_type +inline size(mat_mat_op_expr<E1, E2, SFunctor> const& expr) +{ + expr.check_shape(); + return size(expr.first) ; +} + +template <typename E1, typename E2, typename SFunctor> +typename mat_mat_op_expr<E1, E2, SFunctor>::size_type +inline num_rows(mat_mat_op_expr<E1, E2, SFunctor> const& expr) +{ + expr.check_shape(); + return num_rows(expr.first) ; +} + +template <typename E1, typename E2, typename SFunctor> +typename mat_mat_op_expr<E1, E2, SFunctor>::size_type +inline num_cols(mat_mat_op_expr<E1, E2, SFunctor> const& expr) +{ + expr.check_shape(); + return num_cols(expr.first) ; +} + + +}} // namespace mtl + +#endif // MTL_MAT_MAT_OP_EXPR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/mat_mat_plus_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/mat_mat_plus_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..d13b8f9017971be92ed6fcf31a38b6c054c0f7e2 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/mat_mat_plus_expr.hpp @@ -0,0 +1,73 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MAT_MAT_PLUS_EXPR_INCLUDE +#define MTL_MAT_MAT_PLUS_EXPR_INCLUDE + +#include <boost/numeric/mtl/matrix/mat_mat_op_expr.hpp> +#include <boost/numeric/mtl/vector/vec_vec_pmop_expr.hpp> +#include <boost/numeric/mtl/operation/sfunctor.hpp> + +namespace mtl { namespace matrix { + +template <typename E1, typename E2> +struct mat_mat_plus_expr + : public mat_mat_op_expr< E1, E2, mtl::sfunctor::plus<typename E1::value_type, typename E2::value_type> >, + public mat_expr< mat_mat_plus_expr<E1, E2> > +{ + typedef mat_mat_op_expr< E1, E2, mtl::sfunctor::plus<typename E1::value_type, typename E2::value_type> > op_base; + typedef mat_expr< mat_mat_plus_expr<E1, E2> > crtp_base; + typedef E1 first_argument_type ; + typedef E2 second_argument_type ; + + mat_mat_plus_expr( E1 const& v1, E2 const& v2 ) + : op_base( v1, v2 ), crtp_base(*this), first(v1), second(v2) + {} + + first_argument_type const& first ; + second_argument_type const& second ; +}; + +// Same as mat_mat_plus_expr for pair of dense matrix expressions +// Future versions will probably provide more efficient implementations for it +template <typename E1, typename E2> +struct dmat_dmat_plus_expr + : public mat_mat_op_expr< E1, E2, mtl::sfunctor::plus<typename E1::value_type, typename E2::value_type> > +{ + typedef mat_mat_op_expr< E1, E2, mtl::sfunctor::plus<typename E1::value_type, typename E2::value_type> > base; + dmat_dmat_plus_expr( E1 const& v1, E2 const& v2 ) + : base( v1, v2 ) + {} +}; + +template <typename E1, typename E2> +struct mv_mv_plus_expr + : mat_mat_plus_expr<E1, E2> +{ + typedef mat_mat_plus_expr< E1, E2 > base; + typedef typename E1::vector_type V1; + typedef typename E2::vector_type V2; + typedef mtl::vector::vec_vec_pmop_expr< V1, V2, mtl::sfunctor::plus<typename V1::value_type, typename V2::value_type> > vector_type; + + mv_mv_plus_expr( E1 const& v1, E2 const& v2 ) + : base( v1, v2 ) + {} + + vector_type vector(std::size_t c) const { return vector_type(this->first.vector(c), this->second.vector(c)); } +}; + + + + +}} // Namespace mtl::matrix + +#endif // MTL_MAT_MAT_PLUS_EXPR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/mat_mat_times_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/mat_mat_times_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..0722424d595c15ff63eac44a0962b9d5e3dcba1b --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/mat_mat_times_expr.hpp @@ -0,0 +1,120 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MAT_MAT_TIMES_EXPR_INCLUDE +#define MTL_MAT_MAT_TIMES_EXPR_INCLUDE + +#include <boost/mpl/if.hpp> +#include <boost/mpl/and.hpp> +#include <boost/shared_ptr.hpp> +#include <boost/type_traits/is_base_of.hpp> + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/matrix/mat_mat_op_expr.hpp> +#include <boost/numeric/mtl/operation/sfunctor.hpp> +#include <boost/numeric/mtl/operation/compute_factors.hpp> +#include <boost/numeric/linear_algebra/identity.hpp> +#include <boost/numeric/mtl/matrix/parameter.hpp> +#include <boost/numeric/mtl/matrix/dense2D.hpp> +#include <boost/numeric/mtl/matrix/compressed2D.hpp> +#include <boost/numeric/mtl/concept/std_concept.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> + + +namespace mtl { namespace matrix { + +template <typename E1, typename E2> +struct mat_mat_times_expr + : public mat_mat_op_expr< E1, E2, mtl::sfunctor::times<typename Collection<E1>::value_type, typename Collection<E2>::value_type> >, + public mat_expr< mat_mat_times_expr<E1, E2> > +{ + typedef mat_mat_op_expr< E1, E2, mtl::sfunctor::times<typename Collection<E1>::value_type, typename Collection<E2>::value_type> > op_base; + typedef mat_expr< mat_mat_times_expr<E1, E2> > crtp_base; + typedef mat_mat_times_expr self; + typedef E1 first_argument_type ; + typedef E2 second_argument_type ; + typedef typename E1::orientation orientation; + typedef mtl::non_fixed::dimensions dim_type; + typedef typename E1::key_type key_type; + + + typedef typename Collection<E1>::value_type first_value_type; + typedef typename Collection<E2>::value_type second_value_type; + typedef typename Multiplicable<first_value_type, second_value_type>::result_type result_value_type; + +#if 0 // Just an idea + typedef typename boost::mpl::if_< + boost::mpl::and_< + boost::is_base_of<tag::sparse, typename traits::category<E1>::type> + , boost::is_base_of<tag::sparse, typename traits::category<E2>::type> + > + , compressed2D<result_value_type> + , dense2D<result_value_type, parameters<> > + >::type evaluated_result_type; + + // Convert into matrix + + operator evaluated_result_type() const + { + return evaluated_result_type(first * second); + } +#endif + + mat_mat_times_expr( E1 const& v1, E2 const& v2 ) + : op_base( v1, v2 ), crtp_base(*this), first(v1), second(v2) + {} + + // To prevent that cout << A * B prints the element-wise product, suggestion by Hui Li + // It is rather inefficient, esp. for multiple products (complexity increases with the number of arguments :-!) + // or sparse matrices. + // Better compute your product first and print it then when compute time is an issue, + // this is ONLY for convenience. + result_value_type + operator()(std::size_t r, std::size_t c) const + { + using math::zero; + MTL_THROW_IF(num_cols(first) != num_rows(second), incompatible_size()); + + result_value_type ref, sum(zero(ref)); + for (std::size_t i= 0; i < num_cols(first); i++) + sum+= first(r, i) * second(i, c); + return sum; + } + + + result_value_type + operator()(std::size_t r, std::size_t c) + { + return (*const_cast<const self*>(this))(r, c); + } + + first_argument_type const& first ; + second_argument_type const& second ; +}; + +template <typename E1, typename E2> +std::size_t inline num_rows(const mat_mat_times_expr<E1, E2>& expr) +{ return num_rows(expr.first); } + +template <typename E1, typename E2> +std::size_t inline num_cols(const mat_mat_times_expr<E1, E2>& expr) +{ return num_cols(expr.second); } + +template <typename E1, typename E2> +std::size_t inline size(const mat_mat_times_expr<E1, E2>& expr) +{ return num_rows(expr) * num_cols(expr); } + +}} // Namespace mtl::matrix + +#endif // MTL_MAT_MAT_TIMES_EXPR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/mat_negate_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/mat_negate_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..eed94fca307d44dbb07dfd087459e8e3fe8bb4dd --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/mat_negate_expr.hpp @@ -0,0 +1,30 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MAT_NEGATE_EXPR_INCLUDE +#define MTL_MAT_NEGATE_EXPR_INCLUDE + +#include <boost/numeric/mtl/matrix/map_view.hpp> + +namespace mtl { namespace matrix { + +template <typename E1> +inline negate_view< E1 > +operator- (const mat_expr<E1>& e1) +{ + return negate_view< E1 >(static_cast<const E1&>(e1)); +} + +} } // Namespace mtl::matrix + +#endif + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/morton_dense.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/morton_dense.hpp new file mode 100644 index 0000000000000000000000000000000000000000..f65a876a98a7fa53ad92df86bf45efea110b5429 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/morton_dense.hpp @@ -0,0 +1,904 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MORTON_DENSE_INCLUDE +#define MTL_MORTON_DENSE_INCLUDE + +#include <boost/type_traits/is_same.hpp> +#include <boost/mpl/if.hpp> + +#include <boost/numeric/mtl/utility/common_include.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/matrix/parameter.hpp> +#include <boost/numeric/mtl/matrix/crtp_base_matrix.hpp> +#include <boost/numeric/mtl/matrix/base_sub_matrix.hpp> +#include <boost/numeric/mtl/detail/contiguous_memory_block.hpp> +#include <boost/numeric/mtl/detail/dilated_int.hpp> +#include <boost/numeric/mtl/utility/iterator_adaptor.hpp> +#include <boost/numeric/mtl/operation/set_to_zero.hpp> +#include <boost/numeric/mtl/matrix/mat_expr.hpp> +#include <boost/numeric/mtl/operation/print_matrix.hpp> +#include <boost/numeric/mtl/operation/compute_factors.hpp> +#include <boost/numeric/mtl/operation/clone.hpp> + +#ifdef MTL_WITH_INITLIST +# include <initializer_list> +#endif + + +namespace mtl { namespace matrix { + +// Helper type +struct morton_dense_sub_ctor {}; + +template <std::size_t BitMask> +struct morton_dense_key +{ + typedef std::size_t size_type; + typedef dilated_int<std::size_t, BitMask, true> dilated_row_t; + typedef dilated_int<std::size_t, ~BitMask, true> dilated_col_t; + typedef morton_dense_key self; + + morton_dense_key(size_type my_row, size_type my_col) + : my_row(my_row), my_col(my_col), dilated_row(my_row), dilated_col(my_col) + {} + + bool operator== (self const& x) const + { + return my_row == x.my_row && my_col == x.my_col; + } + + bool operator!= (self const& x) + { + return !(*this == x); + } + + size_type row() const + { + return my_row; + } + + size_type col() const + { + return my_col; + } + + self& advance_row(int row_inc) + { + dilated_row.advance(row_inc); + // potential addition of signed and unsigned + my_row+= row_inc; + return *this; + } + + self& advance_col(int col_inc) + { + dilated_col.advance(col_inc); + // potential addition of signed and unsigned + my_col+= col_inc; + return *this; + } + + self& advance(int row_inc, int col_inc) + { + advance_row(row_inc); + advance_col(col_inc); + return *this; + } + +public: + size_type my_row, my_col; + dilated_row_t dilated_row; + dilated_col_t dilated_col; +}; + +template <std::size_t BitMask> +struct morton_dense_el_cursor + : public morton_dense_key<BitMask> +{ + typedef std::size_t size_type; + typedef dilated_int<std::size_t, ~BitMask, true> dilated_col_t; + typedef morton_dense_el_cursor self; + typedef morton_dense_key<BitMask> base; + typedef base key_type; + + morton_dense_el_cursor(size_type my_row, size_type my_col, size_type num_cols) + : base(my_row, my_col), num_cols(num_cols) + {} + + self& operator++ () + { + ++this->my_col; ++this->dilated_col; + if (this->my_col == num_cols) { + this->my_col= 0; this->dilated_col= dilated_col_t(0); + ++this->my_row; ++this->dilated_row; + } + return *this; + } + + base& operator* () + { + return *this; + } + + const base& operator* () const + { + return *this; + } + +protected: + size_t num_cols; +}; + +template <std::size_t BitMask> +struct morton_dense_row_cursor + : public morton_dense_key<BitMask> +{ + typedef std::size_t size_type; + typedef morton_dense_row_cursor self; + typedef morton_dense_key<BitMask> base; + typedef base key_type; + + morton_dense_row_cursor(size_type my_row, size_type my_col) + : base(my_row, my_col) + {} + + self& operator++ () + { + ++this->my_row; ++this->dilated_row; + return *this; + } + + self& operator+=(int inc) + { + this->advance_row(inc); + return *this; + } + + self& operator-- () + { + --this->my_row; --this->dilated_row; + return *this; + } + + self& operator-=(int dec) + { + this->advance_row(-dec); + return *this; + } + + self operator+ (int inc) const + { + self tmp(*this); + tmp.advance_row(inc); + return tmp; + } + + base& operator* () + { + return *this; + } + + const base& operator* () const + { + return *this; + } +}; + +template <std::size_t BitMask> +struct morton_dense_col_cursor + : public morton_dense_key<BitMask> +{ + typedef std::size_t size_type; + typedef morton_dense_col_cursor self; + typedef morton_dense_key<BitMask> base; + typedef base key_type; + + morton_dense_col_cursor(size_type my_row, size_type my_col) + : base(my_row, my_col) + {} + + self& operator++ () + { + ++this->my_col; ++this->dilated_col; + return *this; + } + + self& operator+=(int inc) + { + this->advance_col(inc); + return *this; + } + + self& operator-- () + { + --this->my_col; --this->dilated_col; + return *this; + } + + self& operator-=(int dec) + { + this->advance_col(-dec); + return *this; + } + + self operator+ (int inc) const + { + self tmp(*this); + tmp.advance_col(inc); + return tmp; + } + + base& operator* () + { + return *this; + } + + const base& operator* () const + { + return *this; + } +}; + + +template <typename Matrix> +struct morton_dense_row_const_iterator + : utilities::const_iterator_adaptor<typename mtl::traits::const_value<Matrix>::type, morton_dense_row_cursor<Matrix::mask>, + typename Matrix::value_type> +{ + static const std::size_t mask= Matrix::mask; + typedef morton_dense_row_cursor<mask> cursor_type; + typedef typename mtl::traits::const_value<Matrix>::type map_type; + typedef typename Matrix::value_type value_type; + typedef typename Matrix::size_type size_type; + typedef utilities::const_iterator_adaptor<map_type, cursor_type, value_type> base; + + morton_dense_row_const_iterator(const Matrix& matrix, size_type row, size_type col) + : base(map_type(matrix), cursor_type(row, col)) + {} +}; + + +template <typename Matrix> +struct morton_dense_row_iterator + : utilities::iterator_adaptor<typename mtl::traits::value<Matrix>::type, morton_dense_row_cursor<Matrix::mask>, + typename Matrix::value_type> +{ + static const std::size_t mask= Matrix::mask; + typedef morton_dense_row_cursor<mask> cursor_type; + typedef typename mtl::traits::value<Matrix>::type map_type; + typedef typename Matrix::value_type value_type; + typedef typename Matrix::size_type size_type; + typedef utilities::iterator_adaptor<map_type, cursor_type, value_type> base; + + morton_dense_row_iterator(Matrix& matrix, size_type row, size_type col) + : base(map_type(matrix), cursor_type(row, col)) + {} +}; + + +template <typename Matrix> +struct morton_dense_col_const_iterator + : utilities::const_iterator_adaptor<typename mtl::traits::const_value<Matrix>::type, morton_dense_col_cursor<Matrix::mask>, + typename Matrix::value_type> +{ + static const std::size_t mask= Matrix::mask; + typedef morton_dense_col_cursor<mask> cursor_type; + typedef typename mtl::traits::const_value<Matrix>::type map_type; + typedef typename Matrix::value_type value_type; + typedef typename Matrix::size_type size_type; + typedef utilities::const_iterator_adaptor<map_type, cursor_type, value_type> base; + + morton_dense_col_const_iterator(const Matrix& matrix, size_type row, size_type col) + : base(map_type(matrix), cursor_type(row, col)) + {} +}; + + +template <typename Matrix> +struct morton_dense_col_iterator + : utilities::iterator_adaptor<typename mtl::traits::value<Matrix>::type, morton_dense_col_cursor<Matrix::mask>, + typename Matrix::value_type> +{ + static const std::size_t mask= Matrix::mask; + typedef morton_dense_col_cursor<mask> cursor_type; + typedef typename mtl::traits::value<Matrix>::type map_type; + typedef typename Matrix::value_type value_type; + typedef typename Matrix::size_type size_type; + typedef utilities::iterator_adaptor<map_type, cursor_type, value_type> base; + + morton_dense_col_iterator(Matrix& matrix, size_type row, size_type col) + : base(map_type(matrix), cursor_type(row, col)) {} +}; + + + +/// Dense Morton-order matrix +template <typename Elt, std::size_t BitMask, typename Parameters = mtl::matrix::parameters<> > +class morton_dense + : public base_sub_matrix<Elt, Parameters>, + public mtl::detail::contiguous_memory_block<Elt, false>, + public crtp_base_matrix< morton_dense<Elt, BitMask, Parameters>, Elt, std::size_t >, + public mat_expr< morton_dense<Elt, BitMask, Parameters> > +{ + typedef morton_dense self; + typedef base_sub_matrix<Elt, Parameters> super; + typedef mtl::detail::contiguous_memory_block<Elt, false> memory_base; + typedef crtp_matrix_assign< self, Elt, std::size_t > assign_base; + typedef mat_expr< morton_dense<Elt, BitMask, Parameters> > expr_base; + + public: + + typedef Parameters parameters; + typedef typename Parameters::orientation orientation; + typedef typename Parameters::index index_type; + typedef typename Parameters::dimensions dim_type; + typedef Elt value_type; + typedef const value_type& const_reference; + typedef value_type& reference; + typedef typename parameters::size_type size_type; + const static std::size_t mask= BitMask; + + // implement cursor for morton matrix, somewhere + // also, morton indexer? + + typedef morton_dense_key<BitMask> key_type; + typedef morton_dense_el_cursor<BitMask> el_cursor_type; + + typedef dilated_int<std::size_t, BitMask, true> dilated_row_t; + typedef dilated_int<std::size_t, ~BitMask, true> dilated_col_t; + + protected: + + // ranges of rows and columns + dilated_row_t my_begin_row, my_end_row; + dilated_col_t my_begin_col, my_end_col; + + // Set ranges from begin_r to end_r and begin_c to end_c + void set_ranges(size_type begin_r, size_type end_r, size_type begin_c, size_type end_c) + { + super::set_ranges(begin_r, end_r, begin_c, end_c); + my_begin_row= begin_r; my_end_row= end_r; + my_begin_col= begin_c; my_end_col= end_c; + set_nnz(); + } + + // Set ranges to a num_row x num_col matrix, keeps indexing + void set_ranges(size_type num_rows, size_type num_cols) + { + set_ranges(this->begin_row(), this->begin_row() + num_rows, + this->begin_col(), this->begin_col() + num_cols); + } + + void init(size_type num_rows, size_type num_cols) + { + set_ranges(num_rows, num_cols); + // set_to_zero(*this); + } + + public: + /// Default constructor + /** If compile time matrix size allocate memory. **/ + morton_dense() : memory_base(memory_need(dim_type().num_rows(), dim_type().num_cols())) + { + init(dim_type().num_rows(), dim_type().num_cols()); + } + + /// Construction from run-time dimension type + explicit morton_dense(mtl::non_fixed::dimensions d) + : memory_base(memory_need(d.num_rows(), d.num_cols())) + { + init(d.num_rows(), d.num_cols()); + } + + /// Construction of matrix of dimension \p num_rows by \p num_cols + morton_dense(size_type num_rows, size_type num_cols) + : memory_base(memory_need(num_rows, num_cols)) + { + init(num_rows, num_cols); + } + + /// Construction of matrix with dimension \p d using pointer \p a to external data + explicit morton_dense(mtl::non_fixed::dimensions d, value_type* a) + : memory_base(a, memory_need(d.num_rows(), d.num_cols())) + { + set_ranges(d.num_rows(), d.num_cols()); + } + + /// Construction of \p num_rows by \p num_cols matrix with pointer \p a to external data + explicit morton_dense(size_type num_rows, size_type num_cols, value_type* a) + : memory_base(a, memory_need(num_rows, num_cols)) + { + set_ranges(num_rows, num_cols); + } + + /// Construction of matrix with static dimension using pointer \p a to external data + explicit morton_dense(value_type* a) + : memory_base(a, memory_need(dim_type().num_rows(), dim_type().num_cols())) + { + BOOST_ASSERT((dim_type::is_static)); + set_ranges(dim_type().num_rows(), dim_type().num_cols()); + } + + /// Copy constructor + morton_dense(const self& m) + : super(m), memory_base(m) + { + set_ranges(m.num_rows(), m.num_cols()); + } + + /// Clone constructor + explicit morton_dense(const self& m, clone_ctor) + : memory_base(m, clone_ctor()) + { + init(m.num_rows(), m.num_cols()); + *this= m; + } + + /// Templated copy constructor + template <typename MatrixSrc> + explicit morton_dense(const MatrixSrc& src) + : memory_base(memory_need(dim_type().num_rows(), dim_type().num_cols())) + { + init(dim_type().num_rows(), dim_type().num_cols()); + *this= src; + } + +#if defined(MTL_WITH_INITLIST) && defined(MTL_WITH_AUTO) && defined(MTL_WITH_RANGEDFOR) + /// Constructor for initializer list \p values + template <typename Value2> + morton_dense(std::initializer_list<std::initializer_list<Value2> > values) + : super(mtl::non_fixed::dimensions(values.size(), values.size()? values.begin()->size() : 0)), + memory_base(this->num_rows() * this->num_cols()) + { + init(this->num_rows(), this->num_cols()); + *this= values; + } +#endif + + + /// Construct a sub-matrix as a view + explicit morton_dense(self& matrix, morton_dense_sub_ctor, + size_type begin_r, size_type end_r, size_type begin_c, size_type end_c) + : memory_base(matrix.data, memory_need(end_r - begin_r, end_c - begin_c), true) // View constructor + { + matrix.check_ranges(begin_r, end_r, begin_c, end_c); + + if (begin_r >= end_r || begin_c >= end_c) { + set_ranges(0, 0); + return; + } + + // Check whether sub-matrix is contigous memory block + // by comparing the address of the last and the first element in the entire and the sub-matrix + MTL_DEBUG_THROW_IF(&matrix[end_r-1][end_c-1] - &matrix[begin_r][begin_c] + != &matrix[end_r-begin_r-1][end_c-begin_c-1] - &matrix[0][0], + range_error("This sub-matrix cannot be used because it is split in memory")); + // Check with David if this is a sufficient condition (it is a necessary at least) + + dilated_row_t dilated_row(begin_r); + dilated_col_t dilated_col(begin_c); + + // Set new start address within masked matrix + this->data += dilated_row.dilated_value() + dilated_col.dilated_value(); + set_ranges(end_r - begin_r, end_c - begin_c); + } + + /// Change dimension to \p num_rows by \p num_cols + void change_dim(size_type num_rows, size_type num_cols) + { + set_ranges(num_rows, num_cols); + this->realloc(memory_need(num_rows, num_cols)); + } + + +#if 0 + // Move assignment (emulation) + self& operator=(self src) + { + // Self-copy would be an indication of an error + assert(this != &src); + + this->check_dim(src.num_rows(), src.num_cols()); + if (this->category == memory_base::view || src.category == memory_base::view) + matrix_copy(src, *this); + else + memory_base::move_assignment(src); + return *this; + } +#endif + + +#ifdef MTL_WITH_MOVE + /// Move Assignment + self& operator=(self&& src) + { + this->checked_change_dim(src.num_rows(), src.num_cols()); + if (this->category == memory_base::view || src.category == memory_base::view) + matrix_copy(src, *this); + else + memory_base::move_assignment(src); + std::cout << "In dense2D::move_assignment\n"; + return *this; + } + + /// Copy Assignment + self& operator=(const self& src) + { + this->checked_change_dim(src.num_rows(), src.num_cols()); + // this->check_dim(src.num_rows(), src.num_cols()); + matrix_copy(src, *this); + return *this; + } +#else + /// Copy assignment (with move emulation) + self& operator=(self src) + { + // Self-copy would be an indication of an error + assert(this != &src); + + this->check_dim(src.num_rows(), src.num_cols()); + if (this->category == memory_base::view || src.category == memory_base::view) + matrix_copy(src, *this); + else + memory_base::move_assignment(src); + return *this; + } +#endif + + using assign_base::operator=; + + + value_type operator() (key_type const& key) const + { + return this->data[key.dilated_row.dilated_value() + key.dilated_col.dilated_value()]; + } + + void operator()(key_type const& key, value_type const& value) + { + this->data[key.dilated_row.dilated_value() + key.dilated_col.dilated_value()]= value; + } + + /// Constant reference to A[row][col] + const_reference operator() (size_type row, size_type col) const + { + MTL_DEBUG_THROW_IF(is_negative(row) || row >= this->num_rows() || is_negative(col) || col >= this->num_cols(), index_out_of_range()); + return this->data[dilated_row_t(row).dilated_value() + dilated_col_t(col).dilated_value()]; + } + + /// Mutable reference to A[row][col] + value_type& operator() (size_type row, size_type col) + { + MTL_DEBUG_THROW_IF(is_negative(row) || row >= this->num_rows() || is_negative(col) || col >= this->num_cols(), index_out_of_range()); + return this->data[dilated_row_t(row).dilated_value() + dilated_col_t(col).dilated_value()]; + } + + void crop() {} ///< Delete structural zeros, only dummy here + + protected: + void set_nnz() + { + this->my_nnz = this->num_rows() * this->num_cols(); + } + + size_type memory_need(size_type rows, size_type cols) + { + dilated_row_t n_rows(rows - 1); + dilated_col_t n_cols(cols - 1); + return (n_rows.dilated_value() + n_cols.dilated_value() + 1); + } + + /// Swap matrices + friend void swap(self& matrix1, self& matrix2) + { + swap(static_cast<memory_base&>(matrix1), static_cast<memory_base&>(matrix2)); + swap(static_cast<super&>(matrix1), static_cast<super&>(matrix2)); + } + + template <typename> friend struct sub_matrix_t; +}; + + +// ================ +// Free functions +// ================ + +/// Number of rows +template <typename Value, std::size_t Mask, typename Parameters> +typename morton_dense<Value, Mask, Parameters>::size_type +inline num_rows(const morton_dense<Value, Mask, Parameters>& matrix) +{ + return matrix.num_rows(); +} + +/// Number of columns +template <typename Value, std::size_t Mask, typename Parameters> +typename morton_dense<Value, Mask, Parameters>::size_type +inline num_cols(const morton_dense<Value, Mask, Parameters>& matrix) +{ + return matrix.num_cols(); +} + +/// Matrix size, i.e. number of rows times columns +template <typename Value, std::size_t Mask, typename Parameters> +typename morton_dense<Value, Mask, Parameters>::size_type +inline size(const morton_dense<Value, Mask, Parameters>& matrix) +{ + return matrix.num_cols() * matrix.num_rows(); +} + +}} // namespace mtl::matrix + + + + +// ================ +// Range generators +// ================ + +namespace mtl { namespace traits { + + // VC 8.0 finds ambiguity with mtl::tag::morton_dense (I wonder why) + using mtl::matrix::morton_dense; + using mtl::matrix::morton_dense_el_cursor; + using mtl::matrix::morton_dense_col_cursor; + using mtl::matrix::morton_dense_row_cursor; + using mtl::matrix::morton_dense_col_const_iterator; + using mtl::matrix::morton_dense_row_const_iterator; + using mtl::matrix::morton_dense_col_iterator; + using mtl::matrix::morton_dense_row_iterator; + + // =========== + // For cursors + // =========== + + template <class Elt, std::size_t BitMask, class Parameters> + struct range_generator<glas::tag::all, morton_dense<Elt, BitMask, Parameters> > + { + typedef morton_dense<Elt, BitMask, Parameters> Matrix; + typedef complexity_classes::linear_cached complexity; + static int const level = 1; + typedef morton_dense_el_cursor<BitMask> type; + type begin(Matrix const& matrix) + { + return type(matrix.begin_row(), matrix.begin_col(), matrix.num_cols()); + } + type end(Matrix const& matrix) + { + return type(matrix.end_row(), matrix.begin_col(), matrix.num_cols()); + } + }; + + template <class Elt, std::size_t BitMask, class Parameters> + struct range_generator<glas::tag::nz, morton_dense<Elt, BitMask, Parameters> > + : range_generator<glas::tag::all, morton_dense<Elt, BitMask, Parameters> > + {}; + + template <class Elt, std::size_t BitMask, class Parameters> + struct range_generator<glas::tag::row, morton_dense<Elt, BitMask, Parameters> > + : detail::all_rows_range_generator<morton_dense<Elt, BitMask, Parameters>, complexity_classes::linear_cached> + {}; + + // For a cursor pointing to some row give the range of elements in this row + template <class Elt, std::size_t BitMask, class Parameters> + struct range_generator<glas::tag::nz, + detail::sub_matrix_cursor<morton_dense<Elt, BitMask, Parameters>, glas::tag::row, 2> > + { + typedef morton_dense<Elt, BitMask, Parameters> matrix; + typedef typename Collection<matrix>::size_type size_type; + typedef detail::sub_matrix_cursor<matrix, glas::tag::row, 2> cursor; + typedef complexity_classes::linear_cached complexity; + static int const level = 1; + typedef morton_dense_col_cursor<BitMask> type; + + type begin(cursor const& c) const + { + return type(c.key, c.ref.begin_col()); + } + type end(cursor const& c) const + { + return type(c.key, c.ref.end_col()); + } + type lower_bound(cursor const& c, size_type position) const + { + return type(c.key, std::min(c.ref.end_col(), position)); + } + }; + + template <class Elt, std::size_t BitMask, class Parameters> + struct range_generator<glas::tag::all, + detail::sub_matrix_cursor<morton_dense<Elt, BitMask, Parameters>, glas::tag::row, 2> > + : range_generator<glas::tag::nz, + detail::sub_matrix_cursor<morton_dense<Elt, BitMask, Parameters>, glas::tag::row, 2> > + {}; + + template <class Elt, std::size_t BitMask, class Parameters> + struct range_generator<glas::tag::col, morton_dense<Elt, BitMask, Parameters> > + : detail::all_cols_range_generator<morton_dense<Elt, BitMask, Parameters>, complexity_classes::linear_cached> + {}; + + // For a cursor pointing to some row give the range of elements in this row + template <class Elt, std::size_t BitMask, class Parameters> + struct range_generator<glas::tag::nz, + detail::sub_matrix_cursor<morton_dense<Elt, BitMask, Parameters>, glas::tag::col, 2> > + { + typedef morton_dense<Elt, BitMask, Parameters> matrix; + typedef typename Collection<matrix>::size_type size_type; + typedef detail::sub_matrix_cursor<matrix, glas::tag::col, 2> cursor; + typedef complexity_classes::linear_cached complexity; + static int const level = 1; + typedef morton_dense_row_cursor<BitMask> type; + + type begin(cursor const& c) + { + return type(c.ref.begin_row(), c.key); + } + type end(cursor const& c) + { + return type(c.ref.end_row(), c.key); + } + type lower_bound(cursor const& c, size_type position) const + { + return type(std::min(c.ref.end_row(), position), c.key); + } + }; + + template <class Elt, std::size_t BitMask, class Parameters> + struct range_generator<glas::tag::all, + detail::sub_matrix_cursor<morton_dense<Elt, BitMask, Parameters>, glas::tag::col, 2> > + : range_generator<glas::tag::nz, + detail::sub_matrix_cursor<morton_dense<Elt, BitMask, Parameters>, glas::tag::col, 2> > + {}; + + +// ============= +// For iterators +// ============= + + namespace detail { + + template <typename OuterTag, typename Matrix, bool is_const> + struct morton_dense_iterator_range_generator + { + typedef Matrix matrix_type; + typedef typename matrix_type::size_type size_type; + typedef typename matrix_type::value_type value_type; + typedef typename matrix_type::parameters parameters; + typedef detail::sub_matrix_cursor<matrix_type, OuterTag, 2> cursor; + + typedef complexity_classes::linear_cached complexity; + static int const level = 1; + + typedef typename boost::mpl::if_< + boost::is_same<OuterTag, glas::tag::row> + , typename boost::mpl::if_c< + is_const + , morton_dense_col_const_iterator<Matrix> + , morton_dense_col_iterator<Matrix> + >::type + , typename boost::mpl::if_c< + is_const + , morton_dense_row_const_iterator<Matrix> + , morton_dense_row_iterator<Matrix> + >::type + >::type type; + + private: + + typedef typename boost::mpl::if_c<is_const, const Matrix&, Matrix&>::type mref_type; + + type begin_dispatch(cursor const& c, glas::tag::row) + { + return type(const_cast<mref_type>(c.ref), c.key, c.ref.begin_col()); + } + + type end_dispatch(cursor const& c, glas::tag::row) + { + return type(const_cast<mref_type>(c.ref), c.key, c.ref.end_col()); + } + + type begin_dispatch(cursor const& c, glas::tag::col) + { + return type(const_cast<mref_type>(c.ref), c.ref.begin_row(), c.key); + } + + type end_dispatch(cursor const& c, glas::tag::col) + { + return type(const_cast<mref_type>(c.ref), c.ref.end_row(), c.key); + } + + public: + + type begin(cursor const& c) + { + return begin_dispatch(c, OuterTag()); + } + + type end(cursor const& c) + { + return end_dispatch(c, OuterTag()); + } + }; + + } // namespace detail + + + template <typename Value, std::size_t BitMask, typename Parameters, typename OuterTag> + struct range_generator<tag::iter::nz, + detail::sub_matrix_cursor<morton_dense<Value, BitMask, Parameters>, OuterTag, 2> > + : public detail::morton_dense_iterator_range_generator<OuterTag, morton_dense<Value, BitMask, Parameters>, false> + {}; + + template <typename Value, std::size_t BitMask, typename Parameters, typename OuterTag> + struct range_generator<tag::iter::all, + detail::sub_matrix_cursor<morton_dense<Value, BitMask, Parameters>, OuterTag, 2> > + : public detail::morton_dense_iterator_range_generator<OuterTag, morton_dense<Value, BitMask, Parameters>, false> + {}; + + template <typename Value, std::size_t BitMask, typename Parameters, typename OuterTag> + struct range_generator<tag::const_iter::nz, + detail::sub_matrix_cursor<morton_dense<Value, BitMask, Parameters>, OuterTag, 2> > + : public detail::morton_dense_iterator_range_generator<OuterTag, morton_dense<Value, BitMask, Parameters>, true> + {}; + + template <typename Value, std::size_t BitMask, typename Parameters, typename OuterTag> + struct range_generator<tag::const_iter::all, + detail::sub_matrix_cursor<morton_dense<Value, BitMask, Parameters>, OuterTag, 2> > + : public detail::morton_dense_iterator_range_generator<OuterTag, morton_dense<Value, BitMask, Parameters>, true> + {}; + + +}} // namespace mtl::traits + + +namespace mtl { namespace matrix { + + // ========== + // Sub matrix + // ========== + + template <typename Value, std::size_t BitMask, typename Parameters> + struct sub_matrix_t<morton_dense<Value, BitMask, Parameters> > + { + typedef morton_dense<Value, BitMask, Parameters> matrix_type; + typedef matrix_type sub_matrix_type; + typedef matrix_type const const_sub_matrix_type; + typedef typename matrix_type::size_type size_type; + + sub_matrix_type operator()(matrix_type& matrix, size_type begin_r, size_type end_r, size_type begin_c, size_type end_c) + { + return sub_matrix_type(matrix, morton_dense_sub_ctor(), begin_r, end_r, begin_c, end_c); + } + + const_sub_matrix_type + operator()(matrix_type const& matrix, size_type begin_r, size_type end_r, size_type begin_c, size_type end_c) + { + // To minimize code duplication, we use the non-const version + sub_matrix_type tmp((*this)(const_cast<matrix_type&>(matrix), begin_r, end_r, begin_c, end_c)); + return tmp; + } + }; + +}} // mtl::matrix + +namespace mtl { + + using matrix::morton_dense; + + // Enable cloning of dense matrices + template <typename Value, std::size_t BitMask, typename Parameters> + struct is_clonable< matrix::morton_dense<Value, BitMask, Parameters> > : boost::mpl::true_ {}; + +} // namespace mtl + +#endif // MTL_MORTON_DENSE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/multi_vector.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/multi_vector.hpp new file mode 100644 index 0000000000000000000000000000000000000000..45a78b87fa8134dc9940118bdfeddcd67c8810b5 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/multi_vector.hpp @@ -0,0 +1,227 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_MULTI_VECTOR_INCLUDE +#define MTL_MATRIX_MULTI_VECTOR_INCLUDE + +#include <cassert> +#include <boost/utility/enable_if.hpp> + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/matrix/parameter.hpp> +#include <boost/numeric/mtl/matrix/crtp_base_matrix.hpp> +#include <boost/numeric/mtl/matrix/mat_expr.hpp> +#include <boost/numeric/mtl/matrix/multi_vector_range.hpp> +#include <boost/numeric/mtl/matrix/make_fast_multi_vector_expr.hpp> +#include <boost/numeric/mtl/utility/is_what.hpp> +#include <boost/numeric/mtl/utility/is_composable_vector.hpp> +#include <boost/numeric/mtl/utility/is_multi_vector_expr.hpp> +#include <boost/numeric/mtl/utility/fast_multi_vector_expr.hpp> +#include <boost/numeric/mtl/utility/static_assert.hpp> +#include <boost/numeric/mtl/vector/parameter.hpp> + + +namespace mtl { namespace matrix { + + +// Might need to be defined later +struct multi_vector_key {}; + +/// Matrix constituting of set of column vectors (under development) +template <typename Vector> +class multi_vector + : public base_matrix<typename mtl::Collection<Vector>::value_type, parameters<> >, + public crtp_base_matrix< multi_vector<Vector>, typename Collection<Vector>::value_type, + typename Collection<Vector>::size_type>, + public mat_expr< multi_vector<Vector> > +{ + typedef base_matrix<typename Collection<Vector>::value_type, parameters<> > super; + + // Vector must by column vector + MTL_STATIC_ASSERT((boost::is_same<typename OrientedCollection<Vector>::orientation, + tag::col_major>::value), + "Vector must be a column vector."); + public: + typedef multi_vector self; + // typedef mtl::matrix::parameters<> parameters; + typedef Vector vector_type; + typedef tag::col_major orientation; + typedef typename Collection<Vector>::value_type value_type; + typedef typename Collection<Vector>::size_type size_type; + typedef const value_type& const_reference; + typedef value_type& reference; + typedef multi_vector_key key_type; + typedef crtp_matrix_assign< self, value_type, size_type > assign_base; + + multi_vector() : super(non_fixed::dimensions(0, 0)), master(0) {} + + private: + void setup_data(size_type num_rows, size_type num_cols, boost::mpl::false_) + { + for (size_type i= 0; i < num_cols; ++i) + data[i]= Vector(num_rows); + master= 0; + } + + void setup_data(size_type num_rows, size_type num_cols, boost::mpl::true_) + { + master= new Vector(num_rows * num_cols); + for (size_type i= 0; i < num_cols; ++i) { + Vector tmp((*master)[irange(i * num_rows, (i+1) * num_rows)]); + swap(data[i], tmp); + } + } + + public: + /// Constructor by number of rows and columns + multi_vector(size_type num_rows, size_type num_cols) + : super(non_fixed::dimensions(num_rows, num_cols)), data(num_cols) + { + setup_data(num_rows, num_cols, mtl::traits::is_composable_vector<Vector>()); + this->my_nnz= num_rows * num_cols; + } + + /// Constructor column vector and number of columns (for easier initialization) + multi_vector(const Vector& v, size_type num_cols) + : super(non_fixed::dimensions(size(v), num_cols)), data(num_cols) + { + using mtl::vector::num_rows; + setup_data(num_rows(v), num_cols, mtl::traits::is_composable_vector<Vector>()); + for (size_type i= 0; i < num_cols; ++i) + data[i]= v; + this->my_nnz= num_cols * size(v); + } + + ~multi_vector() { delete master; } + + private: + + void change_dim(size_type r, size_type c, boost::mpl::false_) + { + for (size_type i= 0; i < c; i++) + data[i].change_dim(r); + } + + void change_dim(size_type r, size_type c, boost::mpl::true_) + { + delete master; + setup_data(r, c, boost::mpl::true_()); + } + + public: + /// Change dimension, can keep old data + void change_dim(size_type r, size_type c) + { + if (r == super::num_rows() && c == super::num_cols()) return; + super::change_dim(r, c); + data.change_dim(c); + change_dim(r, c, mtl::traits::is_composable_vector<Vector>()); + } + + void self_assignment(const self& src, boost::mpl::false_) + { + for (size_type i= 0; i < super::num_cols(); i++) + data[i]= src.data[i]; + } + + void self_assignment(const self& src, boost::mpl::true_) + { *master= *src.master; } + + /// Copy constructor + /** Explicitly needed now. **/ + self& operator=(const self& src) + { + assign_base::checked_change_dim(src.num_rows(), src.num_cols()); + self_assignment(src, mtl::traits::is_composable_vector<Vector>()); + return *this; + } + + // Todo: multi_vector with other matrix expressions + /// Assign multi_vector and expressions thereof, general matrices currently not allowed + template <typename Src> + typename boost::enable_if_c<mtl::traits::is_multi_vector_expr<Src>::value + && !mtl::traits::is_fast_multi_vector_expr<Src>::value, self&>::type + operator=(const Src& src) + { + MTL_THROW_IF((mtl::matrix::num_rows(src) != super::num_rows() + || mtl::matrix::num_cols(src) != super::num_cols()), incompatible_size()); + for (std::size_t i= 0, n= super::num_cols(); i < n; ++i) + vector(i)= src.vector(i); + return *this; + } + + /// Assign multi_vector and expressions thereof that are stored internally by a single vector + template <typename Src> + typename boost::enable_if<mtl::traits::is_fast_multi_vector_expr<Src>, self&>::type + operator=(const Src& src) + { + assert(master); + *master= make_fast_multi_vector_expr(src); + return *this; + } + + template <typename Src> + typename boost::enable_if_c<mtl::traits::is_matrix<Src>::value + && !mtl::traits::is_multi_vector_expr<Src>::value, self&>::type + operator=(const Src& src) + { + assign_base::operator=(src); + return *this; + } + + /// Assign scalar + template <typename Src> + typename boost::enable_if<mtl::traits::is_scalar<Src>, self&>::type + operator=(const Src& src) + { + assign_base::operator=(src); + return *this; + } + + const_reference operator() (size_type i, size_type j) const { return data[j][i]; } + reference operator() (size_type i, size_type j) { return data[j][i]; } + + Vector& vector(size_type i) { return data[i]; } + const Vector& vector(size_type i) const { return data[i]; } + + Vector& at(size_type i) { return data[i]; } + const Vector& at(size_type i) const { return data[i]; } + + multi_vector_range<Vector> vector(irange const& r) const { return multi_vector_range<Vector>(*this, r); } + + inline friend const Vector& make_fast_multi_vector_expr(const self& mv) { assert(mv.master); return *mv.master; } + inline friend Vector& make_fast_multi_vector_expr(self& mv) { assert(mv.master); return *mv.master; } + + protected: + mtl::vector::dense_vector<Vector, mtl::vector::parameters<> > data; + Vector* master; +}; + +/// Number of rows +template< typename Vector > +typename Collection< Vector >::size_type num_cols(const multi_vector< Vector >& A) { return A.num_cols(); } + +/// Number of columns +template< typename Vector > +typename Collection< Vector >::size_type num_rows(const multi_vector< Vector >& A) { return A.num_rows(); } + +/// Size as defined by number of rows times columns +template< typename Vector > +typename Collection< Vector >::size_type size(const multi_vector< Vector >& A) { return num_rows(A) * num_cols(A); } +}} // namespace mtl::matrix + +namespace mtl { + using matrix::multi_vector; +} + +#endif // MTL_MATRIX_MULTI_VECTOR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/multi_vector_range.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/multi_vector_range.hpp new file mode 100644 index 0000000000000000000000000000000000000000..94048f8f14a1967bfcb416b82d1bc47f2ca3dfe3 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/multi_vector_range.hpp @@ -0,0 +1,53 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_MULTI_VECTOR_RANGE_INCLUDE +#define MTL_MATRIX_MULTI_VECTOR_RANGE_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/matrix/multi_vector.hpp> + +namespace mtl { namespace matrix { + +// So far only const, might be refactored for mutability later +template <typename Vector> +class multi_vector_range +{ + public: + typedef multi_vector_range self; + typedef typename Collection<Vector>::size_type size_type; + typedef typename Collection<Vector>::value_type value_type; + typedef const value_type& const_reference; + + multi_vector_range(const multi_vector<Vector>& ref, const irange& r) : ref(ref), r(r) {} + + const_reference operator() (size_type i, size_type j) const { return ref[r.to_range(j)][i]; } + const Vector& vector(size_type i) const { return ref.vector(r.to_range(i)); } + + /// Number of rows + friend size_type num_rows(const self& A) { return num_rows(A.ref); } + + /// Number of columns + friend size_type num_cols(const self& A) { return A.r.size(); } + + /// Size as defined by number of rows times columns + friend size_type size(const self& A) { return num_rows(A) * num_cols(A); } + + protected: + const multi_vector<Vector>& ref; + const irange r; +}; + + +}} // namespace mtl::matrix + +#endif // MTL_MATRIX_MULTI_VECTOR_RANGE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/operators.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/operators.hpp new file mode 100644 index 0000000000000000000000000000000000000000..aaf155b5377cd29154981f6a49ae8bddc0d22131 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/operators.hpp @@ -0,0 +1,100 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_OPERATORS_INCLUDE +#define MTL_MATRIX_OPERATORS_INCLUDE + +#include <boost/utility/enable_if.hpp> +#include <boost/mpl/and.hpp> + +#include <boost/numeric/mtl/utility/ashape.hpp> +#include <boost/numeric/mtl/utility/is_multi_vector_expr.hpp> +#include <boost/numeric/mtl/utility/static_assert.hpp> +#include <boost/numeric/mtl/matrix/all_mat_expr.hpp> +#include <boost/numeric/mtl/mtl_fwd.hpp> + + +namespace mtl { namespace matrix { + +template <typename E1, typename E2> +inline mat_mat_plus_expr<E1, E2> +operator+ (const mat_expr<E1>& e1, const mat_expr<E2>& e2) +{ + // do not add matrices with inconsistent value types + MTL_STATIC_ASSERT((boost::is_same<typename ashape::ashape<E1>::type, + typename ashape::ashape<E2>::type>::value), "Matrices have not consistent algebraic shape (i.e. nested types)."); + return mat_mat_plus_expr<E1, E2>(static_cast<const E1&>(e1), static_cast<const E2&>(e2)); +} + +// if enabled it has priority over previous functions because that performs upcast +template <typename E1, typename E2> +typename boost::enable_if_c<mtl::traits::is_multi_vector_expr<E1>::value && mtl::traits::is_multi_vector_expr<E2>::value, mv_mv_plus_expr<E1, E2> >::type +inline operator+(const E1& e1, const E2& e2) +{ + return mv_mv_plus_expr<E1, E2>(e1, e2); +} + +// Specialization for multi_vector +// template <typename V1, typename V2> +// inline mv_mv_plus_expr<multi_vector<V1>, multi_vector<V2> > +// operator+(const multi_vector<V1>& m1, const multi_vector<V2>& m2) +// { +// return mv_mv_plus_expr<multi_vector<V1>, multi_vector<V2> >(m1, m2); +// } + +#if 0 +// Planned for future optimizations on sums of dense matrix expressions +template <typename E1, typename E2> +inline dmat_dmat_plus_expr<E1, E2> +operator+ (const dmat_expr<E1>& e1, const dmat_expr<E2>& e2) +{ + // do not add matrices with inconsistent value types + MTL_STATIC_ASSERT((boost::is_same<typename ashape::ashape<E1>::type, + typename ashape::ashape<E2>::type>::value), "Matrices have not consistent algebraic shape (i.e. nested types)."); + return dmat_dmat_plus_expr<E1, E2>(static_cast<const E1&>(e1), static_cast<const E2&>(e2)); +} +#endif + + +template <typename E1, typename E2> +inline mat_mat_minus_expr<E1, E2> +operator- (const mat_expr<E1>& e1, const mat_expr<E2>& e2) +{ + // do not add matrices with inconsistent value types + MTL_STATIC_ASSERT((boost::is_same<typename ashape::ashape<E1>::type, + typename ashape::ashape<E2>::type>::value), "Matrices have not consistent algebraic shape (i.e. nested types)."); + return mat_mat_minus_expr<E1, E2>(static_cast<const E1&>(e1), static_cast<const E2&>(e2)); +} + +// if enabled it has priority over previous functions because that performs upcast +template <typename E1, typename E2> +typename boost::enable_if_c<mtl::traits::is_multi_vector_expr<E1>::value && mtl::traits::is_multi_vector_expr<E2>::value, mv_mv_minus_expr<E1, E2> >::type +inline operator-(const E1& e1, const E2& e2) +{ + return mv_mv_minus_expr<E1, E2>(e1, e2); +} + +template <typename E1, typename E2> +inline mat_mat_ele_times_expr<E1, E2> +ele_prod(const mat_expr<E1>& e1, const mat_expr<E2>& e2) +{ + // do not multiply matrices element-wise with inconsistent value types + MTL_STATIC_ASSERT((boost::is_same<typename ashape::ashape<E1>::type, + typename ashape::ashape<E2>::type>::value), "Matrices do not have consistent algebraic shape (i.e. nested types)."); + return mat_mat_ele_times_expr<E1, E2>(static_cast<const E1&>(e1), static_cast<const E2&>(e2)); +} + + + +}} // namespace mtl::matrix + +#endif // MTL_MATRIX_OPERATORS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/parameter.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/parameter.hpp new file mode 100644 index 0000000000000000000000000000000000000000..552eaf54c9d7424af36613b2324023ae476f341f --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/parameter.hpp @@ -0,0 +1,51 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_PARAMETERS_INCLUDE +#define MTL_MATRIX_PARAMETERS_INCLUDE + +#include <boost/numeric/mtl/utility/static_assert.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/detail/index.hpp> +#include <boost/numeric/mtl/matrix/dimension.hpp> +#include <boost/numeric/mtl/utility/is_static.hpp> + +namespace mtl { namespace matrix { + +/// Type for bundling template parameters of common matrix types +/** OnStack = true can only be used with fixed::dimensions. + \sa \ref matrix_parameters + \sa \ref tuning_fsize + \sa \ref tuning_sizetype **/ +template <typename Orientation= row_major, + typename Index= index::c_index, + typename Dimensions= mtl::non_fixed::dimensions, + bool OnStack= mtl::traits::is_static<Dimensions>::value, + typename SizeType= std::size_t> +struct parameters +{ + typedef Orientation orientation; + typedef Index index; + typedef Dimensions dimensions; + static bool const on_stack= OnStack; + typedef SizeType size_type; + + // Matrix dimensions must be known at compile time to be on the stack + MTL_STATIC_ASSERT(( !on_stack || dimensions::is_static ), "Types to be stored on stack must provide static size."); +}; + +/// Short-cut to define parameters with unsigned and defaults otherwise +typedef parameters<row_major, index::c_index, mtl::non_fixed::dimensions, false, unsigned> unsigned_parameters; + +}} // namespace mtl::matrix + +#endif // MTL_MATRIX_PARAMETERS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/permutation.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/permutation.hpp new file mode 100644 index 0000000000000000000000000000000000000000..77f7ad1b888f80ac1784bdf349c1c804d5347b7c --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/permutation.hpp @@ -0,0 +1,59 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_PERMUTATION_INCLUDE +#define MTL_MATRIX_PERMUTATION_INCLUDE + +#include <boost/numeric/mtl/operation/size.hpp> +#include <boost/numeric/mtl/matrix/reorder.hpp> + +namespace mtl { namespace matrix { + + +namespace traits { + + //\ Return type of mtl::matrix::permutation + // Only for completeness + template <typename Value= short> + struct permutation + { + typedef typename reorder<Value>::type type; + }; +} + +template <typename Value, typename PermutationVector> +typename traits::permutation<Value>::type +inline permutation(const PermutationVector& v) +{ + using mtl::size; + return reorder(v, size(v)); +} + +/// Computes permutation matrix from corresponding vector +template <typename PermutationVector> +typename traits::permutation<>::type +inline permutation(const PermutationVector& v) +{ + return permutation<short>(v); +} + + +}} // namespace mtl::matrix + +namespace mtl { namespace vector { + + /// Import into vector namespace; see \ref mtl::matrix::permutation + using mtl::matrix::permutation; + +}} // namespace mtl::vector + +#endif // MTL_MATRIX_PERMUTATION_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/poisson2D_dirichlet.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/poisson2D_dirichlet.hpp new file mode 100644 index 0000000000000000000000000000000000000000..4698b0eafb181104e1a18a4eded6f7eb11feb1a5 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/poisson2D_dirichlet.hpp @@ -0,0 +1,104 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_POISSON2D_DIRICHLET_INCLUDE +#define MTL_MATRIX_POISSON2D_DIRICHLET_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/ashape.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/vector/mat_cvec_multiplier.hpp> + +namespace mtl { namespace matrix { + +/// Matrix-free linear operator for a Poisson equation on a rectangular domain of \p m by \p n with Dirichlet boundary conditions +struct poisson2D_dirichlet +{ + /// Constructor + poisson2D_dirichlet(int m, int n) : m(m), n(n), s(m * n) {} + + /// Member function that realizes the multiplication + template <typename VectorIn, typename VectorOut, typename Assign> + void mult(const VectorIn& v, VectorOut& w, Assign) const + { + MTL_DEBUG_THROW_IF(int(size(v)) != s, incompatible_size()); + MTL_DEBUG_THROW_IF(size(v) != size(w), incompatible_size()); + + const int nb = n < 3 ? 1 : (n - 2) / 4 * 4 + 1; + + // Inner domain + for (int i= 1; i < m-1; i++) { + int kmax= i * n + nb; + for (int k= i * n + 1; k < kmax; k+= 4) { + typename Collection<VectorIn>::value_type const v0= v[k], v1= v[k+1], v2= v[k+2], v3= v[k+3]; + Assign::apply(w[k], 4 * v0 - v[k-n] - v[k+n] - v[k-1] - v1); + Assign::apply(w[k+1], 4 * v1 - v[k-n+1] - v[k+n+1] - v0 - v2); + Assign::apply(w[k+2], 4 * v2 - v[k-n+2] - v[k+n+2] - v1 - v3); + Assign::apply(w[k+3], 4 * v3 - v[k-n+3] - v[k+n+3] - v2 - v[k+4]); + } + for (int j= nb, k= i * n + j; j < n-1; j++, k++) + Assign::apply(w[k], 4 * v[k] - v[k-n] - v[k+n] - v[k-1] - v[k+1]); + } + + // Upper border + for (int j= 1; j < n-1; j++) + Assign::apply(w[j], 4 * v[j] - v[j+n] - v[j-1] - v[j+1]); + + // Lower border + for (int j= 1, k= (m-1) * n + j; j < n-1; j++, k++) + Assign::apply(w[k], 4 * v[k] - v[k-n] - v[k-1] - v[k+1]); + + // Left border + for (int i= 1, k= n; i < m-1; i++, k+= n) + Assign::apply(w[k], 4 * v[k] - v[k-n] - v[k+n] - v[k+1]); + + // Right border + for (int i= 1, k= n+n-1; i < m-1; i++, k+= n) + Assign::apply(w[k], 4 * v[k] - v[k-n] - v[k+n] - v[k-1]); + + // Corners + Assign::apply(w[0], 4 * v[0] - v[1] - v[n]); + Assign::apply(w[n-1], 4 * v[n-1] - v[n-2] - v[2*n - 1]); + Assign::apply(w[(m-1)*n], 4 * v[(m-1)*n] - v[(m-2)*n] - v[(m-1)*n+1]); + Assign::apply(w[m*n-1], 4 * v[m*n-1] - v[m*n-2] - v[m*n-n-1]); + } + + /// Multiplication is procastinated until we know where the product goes + template <typename VectorIn> + vector::mat_cvec_multiplier<poisson2D_dirichlet, VectorIn> operator*(const VectorIn& v) const + { return vector::mat_cvec_multiplier<poisson2D_dirichlet, VectorIn>(*this, v); } + + int m, n, s; +}; + +inline std::size_t size(const poisson2D_dirichlet& A) { return A.s * A.s; } ///< Matrix size +inline std::size_t num_rows(const poisson2D_dirichlet& A) { return A.s; } ///< Number of rows +inline std::size_t num_cols(const poisson2D_dirichlet& A) { return A.s; } ///< Number of columns + +}} // namespace mtl::matrix + +namespace mtl { + + template <> + struct Collection<matrix::poisson2D_dirichlet> + { + typedef double value_type; + typedef int size_type; + }; + + namespace ashape { + template <> struct ashape_aux<matrix::poisson2D_dirichlet> + { typedef nonscal type; }; + } +} + +#endif // MTL_MATRIX_POISSON2D_DIRICHLET_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/reorder.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/reorder.hpp new file mode 100644 index 0000000000000000000000000000000000000000..2a659848bffb3a9d657b837afb0dbd62d6f05cff --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/reorder.hpp @@ -0,0 +1,65 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_REORDER_INCLUDE +#define MTL_MATRIX_REORDER_INCLUDE + +#include <algorithm> + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/matrix/parameter.hpp> +#include <boost/numeric/mtl/matrix/compressed2D.hpp> +#include <boost/numeric/mtl/matrix/reorder_ref.hpp> + +namespace mtl { namespace matrix { + + +namespace traits { + + /// Return type of mtl::matrix::reorder + template <typename Value= short> + struct reorder + { + typedef mtl::matrix::compressed2D<Value, parameters<> > type; + }; +} + + +template <typename Value, typename ReorderVector> +typename traits::reorder<Value>::type +reorder(const ReorderVector& v, std::size_t cols= 0) +{ + typename traits::reorder<Value>::type A; + reorder_ref(v, A, cols); + return A; +} + + +/// Computes reordering matrix from corresponding vector +template <typename ReorderVector> +typename traits::reorder<>::type +inline reorder(const ReorderVector& v, std::size_t cols= 0) +{ + return reorder<short>(v, cols); +} + + +}} // namespace mtl::matrix + +namespace mtl { namespace vector { + + /// Import into vector namespace; see \ref mtl::matrix::reorder + using mtl::matrix::reorder; + +}} // namespace mtl::vector + +#endif // MTL_MATRIX_REORDER_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/reorder_matrix_rows.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/reorder_matrix_rows.hpp new file mode 100644 index 0000000000000000000000000000000000000000..bbc6f87bbf7dbc2ccf467e7d0b4102c332c00659 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/reorder_matrix_rows.hpp @@ -0,0 +1,51 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_REORDER_MATRIX_ROWS_INCLUDE +#define MTL_MATRIX_REORDER_MATRIX_ROWS_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/utility/property_map.hpp> +#include <boost/numeric/mtl/matrix/inserter.hpp> +#include <boost/numeric/mtl/operation/size.hpp> + +namespace mtl { namespace matrix { + +/// Reorder the rows of a matrix without creating a reorder matrix +/** This is less elegant but avoids cyclic dependencies. Does not work with CCS matrices. **/ +template <typename ReorderVector, typename Matrix> +Matrix reorder_matrix_rows(const ReorderVector& v, const Matrix& A) +{ + using mtl::size; + + typename mtl::traits::col<Matrix>::type col(A); + typename mtl::traits::const_value<Matrix>::type value(A); + typedef typename mtl::traits::range_generator<tag::row, Matrix>::type cursor_type; + typedef typename mtl::traits::range_generator<tag::nz, cursor_type>::type icursor_type; + typedef typename mtl::Collection<Matrix>::size_type size_type; + + Matrix B(size(v), num_cols(A)); + + inserter<Matrix> ins(B, size_type(B.nnz() / num_cols(B) * 1.2)); + + for (std::size_t i= 0; i < size(v); i++) { + cursor_type cursor(v[i], A); // go to row given by reorder + for (icursor_type icursor = begin<tag::nz>(cursor), icend = end<tag::nz>(cursor); icursor != icend; ++icursor) + ins[i][col(*icursor)] << value(*icursor); + } + return B; +} + +}} // namespace mtl::matrix + +#endif // MTL_MATRIX_REORDER_MATRIX_ROWS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/reorder_ref.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/reorder_ref.hpp new file mode 100644 index 0000000000000000000000000000000000000000..94aa8e5fca7d045693ec1d4c051d4d0845d0ded9 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/reorder_ref.hpp @@ -0,0 +1,53 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_REORDER_REF_INCLUDE +#define MTL_MATRIX_REORDER_REF_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/operation/size.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/matrix/inserter.hpp> +#include <boost/numeric/linear_algebra/identity.hpp> + +namespace mtl { namespace matrix { + + +template <typename ReorderVector, typename Matrix> +void reorder_ref(const ReorderVector& v, Matrix& A, std::size_t cols= 0) +{ + using math::one; using mtl::size; + typedef typename Collection<Matrix>::value_type value_type; + + if (mtl::size(v) == 0) { + A.change_dim(0, cols); return; } + + // Find maximal entry (don't use mtl::max to allow for arrays and others) + std::size_t s= mtl::size(v), + my_max= std::size_t(*std::max_element(&v[0], &v[0] + s)) + 1; + + if (cols == 0) + cols= my_max; + else + MTL_THROW_IF(my_max > cols, range_error("Too large value in reorder vector")); + + A.change_dim(s, cols); + inserter<Matrix> ins(A, 1); + for (std::size_t i= 0; i < s; i++) + ins[i][v[i]] << one(value_type()); +} + + +}} // namespace mtl::matrix + +#endif // MTL_MATRIX_REORDER_REF_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/shifted_inserter.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/shifted_inserter.hpp new file mode 100644 index 0000000000000000000000000000000000000000..4878a602689b314e6582ae9747320b55bd6b585d --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/shifted_inserter.hpp @@ -0,0 +1,74 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_SHIFTED_INSERTER_INCLUDE +#define MTL_MATRIX_SHIFTED_INSERTER_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/operation/update.hpp> + +namespace mtl { namespace matrix { + +/// Inserter with shifted row and column indices +/** The main work is performed by the underlying base inserter whose type is given as template + argument. **/ +template <typename BaseInserter> +class shifted_inserter +{ + public: + typedef shifted_inserter self; + typedef typename BaseInserter::matrix_type matrix_type; + typedef typename Collection<matrix_type>::size_type size_type; + typedef operations::update_proxy<BaseInserter, size_type> proxy_type; + + /// Constructor with matrix \p A, the slot size and the offsets + shifted_inserter(matrix_type& A, size_type slot_size= 0, + size_type row_offset= 0, size_type col_offset= 0) + : ins(A, slot_size), row_offset(row_offset), col_offset(col_offset) {} + + void set_row_offset(size_type ro) { row_offset= ro; } ///< Change row offset + void set_col_offset(size_type co) { col_offset= co; } ///< Change column offset + + size_type get_row_offset() const { return row_offset; } ///< Get row offset + size_type get_col_offset() const { return col_offset; } ///< Get column offset + + private: + struct bracket_proxy + { + bracket_proxy(BaseInserter& ref, size_type row, size_type col_offset) : ref(ref), row(row), col_offset(col_offset) {} + + proxy_type operator[](size_type col) + { return proxy_type(ref, row, col+col_offset); } + + BaseInserter& ref; + size_type row, col_offset; + }; + + public: + /// To be used in ins[r][c] << value; + bracket_proxy operator[] (size_type row) + { return bracket_proxy(ins, row+row_offset, col_offset); } + + /// To be used in ins(r, c) << value; + proxy_type operator() (size_type row, size_type col) + { return proxy_type(ins, row+row_offset, col+col_offset); } + + // update, modify and operator<< are used from BaseInserter + + private: + BaseInserter ins; + size_type row_offset, col_offset; +}; + +}} // namespace mtl::matrix + +#endif // MTL_MATRIX_SHIFTED_INSERTER_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/sparse_banded.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/sparse_banded.hpp new file mode 100644 index 0000000000000000000000000000000000000000..07d7184be3de0b781bf1cc74039d15423c4a5402 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/sparse_banded.hpp @@ -0,0 +1,360 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_SPARSE_BANDED_INCLUDE +#define MTL_MATRIX_SPARSE_BANDED_INCLUDE + +#include <algorithm> +#include <cassert> +#include <ostream> +#include <vector> +#include <boost/type_traits/make_signed.hpp> + +#include <boost/numeric/mtl/matrix/dimension.hpp> +#include <boost/numeric/mtl/matrix/parameter.hpp> +#include <boost/numeric/mtl/matrix/base_matrix.hpp> +#include <boost/numeric/mtl/matrix/crtp_base_matrix.hpp> +#include <boost/numeric/mtl/matrix/mat_expr.hpp> +#include <boost/numeric/mtl/operation/is_negative.hpp> +#include <boost/numeric/mtl/operation/update.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/is_row_major.hpp> +#include <boost/numeric/mtl/utility/maybe.hpp> +#include <boost/numeric/mtl/utility/static_assert.hpp> + +namespace mtl { namespace matrix { + +/// Sparse banded matrix class +template <typename Value, typename Parameters = matrix::parameters<> > +class sparse_banded + : public base_matrix<Value, Parameters>, + public const_crtp_base_matrix< sparse_banded<Value, Parameters>, Value, typename Parameters::size_type >, + public crtp_matrix_assign< sparse_banded<Value, Parameters>, Value, typename Parameters::size_type >, + public mat_expr< sparse_banded<Value, Parameters> > +{ + MTL_STATIC_ASSERT((mtl::traits::is_row_major<Parameters>::value), "Only row-major sparse banded matrices supported so far."); + + typedef std::size_t size_t; + typedef base_matrix<Value, Parameters> super; + typedef sparse_banded<Value, Parameters> self; + + public: + typedef Value value_type; + typedef typename Parameters::size_type size_type; + typedef typename boost::make_signed<size_type>::type band_size_type; + typedef crtp_matrix_assign<self, Value, size_type> assign_base; + + /// Construct matrix of dimension \p nr by \p nc + explicit sparse_banded(size_type nr= 0, size_type nc= 0) + : super(non_fixed::dimensions(nr, nc)), data(0), inserting(false) + {} + + /// Copy from other types + template <typename MatrixSrc> + explicit sparse_banded(const MatrixSrc& src) : data(0), inserting(false) + { *this= src; } + + + ~sparse_banded() { delete[] data; } + void check() const { MTL_DEBUG_THROW_IF(inserting, access_during_insertion()); } + void check(size_type MTL_DEBUG_ARG(r), size_type MTL_DEBUG_ARG(c)) const + { + check(); + MTL_DEBUG_THROW_IF(is_negative(r) || r >= this->num_rows() + || is_negative(c) || c >= this->num_cols(), index_out_of_range()); + } + + using assign_base::operator=; + + void make_empty() ///< Delete all entries + { + delete[] data; data= 0; + bands.resize(0); + } + + /// Change dimension to \p r by \p c; deletes all entries + void change_dim(size_type r, size_type c) + { + make_empty(); + super::change_dim(r, c); + } + + /// Offset of entry r,c if in matrix (otherwise offset of next entry) + utilities::maybe<size_type> offset(size_type r, size_type c) const + { + check(r, c); + band_size_type dia= band_size_type(c) - band_size_type(r); + size_type b= find_dia(dia); + return utilities::maybe<size_type>(r * bands.size() + b, size_t(b) < bands.size() && bands[b] == dia); + } + + /// Value of matrix entry + value_type operator()(size_type r, size_type c) const + { + using math::zero; + utilities::maybe<size_type> o= offset(r, c); + return o ? data[o.value()] : zero(value_type()); + } + + /// L-value reference of stored matrix entry + /** To be used with care; in debug mode, exception is thrown if entry is not found **/ + value_type& lvalue(size_type r, size_type c) + { + utilities::maybe<size_type> o= offset(r, c); + MTL_DEBUG_THROW_IF(!o, runtime_error("Entry doesn't exist.")); + return data[o.value()]; + } + + /// Print matrix on \p os + friend std::ostream& operator<<(std::ostream& os, const self& A) + { + const size_type bs= A.bands.size(), nc= num_cols(A), s= bs * num_rows(A); + print_size_max p; + for (size_type i= 0; i < s; i++) + p(A.data[i]); + + for (size_type r= 0; r < num_rows(A); r++) { + os << '['; + size_type b= 0; + while (b < bs && -A.bands[b] > long(r)) b++; + for (size_type c= 0; c < nc; c++) { + os.width(p.max); + if (b == bs || long(c) - long(r) < A.bands[b]) + os << Value(0); + else + os << A.data[r * bs + b++]; + os << (c + 1 == nc ? "]\n" : " "); + } + } + return os; + } + + /// Number of structural non-zeros (i.e. stored entries) which is the the number of bands times rows + size_type nnz() const { return bands.size() * this->num_rows(); } + size_type find_major(size_type offset) const { return offset % bands.size(); } + + friend size_t num_rows(const self& A) { return A.num_rows(); } + friend size_t num_cols(const self& A) { return A.num_cols(); } + + std::vector<band_size_type> const& ref_bands() const { return bands; } ///< Refer bands vector [advanced] + const value_type* ref_data() const { return data; } ///< Refer data pointer [advanced] + + private: + size_type find_dia(band_size_type dia) const + { + size_type i= 0; + while (i < size_type(bands.size()) && dia > bands[i]) i++; + return i; + } + + template <typename, typename, typename> friend struct sparse_banded_inserter; + + std::vector<band_size_type> bands; + value_type* data; + bool inserting; +}; + +/// Inserter for sparse banded matrix +template <typename Value, typename Parameters, typename Updater = mtl::operations::update_store<Value> > +struct sparse_banded_inserter +{ + typedef Value value_type; + typedef typename Parameters::size_type size_type; + typedef sparse_banded<Value, Parameters> matrix_type; + typedef sparse_banded_inserter self; + typedef typename matrix_type::band_size_type band_size_type; + typedef operations::update_proxy<self, size_type> proxy_type; + + private: + struct bracket_proxy + { + bracket_proxy(self& ref, size_type row) : ref(ref), row(row) {} + + proxy_type operator[](size_type col) { return proxy_type(ref, row, col); } + + self& ref; + size_type row; + }; + + void insert_dia(size_type dia_band, band_size_type dia) + { + using std::swap; + // empty vector and entry at the end + diagonals.push_back(std::vector<Value>(num_rows(A), Value(0))); + A.bands.push_back(dia); + + for (size_type i= diagonals.size() - 1; i > dia_band; i--) { + swap(diagonals[i-1], diagonals[i]); + swap(A.bands[i-1], A.bands[i]); + } + } + + public: + /// Construct inserter for matrix \p A; second argument for slot_size ignored + sparse_banded_inserter(matrix_type& A, size_type) : A(A) + { + MTL_THROW_IF(A.inserting, runtime_error("Two inserters on same matrix")); + MTL_THROW_IF(A.data, runtime_error("Inserter does not support modifications yet.")); + A.inserting= true; + } + + ~sparse_banded_inserter() + { + const size_type bs= A.bands.size(); + Value* p= A.data= new Value[A.bands.size() * num_rows(A)]; + for (size_type r= 0; r < num_rows(A); r++) + for (size_type b= 0; b < bs; b++) + *p++= diagonals[b][r]; + assert(p - A.data == long(A.bands.size() * num_rows(A))); + A.inserting= false; + } + + /// Proxy to insert into A[row][col] + bracket_proxy operator[] (size_type row) + { + return bracket_proxy(*this, row); + } + + /// Proxy to insert into A[row][col] + proxy_type operator() (size_type row, size_type col) + { + return proxy_type(*this, row, col); + } + + /// Modify A[row][col] with \p val using \p Modifier + template <typename Modifier> + void modify(size_type row, size_type col, Value val) + { + MTL_DEBUG_THROW_IF(is_negative(row) || row >= num_rows(A) || is_negative(col) || col >= num_cols(A), + index_out_of_range()); + const band_size_type dia= col - row; + const size_type dia_band= A.find_dia(dia); + + if (dia_band == size_type(A.bands.size()) || dia != A.bands[dia_band]) + insert_dia(dia_band, dia); + + Modifier()(diagonals[dia_band][row], val); + } + + /// Modify A[row][col] with \p val using the class' updater + void update(size_type row, size_type col, Value val) + { + using math::zero; + modify<Updater>(row, col, val); + } + + private: + matrix_type& A; + std::vector<std::vector<Value> > diagonals; +}; + + +template <typename Value, typename Parameters> +struct sparse_banded_key +{ + typedef std::size_t size_t; + typedef sparse_banded_key self; + typedef mtl::matrix::sparse_banded<Value, Parameters> matrix_type; + + explicit sparse_banded_key(const matrix_type& A, size_t offset) + : A(A), offset(offset) {} + + bool operator== (sparse_banded_key const& other) const { return offset == other.offset; } + bool operator!= (sparse_banded_key const& other) const { return !(*this == other); } + + const matrix_type& A; + size_t offset; +}; + +// Cursor over every element +template <typename Value, typename Parameters> +struct sparse_banded_cursor + : public sparse_banded_key<Value, Parameters> +{ + typedef sparse_banded_key<Value, Parameters> base; + typedef mtl::matrix::sparse_banded<Value, Parameters> matrix_type; + typedef sparse_banded_cursor self; + + explicit sparse_banded_cursor(const matrix_type& A, size_t offset) + : base(A, offset) {} + + self& operator++() { ++this->offset; return *this; } + const base& operator* () const { return *this; } +}; + +// ================ +// Free functions +// ================ + +template <typename Value, typename Parameters> +inline std::size_t size(const sparse_banded<Value, Parameters>& matrix) +{ + return std::size_t(matrix.num_cols()) * std::size_t(matrix.num_rows()); +} + +}} // namespace mtl::matrix + +namespace mtl { + using matrix::sparse_banded; +} + + +// ================ +// Range generators +// ================ + +namespace mtl { namespace traits { + + // Cursor over all rows + // Supported if row major matrix + template <typename Value, typename Parameters> + struct range_generator<glas::tag::row, sparse_banded<Value, Parameters> > + : detail::all_rows_range_generator<sparse_banded<Value, Parameters>, complexity_classes::linear_cached> + {}; + + template <class Value, class Parameters> + struct range_generator<glas::tag::nz, + detail::sub_matrix_cursor<sparse_banded<Value, Parameters>, glas::tag::row, 2> > + { + typedef typename Parameters::size_type size_type; + typedef detail::sub_matrix_cursor<sparse_banded<Value, Parameters>, glas::tag::row, 2> cursor_type; + typedef complexity_classes::linear_cached complexity; + typedef mtl::matrix::sparse_banded_cursor<Value, Parameters> type; + static int const level = 1; + MTL_STATIC_ASSERT((is_row_major<Parameters>::value), "Only row-major sparse banded matrices supported so far."); + + type begin(cursor_type const& cursor) const + { + size_type r= cursor.key, b= 0, bs= cursor.ref.ref_bands().size(); + while (b < bs && -cursor.ref.ref_bands()[b] > long(r)) b++; + return type(cursor.ref, r * bs + b); + } + type end(cursor_type const& cursor) const + { + size_type r= cursor.key, bs= cursor.ref.ref_bands().size(), b= bs, nc= cursor.ref.num_cols(); + while (b > 0 && cursor.ref.ref_bands()[b-1] + long(r) >= long(nc)) b--; + return type(cursor.ref, r * bs + b); + } + + // type lower_bound(cursor_type const& cursor, size_type position) const {} + }; + + + // Cursor over all rows or columns, depending which one is major + template <typename Value, typename Parameters> + struct range_generator<glas::tag::major, sparse_banded<Value, Parameters> > + : range_generator<glas::tag::row, sparse_banded<Value, Parameters> > + {}; + +}} // namespace mtl::traits + +#endif // MTL_MATRIX_SPARSE_BANDED_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/strict_lower.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/strict_lower.hpp new file mode 100644 index 0000000000000000000000000000000000000000..18e2ef93bd65628ad447de70b11f65f92377428a --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/strict_lower.hpp @@ -0,0 +1,46 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_STRICT_LOWER_INCLUDE +#define MTL_MATRIX_STRICT_LOWER_INCLUDE + +namespace mtl { namespace matrix { + +namespace traits { + + template <typename Matrix> + struct strict_lower + { + typedef typename traits::bands<Matrix>::type type; + }; +} + +/// Strict lower triangular matrix +template <typename Matrix> +typename traits::strict_lower<Matrix>::type +inline strict_lower(const Matrix& A) +{ + return bands(A, std::numeric_limits<long>::min(), 0); +} + +/// Triangle-lower starting at off-diagonoal \p d (for compatibility with matlib) +template <typename Matrix> +typename traits::strict_lower<Matrix>::type +inline tril(const Matrix& A, long d= 0) +{ + return bands(A, std::numeric_limits<long>::min(), d+1); +} + + +}} // namespace mtl::matrix + +#endif // MTL_MATRIX_STRICT_LOWER_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/strict_upper.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/strict_upper.hpp new file mode 100644 index 0000000000000000000000000000000000000000..096115eb1629aee52a3ea47399cfd2c6d56ee0c7 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/strict_upper.hpp @@ -0,0 +1,48 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_STRICT_UPPER_INCLUDE +#define MTL_MATRIX_STRICT_UPPER_INCLUDE + +#include <boost/numeric/mtl/matrix/bands.hpp> + +namespace mtl { namespace matrix { + +namespace traits { + + template <typename Matrix> + struct strict_upper + { + typedef typename bands<Matrix>::type type; + }; +} + +/// Strict upper triangle matrix +template <typename Matrix> +typename traits::strict_upper<Matrix>::type +inline strict_upper(const Matrix& A) +{ + return bands(A, 1, std::numeric_limits<long>::max()); +} + +/// Triangle-upper starting at off-diagonoal \p d (for compatibility with matlib) +template <typename Matrix> +typename traits::strict_upper<Matrix>::type +inline triu(const Matrix& A, long d= 0) +{ + return bands(A, d, std::numeric_limits<long>::max()); +} + + +}} // namespace mtl::matrix + +#endif // MTL_MATRIX_STRICT_UPPER_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/transposed_view.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/transposed_view.hpp new file mode 100644 index 0000000000000000000000000000000000000000..348b8e0679624fc9f3f0a0c545d22d9b6294505a --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/transposed_view.hpp @@ -0,0 +1,298 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_TRANSPOSED_VIEW_INCLUDE +#define MTL_TRANSPOSED_VIEW_INCLUDE + +#include <utility> +#include <boost/shared_ptr.hpp> +#include <boost/mpl/if.hpp> +#include <boost/type_traits/is_const.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/type_traits/remove_const.hpp> + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/utility/transposed_orientation.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/utility/property_map_impl.hpp> +#include <boost/numeric/mtl/matrix/crtp_base_matrix.hpp> +#include <boost/numeric/mtl/operation/sub_matrix.hpp> +#include <boost/numeric/mtl/matrix/mat_expr.hpp> + +namespace mtl { namespace matrix { + + +template <class Matrix> +struct transposed_view + : public boost::mpl::if_< + boost::is_const<Matrix> + , const_crtp_base_matrix< const transposed_view<const Matrix>, + typename Matrix::value_type, typename Matrix::size_type > + , crtp_base_matrix< transposed_view<Matrix>, + typename Matrix::value_type, typename Matrix::size_type > + >::type, + public matrix::mat_expr< transposed_view<Matrix> > +{ + typedef transposed_view self; + typedef mat_expr< self > expr_base; + typedef Matrix other; + + typedef typename mtl::traits::transposed_orientation<typename Matrix::orientation>::type orientation; + typedef typename Matrix::index_type index_type; + typedef typename Matrix::value_type value_type; + typedef typename Matrix::const_reference const_reference; + typedef typename Matrix::key_type key_type; + typedef typename Matrix::size_type size_type; + typedef typename Matrix::dim_type::transposed_type dim_type; + typedef matrix::parameters<orientation, index_type, dim_type> parameters; + + typedef typename boost::mpl::if_<boost::is_const<Matrix>, + const_reference, + value_type& + >::type access_type; + + typedef typename boost::mpl::if_<boost::is_const<Matrix>, + const Matrix&, + Matrix& + >::type ref_type; + typedef const Matrix& const_ref_type; + + + transposed_view (ref_type ref) : ref(ref) {} + + transposed_view (const boost::shared_ptr<Matrix>& p) : my_copy(p), ref(*p) {} + +#ifdef MTL_WITH_CPP11_MOVE + transposed_view (self&& that) : my_copy(std::move(that.my_copy)), ref(that.ref) {} + transposed_view (const self& that) : ref(that.ref) { assert(that.my_copy.use_count() == 0); } +#endif + + const_reference operator() (size_type r, size_type c) const + { return ref(c, r); } + + access_type operator() (size_type r, size_type c) + { return ref(c, r); } + + size_type dim1() const { return ref.dim2(); } + size_type dim2() const { return ref.dim1(); } + + dim_type dimensions() const + { return ref.dimensions().transpose(); } + + size_type begin_row() const { return ref.begin_col(); } + size_type end_row() const { return ref.end_col(); } + size_type begin_col() const { return ref.begin_row(); } + size_type end_col() const { return ref.end_row(); } + size_type nnz() const { return ref.nnz(); } + + friend size_type inline num_rows(const self& A) + { using mtl::matrix::num_cols; return num_cols(A.ref); } + friend size_type inline num_cols(const self& A) + { using mtl::matrix::num_rows; return num_rows(A.ref); } + protected: + boost::shared_ptr<Matrix> my_copy; + public: + ref_type ref; +}; + +template <class Matrix> +inline std::size_t size(const transposed_view<Matrix>& A) +{ + return num_rows(A.ref) * num_rows(A.ref); +} + +// ========== +// Sub matrix +// ========== + +template <typename Matrix> +struct sub_matrix_t< transposed_view<Matrix> > +{ + typedef transposed_view<Matrix> matrix_type; + typedef typename boost::remove_const<Matrix>::type tmp_type; + + // Transposed of submatrix type + typedef transposed_view<typename sub_matrix_t<tmp_type>::sub_matrix_type> sub_matrix_type; + typedef transposed_view<typename sub_matrix_t<tmp_type>::const_sub_matrix_type> const_sub_matrix_type; + typedef typename matrix_type::size_type size_type; + + sub_matrix_type operator()(matrix_type& A, size_type begin_r, size_type end_r, size_type begin_c, size_type end_c) + { + typedef typename sub_matrix_t<Matrix>::sub_matrix_type ref_sub_type; + typedef boost::shared_ptr<ref_sub_type> pointer_type; + + // Submatrix of referred matrix, colums and rows interchanged + // Create a submatrix, whos address will be kept by transposed_view + pointer_type p(new ref_sub_type(sub_matrix(A.ref, begin_c, end_c, begin_r, end_r))); + return sub_matrix_type(p); + } + + const_sub_matrix_type operator()(matrix_type const& A, size_type begin_r, size_type end_r, + size_type begin_c, size_type end_c) + { + typedef typename sub_matrix_t<Matrix>::const_sub_matrix_type ref_sub_type; + typedef boost::shared_ptr<ref_sub_type> pointer_type; + + // Submatrix of referred matrix, colums and rows interchanged + // Create a submatrix, whos address will be kept by transposed_view + pointer_type p(new ref_sub_type(sub_matrix(A.ref, begin_c, end_c, begin_r, end_r))); + return const_sub_matrix_type(p); + } + +}; + +}} // mtl::matrix + +namespace mtl { namespace traits { + + + namespace detail { + + template <class Matrix, class Ref> + struct transposed_row + { + typedef typename Matrix::key_type key_type; + typedef typename Matrix::size_type size_type; + + transposed_row(mtl::matrix::transposed_view<Ref> const& transposed_matrix) + : its_col(transposed_matrix.ref) {} + + size_type operator() (key_type const& key) const + { + return its_col(key); + } + + protected: + typename col<typename boost::remove_const<Matrix>::type>::type its_col; + }; + + + template <class Matrix, class Ref> + struct transposed_col + { + typedef typename Matrix::key_type key_type; + typedef typename Matrix::size_type size_type; + + transposed_col(mtl::matrix::transposed_view<Ref> const& transposed_matrix) + : its_row(transposed_matrix.ref) {} + + size_type operator() (key_type const& key) const + { + return its_row(key); + } + + protected: + typename row<typename boost::remove_const<Matrix>::type>::type its_row; + }; + + } // namespace detail + + template <class Matrix> + struct row<matrix::transposed_view<Matrix> > + { + typedef detail::transposed_row<Matrix, Matrix> type; + }; + + template <class Matrix> + struct col<matrix::transposed_view<Matrix> > + { + typedef detail::transposed_col<Matrix, Matrix> type; + }; + + template <class Matrix> + struct const_value<mtl::matrix::transposed_view<Matrix> > + { + typedef mtl::detail::const_value_from_other<mtl::matrix::transposed_view<Matrix> > type; + }; + + + template <class Matrix> + struct value<mtl::matrix::transposed_view<Matrix> > + { + typedef mtl::detail::value_from_other<mtl::matrix::transposed_view<Matrix> > type; + }; + + +// ================ +// Range generators +// ================ + + namespace detail + { + template <class UseTag, class Matrix> + struct range_transposer_impl + { + typedef range_generator<UseTag, typename boost::remove_const<Matrix>::type> generator; + // typedef range_generator<UseTag, Matrix> generator; + typedef typename generator::complexity complexity; + typedef typename generator::type type; + static int const level = generator::level; + type begin(mtl::matrix::transposed_view<Matrix> const& m) + { + return generator().begin(m.ref); + } + type end(mtl::matrix::transposed_view<Matrix> const& m) + { + return generator().end(m.ref); + } + }; + + // If considered range_generator for Matrix isn't supported, i.e. has infinite complexity + // then define as unsupported for transposed view + // (range_transposer_impl wouldn't compile in this case) + template <class UseTag, class Matrix> + struct range_transposer + : boost::mpl::if_< + boost::is_same<typename range_generator<UseTag, typename boost::remove_const<Matrix>::type>::complexity, + complexity_classes::infinite> + , range_generator<tag::unsupported, Matrix> + , range_transposer_impl<UseTag, Matrix> + >::type {}; + } + + // Row and column cursors are interchanged + template <class Matrix> + struct range_generator<glas::tag::col, matrix::transposed_view<Matrix> > + : detail::range_transposer<glas::tag::row, Matrix> + {}; + + template <class Matrix> + struct range_generator<glas::tag::row, matrix::transposed_view<Matrix> > + : detail::range_transposer<glas::tag::col, Matrix> + {}; + + + // To traverse the major dimension refer to the Matrix + template <class Matrix> + struct range_generator<tag::major, matrix::transposed_view<Matrix> > + : detail::range_transposer<tag::major, Matrix> + {}; + + + // Other cursors still use the same tag, e.g. elements + template <class Tag, class Matrix> + struct range_generator<Tag, matrix::transposed_view<Matrix> > + : detail::range_transposer<Tag, Matrix> + {}; + + + +}} // namespace mtl::traits + +namespace mtl { + using matrix::transposed_view; +} + +#endif // MTL_TRANSPOSED_VIEW_INCLUDE + + + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/upper.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/upper.hpp new file mode 100644 index 0000000000000000000000000000000000000000..8b7dafc500217d94768c2c407852bce024900db2 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/upper.hpp @@ -0,0 +1,41 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_UPPER_INCLUDE +#define MTL_MATRIX_UPPER_INCLUDE + +#include <boost/numeric/mtl/matrix/bands.hpp> +#include <limits> + +namespace mtl { namespace matrix { + +namespace traits { + + template <typename Matrix> + struct upper + { + typedef typename traits::bands<Matrix>::type type; + }; +} + +/// Upper triangular matrix +template <typename Matrix> +typename traits::upper<Matrix>::type +inline upper(const Matrix& A) +{ + return bands(A, 0, std::numeric_limits<long>::max()); +} + + +}} // namespace mtl::matrix + +#endif // MTL_MATRIX_UPPER_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/view_ref.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/view_ref.hpp new file mode 100644 index 0000000000000000000000000000000000000000..ec5e26235e053d45cf403a54ef5977f7684d3aff --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/matrix/view_ref.hpp @@ -0,0 +1,55 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_VIEW_REF_INCLUDE +#define MTL_MATRIX_VIEW_REF_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/matrix/map_view.hpp> +#include <boost/numeric/mtl/matrix/transposed_view.hpp> +#include <boost/numeric/mtl/matrix/hermitian_view.hpp> + + +namespace mtl { namespace matrix { + +template <typename Matrix> +inline Matrix& view_ref(Matrix& A) +{ return A; } + +template <typename Matrix> +inline const Matrix& view_ref(const Matrix& A) +{ return A; } + +template <typename Matrix> +inline Matrix& view_ref(transposed_view<Matrix>& A) +{ return A.ref; } + +template <typename Matrix> +inline const Matrix& view_ref(transposed_view<const Matrix>& A) +{ return A.ref; } + +template <typename Matrix> +inline const Matrix& view_ref(const transposed_view<Matrix>& A) +{ return A.ref; } + +template <typename Matrix> +inline const Matrix& view_ref(const conj_view<Matrix>& A) +{ return A.ref; } + +template <typename Matrix> +inline const Matrix& view_ref(const hermitian_view<Matrix>& A) +{ return A.const_ref(); } + + +}} // namespace mtl::matrix + +#endif // MTL_MATRIX_VIEW_REF_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/mtl.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/mtl.hpp new file mode 100644 index 0000000000000000000000000000000000000000..3527167835a7d4e1f5d0324259e0cbc66049269d --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/mtl.hpp @@ -0,0 +1,20 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MTL_INCLUDE +#define MTL_MTL_INCLUDE + +#include <boost/numeric/mtl/types.hpp> +#include <boost/numeric/mtl/operations.hpp> +#include <boost/numeric/mtl/interfaces.hpp> + +#endif // MTL_MTL_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/mtl_fwd.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/mtl_fwd.hpp new file mode 100644 index 0000000000000000000000000000000000000000..f47d4b677c6a7ca8905312b16b34d0e494cc39f1 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/mtl_fwd.hpp @@ -0,0 +1,449 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MTL_FWD_INCLUDE +#define MTL_MTL_FWD_INCLUDE + +/// Main name space for %Matrix Template Library +namespace mtl { + + template <typename T, typename U, typename Assign> struct lazy_assign; + template <typename VectorOut, typename Matrix, typename VectorIn, typename Assign> struct row_mat_cvec_index_evaluator; + + /// Namespace for tags used for concept-free dispatching + namespace tag { + struct row_major; + struct col_major; + + struct scalar; + struct vector; + struct matrix; + + /// Namespace for constant iterator tags + namespace const_iter {} + + /// Namespace for iterator tags + namespace iter {} + } + using tag::row_major; + using tag::col_major; + + namespace index { + struct c_index; + struct f_index; + } + + /// Namespace for compile-time parameters, e.g. %matrix dimensions + namespace fixed { + template <std::size_t Rows, std::size_t Cols> struct dimensions; + } + + /// Namespace for run-time parameters, e.g. %matrix dimensions + namespace non_fixed { + struct dimensions; + } + + /// Namespace for matrices and views and operations exclusively on matrices + namespace matrix { + + template <typename Orientation, typename Index, typename Dimensions, bool OnStack, typename SizeType> struct parameters; + + template <typename Value, typename Parameters> class dense2D; + + template <typename Value, typename Parameters> + typename dense2D<Value, Parameters>::size_type num_cols(const dense2D<Value, Parameters>& matrix); + template <typename Value, typename Parameters> + typename dense2D<Value, Parameters>::size_type num_rows(const dense2D<Value, Parameters>& matrix); + template <typename Value, typename Parameters> + typename dense2D<Value, Parameters>::size_type size(const dense2D<Value, Parameters>& matrix); + + template <typename Value, std::size_t Mask, typename Parameters> class morton_dense; + +#if !defined(_MSC_VER) || _MSC_VER != 1400 // Trouble in MSVC 2005 + template <typename Value, std::size_t Mask, typename Parameters> + typename morton_dense<Value, Mask, Parameters>::size_type num_cols(const morton_dense<Value, Mask, Parameters>& matrix); + template <typename Value, std::size_t Mask, typename Parameters> + typename morton_dense<Value, Mask, Parameters>::size_type num_rows(const morton_dense<Value, Mask, Parameters>& matrix); + template <typename Value, std::size_t Mask, typename Parameters> + typename morton_dense<Value, Mask, Parameters>::size_type size(const morton_dense<Value, Mask, Parameters>& matrix); +#endif + + template <typename Value, typename Parameters> class compressed2D; + + template <typename Value, typename Parameters> + typename compressed2D<Value, Parameters>::size_type num_cols(const compressed2D<Value, Parameters>& matrix); + template <typename Value, typename Parameters> + typename compressed2D<Value, Parameters>::size_type num_rows(const compressed2D<Value, Parameters>& matrix); + template <typename Value, typename Parameters> + // typename compressed2D<Value, Parameters>::size_type + std::size_t + size(const compressed2D<Value, Parameters>& matrix); + + template <typename Value, typename Parameters, typename Updater> struct compressed2D_inserter; + + template <typename T, typename Parameters> class coordinate2D; + template <typename Matrix, typename Updater> struct coordinate2D_inserter; + + template <typename T, typename Parameters> class sparse_banded; + template <typename T, typename Parameters, typename Updater> struct sparse_banded_inserter; + + template <typename Value, typename Parameters> class ell_matrix; + template <typename Value, typename Parameters, typename Updater> struct ell_matrix_inserter; + + template <typename Matrix, typename Updater> struct inserter; + template <typename BaseInserter> class shifted_inserter; + + template <typename Vector> class multi_vector; + template <typename Vector> class multi_vector_range; + template <typename Value> class element; + template <typename Value> class element_structure; + template <typename Functor> class implicit_dense; + template <typename Value> class ones_functor; + template <typename Value> class ones_matrix; + template <typename Value> class hilbert_functor; + template <typename Value> class hilbert_matrix; + template <typename Vector1, typename Vector2> class outer_product_functor; + template <typename Vector1, typename Vector2> class outer_product_matrix; + + template <typename Matrix> struct transposed_view; + + template <typename Matrix> struct mat_expr; + template <typename Matrix> struct dmat_expr; + template <typename Matrix> struct smat_expr; + template <typename M1, typename M2, typename SFunctor> struct mat_mat_op_expr; + template <typename M1, typename M2> struct mat_mat_plus_expr; + template <typename M1, typename M2> struct mv_mv_plus_expr; + template <typename M1, typename M2> struct mat_mat_minus_expr; + template <typename M1, typename M2> struct mv_mv_minus_expr; + template <typename M1, typename M2> struct mat_mat_ele_times_expr; + template <typename M1, typename M2> struct mat_mat_times_expr; + template <typename M1, typename M2> struct mat_mat_asgn_expr; + + template <typename Matrix> struct mat_expr; + template <typename Functor, typename Matrix> struct map_view; + template <typename Scaling, typename Matrix> struct scaled_view; + template <typename Matrix, typename RScaling> struct rscaled_view; // added by Hui Li + template <typename Matrix, typename Divisor> struct divide_by_view; // added by Hui Li + template <typename Matrix> struct conj_view; + template <typename Matrix> struct negate_view; + template <typename Matrix> struct imag_view; + template <typename Matrix> struct real_view; + template <typename Matrix> struct hermitian_view; + template <typename Matrix> struct banded_view; + template <typename Matrix> struct indirect; + + template <typename Matrix> class lu_solver; + + template <typename Matrix> std::size_t size(const banded_view<Matrix>&); + template <class Matrix> std::size_t size(const transposed_view<Matrix>&); + template <typename Functor, typename Matrix> std::size_t size(const map_view<Functor, Matrix>&); + template <class Matrix> std::size_t size(const hermitian_view<Matrix>& ); + } + + //using matrix::dense2D; + //using matrix::morton_dense; + //using matrix::compressed2D; + //using matrix::coordinate2D; + //using matrix::multi_vector; + //using matrix::transposed_view; + + template <typename E1, typename E2> struct mat_cvec_times_expr; + + /// Namespace for vectors and views and %operations exclusively on vectors + namespace vector { + template <typename Vector> struct vec_expr; + template <typename Value, typename Parameters> class dense_vector; + template <typename Value, typename Parameters> class strided_vector_ref; + template <typename Value, typename Parameters> class sparse_vector; + template <typename Functor, typename Vector> struct map_view; + template <typename Vector> struct conj_view; + template <typename Vector> struct real_view; + template <typename Vector> struct imag_view; + template <typename Vector> struct negate_view; + template <typename Scaling, typename Vector> struct scaled_view; + template <typename Vector, typename RScaling> struct rscaled_view; // added by Hui Li + template <typename Vector, typename Divisor> struct divide_by_view; // added by Hui Li + template <class E1, class E2, typename SFunctor> struct vec_vec_op_expr; + template <class E1, class E2, typename SFunctor> struct vec_vec_pmop_expr; + template <class E1, class E2, typename SFunctor> struct vec_vec_aop_expr; + template <class E1, class E2, typename SFunctor> struct vec_vec_ele_prod_expr; + template <class E1, class E2, typename SFunctor> struct vec_scal_aop_expr; + template <class E1, class E2> struct vec_vec_asgn_expr; + template <class E1, class E2> struct vec_vec_plus_asgn_expr; + template <class E1, class E2> struct vec_vec_minus_asgn_expr; + template <class E1, class E2> struct vec_vec_times_asgn_expr; // is this really used??? +// template <class E1, class E2> struct vec_vec_div_asgn_expr; // is this really used??? + template <class E1, class E2> struct vec_scal_times_asgn_expr; + template <class E1, class E2> struct vec_scal_div_asgn_expr; // added by Hui Li + template <class E1, class E2> struct vec_scal_asgn_expr; + template <typename E1, typename E2> struct rvec_mat_times_expr; + + template <typename Vector> struct vec_const_ref_expr; + template <unsigned BSize, typename Vector> class unrolled1; + + template <typename Scalar, typename Vector, typename Functor, typename Assign> struct reduction_index_evaluator; + template <typename Scalar, typename Vector1, typename Vector2, typename ConjOpt, typename Assign> struct dot_index_evaluator; + + template <typename Vector, typename Functor> struct lazy_reduction; + + template <typename Matrix, typename VectorIn> struct mat_cvec_multiplier; + + template <typename Value, typename Parameters, typename Value2> + inline void fill(dense_vector<Value, Parameters>& vector, const Value2& value); + + template <typename Value, typename Parameters> + typename dense_vector<Value, Parameters>::size_type + inline size(const dense_vector<Value, Parameters>& vector); + + template <typename Value, typename Parameters> + typename dense_vector<Value, Parameters>::size_type + inline num_rows(const dense_vector<Value, Parameters>& vector); + + template <typename Value, typename Parameters> + typename dense_vector<Value, Parameters>::size_type + inline num_cols(const dense_vector<Value, Parameters>& vector); + + template <typename Value, typename Parameters> + std::size_t size(const strided_vector_ref<Value, Parameters>& v); + + template <typename Functor, typename Vector> + std::size_t size(const map_view<Functor, Vector>& v); + + template <typename E1, typename E2, typename SFunctor> + std::size_t size(const vec_vec_op_expr<E1, E2, SFunctor>& v); + + template <typename E1, typename E2, typename SFunctor> + std::size_t size(const vec_vec_aop_expr<E1, E2, SFunctor>& v); + + template <typename E1, typename E2, typename SFunctor> + std::size_t size(const vec_vec_pmop_expr<E1, E2, SFunctor>& v); + + template <typename E1, typename E2, typename SFunctor> + inline std::size_t size(const vec_scal_aop_expr<E1, E2, SFunctor>& v); + + template <unsigned BSize, typename Vector> + inline std::size_t size(const unrolled1<BSize, Vector>& v); + + template <typename E1, typename E2> + std::size_t inline size(const rvec_mat_times_expr<E1, E2>& x); + + template <typename E1, typename E2> + std::size_t inline size(const mat_cvec_times_expr<E1, E2>& x); + + template <typename Matrix, typename VectorIn> + std::size_t size(const mat_cvec_multiplier<Matrix, VectorIn>& m); + + /// Namespace for fixed vector dimension types + namespace fixed { + template <std::size_t Size> struct dimension; + } + /// Namespace for non-fixed vector dimension types, i.e. size dynamically determined at run-time + namespace non_fixed { + struct dimension; + } + + } + + //using vector::dense_vector; + + // Export free vector functions into mtl namespace + // It is also needed to handle STL vectors in MTL + using vector::fill; + using vector::size; + using vector::num_rows; + using vector::num_cols; + + /// Namespace for %operations (if not defined in mtl) + namespace operations { + template <typename T> struct update_store; + } + + + namespace vector { + + template <typename Vector, typename Updater = mtl::operations::update_store<typename Vector::value_type> > struct inserter; + template <typename Vector, typename Size> struct update_proxy; + } + + + + + + /// Namespace for type %traits + namespace traits { + template <typename Value> struct category; + template <typename Value> struct algebraic_category; + + template <typename Collection> struct value; + template <typename Collection> struct const_value; + template <typename Collection> struct row; + template <typename Collection> struct col; + template <class Matrix> struct offset; + + template <class Vector> struct index; + template <typename Tag, typename Collection> struct range_generator; + + template <typename T> struct eval_dense; + + template <typename Matrix> struct transposed_orientation; + + template <typename Collection> struct root; + + // for internal implementations + namespace detail { + // needed collection.hpp (at least) + template <typename Collection, typename Cursor, typename Complexity> struct dense_element_range_generator; + template <typename Matrix, typename Cursor, typename Complexity> struct all_offsets_range_generator; + template <typename Matrix, typename Tag, int Level = 2> struct sub_matrix_cursor; + template <typename Matrix> struct matrix_element_key; + template <typename Matrix, int pos> struct matrix_element_cursor; + template <typename Matrix, typename Complexity, int Level = 2> struct all_rows_range_generator; + template <typename Cursor> struct all_cols_in_row_range_generator; + template <typename Matrix, typename Complexity, int Level = 2> struct all_cols_range_generator; + template <typename Cursor> struct all_rows_in_col_range_generator; + template <typename Collection, typename RangeGenerator> struct referred_range_generator; + } + } + + template <typename Matrix> struct ColumnInMatrix; + template <typename Matrix> struct RowInMatrix; + + template <class Tag, class Collection> typename traits::range_generator<Tag, Collection>::type + begin(Collection const& c); + + template <class Tag, class Collection> typename traits::range_generator<Tag, Collection>::type + end(Collection const& c); + + + /// Namespace for functors with application operator and fully typed parameters + namespace tfunctor { + /// Functor for scaling matrices, vectors and ordinary scalars + template <typename V1, typename V2, typename AlgebraicCategory = tag::scalar> struct scale; + + /// Functor for scaling matrices, vectors and ordinary scalars + template <typename V1, typename V2, typename AlgebraicCategory = tag::scalar> struct rscale; + + /// Functor for scaling matrices, vectors and ordinary scalars + template <typename V1, typename V2, typename AlgebraicCategory = tag::scalar> struct divide_by; + } + + /// Namespace for functors with static function apply and fully typed parameters + namespace sfunctor { + template <typename Value, typename AlgebraicCategory = tag::scalar> struct conj_aux; + template <typename Value> struct conj; + template <typename Value> struct imag; + template <typename Value> struct real; + template <typename Value> struct negate; + template <typename Value1, typename Value2> struct plus; + template <typename Value1, typename Value2> struct minus; + template <typename Value1, typename Value2> struct times; + template <typename Value1, typename Value2> struct divide; + template <typename Value1, typename Value2> struct assign; + template <typename Value1, typename Value2> struct plus_assign; + template <typename Value1, typename Value2> struct minus_assign; + template <typename Value1, typename Value2> struct times_assign; + template <typename Value1, typename Value2> struct divide_assign; + template <typename Value> struct identity; + template <typename Value> struct abs; + template <typename Value> struct sqrt; + template <typename Value> struct square; + template <typename F, typename G> struct compose; + template <typename F, typename G> struct compose_first; + template <typename F, typename G> struct compose_second; + template <typename F, typename G, typename H> struct compose_both; + template <typename F, typename G> struct compose_binary; + } + + // Namespace documentations + + /// Namespace for static assignment functors + namespace assign {} + + /// Namespace for complexity classes + namespace complexity_classes {} + + /// Namespace for %operations (if not defined in mtl) + namespace operations {} + + /// Namespace for recursive operations and types with recursive memory layout + namespace recursion {} + + /// Namespace for %utilities + namespace utility {} + + /// Namespace for implementations using recursators + namespace wrec {} + + namespace matrix { + template <typename Matrix, typename ValueType, typename SizeType> struct crtp_matrix_assign; + template <typename Matrix, typename ValueType, typename SizeType> struct const_crtp_matrix_bracket; + template <typename Matrix, typename ValueType, typename SizeType> struct crtp_matrix_bracket; + template <typename Matrix, typename ValueType, typename SizeType> struct const_crtp_base_matrix; + template <typename Matrix, typename ValueType, typename SizeType> struct crtp_base_matrix; + template <typename Matrix> struct const_crtp_matrix_range_bracket; + } + + namespace detail { + template <typename Value, bool OnStack, unsigned Size= 0> struct contiguous_memory_block; + template <typename Matrix, typename Updater> struct trivial_inserter; + template <typename Collection> struct with_format_t; + } + + /// Free function defined for all matrix and vector types + template <typename Collection> void swap(Collection& c1, Collection& c2); + + /// User registration that class has a clone constructor, otherwise use regular copy constructor. + template<typename T> struct is_clonable; + + /// Helper type to define constructors that always copy + struct clone_ctor {}; + + /// Helper type to define constructors that refer to another object instead of copying it (e.g. transposed vectors) + struct refer_ctor {}; + + class irange; + class iset; + class srange; + + template <typename T, typename U> struct fused_expr; + namespace vector { + template <typename T, typename U> struct fused_index_evaluator; + // template <typename T, typename U> size_t size(const fused_index_evaluator<T, U>&); // not needed currently + } + + /// Namespace for I/O operations + namespace io { + class matrix_market_istream; + class matrix_market_ostream; + + template <typename MatrixIStream, typename MatrixOStream> class matrix_file; + typedef matrix_file<matrix_market_istream, matrix_market_ostream> matrix_market; + } + + // Multiplication functors + template <typename Assign, typename Backup> struct gen_cursor_dmat_dmat_mult_t; + template <typename Assign, typename Backup> struct gen_dmat_dmat_mult_t; + template <unsigned long Tiling1, unsigned long Tiling2, typename Assign, typename Backup> struct gen_tiling_dmat_dmat_mult_t; + template <typename Assign, typename Backup> struct gen_tiling_44_dmat_dmat_mult_t; + template <typename Assign, typename Backup> struct gen_tiling_22_dmat_dmat_mult_t; + template <typename BaseMult, typename BaseTest, typename Assign, typename Backup> struct gen_recursive_dmat_dmat_mult_t; + template <typename Assign, typename Backup> struct gen_platform_dmat_dmat_mult_t; + template <typename Assign, typename Backup> struct gen_blas_dmat_dmat_mult_t; + template <std::size_t SizeLimit, typename FunctorSmall, typename FunctorLarge> struct size_switch_dmat_dmat_mult_t; + template <bool IsStatic, typename FunctorStatic, typename FunctorDynamic> struct static_switch_dmat_dmat_mult_t; + template <typename Assign, typename Backup> struct fully_unroll_fixed_size_dmat_dmat_mult_t; + +} // namespace mtl + +#endif // MTL_MTL_FWD_INCLUDE + + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/adjoint.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/adjoint.hpp new file mode 100644 index 0000000000000000000000000000000000000000..6851abdb480e26300382a3960f17de2bc98f0cdc --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/adjoint.hpp @@ -0,0 +1,43 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_ADJOINT_INCLUDE +#define MTL_ADJOINT_INCLUDE + +#include <boost/numeric/mtl/operation/hermitian.hpp> + +namespace mtl { namespace matrix { + +namespace traits { + + template <typename LinOp> + struct adjoint + { + typedef typename mtl::matrix::detail::hermitian<LinOp>::result_type type; + type operator()(const LinOp& A) + { + return hermitian(A); + } + }; +} + +/// Adjoint linear operator, typically Hermitian transposed +template <typename LinOp> +typename traits::adjoint<LinOp>::type +inline adjoint(const LinOp& A) +{ + return traits::adjoint<LinOp>()(A); +} + +}} // namespace mtl::matrix + +#endif // MTL_ADJOINT_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/adjust_cursor.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/adjust_cursor.hpp new file mode 100644 index 0000000000000000000000000000000000000000..127f531bfbf5672a19873dba290a2aa6df181675 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/adjust_cursor.hpp @@ -0,0 +1,27 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_DETAIL_ADJUST_CURSOR_INCLUDE +#define MTL_DETAIL_ADJUST_CURSOR_INCLUDE + +namespace mtl { namespace detail { + + template <typename Size, typename Cursor> + void inline adjust_cursor(Size diff, Cursor& c, tag::dense) { c+= diff; } + + template <typename Size, typename Cursor> + void inline adjust_cursor(Size diff, Cursor& c, tag::sparse) {} + + +}} // namespace mtl::detail + +#endif // MTL_DETAIL_ADJUST_CURSOR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/assign_each_nonzero.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/assign_each_nonzero.hpp new file mode 100644 index 0000000000000000000000000000000000000000..a17d02f594cb37c34039f51a28c6ea404d3e4d6b --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/assign_each_nonzero.hpp @@ -0,0 +1,59 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_ASSIGN_EACH_NONZERO_INCLUDE +#define MTL_ASSIGN_EACH_NONZERO_INCLUDE + +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { + + namespace vector { + + /// Assign the result of \p f(i) to each non-zero i in non-constant vector \p v + template <typename Vector, typename Functor> + inline void assign_each_nonzero(Vector& v, const Functor& f) + { + vampir_trace<3008> tracer; + typedef typename traits::range_generator<tag::iter::nz, Vector>::type iterator; + for (iterator i= begin<tag::iter::nz>(v), iend= end<tag::iter::nz>(v); i != iend; ++i) + *i= f(*i); + } + + } // namespace vector + + namespace matrix { + + /// Assign the result of \p f(i) to each non-zero i in non-constant matrix \p A + template <typename Matrix, typename Functor> + inline void assign_each_nonzero(Matrix& m, const Functor& f) + { + vampir_trace<3008> tracer; + typename mtl::traits::value<Matrix>::type value(m); + + typedef typename mtl::traits::range_generator<tag::major, Matrix>::type cursor_type; + typedef typename mtl::traits::range_generator<tag::nz, cursor_type>::type icursor_type; + + for (cursor_type cursor = begin<tag::major>(m), cend = end<tag::major>(m); cursor != cend; ++cursor) + for (icursor_type icursor = begin<tag::nz>(cursor), icend = end<tag::nz>(cursor); + icursor != icend; ++icursor) + value(*icursor, f(value(*icursor))); + } + + } // namespace matrix + +} // namespace mtl + +#endif // MTL_ASSIGN_EACH_NONZERO_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/assign_mode.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/assign_mode.hpp new file mode 100644 index 0000000000000000000000000000000000000000..1887f4ef7c88d12189ec05a5d59e1bffa3e08b53 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/assign_mode.hpp @@ -0,0 +1,210 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_ASSIGN_MODE_INCLUDE +#define MTL_ASSIGN_MODE_INCLUDE + +#include <boost/numeric/linear_algebra/identity.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> + +namespace mtl { namespace assign { + +/// Functor for assigning the result of a calculation (e.g. a sum) to a typically scalar value +struct assign_sum +{ + static const bool init_to_zero= true; + + template <typename T> + static void init(T& v) + { + using math::zero; + v= zero(v); + } + + // Sets x with y when empty or not initialized + template <typename T, typename U> + static void set_empty(T& x, const U& y) + { + x= y; + } + + // The first update sets the value and avoids the zeroing + template <typename T, typename U> + static void first_update(T& x, const U& y) + { + x= y; + } + + template <typename T, typename U> + static void update(T& x, const U& y) + { + x+= y; + } + + // To be used like sfunctor + template <typename T, typename U> + static T& apply(T& x, const U& y) + { + return x= y; + } + +}; + +/// Functor for incrementing a typically scalar value with the result of a calculation (e.g. a sum) +struct plus_sum +{ + static const bool init_to_zero= false; + + template <typename T> + static void init(T&) {} + + // Sets x with y when empty or not initialized + template <typename T, typename U> + static void set_empty(T& x, const U& y) + { + x= y; + } + + template <typename T, typename U> + static void first_update(T& x, const U& y) + { + x+= y; + } + + template <typename T, typename U> + static void update(T& x, const U& y) + { + x+= y; + } + + // To be used like sfunctor + template <typename T, typename U> + static T& apply(T& x, const U& y) + { + return x+= y; + } +}; + + +/// Functor for incrementing a typically scalar value with the result of a calculation (e.g. a sum) +struct minus_sum +{ + static const bool init_to_zero= false; + + template <typename T> + static void init(T&) {} + + // Sets x with y when empty or not initialized + template <typename T, typename U> + static void set_empty(T& x, const U& y) + { + x= -y; + } + + template <typename T, typename U> + static void first_update(T& x, const U& y) + { + x-= y; + } + + template <typename T, typename U> + static void update(T& x, const U& y) + { + x-= y; + } + + // To be used like sfunctor + template <typename T, typename U> + static T& apply(T& x, const U& y) + { + return x-= y; + } +}; + + + +/// Functor for multiplying a typically scalar value with the result of a calculation (e.g. a sum) +struct times_sum +{ + static const bool init_to_zero= false; + + template <typename T> + static void init(T&) {} + + // Sets x with y when empty or not initialized + template <typename T, typename U> + static void set_empty(T& x, const U&) + { + x= T(0); + } + + template <typename T, typename U> + static void first_update(T& x, const U& y) + { + x*= y; + } + + template <typename T, typename U> + static void update(T& x, const U& y) + { + x*= y; + } + + // To be used like sfunctor + template <typename T, typename U> + static T& apply(T& x, const U& y) + { + return x*= y; + } +}; + +/// Functor for dividing a typically scalar value with the result of a calculation (e.g. a sum) +struct divide_sum +{ + static const bool init_to_zero= false; + + template <typename T> + static void init(T&) {} + + // Sets x with y when empty or not initialized + template <typename T, typename U> + static void set_empty(T& x, const U& y) + { + MTL_DEBUG_THROW_IF(y == U(0), division_by_zero()); + x= T(0); + } + + template <typename T, typename U> + static void first_update(T& x, const U& y) + { + MTL_DEBUG_THROW_IF(y == U(0), division_by_zero()); + x/= y; + } + + template <typename T, typename U> + static void update(T& x, const U& y) + { + MTL_DEBUG_THROW_IF(y == U(0), division_by_zero()); + x/= y; + } + + // To be used like sfunctor + template <typename T, typename U> + static T& apply(T& x, const U& y) + { + return x/= y; + } +}; + +}} // namespace mtl::assign + +#endif // MTL_ASSIGN_MODE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/bin_op_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/bin_op_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..2fac2b375fd3ac61ffea6c1e622da0d70d9454d6 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/bin_op_expr.hpp @@ -0,0 +1,37 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_BIN_OP_EXPR_INCLUDE +#define MTL_BIN_OP_EXPR_INCLUDE + +namespace mtl { + +/// Minimalistic expression template for binary operation: keeps only references. +template <typename E1, typename E2> +struct bin_op_expr +{ + typedef bin_op_expr self; + + typedef E1 first_argument_type ; + typedef E2 second_argument_type ; + + bin_op_expr( first_argument_type const& v1, second_argument_type const& v2 ) + : first( v1 ), second( v2 ) + {} + + first_argument_type const& first ; + second_argument_type const& second ; +}; + +} // namespace mtl + +#endif // MTL_BIN_OP_EXPR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/cholesky.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/cholesky.hpp new file mode 100644 index 0000000000000000000000000000000000000000..ce11965eaf7022afabe8074c1e1f81a684184ce6 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/cholesky.hpp @@ -0,0 +1,615 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_CHOLESKY_INCLUDE +#define MTL_CHOLESKY_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/recursion/matrix_recursator.hpp> +#include <boost/numeric/mtl/utility/glas_tag.hpp> +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/operation/dmat_dmat_mult.hpp> +#include <boost/numeric/mtl/operation/assign_mode.hpp> +#include <boost/numeric/mtl/matrix/transposed_view.hpp> +#include <boost/numeric/mtl/recursion/base_case_cast.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace mtl { namespace matrix { + +namespace with_bracket { + + // ============================================================================ + // Generic Cholesky factorization and operands for Cholesky on with submatrices + // ============================================================================ + + template < typename Matrix > + void cholesky_base (Matrix & matrix) + { + vampir_trace<5001> tracer; + typedef typename Collection<Matrix>::size_type size_type; + for (size_type k = 0; k < matrix.num_cols(); k++) { + matrix[k][k] = sqrt (matrix[k][k]); + + for (size_type i = k + 1; i < matrix.num_rows(); i++) { + matrix[i][k] /= matrix[k][k]; + typename Collection<Matrix>::value_type d = matrix[i][k]; + + for (size_type j = k + 1; j <= i; j++) + matrix[i][j] -= d * matrix[j][k]; + } + } + } + + + template < typename MatrixSW, typename MatrixNW > + void tri_solve_base(MatrixSW & SW, const MatrixNW & NW) + { + vampir_trace<5002> tracer; + typedef typename Collection<MatrixSW>::size_type size_type; + for (size_type k = 0; k < NW.num_rows (); k++) { + + for (size_type i = 0; i < SW.num_rows (); i++) { + SW[i][k] /= NW[k][k]; + typename MatrixSW::value_type d = SW[i][k]; + + for (size_type j = k + 1; j < SW.num_cols (); j++) + SW[i][j] -= d * NW[j][k]; + } + } + } + + + // Lower(SE) -= SW * SW^T + template < typename MatrixSE, typename MatrixSW > + void tri_schur_base(MatrixSE & SE, const MatrixSW & SW) + { + vampir_trace<5003> tracer; + typedef typename Collection<MatrixSE>::size_type size_type; + for (size_type k = 0; k < SW.num_cols (); k++) + + for (size_type i = 0; i < SE.num_rows (); i++) { + typename MatrixSW::value_type d = SW[i][k]; + for (size_type j = 0; j <= i; j++) + SE[i][j] -= d * SW[j][k]; + } + } + + + template < typename MatrixNE, typename MatrixNW, typename MatrixSW > + void schur_update_base(MatrixNE & NE, const MatrixNW & NW, const MatrixSW & SW) + { + vampir_trace<5004> tracer; + typedef typename Collection<MatrixNE>::size_type size_type; + for (size_type k = 0; k < NW.num_cols (); k++) + for (size_type i = 0; i < NE.num_rows (); i++) { + typename MatrixNW::value_type d = NW[i][k]; + for (size_type j = 0; j < NE.num_cols (); j++) + NE[i][j] -= d * SW[j][k]; + } + } + + + // ====================== + // Corresponding functors + // ====================== + + struct cholesky_base_t + { + template < typename Matrix > + void operator() (Matrix & matrix) + { + cholesky_base(matrix); + } + }; + + struct tri_solve_base_t + { + template < typename MatrixSW, typename MatrixNW > + void operator() (MatrixSW & SW, const MatrixNW & NW) + { + tri_solve_base(SW, NW); + } + }; + + struct tri_schur_base_t + { + template < typename MatrixSE, typename MatrixSW > + void operator() (MatrixSE & SE, const MatrixSW & SW) + { + tri_schur_base(SE, SW); + } + }; + + struct schur_update_base_t + { + template < typename MatrixNE, typename MatrixNW, typename MatrixSW > + void operator() (MatrixNE & NE, const MatrixNW & NW, const MatrixSW & SW) + { + schur_update_base(NE, NW, SW); + } + }; + +} // namespace with_bracket + +#if 0 +namespace with_iterator { + + // ============================================================================ + // Generic Cholesky factorization and operands for Cholesky on with submatrices + // ============================================================================ + // CURRENTLY NOT SUPPORTED -- CAUSES SEGFAULT, e.g. with icc 11.0 in r8536 !!!! + // ============================================================================ + + template < typename Matrix > + void cholesky_base (Matrix& matrix) + { + vampir_trace<5001> tracer; + typedef typename Collection<Matrix>::size_type size_type; + + using namespace glas::tag; using mtl::traits::range_generator; + typedef tag::iter::all all_it; + + typedef typename Collection<Matrix>::value_type value_type; + typedef typename range_generator<col, Matrix>::type cur_type; + typedef typename range_generator<all_it, cur_type>::type iter_type; + + typedef typename range_generator<row, Matrix>::type rcur_type; + typedef typename range_generator<all_it, rcur_type>::type riter_type; + + size_type k= 0; + for (cur_type kb= begin<col>(matrix), kend= end<col>(matrix); kb != kend; ++kb, ++k) { + + iter_type ib= begin<all_it>(kb), iend= end<all_it>(kb); + ib+= k; // points now to matrix[k][k] + + value_type root= sqrt (*ib); + *ib= root; + + ++ib; // points now to matrix[k+1][k] + rcur_type rb= begin<row>(matrix); rb+= k+1; // to row k+1 + for (size_type i= k + 1; ib != iend; ++ib, ++rb, ++i) { + *ib = *ib / root; + typename Collection<Matrix>::value_type d = *ib; + riter_type it1= begin<all_it>(rb); it1+= k+1; // matrix[i][k+1] + riter_type it1end= begin<all_it>(rb); it1end+= i+1; // matrix[i][i+1] + iter_type it2= begin<all_it>(kb); it2+= k+1; // matrix[k+1][k] + for (; it1 != it1end; ++it1, ++it2) + *it1 = *it1 - d * *it2; + } + } + } + + + template < typename MatrixSW, typename MatrixNW > + void tri_solve_base(MatrixSW & SW, const MatrixNW & NW) + { + vampir_trace<5002> tracer; + typedef typename Collection<MatrixSW>::size_type size_type; + + using namespace glas::tag; using mtl::traits::range_generator; + typedef tag::iter::all all_it; + typedef tag::const_iter::all all_cit; + + typedef typename range_generator<col, MatrixNW>::type ccur_type; + typedef typename range_generator<all_cit, ccur_type>::type citer_type; + + typedef typename range_generator<row, MatrixSW>::type rcur_type; + typedef typename range_generator<all_it, rcur_type>::type riter_type; + + for (size_type k = 0; k < NW.num_rows (); k++) + for (size_type i = 0; i < SW.num_rows (); i++) { + + typename MatrixSW::value_type d = SW[i][k] /= NW[k][k]; + + rcur_type sw_i= begin<row>(SW); sw_i+= i; // row i + riter_type it1= begin<all_it>(sw_i); it1+= k+1; // SW[i][k+1] + riter_type it1end= end<all_it>(sw_i); + + ccur_type nw_k= begin<col>(NW); nw_k+= k; // column k + citer_type it2= begin<all_cit>(nw_k); it2+= k+1; // NW[k+1][k] + + for(; it1 != it1end; ++it1, ++it2) + *it1 = *it1 - d * *it2; + } + } + + + // Lower(SE) -= SW * SW^T + template < typename MatrixSE, typename MatrixSW > + void tri_schur_base(MatrixSE & SE, const MatrixSW & SW) + { + vampir_trace<5003> tracer; + typedef typename Collection<MatrixSE>::size_type size_type; + + using namespace glas::tag; using mtl::traits::range_generator; + typedef tag::iter::all all_it; + typedef tag::const_iter::all all_cit; + + typedef typename range_generator<col, MatrixSW>::type ccur_type; + typedef typename range_generator<all_cit, ccur_type>::type citer_type; + + typedef typename range_generator<row, MatrixSE>::type rcur_type; + typedef typename range_generator<all_it, rcur_type>::type riter_type; + + for (size_type k = 0; k < SW.num_cols (); k++) + for (size_type i = 0; i < SE.num_rows (); i++) { + typename MatrixSW::value_type d = SW[i][k]; + + rcur_type se_i= begin<row>(SE); se_i+= i; // row i + riter_type it1= begin<all_it>(se_i); // SE[i][0] + riter_type it1end= begin<all_it>(se_i); it1end+= i+1; // SE[i][i+i] + + ccur_type sw_k= begin<col>(SW); sw_k+= k; // column k + citer_type it2= begin<all_cit>(sw_k); // SW[0][k] + + for(; it1 != it1end; ++it1, ++it2) + *it1 = *it1 - d * *it2; + } + } + + + template < typename MatrixNE, typename MatrixNW, typename MatrixSW > + void schur_update_base(MatrixNE & NE, const MatrixNW & NW, const MatrixSW & SW) + { + vampir_trace<5004> tracer; + typedef typename Collection<MatrixNE>::size_type size_type; + + using namespace glas::tag; using mtl::traits::range_generator; + typedef tag::iter::all all_it; + typedef tag::const_iter::all all_cit; + + typedef typename range_generator<col, MatrixSW>::type ccur_type; + typedef typename range_generator<all_cit, ccur_type>::type citer_type; + + typedef typename range_generator<row, MatrixNE>::type rcur_type; + typedef typename range_generator<all_it, rcur_type>::type riter_type; + + for (size_type k = 0; k < NW.num_cols (); k++) + for (size_type i = 0; i < NE.num_rows (); i++) { + typename MatrixNW::value_type d = NW[i][k]; +#if 0 + rcur_type ne_i= begin<row>(NE); ne_i+= i; // row i + riter_type it1= begin<all_it>(ne_i); // NE[i][0] + riter_type it1end= end<all_it>(ne_i); // NE[i][num_col] + + ccur_type sw_k= begin<col>(SW); sw_k+= k; // column k + citer_type it2= begin<all_cit>(sw_k); // SW[0][k] +#endif + for (size_type j = 0; j < NE.num_cols (); j++) + NE[i][j] -= d * SW[j][k]; + } + } + + + // ====================== + // Corresponding functors + // ====================== + + struct cholesky_base_t + { + template < typename Matrix > + void operator() (Matrix & matrix) + { + cholesky_base(matrix); + } + }; + + struct tri_solve_base_t + { + template < typename MatrixSW, typename MatrixNW > + void operator() (MatrixSW & SW, const MatrixNW & NW) + { + tri_solve_base(SW, NW); + } + }; + + struct tri_schur_base_t + { + template < typename MatrixSE, typename MatrixSW > + void operator() (MatrixSE & SE, const MatrixSW & SW) + { + tri_schur_base(SE, SW); + } + }; + + struct schur_update_base_t + { + template < typename MatrixNE, typename MatrixNW, typename MatrixSW > + void operator() (MatrixNE & NE, const MatrixNW & NW, const MatrixSW & SW) + { + schur_update_base(NE, NW, SW); + } + }; + +} // namespace with_iterator +#endif + + +// ================================== +// Functor types for Cholesky visitor +// ================================== + + +template <typename BaseTest, typename CholeskyBase, typename TriSolveBase, typename TriSchur, typename SchurUpdate> +struct recursive_cholesky_visitor_t +{ + typedef BaseTest base_test; + + template < typename Recursator > + bool is_base(const Recursator& recursator) const + { + return base_test()(recursator); + } + + template < typename Matrix > + void cholesky_base(Matrix & matrix) const + { + CholeskyBase()(matrix); + } + + template < typename MatrixSW, typename MatrixNW > + void tri_solve_base(MatrixSW & SW, const MatrixNW & NW) const + { + TriSolveBase()(SW, NW); + } + + template < typename MatrixSE, typename MatrixSW > + void tri_schur_base(MatrixSE & SE, const MatrixSW & SW) const + { + TriSchur()(SE, SW); + } + + template < typename MatrixNE, typename MatrixNW, typename MatrixSW > + void schur_update_base(MatrixNE & NE, const MatrixNW & NW, const MatrixSW & SW) const + { + SchurUpdate()(NE, NW, SW); + } +}; + + +namespace detail { + + // Compute schur update with external multiplication; must have Assign == minus_mult_assign_t !!! + template <typename MatrixMult> + struct mult_schur_update_t + { + template < typename MatrixNE, typename MatrixNW, typename MatrixSW > + void operator()(MatrixNE & NE, const MatrixNW & NW, const MatrixSW & SW) + { + transposed_view<MatrixSW> trans_sw(const_cast<MatrixSW&>(SW)); + MatrixMult()(NW, trans_sw, NE); + } + }; + +} // detail + + +namespace with_bracket { + typedef recursive_cholesky_visitor_t<recursion::bound_test_static<64>, cholesky_base_t, tri_solve_base_t, + tri_schur_base_t, schur_update_base_t > + recursive_cholesky_base_visitor_t; +} + +#if 0 +namespace with_iterator { + typedef recursive_cholesky_visitor_t<recursion::bound_test_static<64>, + cholesky_base_t, tri_solve_base_t, tri_schur_base_t, schur_update_base_t> + recursive_cholesky_base_visitor_t; +} +#endif + +typedef with_bracket::recursive_cholesky_base_visitor_t recursive_cholesky_default_visitor_t; + + + + + + +namespace with_recursator { + + template <typename Recursator, typename Visitor> + void schur_update(Recursator E, Recursator W, Recursator N, Visitor vis) + { + vampir_trace<5005> tracer; + using namespace recursion; + + if (E.is_empty() || W.is_empty() || N.is_empty()) + return; + + if (vis.is_base(E)) { + typedef typename Visitor::base_test base_test; + typedef typename base_case_matrix<typename Recursator::matrix_type, base_test>::type matrix_type; + + matrix_type base_E(base_case_cast<base_test>(E.get_value())), + base_W(base_case_cast<base_test>(W.get_value())), + base_N(base_case_cast<base_test>(N.get_value())); + vis.schur_update_base(base_E, base_W, base_N); + } else{ + schur_update( E.north_east(),W.north_west() ,N.south_west() , vis); + schur_update( E.north_east(), W.north_east(), N.south_east(), vis); + + schur_update(E.north_west() , W.north_east(), N.north_east(), vis); + schur_update(E.north_west() ,W.north_west() ,N.north_west() , vis); + + schur_update(E.south_west() ,W.south_west() ,N.north_west() , vis); + schur_update(E.south_west() , W.south_east(), N.north_east(), vis); + + schur_update( E.south_east(), W.south_east(), N.south_east(), vis); + schur_update( E.south_east(),W.south_west() ,N.south_west() , vis); + } + } + + + template <typename Recursator, typename Visitor> + void tri_solve(Recursator S, Recursator N, Visitor vis) + { + using namespace recursion; + vampir_trace<5006> tracer; + + if (S.is_empty()) + return; + + if (vis.is_base(S)) { + typedef typename Visitor::base_test base_test; + typedef typename base_case_matrix<typename Recursator::matrix_type, base_test>::type matrix_type; + + matrix_type base_S(base_case_cast<base_test>(S.get_value())), + base_N(base_case_cast<base_test>(N.get_value())); + + vis.tri_solve_base(base_S, base_N); + } else{ + + tri_solve(S.north_west() ,N.north_west(), vis); + schur_update( S.north_east(),S.north_west() ,N.south_west(), vis); + tri_solve( S.north_east(), N.south_east(), vis); + tri_solve(S.south_west() ,N.north_west() , vis); + schur_update( S.south_east(),S.south_west() ,N.south_west(), vis); + tri_solve( S.south_east(), N.south_east(), vis); + } + } + + + template <typename Recursator, typename Visitor> + void tri_schur(Recursator E, Recursator W, Visitor vis) + { + using namespace recursion; + vampir_trace<5007> tracer; + + if (E.is_empty() || W.is_empty()) + return; + + if (vis.is_base(W)) { + typedef typename Visitor::base_test base_test; + typedef typename base_case_matrix<typename Recursator::matrix_type, base_test>::type matrix_type; + + matrix_type base_E(base_case_cast<base_test>(E.get_value())), + base_W(base_case_cast<base_test>(W.get_value())); + vis.tri_schur_base(base_E, base_W); + } else{ + + schur_update(E.south_west(), W.south_west(), W.north_west(), vis); + schur_update(E.south_west(), W.south_east(), W.north_east(), vis); + tri_schur( E.south_east() , W.south_east(), vis); + tri_schur( E.south_east() ,W.south_west() , vis); + tri_schur( E.north_west(), W.north_east(), vis); + tri_schur( E.north_west(),W.north_west() , vis); + } + } + + + template <typename Recursator, typename Visitor> + void cholesky(Recursator recursator, Visitor vis) + { + using namespace recursion; + vampir_trace<5008> tracer; + + if (recursator.is_empty()) + return; + + if (vis.is_base (recursator)){ + typedef typename Visitor::base_test base_test; + typedef typename base_case_matrix<typename Recursator::matrix_type, base_test>::type matrix_type; + + matrix_type base_matrix(base_case_cast<base_test>(recursator.get_value())); + vis.cholesky_base (base_matrix); + } else { + cholesky(recursator.north_west(), vis); + tri_solve( recursator.south_west(), recursator.north_west(), vis); + tri_schur( recursator.south_east(), recursator.south_west(), vis); + cholesky( recursator.south_east(), vis); + } + } + +} // namespace with_recursator + + + +template <typename Backup= with_bracket::cholesky_base_t> +struct recursive_cholesky_t +{ + template <typename Matrix> + void operator()(Matrix& matrix) + { + (*this)(matrix, recursive_cholesky_default_visitor_t()); + } + + template <typename Matrix, typename Visitor> + void operator()(Matrix& matrix, Visitor vis) + { + apply(matrix, vis, typename mtl::traits::category<Matrix>::type()); + } + +private: + // If the matrix is not sub-divisible then take backup function + template <typename Matrix, typename Visitor> + void apply(Matrix& matrix, Visitor, tag::universe) + { + Backup()(matrix); + } + + // Only if matrix is sub-divisible, otherwise backup + template <typename Matrix, typename Visitor> + void apply(Matrix& matrix, Visitor vis, tag::qsub_divisible) + { + matrix::recursator<Matrix> recursator(matrix); + with_recursator::cholesky(recursator, vis); + } +}; + + +template <typename Matrix, typename Visitor> +inline void recursive_cholesky(Matrix& matrix, Visitor vis) +{ + recursive_cholesky_t<>()(matrix, vis); +} + +template <typename Matrix> +inline void recursive_cholesky(Matrix& matrix) +{ + recursive_cholesky(matrix, recursive_cholesky_default_visitor_t()); +} + + + + + +template <typename Matrix> +void fill_matrix_for_cholesky(Matrix& matrix) +{ + vampir_trace<5008> tracer; + typedef typename Collection<Matrix>::size_type size_type; + typedef typename Collection<Matrix>::value_type value_type; + + value_type x= 1.0; + for (size_type i= 0; i < num_rows(matrix); i++) + for (size_type j= 0; j <= i; j++) + if (i != j) { + matrix[i][j]= x; matrix[j][i]= x; + x+= 1.0; + } + + for (size_type i= 0; i < num_rows(matrix); i++) { + value_type rowsum= 0.0; + for (size_type j=0; j<matrix.num_cols(); j++) + if (i != j) + rowsum += matrix[i][j]; + matrix[i][i]= rowsum * 2; + } +} + + +}} // namespace mtl::matrix + + + + +#endif // MTL_CHOLESKY_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/clone.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/clone.hpp new file mode 100644 index 0000000000000000000000000000000000000000..aaa6a1addf7b6b6e58650eb33d847d149ef27eca --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/clone.hpp @@ -0,0 +1,68 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_CLONE_INCLUDE +#define MTL_CLONE_INCLUDE + +#include <boost/utility/enable_if.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace mtl { + +template<typename T> +struct is_clonable : boost::mpl::false_ +{ }; + +/// Move-semantics-related anti-dot: always copy in constructor. +/** Some collections have referring semantics in copy constructors, e.g. sub-matrices. + That means + \code + Matrix B= sub_matrix(A, ...); + \endcode + creates a sub-matrix of A in B. As a consequence, changes in B modify A and vice versa + (unless it's outside the sub-matrix). + In contrast, clone forces the copy semantics + \code + Matrix B= clone(sub_matrix(A, ...)); + \endcode + B now contains the values of A's sub-matrix but is an independent matrix. + Modifications to either A or B have no effect to each other. + Requires that type T is declared clonable in terms of + \code + is_clonable<T> : boost::mpl::true_ {}; + \endcode +**/ +template <typename T> +typename boost::enable_if<is_clonable<T>, T>::type +clone(const T& x) +{ + vampir_trace<3004> tracer; + // std::cout << "Cloning clone function.\n"; + return T(x, clone_ctor()); +} + + +template <typename T> +typename boost::disable_if<is_clonable<T>, T>::type +clone(const T& x) +{ + // std::cout << "Not cloning clone function.\n"; + return x; +} + + +} // namespace mtl + +#endif // MTL_CLONE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/column_in_matrix.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/column_in_matrix.hpp new file mode 100644 index 0000000000000000000000000000000000000000..c86dfc622620a981888ee2b0f9f0f24d1f3a8afd --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/column_in_matrix.hpp @@ -0,0 +1,97 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_COLUMN_IN_MATRIX_INCLUDE +#define MTL_COLUMN_IN_MATRIX_INCLUDE + +#include <boost/mpl/if.hpp> +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/vector/parameter.hpp> +#include <boost/numeric/mtl/utility/irange.hpp> + +namespace mtl { + + +/// Type of column in matrix as vector if accessible +template <typename Matrix> +struct ColumnInMatrix +{ + static const bool exists= false; +}; + +template <typename Value, typename Parameters> +struct ColumnInMatrix<mtl::matrix::dense2D<Value, Parameters> > +{ + typedef mtl::matrix::dense2D<Value, Parameters> ref_type; + typedef typename ref_type::size_type size_type; + typedef typename ref_type::value_type value_type; + + static const bool aligned= !boost::is_same<typename Parameters::orientation, row_major>::value; + static const bool exists= true; + + typedef typename boost::mpl::if_c< + aligned + , vector::dense_vector<Value, vector::parameters<> > + , vector::strided_vector_ref<Value, vector::parameters<> > + >::type type; + + static inline type apply(ref_type& A, const irange& row_range, size_type col) + { + return dispatch<type, ref_type>(A, row_range, col, boost::mpl::bool_<aligned>()); + } + + template <typename Ref> + static inline size_type vector_size(const Ref& A, const irange& row_range) + { + using std::min; + size_type finish= min(row_range.finish(), num_rows(A)); + return row_range.start() < finish ? finish - row_range.start() : 0; + } + + template <typename Return, typename Ref> + static inline Return dispatch(Ref& A, const irange& row_range, size_type col, boost::mpl::true_) + { + return Return(vector_size(A, row_range), const_cast<value_type*>(&A[row_range.start()][col])); // TODO make work without const cast + } + + template <typename Return, typename Ref> + static inline Return dispatch(Ref& A, const irange& row_range, size_type col, boost::mpl::false_) + { + return Return(vector_size(A, row_range), &A[row_range.start()][col], num_cols(A)); + } +}; + +template <typename Value, typename Parameters> +struct ColumnInMatrix<const mtl::matrix::dense2D<Value, Parameters> > +{ + typedef mtl::matrix::dense2D<Value, Parameters> const ref_type; + typedef mtl::matrix::dense2D<Value, Parameters> ref2_type; + typedef typename ref2_type::size_type size_type; + + static const bool aligned= !boost::is_same<typename Parameters::orientation, row_major>::value; + static const bool exists= true; + + typedef typename boost::mpl::if_c< + aligned + , vector::dense_vector<Value, vector::parameters<> > // TODO needs constification !!! + , vector::strided_vector_ref<const Value, vector::parameters<> > + >::type type; + + static inline type apply(ref_type& A, const irange& row_range, size_type col) + { + return ColumnInMatrix<ref2_type>::template dispatch<type, ref_type>(A, row_range, col, boost::mpl::bool_<aligned>()); + } +}; + +} // namespace mtl + +#endif // MTL_COLUMN_IN_MATRIX_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/compute_factors.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/compute_factors.hpp new file mode 100644 index 0000000000000000000000000000000000000000..ab3f944f3584837fda40f3d52c134f45b33247e6 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/compute_factors.hpp @@ -0,0 +1,92 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_COMPUTE_FACTORS_INCLUDE +#define MTL_COMPUTE_FACTORS_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> + +namespace mtl { namespace operation { + +// Default is to just refer to the expression +template <typename Result, typename Expr> +struct compute_one_factor +{ + typedef const Expr& type; + typedef const Expr& const_reference; + + compute_one_factor(type src) : value(src) {} + + type value; +}; + +template <typename Result, typename E1, typename E2> +struct compute_one_factor<Result, matrix::mat_mat_times_expr<E1, E2> > +{ + typedef Result type; + typedef const Result& const_reference; + + compute_one_factor(const matrix::mat_mat_times_expr<E1, E2>& src) + : value(src.first * src.second) {} + + type value; +}; + +template <typename Result, typename E1, typename E2> +struct compute_one_factor<Result, matrix::mat_mat_ele_times_expr<E1, E2> > +{ + typedef Result type; + typedef const Result& const_reference; + + compute_one_factor(const matrix::mat_mat_ele_times_expr<E1, E2>& src) + : value(ele_prod(src.first, src.second)) {} + + type value; +}; + + +// Only defined for matrix::mat_mat_times_expr and matrix::mat_mat_ele_times_expr +template <typename Result, typename Expr> +struct compute_factors {}; + +template <typename Result, typename E1, typename E2> +struct compute_factors<Result, matrix::mat_mat_times_expr<E1, E2> > +{ + compute_factors(const matrix::mat_mat_times_expr<E1, E2>& src) + : first_factor(src.first), second_factor(src.second), + first(first_factor.value), second(second_factor.value) + {} + + compute_one_factor<Result, E1> first_factor; + compute_one_factor<Result, E2> second_factor; + + typename compute_one_factor<Result, E1>::const_reference first; + typename compute_one_factor<Result, E2>::const_reference second; +}; + +// First factor is handled implicitly in the evaluation +template <typename Result, typename E1, typename E2> +struct compute_factors<Result, matrix::mat_mat_ele_times_expr<E1, E2> > +{ + compute_factors(const matrix::mat_mat_ele_times_expr<E1, E2>& src) + : first(src.first), second_factor(src.second), + second(second_factor.value) + {} + + const E1& first; + compute_one_factor<Result, E2> second_factor; + typename compute_one_factor<Result, E2>::const_reference second; +}; + +}} // namespace mtl::operation + +#endif // MTL_COMPUTE_FACTORS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/compute_summand.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/compute_summand.hpp new file mode 100644 index 0000000000000000000000000000000000000000..156a9bc6b7eb254ed7a3e67389b0e305a0ae783b --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/compute_summand.hpp @@ -0,0 +1,82 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL__OPERATION_COMPUTE_SUMMAND_INCLUDE +#define MTL__OPERATION_COMPUTE_SUMMAND_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/utility/copy_expression_const_ref_container.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace mtl { namespace operation { + +/// Compute a summand in an expression +/** For instance matrix vector products are transformed into mult function calls + when assigned to a column vector. Adding such a vector to other vector expressions + requires to compute (evaluate) the summand first and then add the resulting + vector. The current implementation assumes that the result of the operation + can be represented by the multiplied column vector. This is for instance wrong + when the matrix is complex and the vector real. To handle this is signifantly + more complicated and is planned for the future. +**/ +template <typename Expr> +struct compute_summand +{ + typedef Expr type; + compute_summand(const Expr& expr) : value(expr) {} + // value is a const& if Expr is a true vector and a copy if it is an expression + typename mtl::traits::copy_expression_const_ref_container<Expr>::type value; +}; + + +/// Specialization for matrix vector products +template <typename Matrix, typename CVector> +struct compute_summand< mat_cvec_times_expr<Matrix, CVector> > +{ + typedef CVector type; + + compute_summand(const mat_cvec_times_expr<Matrix, CVector>& expr) + : value(num_rows(expr.first)) +#ifndef NDEBUG // might be helpful, e.g. for generating AST + , first(expr.first), second(expr.second) +#endif + { + vampir_trace<3005> tracer; + value= expr.first * expr.second; + } + + CVector value; +#ifndef NDEBUG + const Matrix& first; + const CVector& second; +#endif +}; + +/// Specialization for matrix vector products +template <typename Matrix, typename CVector> +struct compute_summand< vector::mat_cvec_multiplier<Matrix, CVector> > +{ + typedef CVector type; + + compute_summand(const vector::mat_cvec_multiplier<Matrix, CVector>& expr) + : value(num_rows(expr.A)) + { + vampir_trace<3005> tracer; + expr.assign_to(value); + } + + CVector value; +}; + +}} // namespace mtl::operation + +#endif // MTL__OPERATION_COMPUTE_SUMMAND_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/conj.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/conj.hpp new file mode 100644 index 0000000000000000000000000000000000000000..4316da42ec174a47b73e3ba9fde87aea4170b8f4 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/conj.hpp @@ -0,0 +1,146 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_CONJ_INCLUDE +#define MTL_CONJ_INCLUDE + +#include <complex> + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/utility/enable_if.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/utility/algebraic_category.hpp> +#include <boost/numeric/mtl/utility/is_what.hpp> +#include <boost/numeric/mtl/utility/view_code.hpp> +#include <boost/numeric/mtl/utility/viewed_collection.hpp> +#include <boost/numeric/mtl/utility/compose_view.hpp> +#include <boost/numeric/linear_algebra/identity.hpp> +#include <boost/numeric/mtl/matrix/view_ref.hpp> + +namespace mtl { + +namespace sfunctor { + + template <typename Value, typename AlgebraicCategory> + struct conj_aux + { + typedef Value result_type; + + static inline result_type apply(const Value& v) + { + return v; + } + + result_type operator() (const Value& v) const + { + return v; + } + }; + + + template <typename Value, typename AlgebraicCategory> + struct conj_aux<std::complex<Value>, AlgebraicCategory> + { + typedef std::complex<Value> result_type; + + static inline result_type apply(const std::complex<Value>& v) + { + return std::conj(v); + } + + result_type operator() (const std::complex<Value>& v) const + { + return std::conj(v); + } + }; + + // Only declarations here, definitions in matrix::map_view (vector::map_view) + template <typename Matrix> + struct conj_aux<Matrix, tag::matrix>; + + template <typename Vector> + struct conj_aux<Vector, tag::vector>; + + // Short cut for result type + template <typename Value> + struct conj + : public conj_aux<Value, typename mtl::traits::algebraic_category<Value>::type> + {}; + +} // namespace sfunctor + + namespace vector { + + /// Conjugate of an vector + template <typename Vector> + typename mtl::traits::enable_if_vector<Vector, conj_view<Vector> >::type + inline conj(const Vector& v) + { + return conj_view<Vector>(v); + } + } + + namespace matrix { + + namespace detail { + + template <typename Matrix> + struct conj_trait + { + static const unsigned code= mtl::traits::view_toggle_conj<mtl::traits::view_code<Matrix> >::value; + typedef typename mtl::traits::compose_view<code, typename mtl::traits::viewed_collection<Matrix>::type>::type type; + + static inline type apply(const Matrix& A) + { + return type(view_ref(A)); + } + }; + + } + + /// Conjugate of a matrix + template <typename Matrix> + typename mtl::traits::lazy_enable_if_matrix<Matrix, detail::conj_trait<Matrix> >::type + inline conj(const Matrix& A) + { + return detail::conj_trait<Matrix>::apply(A); + } + } + + namespace scalar { + + // Only scalar values remain here + template <typename Value> + typename mtl::traits::enable_if_scalar< + Value + , typename sfunctor::conj<Value>::result_type + >::type + inline conj(const Value& v) + { + return mtl::sfunctor::conj<Value>::apply(v); + } + + float inline conj(float v) { return v; } + double inline conj(double v) { return v; } + long double inline conj(long double v) { return v; } + } + + /// Conjugate of vector, matrix, or scalar + using vector::conj; + using matrix::conj; + using scalar::conj; + // using std::conj; + +} // namespace mtl + +#endif // MTL_CONJ_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/copy.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/copy.hpp new file mode 100644 index 0000000000000000000000000000000000000000..c32b8298bf0666e847e89637baf05c795a4b9c31 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/copy.hpp @@ -0,0 +1,299 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_COPY_INCLUDE +#define MTL_COPY_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/detail/index.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/utility/flatcat.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/is_row_major.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/utility/ashape.hpp> +#include <boost/numeric/mtl/utility/property_map.hpp> +#include <boost/numeric/mtl/utility/static_assert.hpp> +#include <boost/numeric/mtl/utility/updater_to_assigner.hpp> +#include <boost/numeric/mtl/matrix/inserter.hpp> +#include <boost/numeric/mtl/operation/set_to_zero.hpp> +#include <boost/numeric/mtl/operation/update.hpp> +#include <boost/numeric/mtl/operation/print.hpp> +#include <boost/numeric/mtl/operation/crop.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +#include <boost/type_traits/is_same.hpp> +#include <boost/utility/enable_if.hpp> +#include <iostream> +#include <limits> + +namespace mtl { + + namespace detail { + + // Set Destination matrix to zero when source is sparse + // (otherwise everything is overwritten anyway) + template <typename MatrixDest> + inline void zero_with_sparse_src(MatrixDest& dest, tag::flat<tag::sparse>) + { + set_to_zero(dest); + } + + template <typename MatrixDest> + inline void zero_with_sparse_src(MatrixDest&, tag::universe) {} + + // Adapt inserter size to operation + template <typename Updater> struct copy_inserter_size {}; + + // Specialization for store + template <typename Value> + struct copy_inserter_size< operations::update_store<Value> > + { + template <typename MatrixSrc, typename MatrixDest> + static inline int apply(const MatrixSrc& src, const MatrixDest& dest) + { + // std::cout << "nnz = " << src.nnz() << ", dim1 = " << dest.dim1() << "\n"; + return int(src.nnz() * 1.2 / dest.dim1()); + } + }; + + struct sum_of_sizes + { + template <typename MatrixSrc, typename MatrixDest> + static inline int apply(const MatrixSrc& src, const MatrixDest& dest) + { return int((src.nnz() + dest.nnz()) * 1.2 / dest.dim1()); } + }; + + // Specialization for plus and minus + template <typename Value> struct copy_inserter_size< operations::update_plus<Value> > : sum_of_sizes {}; + template <typename Value> struct copy_inserter_size< operations::update_minus<Value> > : sum_of_sizes {}; + + } // namespace detail + + + template <typename Updater, typename MatrixSrc, typename MatrixDest> + inline void gen_matrix_copy(const MatrixSrc& src, MatrixDest& dest, bool with_reset) + { + vampir_trace<3002> tracer; + MTL_THROW_IF(num_rows(src) != num_rows(dest) || num_cols(src) != num_cols(dest), incompatible_size()); + + if (with_reset) + detail::zero_with_sparse_src(dest, traits::sparsity_flatcat<MatrixSrc>()); + + typename traits::row<MatrixSrc>::type row(src); + typename traits::col<MatrixSrc>::type col(src); + typename traits::const_value<MatrixSrc>::type value(src); + typedef typename traits::range_generator<tag::major, MatrixSrc>::type cursor_type; + + // std::cout << "Slot size is " << detail::copy_inserter_size<Updater>::apply(src, dest) << "\n"; + matrix::inserter<MatrixDest, Updater> ins(dest, detail::copy_inserter_size<Updater>::apply(src, dest)); + for (cursor_type cursor = mtl::begin<tag::major>(src), cend = mtl::end<tag::major>(src); + cursor != cend; ++cursor) { + // std::cout << dest << '\n'; + + typedef typename traits::range_generator<tag::nz, cursor_type>::type icursor_type; + for (icursor_type icursor = mtl::begin<tag::nz>(cursor), icend = mtl::end<tag::nz>(cursor); + icursor != icend; ++icursor) { + //std::cout << "in " << row(*icursor) << ", " << col(*icursor) << " insert " << value(*icursor) << '\n'; + ins(row(*icursor), col(*icursor)) << value(*icursor); } + } + } + + // Specialization for multi_vector + template <typename Updater, typename MatrixSrc, typename Vector> + inline void gen_matrix_copy(const MatrixSrc& src, mtl::matrix::multi_vector<Vector>& dest, bool) + { + MTL_THROW_IF(num_rows(src) != num_rows(dest) || num_cols(src) != num_cols(dest), incompatible_size()); + typedef typename mtl::traits::updater_to_assigner<Updater>::type Assigner; + + for (std::size_t i= 0, n= num_cols(src); i < n; ++i) + Assigner::first_update(dest.vector(i), src.vector(i)); + } + + namespace { +# ifdef __clang__ +# pragma clang diagnostic ignored "-Wunneeded-internal-declaration" +# pragma clang diagnostic ignored "-Wunused-function" +# endif + inline long inc_wo_over(long i) { return i == std::numeric_limits<long>::max() ? i : i+1; } + inline long negate_wo_over(long i) { return i == std::numeric_limits<long>::min() ? std::numeric_limits<long>::max() : -i; } + } + + template <typename Updater, typename ValueSrc, typename Para, typename ValueDest> + typename boost::enable_if<boost::is_same<Updater, operations::update_store<ValueDest> > >::type + inline gen_matrix_copy(const matrix::banded_view<mtl::matrix::compressed2D<ValueSrc, Para> >& src, mtl::matrix::compressed2D<ValueDest, Para>& dest, bool) + { + vampir_trace<3061> tracer; + typedef typename Para::size_type size_type; + dest.change_dim(num_rows(src), num_cols(src)); // contains make_empty + set_to_zero(dest); + const mtl::matrix::compressed2D<ValueSrc, Para> &sref= src.ref; + const std::vector<size_type> &sstarts= sref.ref_major(), &sindices= sref.ref_minor(); + long first, last; + if (traits::is_row_major<Para>::value) { + first= src.get_begin(); + last= src.get_end(); + } else { + first= inc_wo_over(negate_wo_over(src.get_end())); + last= inc_wo_over(negate_wo_over(src.get_begin())); + } + + long jd= 0, j_end= sstarts[0]; + for (long i= 0, i_end= src.dim1(), f= first, l= last; i < i_end; ++i) { + dest.ref_major()[i]= jd; + long j= j_end; + j_end= sstarts[i+1]; + while (j < j_end && long(sindices[j]) < f) j++; + while (j < j_end && long(sindices[j]) < l) jd++, j++; + f= inc_wo_over(f); + l= inc_wo_over(l); + } + dest.ref_major()[src.dim1()]= jd; + dest.set_nnz(jd); // resizes indices and data + + for (long i= 0, i_end= src.dim1(), jd= 0, j_end= sstarts[0]; i < i_end; ++i) { + dest.ref_major()[i]= jd; + long j= j_end; + j_end= sstarts[i+1]; + while (j < j_end && long(sindices[j]) < first) j++; + while (j < j_end && long(sindices[j]) < last) { + dest.ref_minor()[jd]= sindices[j]; + dest.data[jd++]= sref.data[j++]; + } + first= inc_wo_over(first); + last= inc_wo_over(last); + } + } + + + /// Copy matrix \p src into matrix \p dest + template <typename MatrixSrc, typename MatrixDest> + inline void matrix_copy(const MatrixSrc& src, MatrixDest& dest) + { + gen_matrix_copy< operations::update_store<typename MatrixDest::value_type> >(src, dest, true); + } + + + /// Add matrix \p src to matrix \p dest in copy-like style + template <typename MatrixSrc, typename MatrixDest> + inline void matrix_copy_plus(const MatrixSrc& src, MatrixDest& dest) + { + gen_matrix_copy< operations::update_plus<typename MatrixDest::value_type> >(src, dest, false); + } + + /// Subtract matrix \p src from matrix \p dest in copy-like style + template <typename MatrixSrc, typename MatrixDest> + inline void matrix_copy_minus(const MatrixSrc& src, MatrixDest& dest) + { + gen_matrix_copy< operations::update_minus<typename MatrixDest::value_type> >(src, dest, false); + } + + /// Multiply matrix \p src element-wise with matrix \p dest in copy-like style + template <typename MatrixSrc, typename MatrixDest> + inline void matrix_copy_ele_times(const MatrixSrc& src, MatrixDest& dest) + { + vampir_trace<3001> tracer; + MTL_THROW_IF(num_rows(src) != num_rows(dest) || num_cols(src) != num_cols(dest), incompatible_size()); + + typename traits::row<MatrixDest>::type row(dest); + typename traits::col<MatrixDest>::type col(dest); + typename traits::value<MatrixDest>::type value(dest); + typedef typename traits::range_generator<tag::major, MatrixDest>::type cursor_type; + typedef typename traits::range_generator<tag::nz, cursor_type>::type icursor_type; + + for (cursor_type cursor = begin<tag::major>(dest), cend = end<tag::major>(dest); cursor != cend; ++cursor) + for (icursor_type icursor = begin<tag::nz>(cursor), icend = end<tag::nz>(cursor); icursor != icend; ++icursor) + value(*icursor, value(*icursor) * src[row(*icursor)][col(*icursor)]); +#if 0 // copy would result in a*0 = a and 0*b = b!!!! + gen_matrix_copy< operations::update_times<typename MatrixDest::value_type> >(src, dest, false); +#endif + crop(dest); + } + + + template <typename MatrixSrc, typename MatrixDest> + inline void copy(const MatrixSrc& src, tag::flat<tag::matrix>, MatrixDest& dest, tag::flat<tag::matrix>) + // inline void copy(const MatrixSrc& src, tag::matrix_expr, MatrixDest& dest, tag::matrix) + { + return matrix_copy(src, dest); + } + + + + template <typename Updater, typename VectorSrc, typename VectorDest> + inline void gen_vector_copy(const VectorSrc& src, VectorDest& dest, bool with_reset) + { + // Works only with dense vectors as dest !!!!! (source could be sparse) + // Needs vector inserter + vampir_trace<2001> tracer; + + MTL_STATIC_ASSERT((boost::is_same<typename ashape::ashape<VectorSrc>::type, + typename ashape::ashape<VectorDest>::type>::value), "Source and target must have the same algebraic shape."); + + MTL_THROW_IF(size(src) != size(dest), incompatible_size()); + + if (with_reset) + detail::zero_with_sparse_src(dest, typename traits::category<VectorSrc>::type()); + + typename traits::index<VectorSrc>::type index(src); + typename traits::const_value<VectorSrc>::type value(src); + + typedef typename traits::range_generator<tag::nz, VectorSrc>::type cursor_type; + for (cursor_type cursor = begin<tag::nz>(src), cend = end<tag::nz>(src); + cursor != cend; ++cursor) + Updater()(dest[index(*cursor)], value(*cursor)); + } + + /// Copy vector \p src into vector \p dest + template <typename VectorSrc, typename VectorDest> + inline void vector_copy(const VectorSrc& src, VectorDest& dest) + { + gen_vector_copy< operations::update_store<typename VectorDest::value_type> >(src, dest, true); + } + + + /// Add vector \p src to vector \p dest in copy-like style + template <typename VectorSrc, typename VectorDest> + inline void vector_copy_plus(const VectorSrc& src, VectorDest& dest) + { + gen_vector_copy< operations::update_plus<typename VectorDest::value_type> >(src, dest, false); + } + + /// Subtract vector \p src from vector \p dest in copy-like style + template <typename VectorSrc, typename VectorDest> + inline void vector_copy_minus(const VectorSrc& src, VectorDest& dest) + { + gen_vector_copy< operations::update_minus<typename VectorDest::value_type> >(src, dest, false); + } + + + + template <typename VectorSrc, typename VectorDest> + inline void copy(const VectorSrc& src, tag::flat<tag::vector>, VectorDest& dest, tag::flat<tag::vector>) + { + return vector_copy(src, dest); + } + + + template <typename CollSrc, typename CollDest> + inline void copy(const CollSrc& src, CollDest& dest) + { + vampir_trace<3003> tracer; + return copy(src, traits::flatcat2<CollSrc, tag::matrix, tag::vector>(), + dest, traits::flatcat2<CollDest, tag::matrix, tag::vector>()); + } + + +} // namespace mtl + +#endif // MTL_COPY_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/copysign.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/copysign.hpp new file mode 100644 index 0000000000000000000000000000000000000000..6281f8948bffddf89b06cbc1f8e760976afd279f --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/copysign.hpp @@ -0,0 +1,86 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_COPYSIGN_INCLUDE +#define MTL_COPYSIGN_INCLUDE + +#include <complex> +#include <cmath> +#include <boost/numeric/mtl/operation/real.hpp> +#include <boost/numeric/mtl/operation/imag.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace mtl { + +namespace sfunctor { + + template <typename Value1, typename Value2> + struct copysign + { + static inline Value1 apply(const Value1& v, const Value2& s) + { + using math::zero; using std::abs; + + Value1 a(abs(v)); + return s < zero(s) ? -a : a; + } + }; + + // This specialization is questionable and thus subject to elimination + template <typename Value1, typename Value2> + struct copysign<std::complex<Value1>, Value2> + { + static inline Value1 apply(const std::complex<Value1>& v, const Value2& s) + { + using mtl::real; using mtl::imag; + return std::complex<Value1>(copysign<Value1, Value2>::apply(real(v), s), + copysign<Value1, Value2>::apply(imag(v), s)); + } + }; +#if 0 // ndef _MSC_VER doesn't work on BigRed with gcc 4.2.2 (????) and isn't used anyway + template <> + struct copysign<float, float> + { + static inline float apply(float v, float s) + { return ::copysignf(v, s); } + }; + + template <> + struct copysign<double, double> + { + static inline double apply(double v, double s) + { return ::copysign(v, s); } + }; + + template <> + struct copysign<long double, long double> + { + static inline long double apply(long double v, long double s) + { return copysignl(v, s); } + }; +#endif // _MSC_VER +} + +/// sign of scalars; for complex numbers sign of real part +template <typename Value1, typename Value2> +inline Value1 copysign(const Value1& v, const Value2& s) +{ + vampir_trace<1001> tracer; + return sfunctor::copysign<Value1, Value2>::apply(v, s); +} + + + + +} // namespace mtl + +#endif // MTL_COPYSIGN_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/crop.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/crop.hpp new file mode 100644 index 0000000000000000000000000000000000000000..9c90dea2eeeca881f236bd714fd2d7f07d3c8d8a --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/crop.hpp @@ -0,0 +1,50 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_CROP_INCLUDE +#define MTL_CROP_INCLUDE + +#include <boost/numeric/mtl/utility/enable_if.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace mtl { + + namespace vector { + + /// Remove all zero entries from a collection + /** Does nothing for dense collections **/ + template <typename T> + typename mtl::traits::enable_if_vector<T, T&>::type inline crop(T& x) + { + vampir_trace<3006> tracer; + x.crop(); return x; + } + } + + namespace matrix { + + /// Remove all zero entries from a collection + /** Does nothing for dense collections **/ + template <typename T> + typename mtl::traits::enable_if_matrix<T, T&>::type inline crop(T& x) + { + vampir_trace<3006> tracer; + x.crop(); return x; + } + } + + using vector::crop; + using matrix::crop; + +} // namespace mtl + +#endif // MTL_CROP_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/cross.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/cross.hpp new file mode 100644 index 0000000000000000000000000000000000000000..e75cd7e8438d8d23a81455ddcb4cfd020db16afa --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/cross.hpp @@ -0,0 +1,69 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_VECTOR_CROSS_INCLUDE +#define MTL_VECTOR_CROSS_INCLUDE + +#include <boost/numeric/mtl/concept/std_concept.hpp> +#include <boost/numeric/mtl/vector/dense_vector.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace mtl { namespace vector { + + namespace detail { + + // Result type of cross product + template <typename Vector1, typename Vector2> + struct cross_result + { + typedef typename Multiplicable<typename Collection<Vector1>::value_type, + typename Collection<Vector2>::value_type>::result_type value; + typedef dense_vector<value> type; + }; + } + +/// Cross product +/** Only exists for 3 and 7 dimensions. + Consider specialization for fixed-size types + **/ +template <typename Vector1, typename Vector2> +typename detail::cross_result<Vector1, Vector2>::type +inline cross(const Vector1& v1, const Vector2& v2) +{ + vampir_trace<2002> tracer; + MTL_THROW_IF((size(v1) != 3 && size(v1) != 7 ) || size(v1) != size(v2), incompatible_size()); + + typename detail::cross_result<Vector1, Vector2>::type result(size(v1)); + + if (size(v1) == 3) + for (unsigned i= 0; i < 3; i++) { + unsigned k= (i+1) % 3, l= (i+2) % 3; + result[i]= v1[k] * v2[l] - v1[l] * v2[k]; + } + else // must be 7 thus + for (unsigned i= 0; i < 7; i++) { + unsigned k= (i+1) % 7, l= (i+3) % 7; + result[i]= v1[k] * v2[l] - v1[l] * v2[k]; + + k= (i+2) % 7, l= (i+6) % 7; + result[i]+= v1[k] * v2[l] - v1[l] * v2[k]; + + k= (i+4) % 7, l= (i+5) % 7; + result[i]+= v1[k] * v2[l] - v1[l] * v2[k]; + } + return result; +} + + +}} // namespace mtl::vector + +#endif // MTL_VECTOR_CROSS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/cuppen.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/cuppen.hpp new file mode 100644 index 0000000000000000000000000000000000000000..ccb95202d6d5fe381f82ae0d26194f8c4cee442c --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/cuppen.hpp @@ -0,0 +1,133 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +// With contributions from Cornelius Steinhardt + +#ifndef MTL_MATRIX_CUPPEN_INCLUDE +#define MTL_MATRIX_CUPPEN_INCLUDE + +#include <cmath> +#include <boost/numeric/linear_algebra/identity.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/operation/iota.hpp> +#include <boost/numeric/mtl/operation/secular.hpp> +#include <boost/numeric/mtl/operation/sort.hpp> +#include <boost/numeric/mtl/operation/trans.hpp> +#include <boost/numeric/mtl/utility/domain.hpp> +#include <boost/numeric/mtl/matrix/permutation.hpp> + +#include <boost/numeric/mtl/vector/dense_vector.hpp> +#include <boost/numeric/itl/iteration/basic_iteration.hpp> +#include <boost/numeric/itl/krylov/fsm.hpp> + +namespace mtl { namespace matrix { + +/// Eigenvalues of triangle matrix A with Cuppen's divide and conquer algorithm +/** Eigenvalues are returned in vector lambda. A is overwritten. **/ +template <typename Matrix, typename Vector> +void inline cuppen_inplace(Matrix& A, Matrix& Q, Vector& lambda) +{ + using std::abs; using mtl::irange; using mtl::imax; using mtl::iall; using vector::iota; + + typedef typename Collection<Matrix>::value_type value_type; + typedef typename Collection<Matrix>::size_type size_type; + typedef mtl::vector::dense_vector<size_type, vector::parameters<> > size_vector; // todo: with type trait + + size_type nrows= num_rows(A); + MTL_THROW_IF(nrows != num_cols(A), matrix_not_square()); + const value_type zero= 0, one= 1; + + if (nrows == 1){ + lambda[0]= A[0][0]; + Q= one; + } else { + size_type m= size_type(nrows/2); + irange till_m(m), from_m(m, imax); + + size_vector perm(nrows); + Matrix T1(A[till_m][till_m]), T2(A[from_m][from_m]), // sub-matrices of A + Q0(nrows, nrows), Q1(Q0[till_m][till_m]), Q2(Q0[from_m][from_m]); // Q0 and sub-matrices + Vector v(nrows, zero), diag(nrows), lambda1(diag[till_m]), lambda2(diag[from_m]); // sub-vectors of diag + + //DIVIDE + value_type b= A[m-1][m]; + T1[m-1][m-1]-= abs(b); + T2[0][0]-= abs(b); + + v[m-1]= b > zero ? one : -one; + v[m]= one; + + cuppen_inplace(T1, Q1, lambda1); + cuppen_inplace(T2, Q2, lambda2); + + Q0[till_m][from_m]= zero; Q0[from_m][till_m]= zero; // zero out non-diagonal blocks + + T1[m-1][m-1]+= abs(b); + T2[0][0]+= abs(b); + + iota(perm); + sort(diag, perm); + + // CONQUER, start with eq. (3.0.2) using rows (not columns) + v[till_m]= b < zero ? Vector(-trans(Q1[m-1][iall])) : trans(Q1[m-1][iall]); + v[from_m]= trans(Q2[0][iall]); + + // permutation on v + mtl::matrix::traits::permutation<>::type P= mtl::matrix::permutation(perm); + Vector v1(P * v); + + lambda= secular(v1, diag, abs(b)); // solve secular equation + + // std::cout << "lambda is " << lambda << "\ndiag is " << diag << '\n'; + //Lemma 3.0.2 ... calculate eigenvectors + Matrix Q_tilde(nrows, nrows); + for (size_type i = 0; i < nrows; i++) { + for (size_type j= 0; j < size(diag); ++j) + MTL_DEBUG_THROW_IF (diag[j] == lambda[i], logic_error("Can't compute eigenvector, probably due to double eigenvalue.")); + Vector li(nrows, lambda[i]), lambda_i(ele_quot(v1, diag - li)); + Q_tilde[iall][i]= lambda_i / two_norm(lambda_i); // normalized eigenvector in Matrix Q + } + + Q= Q0 * P * Q_tilde; + +#if 0 + for (size_type i = 0; i < nrows; i++) { + // Vector qi(Q[iall][i]); // Todo: find out valgrind complains about the memory of qi for reasons inexplicable + Vector qi(nrows); + for (size_type j= 0; j < nrows; j++) + qi[j]= Q[j][i]; + + std::cout << "q[" << i << "] = " << qi << ", lambda[i] = " << lambda[i] + << ", diff = " << two_norm(Vector(A*qi - lambda[i]*qi)) << ", A*qi = " << Vector(A*qi) << ", li*qi = " << Vector(lambda[i]*qi) << '\n'; + itl::basic_iteration<double> iter(1.0, 20, 1e-5, 1e-5); + fsm(A, qi, lambda[i], 0.1, iter); + std::cout << "q[" << i << "] = " << qi << ", diff = " << two_norm(Vector(A*qi - lambda[i]*qi)) << '\n'; + Q[iall][i]= qi; + } +#endif + } +} + +/// Eigenvalues of triangle matrix A with Cuppen's divide and conquer algorithm +/** Eigenvalues are returned in vector lambda. A is copied. **/ +// A not as reference to force copy +template <typename Matrix, typename Vector> +void inline cuppen(Matrix A, Matrix& Q, Vector& lambda) +{ + Q= 0.0; + cuppen_inplace(A, Q, lambda); +} + +}} // namespace mtl::matrix + +#endif // MTL_MATRIX_CUPPEN_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/cursor_pseudo_dot.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/cursor_pseudo_dot.hpp new file mode 100644 index 0000000000000000000000000000000000000000..2d9fd080a144af8d56fbb76ae4c07bd1a4223bf2 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/cursor_pseudo_dot.hpp @@ -0,0 +1,90 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_CURSOR_PSEUDO_DOT_INCLUDE +#define MTL_CURSOR_PSEUDO_DOT_INCLUDE + +namespace mtl { + + + +namespace functor { + + template <unsigned MaxDepth, typename Value, typename Cursor1, typename Prop1, typename Cursor2, typename Prop2, unsigned Depth> + struct cursor_pseudo_dot_block + { + static unsigned const offset= MaxDepth - Depth; + + void operator() (Cursor1 i1, Prop1& prop1, Cursor2 i2, Prop2& prop2, + Value& s0, Value& s1, Value& s2, Value& s3, + Value& s4, Value& s5, Value& s6, Value& s7) + { + Cursor1 tmp1(i1); tmp1+= offset; + Cursor2 tmp2(i2); tmp2+= offset; + s0+= prop1(*tmp1) * prop2(*tmp2); + // s0+= prop1(i1 + offset) * prop2(i2 + offset); + typedef cursor_pseudo_dot_block<MaxDepth, Value, Cursor1, Prop1, Cursor2, Prop2, Depth-1> block_rest; + block_rest() (i1, prop1, i2, prop2, s1, s2, s3, s4, s5, s6, s7, s0); + } + }; + + //template <> + template <unsigned MaxDepth, typename Value, typename Cursor1, typename Prop1, typename Cursor2, typename Prop2> + struct cursor_pseudo_dot_block<MaxDepth, Value, Cursor1, Prop1, Cursor2, Prop2, 1> + { + static unsigned const offset= MaxDepth - 1; + + void operator() (Cursor1 i1, Prop1& prop1, Cursor2 i2, Prop2& prop2, + Value& s0, Value&, Value&, Value&, + Value&, Value&, Value&, Value&) + { + s0+= prop1(*(i1 + offset)) * prop2(*(i2 + offset)); + } + }; + + template <unsigned MaxDepth, typename Value, typename Cursor1, typename Prop1, typename Cursor2, typename Prop2> + struct cursor_pseudo_dot_t + { + Value operator() (Cursor1 i1, Cursor1 end1, Prop1& prop1, Cursor2 i2, Prop2& prop2) + { + using math::zero; + Value ref, my_zero(zero(ref)), + s0= my_zero, s1= my_zero, s2= my_zero, s3= my_zero, + s4= my_zero, s5= my_zero, s6= my_zero, s7= my_zero; + std::size_t size= end1 - i1, blocks= size / MaxDepth, blocked_size= blocks * MaxDepth; + + typedef cursor_pseudo_dot_block<MaxDepth, Value, Cursor1, Prop1, Cursor2, Prop2, MaxDepth> dot_block_type; + for (unsigned i= 0; i < blocked_size; i+= MaxDepth, i1+= MaxDepth, i2+= MaxDepth) { + dot_block_type()(i1, prop1, i2, prop2, s0, s1, s2, s3, s4, s5, s6, s7); + } + + typedef cursor_pseudo_dot_block<MaxDepth, Value, Cursor1, Prop1, Cursor2, Prop2, MaxDepth> dot_single_type; + s0+= s1 + s2 + s3 + s4 + s5 + s6 + s7; + for (unsigned i= blocked_size; i < size; ++i, ++i1, ++i2) + dot_single_type()(i1, prop1, i2, prop2, s0, s1, s2, s3, s4, s5, s6, s7); + return s0; + } + }; + +} // namespace functor + +template <unsigned MaxDepth, typename Value, typename Cursor1, typename Prop1, typename Cursor2, typename Prop2> +Value cursor_pseudo_dot(Cursor1 i1, Cursor1 end1, Prop1 prop1, Cursor2 i2, Prop2 prop2, Value) +{ + return functor::cursor_pseudo_dot_t<MaxDepth, Value, Cursor1, Prop1, Cursor2, Prop2>()(i1, end1, prop1, i2, prop2); +} + + + +} // namespace mtl + +#endif // MTL_CURSOR_PSEUDO_DOT_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/diagonal.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/diagonal.hpp new file mode 100644 index 0000000000000000000000000000000000000000..01b60db84250b98cdfe0c165ae3e4de7863bbc4a --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/diagonal.hpp @@ -0,0 +1,69 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_DIAGONAL_INCLUDE +#define MTL_DIAGONAL_INCLUDE + + +#include <boost/numeric/mtl/utility/enable_if.hpp> +#include <boost/numeric/mtl/matrix/parameter.hpp> +#include <boost/numeric/mtl/matrix/compressed2D.hpp> +#include <boost/numeric/mtl/matrix/inserter.hpp> +#include <boost/numeric/mtl/vector/dense_vector.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace mtl { + + namespace vector { + + /// Transform a vector into a diagonal matrix + template <typename Vector> + mtl::matrix::compressed2D<typename Collection<Vector>::value_type, matrix::parameters<> > + // typename mtl::traits::enable_if_vector<Vector, mtl::matrix::compressed2D<typename Collection<Vector>::value_type> >::type + inline diagonal(const Vector& v) + { + vampir_trace<2016> tracer; + typedef mtl::matrix::compressed2D<typename Collection<Vector>::value_type, matrix::parameters<> > matrix_type; + matrix_type D(size(v), size(v)); + D= 0; + mtl::matrix::inserter<matrix_type> ins(D, 1); + for (typename Collection<Vector>::size_type i= 0; i < size(v); ++i) + ins[i][i] << v[i]; + + return D; + } + } + + namespace matrix { + + /// Return the vector with the diagonal of the matrix + template <typename Matrix> + // typename mtl::traits::enable_if_matrix<Matrix, conj_view<Matrix> >::type + mtl::vector::dense_vector<typename Collection<Matrix>::value_type, vector::parameters<> > + inline diagonal(const Matrix& A) + { + vampir_trace<3007> tracer; + using std::min; + typedef typename Collection<Matrix>::size_type size_type; + size_type n= min(num_rows(A), num_cols(A)); + mtl::vector::dense_vector<typename Collection<Matrix>::value_type, vector::parameters<> > v(n); + + for (size_type i= 0; i < n; ++i) + v[i]= A[i][i]; + return v; + } + } + +} // namespace mtl + +#endif // MTL_DIAGONAL_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/div_result.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/div_result.hpp new file mode 100644 index 0000000000000000000000000000000000000000..df0c785a5e14e1178dd276d3b7a56553e65e41ef --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/div_result.hpp @@ -0,0 +1,52 @@ +/* + * div_result.h + * MTL + * + * Created by Hui Li (huil@Princeton.EDU) + * + */ + +#ifndef MTL_DIV_RESULT_INCLUDE +#define MTL_DIV_RESULT_INCLUDE + +#include <boost/numeric/mtl/utility/ashape.hpp> +#include <boost/numeric/mtl/matrix/map_view.hpp> +#include <boost/numeric/mtl/vector/map_view.hpp> + +namespace mtl { namespace traits { + +template < typename Op1, typename Op2, typename DivOp > struct div_result_aux {}; + +/// Result type for dividing Op1 by Op2 +/** Can be used in enable-if-style as type is only defined when appropriate **/ +template < typename Op1, typename Op2 > +struct div_result + : public div_result_aux < Op1, Op2, typename ashape::div_op<typename ashape::ashape<Op1>::type, + typename ashape::ashape<Op2>::type >::type > +{}; + +/// Divide column vector by scalar +template < typename Op1, typename Op2 > +struct div_result_aux < Op1, Op2, ::mtl::ashape::cvec_scal_div > +{ + typedef typename vector::divide_by_view<Op1,Op2> type; +}; + +/// Divide row vector by scalar +template < typename Op1, typename Op2 > +struct div_result_aux < Op1, Op2, ::mtl::ashape::rvec_scal_div > +{ + typedef typename vector::divide_by_view<Op1,Op2> type; +}; + +/// Divide matrix by scalar +template < typename Op1, typename Op2 > +struct div_result_aux < Op1, Op2, ::mtl::ashape::mat_scal_div > +{ + typedef typename matrix::divide_by_view<Op1,Op2> type; +}; + +}} // namespace mtl::traits + + +#endif diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/divide_by.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/divide_by.hpp new file mode 100644 index 0000000000000000000000000000000000000000..a1200677487d197887d94e2288c6b14daabfcd45 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/divide_by.hpp @@ -0,0 +1,94 @@ +/* + * divide_by.h + * MTL4 + * + * Created by Hui Li (huil@Princeton.EDU) + * + */ + +#ifndef MTL_DIVIDE_BY_INCLUDE +#define MTL_DIVIDE_BY_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/concept/std_concept.hpp> +#include <boost/numeric/mtl/matrix/map_view.hpp> +#include <boost/numeric/mtl/vector/map_view.hpp> +#include <boost/numeric/mtl/utility/algebraic_category.hpp> + +namespace mtl { namespace tfunctor { + + // AlgebraicCategory is by default tag::scalar + template <typename Value1, typename Value2, typename AlgebraicCategory> + struct divide_by + { + typedef typename Multiplicable<Value1, Value2>::result_type result_type; + + explicit divide_by(const Value2& v2) : v2(v2) {} + + result_type operator() (const Value1& v1) const + { + return v1 / v2; + } + private: + Value2 v2; + }; + + + template <typename Matrix, typename Value2> + struct divide_by<Matrix, Value2, tag::matrix> + { + typedef matrix::divide_by_view<Matrix,Value2> result_type; + + explicit divide_by(const Value2& v2) : v2(v2) {} + + result_type operator() (const Matrix& matrix) const + { + return result_type(matrix, v2); + } + private: + Value2 v2; + }; + + + template <typename Vector, typename Value2> + struct divide_by<Vector, Value2, tag::vector> + { + typedef vector::divide_by_view<Vector, Value2> result_type; + + explicit divide_by(const Value2& v2) : v2(v2) {} + + result_type operator() (const Vector& vector) const + { + return result_type(vector, v2); + } + private: + Value2 v2; + }; + + +} // namespace tfunctor + + +namespace matrix { + + template <typename Value1, typename Value2> + typename tfunctor::divide_by<Value1, Value2, typename traits::algebraic_category<Value1>::type>::result_type + inline divide_by(const Value1& value1, const Value2& value2) + { + return tfunctor::divide_by<Value1, Value2, typename traits::algebraic_category<Value1>::type>(value2)(value1); + } +} + +namespace vector { + + template <typename Value1, typename Value2> + typename tfunctor::divide_by<Value1, Value2, typename traits::algebraic_category<Value1>::type>::result_type + inline divide_by(const Value1& value1, const Value2& value2) + { + return tfunctor::divide_by<Value1, Value2, typename traits::algebraic_category<Value1>::type>(value2)(value1); + } +} + +} // namespace mtl + +#endif // MTL_DIVIDE_BY_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/divide_by_inplace.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/divide_by_inplace.hpp new file mode 100644 index 0000000000000000000000000000000000000000..f2a3e4f32e7ef38552ed5d99292fe8672faed742 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/divide_by_inplace.hpp @@ -0,0 +1,40 @@ +/* + * divide_by_inplace.hpp + * MTL4 + * + * Created by Hui Li (huil@Princeton.EDU) + * + */ + +#ifndef MTL_DIVIDE_BY_INPLACE_INCLUDE +#define MTL_DIVIDE_BY_INPLACE_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/operation/assign_each_nonzero.hpp> +#include <boost/numeric/mtl/operation/divide_by.hpp> + + +namespace mtl { + + + /// Divide collection \p c (from right) by scalar factor \p alpha; \p c is altered + template <typename Factor, typename Coll> + void divide_by_inplace(Coll& c, const Factor& alpha, tag::scalar) + { + // assign_each_nonzero(c, boost::lambda::_1 / alpha); + assign_each_nonzero(c, tfunctor::divide_by<typename Collection<Coll>::value_type, Factor>(alpha)); + } + + /// Divide collection \p c (from right) by factor \p alpha; \p c is altered + template <typename Factor, typename Collection> + void divide_by_inplace(Collection& c, const Factor& alpha) + { + divide_by_inplace(c, alpha, typename traits::category<Factor>::type()); + } + + +} // namespace mtl + +#endif // MTL_DIVIDE_BY_INPLACE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/dmat_dmat_mult.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/dmat_dmat_mult.hpp new file mode 100644 index 0000000000000000000000000000000000000000..ee612860d74921643a63a6bf2e8549dcd316e600 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/dmat_dmat_mult.hpp @@ -0,0 +1,1067 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_DMAT_DMAT_MULT_INCLUDE +#define MTL_DMAT_DMAT_MULT_INCLUDE + +#include <boost/mpl/bool.hpp> +#include <boost/utility/enable_if.hpp> + +#include <boost/numeric/mtl/operation/set_to_zero.hpp> +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/operation/cursor_pseudo_dot.hpp> +#include <boost/numeric/mtl/operation/multi_action_block.hpp> +#include <boost/numeric/mtl/operation/assign_mode.hpp> +#include <boost/numeric/mtl/operation/static_size.hpp> +#include <boost/numeric/mtl/operation/static_num_rows.hpp> +#include <boost/numeric/mtl/operation/static_num_cols.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/utility/flatcat.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/glas_tag.hpp> +#include <boost/numeric/mtl/utility/is_row_major.hpp> +#include <boost/numeric/mtl/utility/is_static.hpp> +#include <boost/numeric/mtl/utility/static_assert.hpp> +#include <boost/numeric/meta_math/loop.hpp> +#include <boost/numeric/mtl/recursion/base_case_test.hpp> +#include <boost/numeric/mtl/recursion/base_case_matrix.hpp> +#include <boost/numeric/mtl/recursion/matrix_recursator.hpp> +#include <boost/numeric/mtl/recursion/base_case_cast.hpp> +#include <boost/numeric/mtl/interface/blas.hpp> + +#include <boost/numeric/mtl/matrix/dense2D.hpp> +#include <boost/numeric/mtl/operation/print_matrix.hpp> +#include <boost/numeric/mtl/operation/no_op.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +#include <iostream> +#include <complex> + +namespace mtl { + +// ===================================================== +// Generic matrix product with cursors and property maps +// ===================================================== + + +// To allow 5th parameter, is ignored +// This is the bottom line of dmat_dmat_mult implementations. +// All MTL4 matrix types and views (so far) have cursors and property maps +// so that we disabled the backup functor by default. +// If some type has no cursor, one can still use a backup functor (whatever this may be). +template <typename MatrixA, typename MatrixB, typename MatrixC, typename Assign= assign::assign_sum, + typename Backup= no_op> +struct gen_cursor_dmat_dmat_mult_ft +{ + void operator()(MatrixA const& A, MatrixB const& B, MatrixC& C) + { + apply(A, B, C, traits::flatcat1<MatrixA, tag::has_cursor>(), traits::flatcat1<MatrixB, tag::has_cursor>()); + } + +private: + void apply(MatrixA const& A, MatrixB const& B, MatrixC& C, tag::universe, tag::universe) + { + Backup()(A, B, C); + } + + void apply(MatrixA const& A, MatrixB const& B, MatrixC& C, tag::flat<tag::has_cursor>, tag::flat<tag::has_cursor>) + { + // asm("#cursor"); + vampir_trace<4001> tracer; + // std::cout << "Canonical cursor\n"; + typedef glas::tag::row row; + typedef glas::tag::col col; + typedef glas::tag::all all; + + typedef typename traits::const_value<MatrixA>::type a_value_type; + typedef typename traits::const_value<MatrixB>::type b_value_type; + typedef typename traits::value<MatrixC>::type c_value_type; + + typedef typename traits::range_generator<row, MatrixA>::type a_cur_type; + typedef typename traits::range_generator<row, MatrixC>::type c_cur_type; + + typedef typename traits::range_generator<col, MatrixB>::type b_cur_type; + typedef typename traits::range_generator<all, c_cur_type>::type c_icur_type; + + typedef typename traits::range_generator<all, a_cur_type>::type a_icur_type; + typedef typename traits::range_generator<all, b_cur_type>::type b_icur_type; + +#ifndef NDEBUG + typename traits::row<MatrixA>::type row_a(A); + typename traits::col<MatrixA>::type col_a(A); + typename traits::row<MatrixB>::type row_b(B); + typename traits::col<MatrixB>::type col_b(B); + typename traits::row<MatrixC>::type row_c(C); + typename traits::col<MatrixC>::type col_c(C); +#else +# undef MTL_DEBUG_DMAT_DMAT_MULT // doesn't work with NDEBUG +#endif + + if (Assign::init_to_zero) set_to_zero(C); + + a_value_type a_value(A); + b_value_type b_value(B); + c_value_type c_value(C); + + a_cur_type ac= begin<row>(A), aend= end<row>(A); + for (c_cur_type cc= begin<row>(C); ac != aend; ++ac, ++cc) { + + b_cur_type bc= begin<col>(B), bend= end<col>(B); + for (c_icur_type cic= begin<all>(cc); bc != bend; ++bc, ++cic) { + + typename MatrixC::value_type c_tmp(c_value(*cic)); +#ifdef MTL_DEBUG_DMAT_DMAT_MULT + std::cout << "Calculating C[" << row_c(*cic) << "][" << col_c(*cic) << "], initial value is " + << c_tmp << "\n"; +#endif + a_icur_type aic= begin<all>(ac), aiend= end<all>(ac); + for (b_icur_type bic= begin<all>(bc); aic != aiend; ++aic, ++bic) { +#ifdef MTL_DEBUG_DMAT_DMAT_MULT + std::cout << "Updating with A[" << row_a(*aic) << "][" << col_a(*aic) << "] /* value is " + << a_value(*aic) << " */ * "; + std::cout << "B[" << row_b(*bic) << "][" << col_b(*bic) << "] /* value is " + << b_value(*bic) << " */ * "; +#endif + assert(row_a(*aic) == row_c(*cic)); // Must do here because ac has no props + assert(col_b(*bic) == col_c(*cic)); + assert(col_a(*aic) == row_b(*bic)); + Assign::update(c_tmp, a_value(*aic) * b_value(*bic)); +#ifdef MTL_DEBUG_DMAT_DMAT_MULT + std::cout << "C's current value is " << c_tmp << "\n"; +#endif + } + c_value(*cic, c_tmp); + } + } + } +}; + + +template <typename Assign= assign::assign_sum, + typename Backup= no_op> // To allow 2nd parameter, is ignored +struct gen_cursor_dmat_dmat_mult_t +{ + template <typename MatrixA, typename MatrixB, typename MatrixC> + void operator()(MatrixA const& A, MatrixB const& B, MatrixC& C) + { + gen_cursor_dmat_dmat_mult_ft<MatrixA, MatrixB, MatrixC, Assign, Backup>()(A, B, C); + } +}; + + +// ===================================== +// Generic matrix product with iterators +// ===================================== + +template <typename MatrixA, typename MatrixB, typename MatrixC, + typename Assign= assign::assign_sum, + typename Backup= gen_cursor_dmat_dmat_mult_t<Assign> > +struct gen_dmat_dmat_mult_ft +{ + void operator()(MatrixA const& A, MatrixB const& B, MatrixC& C) + { + apply(A, B, C, traits::flatcat1<MatrixA, tag::has_iterator>(), traits::flatcat1<MatrixB, tag::has_iterator>()); + } + +private: + void apply(MatrixA const& A, MatrixB const& B, MatrixC& C, tag::universe, tag::universe) + { + Backup()(A, B, C); + } + + void apply(MatrixA const& A, MatrixB const& B, MatrixC& C, tag::flat<tag::has_iterator>, tag::flat<tag::has_iterator>) + { + // asm("#iterator"); + vampir_trace<4002> tracer; + // std::cout << "Canonical iterator\n"; + using namespace tag; + using traits::range_generator; + typedef typename range_generator<row, MatrixA>::type a_cur_type; + typedef typename range_generator<row, MatrixC>::type c_cur_type; + typedef typename range_generator<col, MatrixB>::type b_cur_type; + typedef typename range_generator<iter::all, c_cur_type>::type c_icur_type; + typedef typename range_generator<const_iter::all, a_cur_type>::type a_icur_type; + typedef typename range_generator<const_iter::all, b_cur_type>::type b_icur_type; + + if (Assign::init_to_zero) set_to_zero(C); + + a_cur_type ac= mtl::begin<row>(A), aend= mtl::end<row>(A); + for (c_cur_type cc= mtl::begin<row>(C); ac != aend; ++ac, ++cc) { + + b_cur_type bc= mtl::begin<col>(B), bend= mtl::end<col>(B); + for (c_icur_type cic= mtl::begin<iter::all>(cc); bc != bend; ++bc, ++cic) { + + typename MatrixC::value_type c_tmp(*cic); + a_icur_type aic= mtl::begin<const_iter::all>(ac), aiend= mtl::end<const_iter::all>(ac); + for (b_icur_type bic= mtl::begin<const_iter::all>(bc); aic != aiend; ++aic, ++bic) { + Assign::update(c_tmp, *aic * *bic); + } + *cic= c_tmp; + } + } + } +}; + + +template <typename Assign= assign::assign_sum, + typename Backup= gen_cursor_dmat_dmat_mult_t<Assign> > +struct gen_dmat_dmat_mult_t +{ + template <typename MatrixA, typename MatrixB, typename MatrixC> + void operator()(MatrixA const& A, MatrixB const& B, MatrixC& C) + { + gen_dmat_dmat_mult_ft<MatrixA, MatrixB, MatrixC, Assign, Backup>()(A, B, C); + } +}; + + +/* + +Unrolling matrix product with dimensions that are not multiples of blocks + +1. Do with optimization: + C_nw += A_nw * B_nw + - wherby the matrix dimensions of sub-matrices are the largest multiples of block sizes + smaller or equal to the matrix dimensions of the original matrix + + +2. Do without optimization + C_nw += A_ne * B_sw + C_ne += A_n * B_e + C_s += A_s * B + +The inner loop can be unrolled arbitrarily. So, we can simplify + +1. Do with optimization: + C_nw += A_n * B_w + - wherby the matrix dimensions of sub-matrices are the largest multiples of block sizes + smaller or equal to the matrix dimensions of the original matrix + + +2. Do with optimization only in inner loop + C_ne += A_n * B_e + C_s += A_s * B + + +*/ + +// ======================= +// Unrolled with iterators +// required has_2D_layout +// ======================= + +// Define defaults if not yet given as Compiler flag +#ifndef MTL_DMAT_DMAT_MULT_TILING1 +# define MTL_DMAT_DMAT_MULT_TILING1 2 +#endif + +#ifndef MTL_DMAT_DMAT_MULT_TILING2 +# define MTL_DMAT_DMAT_MULT_TILING2 4 +#endif + +#ifndef MTL_DMAT_DMAT_MULT_INNER_UNROLL +# define MTL_DMAT_DMAT_MULT_INNER_UNROLL 8 +#endif + + +template <unsigned long Index0, unsigned long Max0, unsigned long Index1, unsigned long Max1, typename Assign> +struct gen_tiling_dmat_dmat_mult_block + : public meta_math::loop2<Index0, Max0, Index1, Max1> +{ + typedef meta_math::loop2<Index0, Max0, Index1, Max1> base; + typedef gen_tiling_dmat_dmat_mult_block<base::next_index0, Max0, base::next_index1, Max1, Assign> next_t; + + template <typename Value, typename ValueA, typename SizeA, typename ValueB, typename SizeB> + static inline void apply(Value& tmp00, Value& tmp01, Value& tmp02, Value& tmp03, Value& tmp04, + Value& tmp05, Value& tmp06, Value& tmp07, Value& tmp08, Value& tmp09, + Value& tmp10, Value& tmp11, Value& tmp12, Value& tmp13, Value& tmp14, Value& tmp15, + ValueA *begin_a, SizeA& ari, ValueB *begin_b, SizeB& bci) + { + tmp00+= begin_a[ base::index0 * ari ] * begin_b[ base::index1 * bci ]; + next_t::apply(tmp01, tmp02, tmp03, tmp04, tmp05, tmp06, tmp07, tmp08, tmp09, + tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp00, + begin_a, ari, begin_b, bci); + } + + template <typename Value, typename MatrixC, typename SizeC> + static inline void update(Value& tmp00, Value& tmp01, Value& tmp02, Value& tmp03, Value& tmp04, + Value& tmp05, Value& tmp06, Value& tmp07, Value& tmp08, Value& tmp09, + Value& tmp10, Value& tmp11, Value& tmp12, Value& tmp13, Value& tmp14, Value& tmp15, + MatrixC& C, SizeC i, SizeC k) + { + Assign::update(C(i + base::index0, k + base::index1), tmp00); + next_t::update(tmp01, tmp02, tmp03, tmp04, tmp05, tmp06, tmp07, tmp08, tmp09, + tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp00, + C, i, k); + } +}; + +template <unsigned long Max0, unsigned long Max1, typename Assign> +struct gen_tiling_dmat_dmat_mult_block<Max0, Max0, Max1, Max1, Assign> + : public meta_math::loop2<Max0, Max0, Max1, Max1> +{ + typedef meta_math::loop2<Max0, Max0, Max1, Max1> base; + + template <typename Value, typename ValueA, typename SizeA, typename ValueB, typename SizeB> + static inline void apply(Value& tmp00, Value&, Value&, Value&, Value&, + Value&, Value&, Value&, Value&, Value&, + Value&, Value&, Value&, Value&, Value&, Value&, + ValueA *begin_a, SizeA& ari, ValueB *begin_b, SizeB& bci) + { + tmp00+= begin_a[ base::index0 * ari ] * begin_b[ base::index1 * bci ]; + } + + template <typename Value, typename MatrixC, typename SizeC> + static inline void update(Value& tmp00, Value&, Value&, Value&, Value&, + Value&, Value&, Value&, Value&, Value&, + Value&, Value&, Value&, Value&, Value&, Value&, + MatrixC& C, SizeC i, SizeC k) + { + Assign::update(C(i + base::index0, k + base::index1), tmp00); + } +}; + + +template <typename MatrixA, typename MatrixB, typename MatrixC, + unsigned long Tiling1= MTL_DMAT_DMAT_MULT_TILING1, + unsigned long Tiling2= MTL_DMAT_DMAT_MULT_TILING2, + typename Assign= assign::assign_sum, + typename Backup= gen_dmat_dmat_mult_t<Assign> > +struct gen_tiling_dmat_dmat_mult_ft +{ + MTL_STATIC_ASSERT((Tiling1 * Tiling2 <= 16), "Tile (Tiling1 * Tiling2) cannot be larger than 16."); + + void operator()(MatrixA const& A, MatrixB const& B, MatrixC& C) + { + apply(A, B, C, traits::layout_flatcat<MatrixA>(), traits::layout_flatcat<MatrixB>()); + } + +private: + void apply(MatrixA const& A, MatrixB const& B, MatrixC& C, tag::universe, tag::universe) + { + Backup()(A, B, C); + } + + void apply(MatrixA const& A, MatrixB const& B, MatrixC& C, tag::flat<tag::has_2D_layout>, tag::flat<tag::has_2D_layout>) + { + // asm("#tiling"); + vampir_trace<4003> tracer; + // Indices run out of range for smaller matrices + if (num_rows(A) < 2 || num_cols(A) < 2 || num_cols(B) < 2) { + Backup()(A, B, C); + return; + } + + // std::cout << "meta-unrolling\n"; + if (Assign::init_to_zero) set_to_zero(C); + + typedef gen_tiling_dmat_dmat_mult_block<1, Tiling1, 1, Tiling2, Assign> block; + typedef typename MatrixC::size_type size_type; + typedef typename MatrixC::value_type value_type; + const value_type z= math::zero(C[0][0]); // if this are matrices we need their size + + size_type i_max= num_rows(C), i_block= Tiling1 * (i_max / Tiling1), + k_max= num_cols(C), k_block= Tiling2 * (k_max / Tiling2); + size_t ari= &A(1, 0) - &A(0, 0), // how much is the offset of A's entry increased by incrementing row + aci= &A(0, 1) - &A(0, 0), bri= &B(1, 0) - &B(0, 0), bci= &B(0, 1) - &B(0, 0); + + // C_nw += A_nw * B_nw + for (size_type i= 0; i < i_block; i+= Tiling1) + for (size_type k= 0; k < k_block; k+= Tiling2) { + + value_type tmp00= z, tmp01= z, tmp02= z, tmp03= z, tmp04= z, + tmp05= z, tmp06= z, tmp07= z, tmp08= z, tmp09= z, + tmp10= z, tmp11= z, tmp12= z, tmp13= z, tmp14= z, tmp15= z; + const typename MatrixA::value_type *begin_a= &A(i, 0), *end_a= begin_a + num_cols(A) * aci; + const typename MatrixB::value_type *begin_b= &B(0, k); + + for (; begin_a != end_a; begin_a+= aci, begin_b+= bri) + block::apply(tmp00, tmp01, tmp02, tmp03, tmp04, tmp05, tmp06, tmp07, tmp08, tmp09, + tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, + begin_a, ari, begin_b, bci); + block::update(tmp00, tmp01, tmp02, tmp03, tmp04, tmp05, tmp06, tmp07, tmp08, tmp09, + tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, + C, i, k); + } + + // C_ne += A_n * B_e + for (size_type i= 0; i < i_block; i++) + for (size_type k = k_block; k < k_max; k++) { + value_type tmp00= z; + const typename MatrixA::value_type *begin_a= &A(i, 0), *end_a= begin_a + num_cols(A) * aci; + const typename MatrixB::value_type *begin_b= &B(0, k); + + for (; begin_a != end_a; begin_a+= aci, begin_b+= bri) + tmp00 += *begin_a * *begin_b; + Assign::update(C(i, k), tmp00); + } + + // C_s += A_s * B + for (size_type i= i_block; i < i_max; i++) + for (size_type k = 0; k < k_max; k++) { + value_type tmp00= z; + const typename MatrixA::value_type *begin_a= &A(i, 0), *end_a= begin_a + num_cols(A) * aci; + const typename MatrixB::value_type *begin_b= &B(0, k); + + for (; begin_a != end_a; begin_a+= aci, begin_b+= bri) + tmp00 += *begin_a * *begin_b; + Assign::update(C(i, k), tmp00); + } + } +}; + +template <unsigned long Tiling1= MTL_DMAT_DMAT_MULT_TILING1, + unsigned long Tiling2= MTL_DMAT_DMAT_MULT_TILING2, + typename Assign= assign::assign_sum, + typename Backup= gen_dmat_dmat_mult_t<Assign> > +struct gen_tiling_dmat_dmat_mult_t +{ + template <typename MatrixA, typename MatrixB, typename MatrixC> + void operator()(MatrixA const& A, MatrixB const& B, MatrixC& C) + { + gen_tiling_dmat_dmat_mult_ft< + MatrixA, MatrixB, MatrixC, Tiling1, Tiling2, Assign, Backup + >()(A, B, C); + } +}; + + + +// ================================= +// Unrolled with iterators fixed 4x4 +// required has_2D_layout +// ================================= + + +template <typename MatrixA, typename MatrixB, typename MatrixC, + typename Assign= assign::assign_sum, + typename Backup= gen_dmat_dmat_mult_t<Assign> > +struct gen_tiling_44_dmat_dmat_mult_ft +{ + void operator()(MatrixA const& A, MatrixB const& B, MatrixC& C) + { + apply(A, B, C, traits::layout_flatcat<MatrixA>(), traits::layout_flatcat<MatrixB>()); + } + +private: + void apply(MatrixA const& A, MatrixB const& B, MatrixC& C, tag::universe, tag::universe) + { + Backup()(A, B, C); + } + + void apply(MatrixA const& A, MatrixB const& B, MatrixC& C, tag::flat<tag::has_2D_layout>, tag::flat<tag::has_2D_layout>) + { + // asm("#tiling44"); + vampir_trace<4004> tracer; + // Indices run out of range for smaller matrices + if (num_rows(A) < 2 || num_cols(A) < 2 || num_cols(B) < 2) { + Backup()(A, B, C); + return; + } + + // std::cout << "4x4 unrolling\n"; + if (Assign::init_to_zero) set_to_zero(C); + + typedef typename MatrixC::size_type size_type; + typedef typename MatrixC::value_type value_type; + + const size_type Tiling1= 4, Tiling2= 4; + const value_type z= math::zero(C[0][0]); // if this are matrices we need their size + + size_type i_max= num_rows(C), i_block= Tiling1 * (i_max / Tiling1), + k_max= num_cols(C), k_block= Tiling2 * (k_max / Tiling2); + size_t ari= &A(1, 0) - &A(0, 0), // how much is the offset of A's entry increased by incrementing row + aci= &A(0, 1) - &A(0, 0), bri= &B(1, 0) - &B(0, 0), bci= &B(0, 1) - &B(0, 0); + + // C_nw += A_nw * B_nw + for (size_type i= 0; i < i_block; i+= Tiling1) + for (size_type k= 0; k < k_block; k+= Tiling2) { + + value_type tmp00= z, tmp01= z, tmp02= z, tmp03= z, tmp04= z, + tmp05= z, tmp06= z, tmp07= z, tmp08= z, tmp09= z, + tmp10= z, tmp11= z, tmp12= z, tmp13= z, tmp14= z, tmp15= z; + const typename MatrixA::value_type *begin_a= &A(i, 0), *end_a= begin_a + num_cols(A) * aci; + const typename MatrixB::value_type *begin_b= &B(0, k); + + for (; begin_a != end_a; begin_a+= aci, begin_b+= bri) { + tmp00+= begin_a[ 0 * ari ] * begin_b[ 0 * bci ]; + tmp01+= begin_a[ 0 * ari ] * begin_b[ 1 * bci ]; + tmp02+= begin_a[ 0 * ari ] * begin_b[ 2 * bci ]; + tmp03+= begin_a[ 0 * ari ] * begin_b[ 3 * bci ]; + tmp04+= begin_a[ 1 * ari ] * begin_b[ 0 * bci ]; + tmp05+= begin_a[ 1 * ari ] * begin_b[ 1 * bci ]; + tmp06+= begin_a[ 1 * ari ] * begin_b[ 2 * bci ]; + tmp07+= begin_a[ 1 * ari ] * begin_b[ 3 * bci ]; + tmp08+= begin_a[ 2 * ari ] * begin_b[ 0 * bci ]; + tmp09+= begin_a[ 2 * ari ] * begin_b[ 1 * bci ]; + tmp10+= begin_a[ 2 * ari ] * begin_b[ 2 * bci ]; + tmp11+= begin_a[ 2 * ari ] * begin_b[ 3 * bci ]; + tmp12+= begin_a[ 3 * ari ] * begin_b[ 0 * bci ]; + tmp13+= begin_a[ 3 * ari ] * begin_b[ 1 * bci ]; + tmp14+= begin_a[ 3 * ari ] * begin_b[ 2 * bci ]; + tmp15+= begin_a[ 3 * ari ] * begin_b[ 3 * bci ]; + } + Assign::update(C(i + 0, k + 0), tmp00); + Assign::update(C(i + 0, k + 1), tmp01); + Assign::update(C(i + 0, k + 2), tmp02); + Assign::update(C(i + 0, k + 3), tmp03); + Assign::update(C(i + 1, k + 0), tmp04); + Assign::update(C(i + 1, k + 1), tmp05); + Assign::update(C(i + 1, k + 2), tmp06); + Assign::update(C(i + 1, k + 3), tmp07); + Assign::update(C(i + 2, k + 0), tmp08); + Assign::update(C(i + 2, k + 1), tmp09); + Assign::update(C(i + 2, k + 2), tmp10); + Assign::update(C(i + 2, k + 3), tmp11); + Assign::update(C(i + 3, k + 0), tmp12); + Assign::update(C(i + 3, k + 1), tmp13); + Assign::update(C(i + 3, k + 2), tmp14); + Assign::update(C(i + 3, k + 3), tmp15); + } + + // C_ne += A_n * B_e + for (size_type i= 0; i < i_block; i++) + for (size_type k = k_block; k < k_max; k++) { + value_type tmp00= z; + const typename MatrixA::value_type *begin_a= &A(i, 0), *end_a= begin_a + num_cols(A) * aci; + const typename MatrixB::value_type *begin_b= &B(0, k); + + for (; begin_a != end_a; begin_a+= aci, begin_b+= bri) + tmp00 += *begin_a * *begin_b; + Assign::update(C(i, k), tmp00); + } + + // C_s += A_s * B + for (size_type i= i_block; i < i_max; i++) + for (size_type k = 0; k < k_max; k++) { + value_type tmp00= z; + const typename MatrixA::value_type *begin_a= &A(i, 0), *end_a= begin_a + num_cols(A) * aci; + const typename MatrixB::value_type *begin_b= &B(0, k); + + for (; begin_a != end_a; begin_a+= aci, begin_b+= bri) + tmp00 += *begin_a * *begin_b; + Assign::update(C(i, k), tmp00); + } + } +}; + +template <typename Assign= assign::assign_sum, + typename Backup= gen_dmat_dmat_mult_t<Assign> > +struct gen_tiling_44_dmat_dmat_mult_t +{ + template <typename MatrixA, typename MatrixB, typename MatrixC> + void operator()(MatrixA const& A, MatrixB const& B, MatrixC& C) + { + gen_tiling_44_dmat_dmat_mult_ft< + MatrixA, MatrixB, MatrixC, Assign, Backup + >()(A, B, C); + } +}; + + + + +// ================================= +// Unrolled with iterators fixed 2x2 +// required has_2D_layout +// ================================= + + +template <typename MatrixA, typename MatrixB, typename MatrixC, + typename Assign= assign::assign_sum, + typename Backup= gen_dmat_dmat_mult_t<Assign> > +struct gen_tiling_22_dmat_dmat_mult_ft +{ + void operator()(MatrixA const& A, MatrixB const& B, MatrixC& C) + { + apply(A, B, C, traits::layout_flatcat<MatrixA>(), traits::layout_flatcat<MatrixB>()); + } + +private: + void apply(MatrixA const& A, MatrixB const& B, MatrixC& C, tag::universe, tag::universe) + { + Backup()(A, B, C); + } + + void apply(MatrixA const& A, MatrixB const& B, MatrixC& C, tag::flat<tag::has_2D_layout>, tag::flat<tag::has_2D_layout>) + { + // asm("#tiling22"); + vampir_trace<4005> tracer; + // Indices run out of range for smaller matrices + if (num_rows(A) < 2 || num_cols(A) < 2 || num_cols(B) < 2) { + Backup()(A, B, C); + return; + } + + // std::cout << "2x2 unrolling\n"; + if (Assign::init_to_zero) set_to_zero(C); + + typedef typename MatrixC::size_type size_type; + typedef typename MatrixC::value_type value_type; + + const size_type Tiling1= 2, Tiling2= 2; + const value_type z= math::zero(C[0][0]); // if this are matrices we need their size + + size_type i_max= num_rows(C), i_block= Tiling1 * (i_max / Tiling1), + k_max= num_cols(C), k_block= Tiling2 * (k_max / Tiling2); + size_t ari= &A(1, 0) - &A(0, 0), // how much is the offset of A's entry increased by incrementing row + aci= &A(0, 1) - &A(0, 0), bri= &B(1, 0) - &B(0, 0), bci= &B(0, 1) - &B(0, 0); + + // C_nw += A_nw * B_nw + for (size_type i= 0; i < i_block; i+= Tiling1) + for (size_type k= 0; k < k_block; k+= Tiling2) { + + value_type tmp00= z, tmp01= z, tmp02= z, tmp03= z; + const typename MatrixA::value_type *begin_a= &A(i, 0), *end_a= begin_a + num_cols(A) * aci; + const typename MatrixB::value_type *begin_b= &B(0, k); + + for (; begin_a != end_a; begin_a+= aci, begin_b+= bri) { + tmp00+= begin_a[ 0 ] * begin_b[ 0 ]; + tmp01+= begin_a[ 0 ] * begin_b[bci]; + tmp02+= begin_a[ari] * begin_b[ 0 ]; + tmp03+= begin_a[ari] * begin_b[bci]; + } + Assign::update(C(i + 0, k + 0), tmp00); + Assign::update(C(i + 0, k + 1), tmp01); + Assign::update(C(i + 1, k + 0), tmp02); + Assign::update(C(i + 1, k + 1), tmp03); + } + + // C_ne += A_n * B_e + for (size_type i= 0; i < i_block; i++) + for (size_type k = k_block; k < k_max; k++) { + value_type tmp00= z; + const typename MatrixA::value_type *begin_a= &A(i, 0), *end_a= begin_a + num_cols(A) * aci; + const typename MatrixB::value_type *begin_b= &B(0, k); + + for (; begin_a != end_a; begin_a+= aci, begin_b+= bri) + tmp00 += *begin_a * *begin_b; + Assign::update(C(i, k), tmp00); + } + + // C_s += A_s * B + for (size_type i= i_block; i < i_max; i++) + for (size_type k = 0; k < k_max; k++) { + value_type tmp00= z; + const typename MatrixA::value_type *begin_a= &A(i, 0), *end_a= begin_a + num_cols(A) * aci; + const typename MatrixB::value_type *begin_b= &B(0, k); + + for (; begin_a != end_a; begin_a+= aci, begin_b+= bri) + tmp00 += *begin_a * *begin_b; + Assign::update(C(i, k), tmp00); + } + } +}; + +template <typename Assign= assign::assign_sum, + typename Backup= gen_dmat_dmat_mult_t<Assign> > +struct gen_tiling_22_dmat_dmat_mult_t +{ + template <typename MatrixA, typename MatrixB, typename MatrixC> + void operator()(MatrixA const& A, MatrixB const& B, MatrixC& C) + { + gen_tiling_22_dmat_dmat_mult_ft< + MatrixA, MatrixB, MatrixC, Assign, Backup + >()(A, B, C); + } +}; + + + + +// ======================== +// Recursive Multiplication +// ======================== + +namespace wrec { + + template <typename BaseMult, typename BaseTest= recursion::bound_test_static<64> > + struct gen_dmat_dmat_mult_t + { + template <typename RecA, typename RecB, typename RecC> + void operator()(RecA const& rec_a, RecB const& rec_b, RecC& rec_c) + { + vampir_trace<4006> tracer; + // std::cout << "wrec::mult \n"; + using namespace recursion; + // using mtl::matrix::is_empty; // ambiguity with std::tr1::is_empty in VS2010 + // Ambiguity with boost::is_empty in Open64 + if (mtl::matrix::is_empty(rec_a) || mtl::matrix::is_empty(rec_b) || mtl::matrix::is_empty(rec_c)) + return; + + if (BaseTest()(rec_a)) { + typename base_case_matrix<typename RecC::matrix_type, BaseTest>::type + C= base_case_cast<BaseTest>(*rec_c); + BaseMult()(base_case_cast<BaseTest>(*rec_a), + base_case_cast<BaseTest>(*rec_b), C); + } else { + RecC c_north_west= north_west(rec_c), c_north_east= north_east(rec_c), + c_south_west= south_west(rec_c), c_south_east= south_east(rec_c); + + (*this)(north_west(rec_a), north_west(rec_b), c_north_west); + (*this)(north_west(rec_a), north_east(rec_b), c_north_east); + (*this)(south_west(rec_a), north_east(rec_b), c_south_east); + (*this)(south_west(rec_a), north_west(rec_b), c_south_west); + (*this)(south_east(rec_a), south_west(rec_b), c_south_west); + (*this)(south_east(rec_a), south_east(rec_b), c_south_east); + (*this)(north_east(rec_a), south_east(rec_b), c_north_east); + (*this)(north_east(rec_a), south_west(rec_b), c_north_west); + } + } + }; + +} // namespace wrec + + +template <typename BaseMult, + typename BaseTest= recursion::bound_test_static<64>, + typename Assign= assign::assign_sum, + typename Backup= gen_dmat_dmat_mult_t<Assign> > +struct gen_recursive_dmat_dmat_mult_t +{ + template <typename MatrixA, typename MatrixB, typename MatrixC> + void operator()(MatrixA const& A, MatrixB const& B, MatrixC& C) + { + apply(A, B, C, traits::flatcat1<MatrixA, tag::qsub_divisible>(), + traits::flatcat1<MatrixB, tag::qsub_divisible>(), traits::flatcat1<MatrixC, tag::qsub_divisible>()); + } + +private: + // If one matrix is not sub-divisible then take backup function + template <typename MatrixA, typename MatrixB, typename MatrixC> + void apply(MatrixA const& A, MatrixB const& B, MatrixC& C, tag::universe, tag::universe, tag::universe) + { + Backup()(A, B, C); + } + + // Only if matrix is sub-divisible, otherwise backup + template <typename MatrixA, typename MatrixB, typename MatrixC> + void apply(MatrixA const& A, MatrixB const& B, MatrixC& C, + tag::flat<tag::qsub_divisible>, tag::flat<tag::qsub_divisible>, tag::flat<tag::qsub_divisible>) + { + vampir_trace<4007> tracer; + // std::cout << "do recursion\n"; + if (Assign::init_to_zero) set_to_zero(C); + + // Make sure that mult functor of basecase has appropriate assign mode (in all nestings) + // i.e. replace assign::assign_sum by assign::plus_sum including backup functor + + using matrix::recursator; + recursator<MatrixA> rec_a(A); + recursator<MatrixB> rec_b(B); + recursator<MatrixC> rec_c(C); + equalize_depth(rec_a, rec_b, rec_c); + + wrec::gen_dmat_dmat_mult_t<BaseMult, BaseTest>() (rec_a, rec_b, rec_c); + } +}; + + + +// ================================== +// Plattform specific implementations +// ================================== + +// Here only general definition that calls backup function +// Special implementations needed in other files, which are included at the end + +template <typename MatrixA, typename MatrixB, typename MatrixC, typename Assign= assign::assign_sum, + typename Backup= gen_dmat_dmat_mult_t<Assign> > +struct gen_platform_dmat_dmat_mult_ft + : public Backup +{}; + + +template <typename Assign= assign::assign_sum, + typename Backup= gen_dmat_dmat_mult_t<Assign> > +struct gen_platform_dmat_dmat_mult_t +{ + template <typename MatrixA, typename MatrixB, typename MatrixC> + void operator()(MatrixA const& A, MatrixB const& B, MatrixC& C) + { + gen_platform_dmat_dmat_mult_ft<MatrixA, MatrixB, MatrixC, Assign, Backup>()(A, B, C); + } +}; + + +// ================================== +// BLAS functions as far as supported +// ================================== + + +template <typename MatrixA, typename MatrixB, typename MatrixC, typename Assign= assign::assign_sum, + typename Backup= gen_dmat_dmat_mult_t<Assign> > +struct gen_blas_dmat_dmat_mult_ft + : public Backup +{}; + + +#ifdef MTL_HAS_BLAS + +namespace detail { + + // Transform from assign representation to BLAS + double inline dgemm_alpha(assign::assign_sum) { return 1.0; } + double inline dgemm_alpha(assign::plus_sum) { return 1.0; } + double inline dgemm_alpha(assign::minus_sum) { return -1.0; } + + // Transform from assign representation to BLAS + double inline dgemm_beta(assign::assign_sum) { return 0.0; } + double inline dgemm_beta(assign::plus_sum) { return 1.0; } + double inline dgemm_beta(assign::minus_sum) { return 1.0; } + + template <typename Value, typename ParaA, typename ParaB, typename ParaC, typename Function, typename Assign> + void inline xgemm(const dense2D<Value, ParaA>& A, const dense2D<Value, ParaB>& B, + dense2D<Value, ParaC>& C, Function f, Assign) + { + vampir_trace<4008> tracer; + // std::cout << "use generic BLAS\n"; + int m= num_rows(A), n= num_cols(B), k= num_cols(A), lda= A.get_ldim(), ldb= B.get_ldim(), ldc= C.get_ldim(); + Value alpha= dgemm_alpha(Assign()), beta= dgemm_beta(Assign()); + char a_trans= traits::is_row_major<ParaA>::value ? 'T' : 'N', + b_trans= traits::is_row_major<ParaB>::value ? 'T' : 'N'; + + if (traits::is_row_major<ParaC>::value) { + // C^T= B^T * A^T + a_trans= 'T' + 'N' - a_trans; b_trans= 'T' + 'N' - b_trans; + f(&b_trans, &a_trans, &n /* col(B) */, &m /* row(A) */, &k /* col(A)=row(B) */, + &alpha, &B[0][0], &ldb, &A[0][0], &lda, &beta, &C[0][0], &ldc); + } else + f(&a_trans, &b_trans, &m, &n, &k, &alpha, &A[0][0], &lda, &B[0][0], &ldb, &beta, &C[0][0], &ldc); + } + +} // detail + +template<typename ParaA, typename ParaB, typename ParaC, typename Assign, typename Backup> +struct gen_blas_dmat_dmat_mult_ft<dense2D<float, ParaA>, dense2D<float, ParaB>, + dense2D<float, ParaC>, Assign, Backup> +{ + void operator()(const dense2D<float, ParaA>& A, const dense2D<float, ParaB>& B, + dense2D<float, ParaC>& C) + { + detail::xgemm(A, B, C, MTL_BLAS_NAME(sgemm), Assign()); + } +}; + +template<typename ParaA, typename ParaB, typename ParaC, typename Assign, typename Backup> +struct gen_blas_dmat_dmat_mult_ft<dense2D<double, ParaA>, dense2D<double, ParaB>, + dense2D<double, ParaC>, Assign, Backup> +{ + void operator()(const dense2D<double, ParaA>& A, const dense2D<double, ParaB>& B, + dense2D<double, ParaC>& C) + { + detail::xgemm(A, B, C, MTL_BLAS_NAME(dgemm), Assign()); + } +}; + + +template<typename ParaA, typename ParaB, typename ParaC, typename Assign, typename Backup> +struct gen_blas_dmat_dmat_mult_ft<dense2D<std::complex<float>, ParaA>, dense2D<std::complex<float>, ParaB>, + dense2D<std::complex<float>, ParaC>, Assign, Backup> +{ + void operator()(const dense2D<std::complex<float>, ParaA>& A, const dense2D<std::complex<float>, ParaB>& B, + dense2D<std::complex<float>, ParaC>& C) + { + detail::xgemm(A, B, C, MTL_BLAS_NAME(cgemm), Assign()); + } +}; + + +template<typename ParaA, typename ParaB, typename ParaC, typename Assign, typename Backup> +struct gen_blas_dmat_dmat_mult_ft<dense2D<std::complex<double>, ParaA>, dense2D<std::complex<double>, ParaB>, + dense2D<std::complex<double>, ParaC>, Assign, Backup> +{ + void operator()(const dense2D<std::complex<double>, ParaA>& A, const dense2D<std::complex<double>, ParaB>& B, + dense2D<std::complex<double>, ParaC>& C) + { + detail::xgemm(A, B, C, MTL_BLAS_NAME(zgemm), Assign()); + } +}; + + + +#endif // MTL_HAS_BLAS + +template <typename Assign= assign::assign_sum, + typename Backup= gen_dmat_dmat_mult_t<Assign> > +struct gen_blas_dmat_dmat_mult_t + : public Backup +{ + template <typename MatrixA, typename MatrixB, typename MatrixC> + void operator()(MatrixA const& A, MatrixB const& B, MatrixC& C) + { + gen_blas_dmat_dmat_mult_ft<MatrixA, MatrixB, MatrixC, Assign, Backup>()(A, B, C); + } +}; + + +// ============================================================ +// Switch between two functors depending on minimal matrix size +// ============================================================ + +template <std::size_t SizeLimit, typename FunctorSmall, typename FunctorLarge> +struct size_switch_dmat_dmat_mult_t +{ + template <typename MatrixA, typename MatrixB, typename MatrixC> + void operator()(MatrixA const& A, MatrixB const& B, MatrixC& C) + { + const bool all_static= traits::is_static<MatrixA>::value && traits::is_static<MatrixB>::value + && traits::is_static<MatrixC>::value; + apply(A, B, C, boost::mpl::bool_<all_static>()); + } + + private: + // Decided at run time + template <typename MatrixA, typename MatrixB, typename MatrixC> + void apply(MatrixA const& A, MatrixB const& B, MatrixC& C, boost::mpl::false_) + { + if (mtl::matrix::size(A) <= SizeLimit || mtl::matrix::size(B) <= SizeLimit || mtl::matrix::size(C) <= SizeLimit) + FunctorSmall()(A, B, C); + else + FunctorLarge()(A, B, C); + } + + // Decided at compile time + template <typename MatrixA, typename MatrixB, typename MatrixC> + void apply(MatrixA const& A, MatrixB const& B, MatrixC& C, boost::mpl::true_) + { + const bool is_small= mtl::static_size<MatrixA>::value <= SizeLimit || mtl::static_size<MatrixB>::value <= SizeLimit + || mtl::static_size<MatrixC>::value <= SizeLimit; + typename boost::mpl::if_c<is_small, FunctorSmall, FunctorLarge>::type()(A, B, C); + } +}; + + +// ==================================================================================== +// Switch between two functors depending on whether matrix size is know at compile time +// ==================================================================================== + +template <bool IsStatic, typename FunctorStatic, typename FunctorDynamic> +struct static_switch_dmat_dmat_mult_t +{ + template <typename MatrixA, typename MatrixB, typename MatrixC> + void operator()(MatrixA const& A, MatrixB const& B, MatrixC& C) + { + typename boost::mpl::if_c<IsStatic, FunctorStatic, FunctorDynamic>::type()(A, B, C); + } +}; + +// ============================================================== +// Completely unroll fixed size computations, will be tuned later +// ============================================================== + +template <std::size_t Index0, std::size_t Max0, std::size_t Index1, std::size_t Max1, typename Assign> +struct fully_unroll_dmat_dmat_mult_init_block + : public meta_math::loop2<Index0, Max0, Index1, Max1> +{ + typedef meta_math::loop2<Index0, Max0, Index1, Max1> base; + typedef fully_unroll_dmat_dmat_mult_init_block<base::next_index0, Max0, base::next_index1, Max1, Assign> next_t; + + template <typename MatrixA, typename MatrixB, typename MatrixC> + static inline void apply(MatrixA const& A, MatrixB const& B, MatrixC& C) + { + // Assign::first_update(C[base::index0][base::index1], A[base::index0][0] * B[0][base::index1]); + Assign::first_update(C(base::index0, base::index1), A(base::index0, 0) * B(0, base::index1)); + next_t::apply(A, B, C); + } +}; + +template <std::size_t Max0, std::size_t Max1, typename Assign> +struct fully_unroll_dmat_dmat_mult_init_block<Max0, Max0, Max1, Max1, Assign> + : public meta_math::loop2<Max0, Max0, Max1, Max1> +{ + typedef meta_math::loop2<Max0, Max0, Max1, Max1> base; + + template <typename MatrixA, typename MatrixB, typename MatrixC> + static inline void apply(MatrixA const& A, MatrixB const& B, MatrixC& C) + { + Assign::first_update(C(base::index0, base::index1), A(base::index0, 0) * B(0, base::index1)); + } +}; + + +template <std::size_t Index0, std::size_t Max0, std::size_t Index1, std::size_t Max1, + std::size_t Index2, std::size_t Max2, typename Assign> +struct fully_unroll_dmat_dmat_mult_block + : public meta_math::loop3<Index0, Max0, Index1, Max1, Index2, Max2> +{ + typedef meta_math::loop3<Index0, Max0, Index1, Max1, Index2, Max2> base; + typedef fully_unroll_dmat_dmat_mult_block<base::next_index0, Max0, base::next_index1, Max1, base::next_index2, Max2, Assign> next_t; + + template <typename MatrixA, typename MatrixB, typename MatrixC> + static inline void apply(MatrixA const& A, MatrixB const& B, MatrixC& C) + { + Assign::update(C(base::index1, base::index2), A(base::index1, base::index0) * B(base::index0, base::index2)); + next_t::apply(A, B, C); + } +}; + +template <std::size_t Max0, std::size_t Max1, std::size_t Max2, typename Assign> +struct fully_unroll_dmat_dmat_mult_block<Max0, Max0, Max1, Max1, Max2, Max2, Assign> + : public meta_math::loop3<Max0, Max0, Max1, Max1, Max2, Max2> +{ + typedef meta_math::loop3<Max0, Max0, Max1, Max1, Max2, Max2> base; + + template <typename MatrixA, typename MatrixB, typename MatrixC> + static inline void apply(MatrixA const& A, MatrixB const& B, MatrixC& C) + { + Assign::update(C(base::index1, base::index2), A(base::index1, base::index0) * B(base::index0, base::index2)); + } +}; + +template <typename Assign= assign::assign_sum, + typename Backup= gen_dmat_dmat_mult_t<Assign> > +struct fully_unroll_fixed_size_dmat_dmat_mult_t +{ + // if C is empty just do nothing + template <typename MatrixA, typename MatrixB, typename MatrixC> + typename boost::enable_if_c<static_size<MatrixC>::value == 0>::type + operator()(MatrixA const&, MatrixB const&, MatrixC&) {} + + // just initialize + template <typename MatrixA, typename MatrixB, typename MatrixC> + typename boost::enable_if_c<static_num_cols<MatrixA>::value == 0 && static_size<MatrixC>::value != 0>::type + operator()(MatrixA const&, MatrixB const&, MatrixC& C) { if (Assign::init_to_zero) set_to_zero(C); } + + struct noop + { + template <typename MatrixA, typename MatrixB, typename MatrixC> + static inline void apply(MatrixA const&, MatrixB const&, MatrixC&) {} + }; + + // really compute + template <typename MatrixA, typename MatrixB, typename MatrixC> + typename boost::enable_if_c<static_size<MatrixA>::value != 0 && static_size<MatrixC>::value != 0>::type + operator()(MatrixA const& A, MatrixB const& B, MatrixC& C) + { + vampir_trace<1002> tracer; + typedef typename static_num_rows<MatrixC>::type size_type; + static const size_type rows_c= static_num_rows<MatrixC>::value, cols_c= static_num_cols<MatrixC>::value, + cols_a= static_num_cols<MatrixA>::value; + // corresponds to C= A[all][0] * B[0][all]; + fully_unroll_dmat_dmat_mult_init_block<1, rows_c, 1, cols_c, Assign>::apply(A, B, C); + + // corresponds to C+= A[all][1:] * B[1:][all]; if necessary + typedef fully_unroll_dmat_dmat_mult_block<2, cols_a, 1, rows_c, 1, cols_c, Assign> f2; + typedef typename boost::mpl::if_c<(cols_a > 1), f2, noop>::type f3; + f3::apply(A, B, C); + } +}; + + +} // namespace mtl + +#endif // MTL_DMAT_DMAT_MULT_INCLUDE + +// Include plattform specific implementations +#include <boost/numeric/mtl/operation/opteron/matrix_mult.hpp> + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/dot.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/dot.hpp new file mode 100644 index 0000000000000000000000000000000000000000..029cfa4a2b700f5f0db546e365d4df4ec2163f86 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/dot.hpp @@ -0,0 +1,268 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_DOT_INCLUDE +#define MTL_DOT_INCLUDE + + +#include <boost/numeric/mtl/concept/std_concept.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/operation/conj.hpp> +#include <boost/numeric/meta_math/loop1.hpp> +#include <boost/numeric/linear_algebra/identity.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> +#include <boost/numeric/mtl/utility/omp_size_type.hpp> +#include <boost/numeric/mtl/utility/static_assert.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> + +namespace mtl { + + namespace vector { + + namespace detail { + + // Result type of dot product + template <typename Vector1, typename Vector2> + struct dot_result + { + typedef typename Multiplicable<typename Collection<Vector1>::value_type, + typename Collection<Vector2>::value_type>::result_type type; + }; + + // Whether or not conjugating first argument + struct without_conj + { + template <typename Value> + Value operator()(const Value& v) { return v; } + }; + + struct with_conj + { + template <typename Value> + typename mtl::sfunctor::conj<Value>::result_type + operator() (const Value& v) + { + using mtl::conj; + return conj(v); + } + }; + } + + namespace sfunctor { + + template <unsigned long Index0, unsigned long Max0> + struct dot_aux + : public meta_math::loop1<Index0, Max0> + { + typedef meta_math::loop1<Index0, Max0> base; + typedef dot_aux<base::next_index0, Max0> next_t; + + template <typename Value, typename Vector1, typename Vector2, typename Size, typename ConjOpt> + static inline void + apply(Value& tmp00, Value& tmp01, Value& tmp02, Value& tmp03, Value& tmp04, + Value& tmp05, Value& tmp06, Value& tmp07, + const Vector1& v1, const Vector2& v2, Size i, ConjOpt conj_opt) + { + // vampir_trace<9901> tracer; + tmp00+= conj_opt(v1[ i + base::index0 ]) * v2[ i + base::index0 ]; + next_t::apply(tmp01, tmp02, tmp03, tmp04, tmp05, tmp06, tmp07, tmp00, + v1, v2, i, conj_opt); + } + }; + + + template <unsigned long Max0> + struct dot_aux<Max0, Max0> + { + typedef meta_math::loop1<Max0, Max0> base; + + template <typename Value, typename Vector1, typename Vector2, typename Size, typename ConjOpt> + static inline void + apply(Value& tmp00, Value&, Value&, Value&, Value&, Value&, Value&, Value&, + const Vector1& v1, const Vector2& v2, Size i, ConjOpt conj_opt) + { + tmp00+= conj_opt(v1[ i + base::index0 ]) * v2[ i + base::index0 ]; + } + }; + + + template <unsigned long Unroll> + struct dot + { + template <typename Vector1, typename Vector2, typename ConjOpt> + typename detail::dot_result<Vector1, Vector2>::type + static inline apply(const Vector1& v1, const Vector2& v2, ConjOpt conj_opt) + { + MTL_STATIC_ASSERT((Unroll >= 1), "Unroll size must be at least 1."); + // MTL_STATIC_ASSERT((Unroll <= 8), "Maximal unrolling is 8."); // Might be relaxed in future versions + + vampir_trace<2003> tracer; + MTL_THROW_IF(mtl::size(v1) != mtl::size(v2), incompatible_size()); + typedef typename detail::dot_result<Vector1, Vector2>::type value_type; + +# ifdef MTL_WITH_OPENMP + value_type dummy, z= math::zero(dummy), result= z; + typedef typename mtl::traits::omp_size_type<typename Collection<Vector1>::size_type>::type size_type; + size_type i_max= mtl::size(v1), i_block= Unroll * (i_max / Unroll); + + + #pragma omp parallel + { + + vampir_trace<8001> tracer; + value_type tmp00= z, tmp01= z, tmp02= z, tmp03= z, tmp04= z, tmp05= z, tmp06= z, tmp07= z; + + #pragma omp for + for (size_type i= 0; i < i_block; i+= Unroll) + dot_aux<1, Unroll>::apply(tmp00, tmp01, tmp02, tmp03, tmp04, tmp05, tmp06, tmp07, v1, v2, i, conj_opt); + + #pragma omp critical + result+= ((tmp00 + tmp01) + (tmp02 + tmp03)) + ((tmp04 + tmp05) + (tmp06 + tmp07)); + } + for (size_type i= i_block; i < i_max; i++) + result+= conj_opt(v1[i]) * v2[i]; + + return result; +# else + typedef typename Collection<Vector1>::size_type size_type; + + value_type dummy, z= math::zero(dummy), tmp00= z, tmp01= z, tmp02= z, tmp03= z, tmp04= z, + tmp05= z, tmp06= z, tmp07= z; + size_type i_max= mtl::size(v1), i_block= Unroll * (i_max / Unroll); + + for (size_type i= 0; i < i_block; i+= Unroll) + dot_aux<1, Unroll>::apply(tmp00, tmp01, tmp02, tmp03, tmp04, tmp05, tmp06, tmp07, v1, v2, i, conj_opt); + + for (size_type i= i_block; i < i_max; i++) + tmp00+= conj_opt(v1[i]) * v2[i]; + return ((tmp00 + tmp01) + (tmp02 + tmp03)) + ((tmp04 + tmp05) + (tmp06 + tmp07)); +# endif + } + + + }; + } + + template <typename Vector1, typename Vector2, typename ConjOpt> + typename detail::dot_result<Vector1, Vector2>::type + inline dot_simple(const Vector1& v1, const Vector2& v2, ConjOpt conj_opt) + { + vampir_trace<2040> tracer; + typedef typename Collection<Vector1>::size_type size_type; + typedef typename detail::dot_result<Vector1, Vector2>::type value_type; + + value_type dummy, s= math::zero(dummy); + for (size_type i= 0, i_max= mtl::size(v1); i < i_max; ++i) + s+= conj_opt(v1[i]) * v2[i]; + return s; + } + + template <unsigned long Unroll, typename Vector1, typename Vector2, typename ConjOpt> + struct dot_class + { + typedef typename detail::dot_result<Vector1, Vector2>::type result_type; + dot_class(const Vector1& v1, const Vector2& v2) : v1(v1), v2(v2) {} + + operator result_type() const { return sfunctor::dot<Unroll>::apply(v1, v2, ConjOpt()); } + + const Vector1& v1; + const Vector2& v2; + }; + + template <typename Vector1, typename Vector2, typename ConjOpt> + struct dot_class<1, Vector1, Vector2, ConjOpt> + { + typedef typename detail::dot_result<Vector1, Vector2>::type result_type; + dot_class(const Vector1& v1, const Vector2& v2) : v1(v1), v2(v2) {} + + operator result_type() const { return dot_simple(v1, v2, ConjOpt()); } + + const Vector1& v1; + const Vector2& v2; + }; + + /// Lazy dot product + /** It is automatically evaluated when (implicitly) converted to result_type which doesn't work in template expressions. + Can be used for source-to-source transformations. **/ + template <typename Vector1, typename Vector2> + dot_class<4, Vector1, Vector2, detail::with_conj> + inline lazy_dot(const Vector1& v1, const Vector2& v2) + { + return dot_class<4, Vector1, Vector2, detail::with_conj>(v1, v2); + } + + template <unsigned long Unroll, typename Vector1, typename Vector2> + dot_class<Unroll, Vector1, Vector2, detail::with_conj> + inline lazy_dot(const Vector1& v1, const Vector2& v2) + { + return dot_class<Unroll, Vector1, Vector2, detail::with_conj>(v1, v2); + } + + template <typename Vector1, typename Vector2> + dot_class<4, Vector1, Vector2, detail::without_conj> + inline lazy_dot_real(const Vector1& v1, const Vector2& v2) + { + return dot_class<4, Vector1, Vector2, detail::without_conj>(v1, v2); + } + + template <unsigned long Unroll, typename Vector1, typename Vector2> + dot_class<Unroll, Vector1, Vector2, detail::without_conj> + inline lazy_dot_real(const Vector1& v1, const Vector2& v2) + { + return dot_class<Unroll, Vector1, Vector2, detail::without_conj>(v1, v2); + } + + /// Dot product defined as hermitian(v) * w + /** Unrolled four times by default **/ + template <typename Vector1, typename Vector2> + typename detail::dot_result<Vector1, Vector2>::type + inline dot(const Vector1& v1, const Vector2& v2) + { + // return dot_simple(v1, v2, detail::with_conj()); + return sfunctor::dot<4>::apply(v1, v2, detail::with_conj()); + } + + /// Dot product with user-specified unrolling defined as hermitian(v) * w + template <unsigned long Unroll, typename Vector1, typename Vector2> + typename detail::dot_result<Vector1, Vector2>::type + inline dot(const Vector1& v1, const Vector2& v2) + { + return sfunctor::dot<Unroll>::apply(v1, v2, detail::with_conj()); + } + /// Dot product without conjugate defined as trans(v) * w + /** Unrolled four times by default **/ + template <typename Vector1, typename Vector2> + typename detail::dot_result<Vector1, Vector2>::type + inline dot_real(const Vector1& v1, const Vector2& v2) + { + return sfunctor::dot<4>::apply(v1, v2, detail::without_conj()); + } + + /// Dot product without conjugate with user-specified unrolling defined as trans(v) * w + template <unsigned long Unroll, typename Vector1, typename Vector2> + typename detail::dot_result<Vector1, Vector2>::type + inline dot_real(const Vector1& v1, const Vector2& v2) + { + return sfunctor::dot<Unroll>::apply(v1, v2, detail::without_conj()); + } + + + } // namespace vector + + using vector::dot; + using vector::dot_real; + using vector::lazy_dot; + using vector::lazy_dot_real; + +} // namespace mtl + +#endif // MTL_DOT_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/eigenvalue.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/eigenvalue.hpp new file mode 100644 index 0000000000000000000000000000000000000000..afb3632f913d181a3ad02d2221e424d2f719281a --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/eigenvalue.hpp @@ -0,0 +1,256 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. +// +// Author Marc Hartung + +#ifndef MTL_MATRIX_EIGENVALUE_INCLUDE +#define MTL_MATRIX_EIGENVALUE_INCLUDE + +#include <cmath> +#include <complex> +#include <utility> + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/operation/qr_givens.hpp> +#include <boost/numeric/mtl/operation/misc.hpp> +#include <boost/numeric/linear_algebra/identity.hpp> +#include <boost/numeric/mtl/utility/irange.hpp> +#include <boost/numeric/mtl/vector/dense_vector.hpp> + +namespace mtl { namespace matrix { + + +/// Solver class for general eigenvalues +/** Not yet tested for complex matrices. **/ +template <typename Matrix> +class eigenvalue_solver { + + typedef typename Collection<Matrix>::value_type value_type; + typedef typename Collection<Matrix>::size_type size_type; + +public: + + /** \brief Constructor needs a sqare-matrix as input + * \param MTL-Matrix type + * + */ + eigenvalue_solver(const Matrix& IN) : ncols(num_cols(IN)), nrows(num_rows(IN)) { + zero= math::zero(IN[0][0]); + one= math::one(IN[0][0]); + R = hessenberg(IN); + I = Matrix(ncols,nrows); + I = one; + + //Standartwert Initialisierung: + + maxIteration = 20*ncols*ncols; + eps = 1.0e-8; + } + + + /** \brief Changes the zero-tolerance + * \param value_type of allowed distance to zero + */ + void setTolerance(value_type in) { + eps = in; + } + + /** \brief Changes the number of allowed iterations + * \param size_type variable of maximum allowed iterations + */ + void setMaxIteration(size_type in) { + maxIteration = in; + } + + /** \brief Starts the calculation of eigenvalues. + */ + void calc() { + value_type singleCont; + std::complex<value_type> compCont; + size_type size, allIt = 0; + for(size_type i=ncols-1;i>0 && i<ncols && allIt<=maxIteration;i--) { + size = i+1; // verkleinert die Matrix-Dimensionen + irange r(0,size); + singleCont = std::abs(R[i][i-1])+1; + compCont = getComplex2x2EW(i) + 1; + while( allIt < maxIteration && std::abs(R[i][i-1])>eps) { + if(isRealEW(i)) { + if(std::abs(R[i][i-1])<singleCont) { //SingleShift + singleCont = std::abs(R[i][i-1]); + singleShift(r); + } + else { //DoubleShift + singleCont = std::abs(R[i][i-1]); + doubleShift(r); + } + allIt++; + } + else { + if(std::abs(compCont-getComplex2x2EW(i))>eps) { + compCont = getComplex2x2EW(i); + doubleShift(r); + allIt++; + } + else { + i--; + break; + } + } + } + } + } + + + /** \brief Returner for the calculated eigenvalues + * + * Before using get_eigenvalues() you have to use calc()! + * \param dense_vector<complex<value_type>> of eigenvalues + */ + dense_vector<std::complex<value_type> > get_eigenvalues() + { + using mtl::conj; + dense_vector<std::complex<double> > res(ncols, 0.0); + size_type i; + for(i=ncols-1;i>0 && i<ncols;i--) { + if(std::abs(R[i][i-1])<eps || isRealEW(i)) { // wenn ein reeller EW + res[i] = R[i][i]; + } + else { // wenn zwei konjungiert komplexe EW + + std::complex<value_type> ews = getComplex2x2EW(i); + res[i-1] = ews; + res[i] = conj(ews); + i--; + } + } + if(i==0) { // zur Vermeidung von Zugriffsfehler + res[0] = R[0][0]; + } + return res; + } + + + +private: + Matrix R, I; + size_type ncols, nrows, maxIteration; + value_type zero, one, eps; + + + bool isRealEW(size_type k) { + if(std::abs(sqrt(square(R[k-1][k-1]+R[k][k])/4.0+R[k-1][k]*R[k][k-1]-R[k-1][k-1]*R[k][k])) >= 0.0) { + return true; + } + return false; + } + + /** \brief Calculates real eigenvalues of a 2x2-matrix defined by col/row k arround the diagonal of the input-matrix + * + * First entry of the pair is the eigenvalue closer to the (kxk)-entry (Wilkinson-shift for single shifting) + */ + std::pair<value_type, value_type> get2x2EW(const size_type k) { + std::pair<value_type, value_type> res; + value_type front, back, comparator; + + front = (R[k-1][k-1]+R[k][k])/2.0; + back = sqrt(square(R[k-1][k-1]+R[k][k])/4.0+R[k-1][k]*R[k][k-1]-R[k-1][k-1]*R[k][k]); + comparator = R[k][k]-front; + + if( std::abs(comparator-back) < std::abs(comparator+back) ) { + res.first = front+back; + res.second = front-back; + } + else { + res.first = front-back; + res.second = front+back; + } + return res; + } + + + /** \brief Calculates a complex eigenvalue of a 2x2-matrix defined by col/row k arround the diagonal of the input-matrix + * + */ + std::complex<value_type> getComplex2x2EW(const size_type k) { + std::complex<value_type> res; + res = square(R[k-1][k-1]+R[k][k])/4.0+R[k-1][k]*R[k][k-1]-R[k-1][k-1]*R[k][k]; + res = sqrt(res); + res += (R[k-1][k-1]+R[k][k])/2.0; + return res; + } + + /** \brief Performes a double shift for submatrix defined by range r + */ + + void doubleShift(irange r) + { + using mtl::conj; + value_type s,t; + + if(isRealEW(r.finish()-1)) { + std::pair<value_type, value_type> ews = get2x2EW(r.finish()-1); + s = ews.first+ews.second; + t = ews.first*ews.second; + } + else { + std::complex<value_type> ew = getComplex2x2EW(r.finish()-1); + s = 2.0*ew.real(); + t = std::abs(ew*conj(ew)); + } + + Matrix RIter(R[r][r]*R[r][r] - s*R[r][r] + t*I[r][r]); + + qr_givens_solver<Matrix> QR(RIter); + QR.setTolerance(eps); + QR.calc(); + + RIter = R[r][r]; + R[r][r] = (QR.getQ()) * RIter * trans(QR.getQ()); + + } + + + + /** \brief Performes a single shift for submatrix defined by range r + */ + void singleShift(irange r) { + value_type sh = get2x2EW(r.finish()-1).first; + if(!(std::abs(sh) >= 0.0)) { + sh = R[r.finish()-1][r.finish()-1]; + } + Matrix RIter(R[r][r] - sh*I[r][r]); //Shift wird abgezogen + + qr_givens_solver<Matrix> QR(RIter); //QR-Zerlegung + QR.setTolerance(eps); + QR.calc(); + + R[r][r] = ((QR.getR())*trans(QR.getQ())) + sh*I[r][r]; //QR-Iteration mit dem Rückshift + + } + +}; + +/// Calculation of eigenvalues of general matrix A +/** Not yet tested for complex matrices. **/ +template <typename Matrix> +dense_vector<std::complex<typename Collection<Matrix>::value_type> > +inline eigenvalues(const Matrix& A) +{ + eigenvalue_solver<Matrix> s(A); + s.calc(); + return s.get_eigenvalues(); +} + + +}} // namespace mtl::matrix + +#endif // MTL_MATRIX_EIGENVALUE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/eigenvalue_symmetric.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/eigenvalue_symmetric.hpp new file mode 100644 index 0000000000000000000000000000000000000000..ef1f6f144d4e482fe8019ba9b56a107108e9d85f --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/eigenvalue_symmetric.hpp @@ -0,0 +1,177 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +// With contributions from Cornelius Steinhardt + +#ifndef MTL_MATRIX_EIGENVALUE_SYMMETRIC_INCLUDE +#define MTL_MATRIX_EIGENVALUE_SYMMETRIC_INCLUDE + +#include <cmath> +#include <boost/utility.hpp> +#include <boost/numeric/linear_algebra/identity.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/make_copy_or_reference.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/concept/magnitude.hpp> +#include <boost/numeric/mtl/operation/conj.hpp> +#include <boost/numeric/mtl/operation/diagonal.hpp> +#include <boost/numeric/mtl/operation/givens.hpp> +#include <boost/numeric/mtl/operation/hessenberg.hpp> +#include <boost/numeric/mtl/operation/householder.hpp> +#include <boost/numeric/mtl/operation/qr.hpp> +#include <boost/numeric/mtl/operation/rank_one_update.hpp> +#include <boost/numeric/mtl/operation/signum.hpp> +#include <boost/numeric/mtl/operation/trans.hpp> + +#include <boost/numeric/mtl/vector/dense_vector.hpp> +#include <boost/numeric/mtl/vector/parameter.hpp> +#include <boost/numeric/mtl/matrix/dense2D.hpp> +#include <boost/numeric/mtl/matrix/parameter.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { namespace matrix { + + +/// Eigenvalues of symmetric matrix A with implicit QR algorithm +// Return Diagonalmatrix with eigenvalues as diag(A) +template <typename Matrix> +mtl::vector::dense_vector<typename Collection<Matrix>::value_type, vector::parameters<> > +inline qr_sym_imp(const Matrix& A) +{ + vampir_trace<5010> tracer; + using std::abs; using mtl::signum; using mtl::real; + typedef typename Collection<Matrix>::value_type value_type; + typedef typename Magnitude<value_type>::type magnitude_type; // to multiply with 2 not 2+0i + typedef typename Collection<Matrix>::size_type size_type; + size_type ncols = num_cols(A), nrows = num_rows(A), N; + value_type zero= math::zero(A[0][0]), h00, h10, h11, beta, mu, a, b, tol; + const magnitude_type two(2); + Matrix Q(nrows,ncols), H(nrows,ncols), G(2,2); + + tol= 1.0e-8; // ????evtl ein Iterator wie bei den Gleichungssystemen, Problem: Keine Rechte Seite bzw b + + MTL_THROW_IF(ncols != nrows , matrix_not_square()); + + // Hessenberg_form of Matrix A + H= hessenberg(A); + N= nrows; + + // QR_algo with implizit sym QR-step from Wilkinson + while (1) { + h00= H[N-2][N-2]; + h10= H[N-1][N-2]; + h11= H[N-1][N-1]; + + //reduction, residuum and watch for breakdown + if(abs(h10) < tol * abs(h11 + h00)) + N--; + if (N < 2) + break; + + // Wilkinson_shift + beta= (h00 - h11) / two; + mu = h11 + (beta != zero ? beta - signum(beta) * sqrt(beta * beta + h10 * h10) : -h10); + a= H[0][0] - mu, b= H[1][0]; + + //implizit QR-step + for (size_type k = 0; k < N - 1; k++) { + givens<Matrix>(H, a, b).trafo(k); + if (k < N - 2) + a= H[k+1][k], b= H[k+2][k]; + } + } + return diagonal(H); +} + + +/// Evaluation of eigenvalues with QR-Algorithm of matrix A +// Return Diagonalmatrix with eigenvalues as diag(A) +template <typename Matrix> +mtl::vector::dense_vector<typename Collection<Matrix>::value_type, vector::parameters<> > +inline qr_algo(const Matrix& A, typename Collection<Matrix>::size_type itMax) +{ + vampir_trace<5011> tracer; + typedef typename Collection<Matrix>::size_type size_type; + size_type ncols = num_cols(A), nrows = num_rows(A); + Matrix Q(nrows, ncols), H(nrows, ncols), R(nrows, ncols); + + MTL_THROW_IF(ncols != nrows , matrix_not_square()); + + H= hessenberg(A); + for (size_type i = 0; i < itMax; i++) { + boost::tie(Q, R)= qr_factors(H); + H= R * Q; + } + return diagonal(H); +} + + +# ifdef MTL_SYMMETRIC_EIGENVALUE_WITH_QR + +/// Calculation of eigenvalues of symmetric matrix A +template <typename Matrix> +mtl::vector::dense_vector<typename Collection<Matrix>::value_type, vector::parameters<> > +inline eigenvalue_symmetric(const Matrix& A, typename Collection<Matrix>::size_type itMax) +{ + return qr_algo(A, itMax == 0 ? num_rows(A) : itMax); +} + +#else + +/// Calculation of eigenvalues of symmetric matrix A +template <typename Matrix> +mtl::vector::dense_vector<typename Collection<Matrix>::value_type, vector::parameters<> > +inline eigenvalue_symmetric(const Matrix& A, typename Collection<Matrix>::size_type) +{ + typedef dense2D<typename Collection<Matrix>::value_type, parameters<> > arg_type; + make_in_copy_or_reference<arg_type, Matrix> copy_or_ref(A); + return qr_sym_imp(copy_or_ref.value); +} + +#endif + +#if 0 // Too nasty to get it through all warnings :-! + +/// Calculation of eigenvalues of symmetric matrix A +template <typename Matrix> +mtl::vector::dense_vector<typename Collection<Matrix>::value_type, vector::parameters<> > +inline eigenvalue_symmetric(const Matrix& A, + typename Collection<Matrix>::size_type itMax= 0) +{ + vampir_trace<5012> tracer; +# ifdef MTL_SYMMETRIC_EIGENVALUE_WITH_QR + return qr_algo(A, itMax == 0 ? num_rows(A) : itMax); +# else + itMax= 0; // for not yelling at unused variable + // qr_sym_imp works only with dense matrices of dynamic size, for other types copy + typedef dense2D<typename Collection<Matrix>::value_type> arg_type; + make_in_copy_or_reference<arg_type, Matrix> copy_or_ref(A); + return qr_sym_imp(copy_or_ref.value); +# endif +} + +#endif + +template <typename Matrix> +mtl::vector::dense_vector<typename Collection<Matrix>::value_type, vector::parameters<> > +inline eigenvalue_symmetric(const Matrix& A) +{ + return eigenvalue_symmetric(A, 0); +} + + +}} // namespace mtl::matrix + + +#endif // MTL_MATRIX_EIGENVALUE_SYMMETRIC_INCLUDE + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/element_structure_algorithms.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/element_structure_algorithms.hpp new file mode 100644 index 0000000000000000000000000000000000000000..905192cdf7109b5660e86561be368ae8b5ecd128 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/element_structure_algorithms.hpp @@ -0,0 +1,256 @@ + +#ifndef ELEMENT_STRUCTURE_ALGORITHMS +#define ELEMENT_STRUCTURE_ALGORITHMS + + +#include <boost/numeric/mtl/mtl.hpp> +#include <boost/numeric/mtl/matrix/element.hpp> + +namespace imf { + +// Extracts an artificial element structure from the given sparse matrix. This +// algorithm +template< class Element_struct, class Matrix > +void greedy_extract_element_structure(Element_struct& es, Matrix& M , std::string& output) { + +/******************************************************************************* + * PHASE 1: Generate Artificial 1x1 and kxk Elements + ******************************************************************************/ + + typedef unsigned int usint; + + // Elements + typedef typename Matrix::value_type value_type; + typedef typename Matrix::size_type size_type; + typedef mtl::matrix::element<value_type> element_type; + typedef typename element_type::index_type index_type; + typedef typename element_type::matrix_type matrix_type; + // typedef typename element_type::neighbor_iterator neigh_iterator; + +#if 0 + // Sparse matrices + typedef glas::compressed_sparse_structure<glas::row_orientation> sparse_structure; + typedef typename sparse_structure::compressed_index_array_type compressed_index_array_type; + typedef glas::sparse_matrix<value_type, sparse_structure> sparse_type; + + compressed_index_array_type& row_start = glas::compressed_index_array( M ); + typename sparse_structure::index_array_type& col_idx = glas::index_array( M ); + typename sparse_type::value_array_type& values = glas::value_array(M); +#endif + std::vector<size_type> row_start(M.ref_major()); + std::vector<size_type> col_idx(M.ref_minor()); + std::vector<value_type> values(M.data); + + const value_type ZERO = value_type(0); + const usint nb_rows = num_rows( M ); + + // Determine a "suitable" guess for the maximum size of the elements. + double avg_nnz_row = M.nnz(); + double std_dev = 0; + for(usint r = 0; r < nb_rows; ++r) { + std_dev += pow(double(row_start[r+1]-row_start[r]), 2) / double(nb_rows); + } + int max_idx = int(avg_nnz_row + 2*std_dev) + 1; + if( max_idx < 7 ) { + max_idx = 7; + } + + std::cout << "max_idx="<<max_idx<< std::endl; + + std::cout << "nnz="<< M.nnz() << std::endl; + + std::vector<element_type*> elements; + elements.reserve(M.nnz() / max_idx); + + std::vector<int> idx; + idx.reserve(max_idx); + + // Generate the element matrices from the given sparse matrix. + int seq_nbr = 0; + for(usint row = 0; row < nb_rows; ++row) { + for( + usint col_off = row_start[row]; + col_off < row_start[row+1]; + ) { + std::cout<< "row="<< row << "-"<< nb_rows << "\n"; + // We have at most k different indices. + idx.clear(); + idx.push_back(row); + for( + int my_size = 1; + (my_size < max_idx) && (col_off < row_start[row+1]); + ++col_off + ) { + if( col_idx[col_off] != row ) { + idx.push_back( col_idx[col_off] ); + ++my_size; + } + } + std::sort( idx.begin(), idx.end() ); + + // Construct index. + index_type el_index( idx.size() ); + for(usint i = 0; i < idx.size(); ++i) { + el_index(i) = idx[i]; + } + + // Copy values. + const usint n = size(el_index); + matrix_type el_vals(n,n); + el_vals = ZERO; + bool non_zero = false; + for(usint i = 0; i < n; ++i) { + const int lrow = el_index(i); + + // Seek matching indices. + usint k = row_start[lrow]; + usint j = 0; + while( (k < row_start[lrow+1]) && (j < n) ) { + const int diff = el_index(j) - col_idx[k]; + if(diff > 0) { + ++k; + } else if(diff < 0) { + ++j; + } else { + // We found a match. Copy the value. + el_vals( i,j ) = values[k]; + values[k] = ZERO; + non_zero |= (el_vals(i,j) != ZERO); + ++j; + ++k; + } + } + } + + // if the element matrix is non-zero, add it. + if(non_zero) { + element_type* el = new element_type(seq_nbr, el_index, el_vals); + elements.push_back(el); + ++seq_nbr; + } + } + // If the diagonal entry is not included in the sparsity of the matrix, + // it is wise *not* to add an element with a single node. In this + // manner, we will avoid the situation wherein that element is selected, + // and the matrix is zero at this position, but where the elimination of + // a different element (which includes the node of this row as off- + // diagonal element) would make the matrix at this position non-zero + // (and hence invertible). + } + + // Remove unnecessary nodes. + for(usint i = 0; i < elements.size(); ++i) { + element_type& el = *(elements[i]); + index_type& idx = el.get_indices(); + matrix_type& vals = el.get_values(); + + std::vector<int> remove_nodes; + for(int c = 0; c < el.nb_vars(); ++c) { + bool all_zero = true; + for(int k = 0; k < el.nb_vars(); ++k) { + all_zero &= ( (vals(k,c) == ZERO) && (vals(c,k) == ZERO) ); + } + if(all_zero) { + remove_nodes.push_back( idx(c) ); + } + } + el.remove_nodes(remove_nodes, el); + } + + // Generate neighbourhood information. + std::vector<int>* node_element_map = new std::vector<int>[nb_rows]; + for( usint i = 0; i < elements.size(); ++i ) { + element_type& el = *(elements[i]); + index_type& idx = el.get_indices(); + for(int j = 0; j < el.nb_vars(); ++j) { + node_element_map[ idx(j) ].push_back(el.get_id()); + } + } + // Construct neighbourhood set for every element. + for( usint i = 0; i < elements.size(); ++i ) { + element_type& el = *(elements[i]); + index_type& idx = el.get_indices(); + std::set<int> neighs; + for(int j = 0; j < el.nb_vars(); ++j) { + neighs.insert( + node_element_map[ idx(j) ].begin(), + node_element_map[ idx(j) ].end() + ); + } + // An element shouldn't neighbour itself. + neighs.erase( el.get_id() ); + for( + std::set<int>::iterator it = neighs.begin(); + it != neighs.end(); + ++it + ) { + el.get_neighbors().push_back( elements[*it] ); + } + } + delete[] node_element_map; + +/******************************************************************************* + * PHASE 3: Construct Grid + ******************************************************************************/ + const int orig_els = elements.size(); + element_type* elems = new element_type[ elements.size() ]; + + // Map the location of the new elements. + std::vector<int> seq_nbr_map( orig_els, -1 ); + for(usint i = 0; i < elements.size(); ++i) { + seq_nbr_map[ elements[i]->get_id() ] = i; + } + + // Construct the element set. + for(usint i = 0; i < elements.size(); ++i) { + // Copy the element to the grid. + elems[i] = *(elements[i]); + element_type& el = elems[i]; + el.get_id() = i; + + typename element_type::neighbor_collection_type& neighs = + el.get_neighbors(); + for( usint j = 0; j < neighs.size(); ++j ) { + // Remap the neighbour pointer to the new location. + int offset = seq_nbr_map[neighs[j]->get_id()]; + neighs[j] = elems + offset; + + assert( offset >= 0 ); + } + + // Clear the data of the copy. + elements[i]->clear(); + } +#if 0 +#ifndef NDEBUG +#if VERBOSE_MODE > 10 + std::cout << "The elements in the algebraic grid: " << std::endl; + for(usint i = 0; i < elements.size(); ++i) { + std::cout << elems[i] << std::endl; + } +#endif +#endif +#endif + + es.consume(orig_els, nb_rows, elems); +#if 0 + element_structure<value_type>* es = new element_structure<value_type>( + orig_els, nb_rows, elems + ); +#endif + // Delete the copied elements. + for(usint i = 0; i < elements.size(); ++i) { + assert( elements[i] ); + delete elements[i]; + } + elements.clear(); + + std::cout << "Generated " << orig_els << " artificial elements." << + std::endl; + es.write_to_file(output); +// return es; +} + +} // end namespace imf + +#endif /* ELEMENT_STRUCTURE_ALGORITHMS */ diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/entry1D.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/entry1D.hpp new file mode 100644 index 0000000000000000000000000000000000000000..fbeb44bcb3f780ac2cab959044a5b83397c2d7e0 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/entry1D.hpp @@ -0,0 +1,55 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_ENTRY1D_INCLUDE +#define MTL_ENTRY1D_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/matrix/multi_vector.hpp> + +namespace mtl { + + namespace vector { + + template <typename Vector> + inline typename Collection<Vector>::value_type const& + entry1D(const Vector& v, typename Collection<Vector>::size_type i) + { + return v[i]; + } + + template <typename Vector> + inline typename Collection<Vector>::value_type& + entry1D(Vector& v, typename Collection<Vector>::size_type i) + { + return v[i]; + } + } + + namespace matrix { + + template <typename Vector> + inline Vector& entry1D(multi_vector<Vector>& A, typename Collection<Vector>::size_type i) + { + return A.vector(i); + } + + template <typename Vector> + inline Vector const& entry1D(const multi_vector<Vector>& A, typename Collection<Vector>::size_type i) + { + return A.vector(i); + } + } + +} // namespace mtl + +#endif // MTL_ENTRY1D_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/entry_similar.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/entry_similar.hpp new file mode 100644 index 0000000000000000000000000000000000000000..eea2fee2e32b53d6083665a02885fa43eddea66e --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/entry_similar.hpp @@ -0,0 +1,70 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_ENTRY_SIMILAR_INCLUDE +#define MTL_ENTRY_SIMILAR_INCLUDE + + + +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> + + +namespace mtl { + + namespace matrix { + + template <typename Matrix, typename Value> + bool inline entry_similar(const Matrix& A, typename Collection<Matrix>::size_type i, + typename Collection<Matrix>::size_type j, const Value& v, const Value& eps, tag::universe) + { + using std::abs; + return abs(A[i][j] - v) <= eps; + } + + /// Compares A[i][j] with \p v returns false if larger than eps + /** Function works on distributed matrices where only one process tests and the other return true. + The functions enables writing tests that work in parallel (and all other platforms). **/ + template <typename Matrix, typename Value> + bool inline entry_similar(const Matrix& A, typename Collection<Matrix>::size_type i, + typename Collection<Matrix>::size_type j, const Value& v, const Value& eps) + { + return entry_similar(A, i, j, v, eps, typename mtl::traits::category<Matrix>::type()); + } + + } // namespacs matrix + + namespace vector { + + template <typename Vector, typename Value> + bool inline entry_similar(const Vector& x, typename Collection<Vector>::size_type i, + const Value& v, const Value& eps, tag::universe) + { + using std::abs; + return abs(x[i] - v) <= eps; + } + + /// Compares x[i] with \p v returns false if larger than eps + /** Function works on distributed matrices where only one process tests and the other return true. + The functions enables writing tests that work in parallel (and all other platforms). **/ + template <typename Vector, typename Value> + bool inline entry_similar(const Vector& x, typename Collection<Vector>::size_type i, + const Value& v, const Value& eps) + { + return entry_similar(x, i, v, eps, typename mtl::traits::category<Vector>::type()); + } + + } + +} // namespace mtl + +#endif // MTL_ENTRY_SIMILAR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/evaluate_lazy.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/evaluate_lazy.hpp new file mode 100644 index 0000000000000000000000000000000000000000..cb54c22dbb2f14184cd8e4f56a8a9b7d2ee34018 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/evaluate_lazy.hpp @@ -0,0 +1,37 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_EVALUATE_LAZY_INCLUDE +#define MTL_EVALUATE_LAZY_INCLUDE + +#include <boost/numeric/mtl/operation/lazy_assign.hpp> +#include <boost/numeric/mtl/vector/lazy_reduction.hpp> + + +namespace mtl { + +/// Overloaded function to evaluate lazy expressions +template <typename T, typename U, typename Assign> +void inline evaluate_lazy(lazy_assign<T, U, Assign>& lazy) +{ + Assign::first_update(lazy.first, lazy.second); +} + +template <typename T, typename Vector, typename Functor, typename Assign> +void inline evaluate_lazy(lazy_assign<T, vector::lazy_reduction<Vector, Functor>, Assign>& lazy) +{ + lazy.first= Functor::post_reduction(vector::reduction<4, Functor, T>::apply(lazy.second.v)); +} + +} // namespace mtl + +#endif // MTL_EVALUATE_LAZY_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/extended_complex.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/extended_complex.hpp new file mode 100644 index 0000000000000000000000000000000000000000..2b79001c3b81a9593238614681f075560bc20df5 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/extended_complex.hpp @@ -0,0 +1,206 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_OPERATION_EXTENDED_COMPLEX_INCLUDE +#define MTL_OPERATION_EXTENDED_COMPLEX_INCLUDE + +#include <complex> +#include <boost/utility/enable_if.hpp> +#include <boost/type_traits/is_unsigned.hpp> +#include <boost/numeric/mtl/utility/different_non_complex.hpp> +#include <boost/numeric/mtl/utility/extended_complex.hpp> + + +// Now we dare writing in the standard namespace +namespace std { + +// ======== +// Addition +// ======== + +template <typename T, typename U> +typename mtl::traits::extended_complex<T, U>::type // implicit enable_if +inline operator+(const T& x, const complex<U>& y) +{ + typedef typename mtl::traits::extended_complex<T, U>::type type; + return type(x + real(y), imag(y)); +} + +template <typename T, typename U> +typename mtl::traits::extended_complex<T, U>::type // implicit enable_if +inline operator+(const complex<T>& x, const U& y) +{ + typedef typename mtl::traits::extended_complex<T, U>::type type; + return type(real(x) + y, imag(x)); +} + +template <typename T, typename U> +typename mtl::traits::extended_complex<T, U>::type // implicit enable_if +inline operator+(const complex<T>& x, const complex<U>& y) +{ + typedef typename mtl::traits::extended_complex<T, U>::type type; + return type(real(x) + real(y), imag(x) + imag(y)); +} + +// =========== +// Subtraction +// =========== + +namespace detail { + + // To avoid stupid warnings on unary - for unsigned int specialize it + template <typename T> + typename boost::disable_if<boost::is_unsigned<T>, T>::type + inline negate_helper(const T& x) + { return -x; } + + template <typename T> + typename boost::enable_if<boost::is_unsigned<T>, T>::type + inline negate_helper(const T& x) + { return T(0) - x; } +} + +template <typename T, typename U> +typename mtl::traits::extended_complex<T, U>::type // implicit enable_if +inline operator-(const T& x, const complex<U>& y) +{ + typedef typename mtl::traits::extended_complex<T, U>::type type; + return type(x - real(y), detail::negate_helper(imag(y))); // see above for helper +} + +template <typename T, typename U> +typename mtl::traits::extended_complex<T, U>::type // implicit enable_if +inline operator-(const complex<T>& x, const U& y) +{ + typedef typename mtl::traits::extended_complex<T, U>::type type; + return type(real(x) - y, imag(x)); +} + +template <typename T, typename U> +typename mtl::traits::extended_complex<T, U>::type // implicit enable_if +inline operator-(const complex<T>& x, const complex<U>& y) +{ + typedef typename mtl::traits::extended_complex<T, U>::type type; + return type(real(x) - real(y), imag(x) - imag(y)); +} + +// ============== +// Multiplication +// ============== + +template <typename T, typename U> +typename mtl::traits::extended_complex<T, U>::type // implicit enable_if +inline operator*(const T& x, const complex<U>& y) +{ + typedef typename mtl::traits::extended_complex<T, U>::type type; + return type(x * real(y), x * imag(y)); +} + +template <typename T, typename U> +typename mtl::traits::extended_complex<T, U>::type // implicit enable_if +inline operator*(const complex<T>& x, const U& y) +{ + typedef typename mtl::traits::extended_complex<T, U>::type type; + return type(real(x) * y, imag(x) * y); +} + +template <typename T, typename U> +typename mtl::traits::extended_complex<T, U>::type // implicit enable_if +inline operator*(const complex<T>& x, const complex<U>& y) +{ + typedef typename mtl::traits::extended_complex<T, U>::type type; + return type(real(x) * real(y) - imag(x) * imag(y), + real(x) * imag(y) + imag(x) * real(y)); +} + +// ======== +// Division +// ======== +// Not necessarily the most efficient implementations +// Dealing primarily with types + +template <typename T, typename U> +typename mtl::traits::extended_complex<T, U>::type // implicit enable_if +inline operator/(const T& x, const complex<U>& y) +{ + typedef typename mtl::traits::extended_complex<T, U>::type type; + type r(x); + return r/= type(real(y), imag(y)); +} + +template <typename T, typename U> +typename mtl::traits::extended_complex<T, U>::type // implicit enable_if +inline operator/(const complex<T>& x, const U& y) +{ + typedef typename mtl::traits::extended_complex<T, U>::type type; + return type(real(x) / y, imag(x) / y); +} + +template <typename T, typename U> +typename mtl::traits::extended_complex<T, U>::type // implicit enable_if +inline operator/(const complex<T>& x, const complex<U>& y) +{ + typedef typename mtl::traits::extended_complex<T, U>::type type; + type r(real(x), imag(x)); + return r/= type(real(y), imag(y)); +} + + +// ========== +// Comparison +// ========== + +template <typename T, typename U> +typename boost::enable_if<mtl::traits::different_non_complex<T, U>, bool>::type +inline operator==(const complex<T>& x, const U& y) +{ + return real(x) == y && imag(x) == T(0); +} + +template <typename T, typename U> +typename boost::enable_if<mtl::traits::different_non_complex<T, U>, bool>::type +inline operator==(const T& x, const complex<U>& y) +{ + return x == real(y) && imag(y) == T(0); +} + +template <typename T, typename U> +typename boost::enable_if<mtl::traits::different_non_complex<T, U>, bool>::type +inline operator==(const complex<T>& x, const complex<U>& y) +{ + return real(x) == real(y) && imag(x) == imag(y); +} + +template <typename T, typename U> +typename boost::enable_if<mtl::traits::different_non_complex<T, U>, bool>::type +inline operator!=(const complex<T>& x, const U& y) +{ + return real(x) != y || imag(x) != T(0); +} + +template <typename T, typename U> +typename boost::enable_if<mtl::traits::different_non_complex<T, U>, bool>::type +inline operator!=(const T& x, const complex<U>& y) +{ + return x != real(y) || imag(y) != T(0); +} + +template <typename T, typename U> +typename boost::enable_if<mtl::traits::different_non_complex<T, U>, bool>::type +inline operator!=(const complex<T>& x, const complex<U>& y) +{ + return real(x) != real(y) || imag(x) != imag(y); +} + +} // namespace std + +#endif // MTL_OPERATION_EXTENDED_COMPLEX_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/fill.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/fill.hpp new file mode 100644 index 0000000000000000000000000000000000000000..28a5434c8c49e0e976ea4cd290e851294ebf02c4 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/fill.hpp @@ -0,0 +1,35 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_FILL_INCLUDE +#define MTL_FILL_INCLUDE + +#include <algorithm> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace mtl { + +// Sets all values of a matrix +template <class Matrix> +void fill(Matrix& ma, typename Matrix::value_type value) +{ + vampir_trace<3009> tracer; + std::fill(ma.elements(), ma.elements()+ma.num_elements(), value); +} + +// Temporary solution +// will be replaced by sequences and cursors generated by begin<all>(ma) and end<all>(ma) +// Using segmented cursors, matrices with non-contigous element storing can be handled + +} // namespace mtl + +#endif // MTL_FILL_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/frobenius_norm.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/frobenius_norm.hpp new file mode 100644 index 0000000000000000000000000000000000000000..021bc5465b96635d85d7bec0eb0b27c3e73ad4b4 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/frobenius_norm.hpp @@ -0,0 +1,54 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_FROBENIUS_NORM_INCLUDE +#define MTL_FROBENIUS_NORM_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/is_row_major.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/utility/property_map.hpp> +#include <boost/numeric/mtl/operation/max_of_sums.hpp> +#include <boost/numeric/mtl/operation/squared_abs.hpp> +#include <boost/numeric/linear_algebra/identity.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { namespace matrix { + +/// Frobenius norm, i.e. square root of sum of squares of all entries sqrt(sum_i sum_j(|a[i][j]|^2)) +template <typename Matrix> +typename RealMagnitude<typename Collection<Matrix>::value_type>::type +inline frobenius_norm(const Matrix& matrix) +{ + vampir_trace<3010> tracer; + using std::sqrt; using std::abs; using math::zero; + namespace traits = mtl::traits; + typename traits::const_value<Matrix>::type value(matrix); + + typedef typename Collection<Matrix>::value_type value_type; + typedef typename RealMagnitude<value_type>::type real_type; + real_type ref, sum= zero(ref); + + typedef typename traits::range_generator<tag::major, Matrix>::type cursor_type; + typedef typename traits::range_generator<tag::nz, cursor_type>::type icursor_type; + + for (cursor_type cursor = begin<tag::major>(matrix), cend = end<tag::major>(matrix); cursor != cend; ++cursor) + for (icursor_type icursor = begin<tag::nz>(cursor), icend = end<tag::nz>(cursor); icursor != icend; ++icursor) + sum+= squared_abs(value(*icursor)); + return sqrt(sum); +} + +}} // namespace mtl::matrix + +#endif // MTL_FROBENIUS_NORM_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/fuse.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/fuse.hpp new file mode 100644 index 0000000000000000000000000000000000000000..ecc3e93a6cf1bc50156afa7c3f8db58f35bd742a --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/fuse.hpp @@ -0,0 +1,44 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_FUSE_INCLUDE +#define MTL_FUSE_INCLUDE + +#include <boost/utility/enable_if.hpp> +#include <boost/mpl/and.hpp> + +#include <boost/numeric/mtl/utility/is_lazy.hpp> +#include <boost/numeric/mtl/operation/fused_expr.hpp> + +namespace mtl { + +/// Fuse two lazy expressions (operator notation of fuse) +template <typename T, typename U> +typename boost::enable_if<boost::mpl::and_<traits::is_lazy<T>, traits::is_lazy<U> >, fused_expr<T, U> >::type +operator||(const T& x, const U& y) +{ + return fused_expr<T, U>(const_cast<T&>(x), const_cast<U&>(y)); +} + +/// Fuse two lazy expressions +template <typename T, typename U> +typename boost::enable_if<boost::mpl::and_<traits::is_lazy<T>, traits::is_lazy<U> >, fused_expr<T, U> >::type +fuse(const T& x, const U& y) +{ + return fused_expr<T, U>(const_cast<T&>(x), const_cast<U&>(y)); +} + + + +} // namespace mtl + +#endif // MTL_FUSE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/fused_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/fused_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..99bb92c9e2a887692416e24adc9d55ee2f914dc8 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/fused_expr.hpp @@ -0,0 +1,153 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_FUSED_EXPR_INCLUDE +#define MTL_FUSED_EXPR_INCLUDE + +#include <boost/mpl/bool.hpp> +#include <boost/mpl/and.hpp> +#include <boost/numeric/mtl/operation/index_evaluator.hpp> +#include <boost/numeric/mtl/utility/index_evaluatable.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace mtl { + +/// Expression template for fusing other expression +template <typename T, typename U> +struct fused_expr +{ + typedef boost::mpl::and_<traits::forward_index_evaluatable<T>, traits::forward_index_evaluatable<U> > forward; + typedef boost::mpl::and_<traits::backward_index_evaluatable<T>, traits::backward_index_evaluatable<U> > backward; + + fused_expr(T& first, U& second) + : first(first), second(second), delayed_assign(false) + { + first.delay_assign(); second.delay_assign(); + } + + ~fused_expr() { if (!delayed_assign) eval(forward(), backward()); } + + void delay_assign() const { delayed_assign= true; } + + template <typename TT, typename UU> + void forward_eval_loop(const TT& const_first_eval, const UU& const_second_eval, boost::mpl::false_) + { + vampir_trace<6001> tracer; + // hope there is a more elegant way; copying the arguments causes errors due to double destructor evaluation + TT& first_eval= const_cast<TT&>(const_first_eval); + UU& second_eval= const_cast<UU&>(const_second_eval); + MTL_DEBUG_THROW_IF(mtl::vector::size(first_eval) != mtl::vector::size(second_eval), incompatible_size()); + + for (std::size_t i= 0, s= size(first_eval); i < s; i++) { + first_eval(i); second_eval(i); + } + } + + template <typename TT, typename UU> + void forward_eval_loop(const TT& const_first_eval, const UU& const_second_eval, boost::mpl::true_) + { + vampir_trace<6002> tracer; + // hope there is a more elegant way; copying the arguments causes errors due to double destructor evaluation + TT& first_eval= const_cast<TT&>(const_first_eval); + UU& second_eval= const_cast<UU&>(const_second_eval); + MTL_DEBUG_THROW_IF(mtl::vector::size(first_eval) != mtl::vector::size(second_eval), incompatible_size()); + + const std::size_t s= size(first_eval), sb= s >> 2 << 2; + + for (std::size_t i= 0; i < sb; i+= 4) { + first_eval.template at<0>(i); second_eval.template at<0>(i); + first_eval.template at<1>(i); second_eval.template at<1>(i); + first_eval.template at<2>(i); second_eval.template at<2>(i); + first_eval.template at<3>(i); second_eval.template at<3>(i); + } + + for (std::size_t i= sb; i < s; i++) { + first_eval(i); second_eval(i); + } + } + + // Forward evaluation dominates backward + template <bool B2> + void eval(boost::mpl::true_, boost::mpl::bool_<B2>) + { +#ifdef MTL_LAZY_LOOP_WO_UNROLL + typedef boost::mpl::false_ to_unroll; +#else + typedef boost::mpl::and_<traits::unrolled_index_evaluatable<T>, traits::unrolled_index_evaluatable<U> > to_unroll; +#endif + // Currently lazy evaluation is only available on vector expressions, might change in the future + // std::cout << "Forward evaluation\n"; + forward_eval_loop(index_evaluator(first), index_evaluator(second), to_unroll()); + } + + template <typename TT, typename UU> + void backward_eval_loop(const TT& const_first_eval, const UU& const_second_eval, boost::mpl::false_) + { + vampir_trace<6003> tracer; + // hope there is a more elegant way; copying the arguments causes errors due to double destructor evaluation + TT& first_eval= const_cast<TT&>(const_first_eval); + UU& second_eval= const_cast<UU&>(const_second_eval); + MTL_DEBUG_THROW_IF(mtl::vector::size(first_eval) != mtl::vector::size(second_eval), incompatible_size()); + + for (std::size_t i= size(first_eval); i-- > 0; ) { + // std::cout << "i is " << i << "\n"; + first_eval(i); second_eval(i); + } + } + + template <typename TT, typename UU> + void backward_eval_loop(const TT& const_first_eval, const UU& const_second_eval, boost::mpl::true_) + { + vampir_trace<6004> tracer; + // hope there is a more elegant way; copying the arguments causes errors due to double destructor evaluation + TT& first_eval= const_cast<TT&>(const_first_eval); + UU& second_eval= const_cast<UU&>(const_second_eval); + MTL_DEBUG_THROW_IF(mtl::vector::size(first_eval) != mtl::vector::size(second_eval), incompatible_size()); + + std::size_t s= size(first_eval), i= s-1, m= s % 4; + for (; m; m--) { + // std::cout << "i is " << i << "\n"; + first_eval(i); second_eval(i--); + } + for(long j= i - 3; j >= 0; j-= 4) { + // std::cout << "i is " << j+3 << ".." << j << "\n"; + first_eval.template at<3>(j); second_eval.template at<3>(j); + first_eval.template at<2>(j); second_eval.template at<2>(j); + first_eval.template at<1>(j); second_eval.template at<1>(j); + first_eval.template at<0>(j); second_eval.template at<0>(j); + } + } + + // Backward evaluation if forward isn't possible + void eval(boost::mpl::false_, boost::mpl::true_) + { + // std::cout << "Backward evaluation\n"; + backward_eval_loop(index_evaluator(first), index_evaluator(second), boost::mpl::true_()); + } + + // Sequential evaluation + void eval(boost::mpl::false_, boost::mpl::false_) + { + // std::cout << "Non-fused evaluation\n"; + evaluate_lazy(first); evaluate_lazy(second); + } + + T& first; + U& second; + mutable bool delayed_assign; +}; + + +} // namespace mtl + +#endif // MTL_FUSED_EXPR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/fused_index_evaluator.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/fused_index_evaluator.hpp new file mode 100644 index 0000000000000000000000000000000000000000..9c8f151372b0278237cf39a4c2813d3e854cb02b --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/fused_index_evaluator.hpp @@ -0,0 +1,45 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_FUSED_INDEX_EVALUATOR_INCLUDE +#define MTL_FUSED_INDEX_EVALUATOR_INCLUDE + +#include <boost/numeric/mtl/utility/index_evaluator.hpp> + +namespace mtl { namespace vector { + +template <typename T, typename U> +struct fused_index_evaluator +{ + fused_index_evaluator(T& first, U& second) + : first(index_evaluator(first)), second(index_evaluator(second)) {} + + template <unsigned Offset> + void at(std::size_t i) + { + first.template at<Offset>(i); + second.template at<Offset>(i); + } + + void operator() (std::size_t i) { at<0>(i); } + void operator[] (std::size_t i) { at<0>(i); } + + typename traits::index_evaluator<T>::type first; + typename traits::index_evaluator<U>::type second; +}; + +template <typename T, typename U> +inline size_t size(const fused_index_evaluator<T, U>& expr) { return size(expr.first); } + +}} // namespace mtl::vector + +#endif // MTL_FUSED_INDEX_EVALUATOR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/givens.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/givens.hpp new file mode 100644 index 0000000000000000000000000000000000000000..228f541aa99f3024ea6b0797ac1c3ea0f649a4e4 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/givens.hpp @@ -0,0 +1,129 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +// With contributions from Cornelius Steinhardt + +#ifndef MTL_MATRIX_GIVENS_INCLUDE +#define MTL_MATRIX_GIVENS_INCLUDE + +#include <cmath> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/irange.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/operation/householder.hpp> +#include <boost/numeric/mtl/operation/rank_one_update.hpp> +#include <boost/numeric/mtl/operation/trans.hpp> + +namespace mtl { namespace matrix { + +/// Given's transformator +/** Requires Hessenberg form, i.e. for transformations near the diagonal. + For general form use qr_givens. + \sa qr_givens. **/ +template <typename Matrix> +class givens +{ + typedef typename Collection<Matrix>::value_type value_type; + typedef typename Collection<Matrix>::size_type size_type; + + public: + /// Re-set the rotation parameters \p a and \p b + void set_rotation(value_type a, value_type b) + { + using std::abs; + value_type zero= math::zero(a), one= math::one(b), t; + + if ( b == zero ) { + c= one; s= zero; + } else if ( abs(b) > abs(a) ) { + t= -a / b; + s= one / sqrt(one + t*t); + c= s * t; + } else { + t= -b / a; + c= one / sqrt(one + t*t); + s= c * t; + } + G= c, s, + -s, c; + } + + + /// Constructor takes %matrix \p H to be transformed and the rotation parameters \p a and \p b + givens(Matrix& H, value_type a, value_type b) : H(H), G(2, 2) + { set_rotation(a, b); } + + /// Given's transformation of \p H with \p G regarding column \p k + Matrix& trafo(const Matrix& G, size_type k) + { + irange r(k,k+2); + // trans(H[r][ind])*= G; H[ind][r]*= G; // most compact form but does not work yet + + Matrix col_block(H[r][iall]), col_perm(trans(G) * col_block); + H[r][iall]= col_perm; + Matrix row_perm(H[iall][r] * G); + H[iall][r]= row_perm; + + return H; + } + + /// Given's transformation of \p H regarding column \p k + Matrix& trafo(size_type k) + { + return trafo(G, k); + } + + private: + Matrix& H, G; + value_type c, s; +}; + +}// namespace matrix + + +namespace vector { + +/// Given's transformator on %vector (swap a*line(k) with b*line(k+1) ) +template <typename Vector> +class givens +{ + typedef typename Collection<Vector>::value_type value_type; + typedef typename Collection<Vector>::size_type size_type; + + public: + /// Constructor takes %vector \p v to be transformed and the rotation parameters \p a and \p b + givens(Vector& v, value_type a, value_type b) : v(v), a(a), b(b) + { } + + /// Given's transformation of \p v with \p a and \p b regarding column \p k + Vector& trafo(size_type k) + { + value_type w1(0), w2(0); + w1= a*v[k] - b*v[k+1]; //given's rotation on solution + w2= b*v[k] + a*v[k+1]; //rotation on vector + v[k]= w1; + v[k+1]= w2; + + return v; + } + + private: + Vector& v; + value_type a, b; +}; + +}// namespace vector + + +} // namespace mtl + +#endif // MTL_MATRIX_GIVENS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/hermitian.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/hermitian.hpp new file mode 100644 index 0000000000000000000000000000000000000000..a1460d2630a13da108a98cfce8e36280ebcd20b8 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/hermitian.hpp @@ -0,0 +1,58 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_HERMITIAN_INCLUDE +#define MTL_HERMITIAN_INCLUDE + +#include <boost/numeric/mtl/matrix/hermitian_view.hpp> +#include <boost/numeric/mtl/matrix/view_ref.hpp> +#include <boost/numeric/mtl/utility/enable_if.hpp> +#include <boost/numeric/mtl/utility/view_code.hpp> +#include <boost/numeric/mtl/utility/viewed_collection.hpp> +#include <boost/numeric/mtl/utility/compose_view.hpp> + +namespace mtl { + + // vector version to be done + + namespace matrix { + + namespace detail { + + template <typename Matrix> + struct hermitian + { + static const unsigned code= mtl::traits::view_toggle_hermitian<mtl::traits::view_code<Matrix> >::value; + typedef typename mtl::traits::compose_view<code, typename mtl::traits::viewed_collection<Matrix>::type>::type result_type; + + static inline result_type apply(const Matrix& A) + { + return result_type(view_ref(A)); + } + }; + + } // namespace detail + + /// Return hermitian of matrix A + template <typename Matrix> + typename mtl::traits::enable_if_matrix<Matrix, typename detail::hermitian<Matrix>::result_type >::type + inline hermitian(const Matrix& A) + { + return detail::hermitian<Matrix>::apply(A); + } + } + + using matrix::hermitian; + +} // namespace mtl + +#endif // MTL_HERMITIAN_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/hessenberg.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/hessenberg.hpp new file mode 100644 index 0000000000000000000000000000000000000000..9408752e6a6ed1aaa49d5f97809d2128c8c0ff73 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/hessenberg.hpp @@ -0,0 +1,194 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +// With contributions from Cornelius Steinhardt + +#ifndef MTL_MATRIX_HESSENBERG_INCLUDE +#define MTL_MATRIX_HESSENBERG_INCLUDE + +#include <cmath> +#include <boost/numeric/linear_algebra/identity.hpp> +#include <boost/numeric/mtl/vector/parameter.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/irange.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/concept/magnitude.hpp> +#include <boost/numeric/mtl/operation/householder.hpp> +#include <boost/numeric/mtl/operation/rank_one_update.hpp> +#include <boost/numeric/mtl/operation/trans.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { namespace matrix { + +/// Hessenberg-Factorization of matrix A with householder-vectors +/** Return Hessenberg matrix and tril(B,-2) are Householder-vectors **/ +template <typename Matrix> +Matrix inline hessenberg_factors(const Matrix& A) +{ + vampir_trace<5014> tracer; + if (num_rows(A) < 3) + return A; + + using mtl::imax; + typedef typename Collection<Matrix>::value_type value_type; + typedef typename Collection<Matrix>::size_type size_type; + size_type ncols = num_cols(A), nrows = num_rows(A); + value_type zero= math::zero(A[0][0]), beta; + Matrix B(clone(A)); + + for(size_type i= 0; i < ncols-2; i++){ + // mtl::vector::dense_vector<value_type> v(B[irange(i+1, imax)][i]); + mtl::vector::dense_vector<value_type, vector::parameters<> > v(nrows-i-1), w(nrows); + for (size_type j = 0; j < size(v); j++) + v[j]= B[j+i+1][i]; + beta= householder(v).second; + v= householder(v).first; +; + if( beta != zero){ + w= beta * B[irange(0,imax)][irange(i+1,imax)] * v; + //rank_one_update(B[irange(0,imax)][irange(i+1,imax)],-w,v); + for(size_type row = 0; row < nrows; row++){ + for(size_type col = i+1; col < ncols; col++){ + B[row][col] -= w[row] * v[col-i-1]; + } + } + //vector*Matrix + for(size_type k=0; k < size(w); k++){ + w[k]= zero; + for(size_type j = 0; j < size(v); j++){ + w[k] += beta * v[j] * B[j+i+1][k]; + } + } + //rank_one_update(A[irange(i+1,imax)][irange(0,imax)],-v,w); + for(size_type row = i+1; row < nrows; row++){ + for(size_type col = 0; col < ncols; col++){ + B[row][col] -= v[row-i-1] * w[col]; + } + } + // B[irange(i+2, imax)][i]= v[irange(1, nrows-i-1)]; + for(size_type row = i+2; row < nrows; row++){ + B[row][i] = v[row-i-1]; + } + } + } + return B; +} + + +/// Extract Householder vectors from Hessenberg factorization H of some A +template <typename Matrix> +Matrix inline extract_householder_hessenberg(const Matrix& H) +{ + vampir_trace<5015> tracer; + return Matrix(tril(H, -2)); +} + +/// Compute Householder vectors from Hessenberg factorization of A +template <typename Matrix> +Matrix inline householder_hessenberg(const Matrix& A) +{ + vampir_trace<5016> tracer; + return Matrix(tril(hessenberg_factors(A), -2)); +} + + +/// Extract Hessenberg form from factorization H of some A +template <typename Matrix> +Matrix inline extract_hessenberg(const Matrix& H) +{ + vampir_trace<5017> tracer; + return Matrix(triu(H, -1)); +} + +/// Hessenberg form of A +template <typename Matrix> +Matrix inline hessenberg(const Matrix& A) +{ + vampir_trace<5018> tracer; + // return triu(hessenberg_factors(A), -1); + MTL_THROW_IF(num_rows(A) < 3, matrix_too_small()); + + typedef typename Collection<Matrix>::value_type value_type; + // typedef typename Magnitude<value_type>::type magnitude_type; // to multiply with 2 not 2+0i + typedef typename Collection<Matrix>::size_type size_type; + size_type ncols = num_cols(A), nrows = num_rows(A); + value_type zero= math::zero(A[0][0]); + Matrix H(nrows,ncols); + + H= hessenberg_factors(A); + + // H= bands(hessenberg_factors(A), -nrows, -1); + // set (doubly) strict lower triangle to zero + for(size_type row = 2; row < nrows; row++){ + for(size_type col = 0; col < row-1; col++){ + H[row][col]= zero; + } + } + + return H; +} + + +/// Return Q where Q'*A*Q == hessenberg(A) +template <typename Matrix> +Matrix inline hessenberg_q(const Matrix& A) +{ + vampir_trace<5013> tracer; + using std::abs; + typedef typename Collection<Matrix>::value_type value_type; + typedef typename Magnitude<value_type>::type magnitude_type; // to multiply with 2 not 2+0i + typedef typename Collection<Matrix>::size_type size_type; + size_type ncols = num_cols(A), nrows = num_rows(A), mini; + value_type zero= math::zero(A[0][0]), one= math::one(A[0][0]); + const magnitude_type two(2); + Matrix Q(nrows,ncols); + + MTL_THROW_IF(num_rows(A) < 3, matrix_too_small()); + + Q= one; + + //Extract Q + for(size_type i = 0; i < nrows-2; i++){ + mtl::vector::dense_vector<value_type, vector::parameters<> > v(nrows-1), w(nrows); + v[0]= one; +// std::cout<< "v=" << v << "\n"; +// std::cout<< "w=" << w << "\n"; + for(size_type k = 1; k < size(v); k++) + v[k]= A[nrows-k][i]; + + magnitude_type beta= two / abs(dot(v, v)); // abs: x+0i -> x + if (beta != two) { + //trans(Vector)*Matrix + for(size_type k = 0; k < size(w); k++) { + w[k]= zero; + for(size_type j = 0; j < size(v); j++){ +// std::cout<< "k=" << k << " j=" << j << "\n"; + w[k]+= beta * v[j] * Q[j+i+1][k]; + } + } + //rank_one_update(Q[irange(i+1,imax)][irange(0,imax)],-v,w); + for(size_type row = i+1; row < nrows; row++) + for(size_type col = 0; col < ncols; col++){ +// std::cout<< "row=" << row << " col=" << col << "\n"; + Q[row][col] -= v[row-1] * w[col]; + } + } + } + return Q; +} + + +}} // namespace mtl::matrix + +#endif // MTL_MATRIX_HESSENBERG_INCLUDE + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/householder.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/householder.hpp new file mode 100644 index 0000000000000000000000000000000000000000..d435b2b75b9ee32e806bce971b92eda43e751f41 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/householder.hpp @@ -0,0 +1,90 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +// With contributions from Cornelius Steinhardt + +#ifndef MTL_MATRIX_HOUSEHOLDER_INCLUDE +#define MTL_MATRIX_HOUSEHOLDER_INCLUDE + +#include <cmath> +#include <cassert> +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/vector/parameter.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { namespace vector { + + +/// Computes Householder vector v and scalar b for vector \p y +/** such that identity_matrix(size(y))-b*v*v' projects the vector y + to a positive multiple of the first unit vector. **/ +template <typename Vector> +std::pair<typename mtl::vector::dense_vector<typename Collection<Vector>::value_type, parameters<> >, typename Collection<Vector>::value_type> +inline householder(Vector& y) +{ + vampir_trace<2004> tracer; + assert(size(y) > 0); + typedef typename Collection<Vector>::value_type value_type; + // typedef typename Collection<Vector>::size_type size_type; + const value_type zero= math::zero(y[0]), one= math::one(y[0]); + + Vector v(y); + v[0]= one; + irange tail(1, imax); + value_type s( dot(v[tail], v[tail]) ), b, v0; + + //evaluation of v and b + if (s == zero) + b= zero; + else { + value_type mu= sqrt(y[0] * y[0] + s); + v0= v[0]= y[0] <= zero ? y[0] - mu : -s / (y[0] + mu); // complex < zero???? + b= 2 * v0 * v0 / (s + v0 * v0); // 2* complex??????? + v/= v0; // normalization of the first entry + } + + return std::make_pair(v,b); +} + +/// Computes Householder vector for vector \p y +/** More stable Householder transformation, also for non-square matrices. **/ +template <typename Vector> +typename mtl::vector::dense_vector<typename Collection<Vector>::value_type, parameters<> > +inline householder_s(Vector& y) +{ + vampir_trace<2005> tracer; + typedef typename Collection<Vector>::value_type value_type; + const value_type zero= math::zero(y[0]); + + Vector u(y); + value_type nu(sqrt( dot(u, u) )), s; + + if (nu != zero){ + if(u[0] < 0){ + s= -1; + } else { + s= 1; + } + u[0]= u[0] + s * nu; + u/= sqrt( dot(u, u) ); + } + + return u; +} + + +}} // namespace mtl::matrix + +#endif // MTL_MATRIX_HOUSEHOLDER_INCLUDE + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/imag.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/imag.hpp new file mode 100644 index 0000000000000000000000000000000000000000..53eefea2a6d830ed2fd6f876e983883bd7381906 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/imag.hpp @@ -0,0 +1,90 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_IMAG_INCLUDE +#define MTL_IMAG_INCLUDE + +#include <complex> +#include <boost/numeric/linear_algebra/identity.hpp> + +namespace mtl { + +namespace sfunctor { + + template <typename Value> + struct imag + { + typedef Value result_type; + + static inline result_type apply(const Value& v) + { + using math::zero; + return zero(v); + } + result_type operator()(const Value& v) const + { + using math::zero; + return zero(v); + } + }; + + template <typename Value> + struct imag<std::complex<Value> > + { + typedef Value result_type; + + static inline result_type apply(const std::complex<Value>& v) + { + return std::imag(v); + } + result_type operator()(const std::complex<Value>& v) const + { + return std::imag(v); + } + }; + +} + +/// Imaginary part of scalars (including non-complex) +template <typename Value> +typename mtl::traits::enable_if_scalar<Value, typename sfunctor::imag<Value>::result_type>::type +inline imag(const Value& v) +{ + return sfunctor::imag<Value>::apply(v); +} + +namespace vector { + + /// Imaginary part of an vector + template <typename Vector> + typename mtl::traits::enable_if_vector<Vector, imag_view<Vector> >::type + inline imag(const Vector& v) + { + return imag_view<Vector>(v); + } +} + +namespace matrix { + + /// Imaginary part of an vector + template <typename Matrix> + typename mtl::traits::enable_if_matrix<Matrix, imag_view<Matrix> >::type + inline imag(const Matrix& v) + { + return imag_view<Matrix>(v); + } +} + + +} // namespace mtl + +#endif // MTL_IMAG_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/index_evaluator.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/index_evaluator.hpp new file mode 100644 index 0000000000000000000000000000000000000000..41ef939fe2d3cfe513d3207aa527d604c61e2543 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/index_evaluator.hpp @@ -0,0 +1,94 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_INDEX_EVALUATOR_INCLUDE +#define MTL_INDEX_EVALUATOR_INCLUDE + +#include <boost/utility/enable_if.hpp> +#include <boost/mpl/and.hpp> + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/operation/lazy_assign.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/vector/vec_vec_aop_expr.hpp> +#include <boost/numeric/mtl/vector/vec_scal_aop_expr.hpp> +#include <boost/numeric/mtl/vector/reduction_index_evaluator.hpp> +#include <boost/numeric/mtl/vector/dot_index_evaluator.hpp> +#include <boost/numeric/mtl/vector/row_mat_cvec_index_evaluator.hpp> +#include <boost/numeric/mtl/operation/fused_index_evaluator.hpp> +#include <boost/numeric/mtl/operation/fused_expr.hpp> +#include <boost/numeric/itl/pc/ic_0.hpp> +#include <boost/numeric/itl/pc/ilu_0.hpp> + +namespace mtl { + +/// Overloaded function that maps from lazy expressions to the according index-wise evaluation classes +template <typename T, typename U, typename Assign> +typename boost::enable_if<boost::mpl::and_<mtl::traits::is_vector<T>, mtl::traits::is_vector<U> >, + mtl::vector::vec_vec_aop_expr<T, U, Assign> >::type +inline index_evaluator(lazy_assign<T, U, Assign>& lazy) +{ + return mtl::vector::vec_vec_aop_expr<T, U, Assign>(lazy.first, lazy.second, true); +} + +template <typename T, typename U, typename Assign> +typename boost::enable_if<boost::mpl::and_<mtl::traits::is_vector<T>, mtl::traits::is_scalar<U> >, + mtl::vector::vec_scal_aop_expr<T, U, Assign> >::type +inline index_evaluator(lazy_assign<T, U, Assign>& lazy) +{ + return mtl::vector::vec_scal_aop_expr<T, U, Assign>(lazy.first, lazy.second, true); +} + +template <typename Scalar, typename Vector, typename Functor, typename Assign> +mtl::vector::reduction_index_evaluator<Scalar, Vector, Functor, Assign> +inline index_evaluator(lazy_assign<Scalar, mtl::vector::lazy_reduction<Vector, Functor>, Assign>& lazy) +{ + return mtl::vector::reduction_index_evaluator<Scalar, Vector, Functor, Assign>(lazy.first, lazy.second.v); +} + +template <typename Scalar, unsigned long Unroll, typename Vector1, + typename Vector2, typename ConjOpt, typename Assign> +mtl::vector::dot_index_evaluator<Scalar, Vector1, Vector2, ConjOpt, Assign> +inline index_evaluator(lazy_assign<Scalar, mtl::vector::dot_class<Unroll, Vector1, Vector2, ConjOpt>, Assign>& lazy) +{ + return mtl::vector::dot_index_evaluator<Scalar, Vector1, Vector2, ConjOpt, Assign>(lazy.first, lazy.second.v1, lazy.second.v2); +} + +template <typename VectorOut, typename Matrix, typename VectorIn, typename Assign> +mtl::vector::row_mat_cvec_index_evaluator<VectorOut, Matrix, VectorIn, Assign> +inline index_evaluator(lazy_assign<VectorOut, mtl::mat_cvec_times_expr<Matrix, VectorIn>, Assign>& lazy) +{ + return mtl::vector::row_mat_cvec_index_evaluator<VectorOut, Matrix, VectorIn, Assign>(lazy.first, lazy.second.first, lazy.second.second); +} + +template <typename V1, typename Matrix, typename Value, typename V2> +itl::pc::ic_0_evaluator<V1, itl::pc::solver<itl::pc::ic_0<Matrix, Value>, V2, true> > +inline index_evaluator(lazy_assign<V1, itl::pc::solver<itl::pc::ic_0<Matrix, Value>, V2, true>, assign::assign_sum>& lazy) +{ + return itl::pc::ic_0_evaluator<V1, itl::pc::solver<itl::pc::ic_0<Matrix, Value>, V2, true> >(lazy.first, lazy.second); +} + +// reuse ic_0_evaluator with ilu_0 preconditioner since IC(0) and ILU(0) do the same at the upper triangle ;-) +template <typename V1, typename Factorizer, typename Matrix, typename Value, typename V2> +itl::pc::ic_0_evaluator<V1, itl::pc::solver<itl::pc::ilu<Matrix, Factorizer, Value>, V2, true> > +inline index_evaluator(lazy_assign<V1, itl::pc::solver<itl::pc::ilu<Matrix, Factorizer, Value>, V2, true>, assign::assign_sum>& lazy) +{ + return itl::pc::ic_0_evaluator<V1, itl::pc::solver<itl::pc::ilu<Matrix, Factorizer, Value>, V2, true> >(lazy.first, lazy.second); +} + +template <typename T, typename U> +inline mtl::vector::fused_index_evaluator<T, U> index_evaluator(fused_expr<T, U>& expr) +{ return mtl::vector::fused_index_evaluator<T, U>(expr.first, expr.second); } + +} // namespace mtl + +#endif // MTL_INDEX_EVALUATOR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/infinity_norm.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/infinity_norm.hpp new file mode 100644 index 0000000000000000000000000000000000000000..b0fb07df8cb831af11a76af6de82d0c02bd280c1 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/infinity_norm.hpp @@ -0,0 +1,98 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_INFINITY_NORM_INCLUDE +#define MTL_INFINITY_NORM_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/concept/magnitude.hpp> +#include <boost/numeric/mtl/utility/enable_if.hpp> +#include <boost/numeric/mtl/utility/is_row_major.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/property_map.hpp> +#include <boost/numeric/mtl/operation/max_of_sums.hpp> +#include <boost/numeric/mtl/vector/lazy_reduction.hpp> +#include <boost/numeric/mtl/vector/reduction.hpp> +#include <boost/numeric/mtl/vector/reduction_functors.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { + + namespace vector { + + template <unsigned long Unroll, typename Vector> + typename traits::enable_if_vector<Vector, typename RealMagnitude<typename Collection<Vector>::value_type>::type>::type + inline infinity_norm(const Vector& vector) + { + vampir_trace<2006> tracer; + typedef typename RealMagnitude<typename Collection<Vector>::value_type>::type result_type; + return vector::reduction<Unroll, vector::infinity_norm_functor, result_type>::apply(vector); + } + + /*! Infinity-norm for vectors: infinity_norm(x) \f$\rightarrow |x|_\infty\f$. + \retval The magnitude type of the respective value type, see Magnitude. + + The norms are defined as \f$|v|_\infty=\max_i |v_i|\f$. + + Vector norms are unrolled 8-fold by default. + An n-fold unrolling can be generated with infinity_norm<n>(x). + The maximum for n is 8 (it might be increased later). + **/ + template <typename Vector> + typename mtl::traits::enable_if_vector<Vector, typename RealMagnitude<typename Collection<Vector>::value_type>::type>::type + inline infinity_norm(const Vector& vector) + { + return infinity_norm<8>(vector); + } + + template <typename Vector> + lazy_reduction<Vector, infinity_norm_functor> inline lazy_infinity_norm(const Vector& v) + { return lazy_reduction<Vector, infinity_norm_functor>(v); } + } + + namespace matrix { + + // Ignore unrolling for matrices + template <unsigned long Unroll, typename Matrix> + typename mtl::traits::enable_if_matrix<Matrix, typename RealMagnitude<typename Collection<Matrix>::value_type>::type>::type + inline infinity_norm(const Matrix& matrix) + { + vampir_trace<3011> tracer; + using mtl::impl::max_of_sums; + typename mtl::traits::row<Matrix>::type row(matrix); + return max_of_sums(matrix, mtl::traits::is_row_major<typename OrientedCollection<Matrix>::orientation>(), + row, num_rows(matrix)); + } + + /*! Infinity-norm for matrices: infinity_norm(x) \f$\rightarrow |x|_\infty\f$. + \retval The magnitude type of the respective value type, see Magnitude. + + The norms are defined as \f$|A|_\infty=\max_i\{\sum_j(|A_{ij}|)\}\f$. + Matrix norms are not (yet) optimized by unrolling. + **/ + template <typename Matrix> + typename mtl::traits::enable_if_matrix<Matrix, typename RealMagnitude<typename Collection<Matrix>::value_type>::type>::type + inline infinity_norm(const Matrix& matrix) + { + return infinity_norm<8>(matrix); + } + } + + using vector::infinity_norm; + using vector::lazy_infinity_norm; + using matrix::infinity_norm; + +} // namespace mtl + +#endif // MTL_INFINITY_NORM_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/inv.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/inv.hpp new file mode 100644 index 0000000000000000000000000000000000000000..f71b0481c4ac7021c66ddc76f1050b5737656098 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/inv.hpp @@ -0,0 +1,171 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_INV_INCLUDE +#define MTL_MATRIX_INV_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/matrix/identity.hpp> +#include <boost/numeric/mtl/operation/upper_trisolve.hpp> +#include <boost/numeric/mtl/operation/lu.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/irange.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/vector/parameter.hpp> +#include <boost/numeric/mtl/vector/dense_vector.hpp> +#include <boost/numeric/mtl/vector/unit_vector.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace mtl { namespace matrix { + +namespace traits { + + /// Return type of inv(Matrix) + /** Might be specialized later for the sake of efficiency **/ + template <typename Matrix> + struct inv + { + typedef typename Collection<Matrix>::value_type value_type; + typedef ::mtl::matrix::dense2D<value_type> type; + }; + +} // traits + +/// Invert upper triangular matrix +template <typename Matrix, typename MatrixOut> +void inv_upper(Matrix const& A, MatrixOut& Inv) +{ + vampir_trace<5019> tracer; + typedef typename Collection<Matrix>::value_type value_type; + typedef typename Collection<Matrix>::size_type size_type; + + const size_type N= num_rows(A); + MTL_DEBUG_THROW_IF(num_cols(A) != N, matrix_not_square()); + MTL_DEBUG_THROW_IF(N != num_rows(Inv) || num_cols(A) != num_cols(Inv), incompatible_size()); + + Inv= math::zero(value_type()); + + for (size_type k= 0; k < N; ++k) { + irange r(k+1); + typename mtl::ColumnInMatrix<MatrixOut>::type col_k(Inv[r][k]); + upper_trisolve(A[r][r], vector::unit_vector<value_type>(k, k+1), col_k, mtl::tag::regular_diagonal()); + } +} + + +/// Invert upper triangular matrix +template <typename Matrix> +inline typename traits::inv<Matrix>::type +inv_upper(Matrix const& A) +{ + typedef typename Collection<Matrix>::size_type size_type; + const size_type N= num_rows(A); + typename traits::inv<Matrix>::type Inv(N, N); + inv_upper(A, Inv); + return Inv; +} + +#if 0 +/// Invert lower triangular matrix +template <typename Matrix, typename MatrixOut> +inline void inv_lower(Matrix const& A, MatrixOut& Inv) +{ + vampir_trace<5020> tracer; + typedef typename Collection<Matrix>::value_type value_type; + typedef typename Collection<Matrix>::size_type size_type; + + const size_type N= num_rows(A); + MTL_DEBUG_THROW_IF(num_cols(A) != N, matrix_not_square()); + MTL_DEBUG_THROW_IF(N != num_rows(Inv) || num_cols(A) != num_cols(Inv), incompatible_size()); + + Inv= math::zero(value_type()); + + for (size_type k= 0; k < N; ++k) { + irange r(k, N); + typename mtl::ColumnInMatrix<MatrixOut>::type col_k(Inv[r][k]); + lower_trisolve(A[r][r], vector::unit_vector<value_type>(0, N-k), col_k, mtl::tag::regular_diagonal()); + } +} + +template <typename Matrix> +typename traits::inv<Matrix>::type +inline inv_lower(Matrix const& A) +{ + typedef typename Collection<Matrix>::size_type size_type; + const size_type N= num_rows(A); + typename traits::inv<Matrix>::type Inv(N, N); + inv_lower(A, Inv); + return Inv; +} +#endif + +#if 1 +/// Invert lower triangular matrix +template <typename Matrix> +typename traits::inv<Matrix>::type +inline inv_lower(Matrix const& A) +{ + vampir_trace<5020> tracer; + Matrix T(trans(A)); // Shouldn't be needed + return typename traits::inv<Matrix>::type(trans(inv_upper(T))); +} +#endif + + + + +/// Invert matrix +/** Uses pivoting LU factorization and triangular inversion + \sa \ref lu, \ref inv_upper, \ref inv_lower **/ +template <typename Matrix, typename MatrixOut> +inline void inv(Matrix const& A, MatrixOut& Inv) +{ + vampir_trace<5021> tracer; + typedef typename Collection<Matrix>::size_type size_type; + typedef typename Collection<Matrix>::value_type value_type; + typedef typename traits::inv<Matrix>::type result_type; + + const size_type N= num_rows(A); + MTL_THROW_IF(num_cols(A) != num_cols(A), matrix_not_square()); + MTL_DEBUG_THROW_IF(N != num_rows(Inv) || num_cols(A) != num_cols(Inv), incompatible_size()); + + if (N == 1) { + Inv[0][0]= value_type(1) / A[0][0]; + return; + } + + result_type PLU(A); + mtl::vector::dense_vector<size_type, vector::parameters<> > Pv(num_rows(A)); + + lu(PLU, Pv); + result_type PU(upper(PLU)), PL(strict_lower(PLU)); + for (size_type i= 0; i < num_rows(A); i++) + PL[i][i]= value_type(1); + + Inv= inv_upper(PU) * inv_lower(PL) * permutation(Pv); +} + +template <typename Matrix> +typename traits::inv<Matrix>::type +inline inv(Matrix const& A) +{ + typedef typename Collection<Matrix>::size_type size_type; + const size_type N= num_rows(A); + typename traits::inv<Matrix>::type Inv(N, N); + inv(A, Inv); + return Inv; +} + +}} // namespace mtl::matrix + +#endif // MTL_MATRIX_INV_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/invert_diagonal.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/invert_diagonal.hpp new file mode 100644 index 0000000000000000000000000000000000000000..ca82829820f531e8a1f4ec0960691b30f5439986 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/invert_diagonal.hpp @@ -0,0 +1,59 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_INVERT_DIAGONAL_INCLUDE +#define MTL_INVERT_DIAGONAL_INCLUDE + +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/utility/property_map.hpp> +#include <boost/numeric/mtl/matrix/compressed2D.hpp> +#include <boost/numeric/linear_algebra/inverse.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace mtl { namespace matrix { + +///Returns \p A with invert diagonal +template <typename Matrix> +inline void invert_diagonal(Matrix& A) +{ + vampir_trace<3012> tracer; + using math::reciprocal; + namespace traits = mtl::traits; + + typename traits::row<Matrix>::type row(A); + typename traits::col<Matrix>::type col(A); + typename traits::value<Matrix>::type value(A); + + typedef typename traits::range_generator<tag::major, Matrix>::type cursor_type; + typedef typename traits::range_generator<tag::nz, cursor_type>::type icursor_type; + + for (cursor_type cursor = begin<tag::major>(A), cend = end<tag::major>(A); cursor != cend; ++cursor) + for (icursor_type icursor = begin<tag::nz>(cursor), icend = end<tag::nz>(cursor); icursor != icend; ++icursor) + if (row(*icursor) == col(*icursor)) + value(*icursor, reciprocal(value(*icursor))); +} + +// Specialization for compressed2D +template <typename Value, typename Parameters> +inline void invert_diagonal(compressed2D<Value, Parameters>& A) +{ + vampir_trace<3026> tracer; + using math::reciprocal; + for (typename Parameters::size_type i= 0, end= std::min(num_rows(A), num_cols(A)); i < end; i++) + A.lvalue(i, i)= reciprocal(A.lvalue(i, i)); +} + + +}} // namespace mtl::matrix + +#endif // MTL_INVERT_DIAGONAL_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/iota.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/iota.hpp new file mode 100644 index 0000000000000000000000000000000000000000..aca39ca0f216c6a92eca2fd9a004aa3314c87675 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/iota.hpp @@ -0,0 +1,32 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_VECTOR_IOTA_INCLUDE +#define MTL_VECTOR_IOTA_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace mtl { namespace vector { + +/// Assigns sequentially increasing values to %vector v +template <typename Vector> +void iota(Vector& v, const typename Collection<Vector>::value_type offset= 0) +{ + vampir_trace<3013> tracer; + for (typename Collection<Vector>::size_type i= 0; i < size(v); i++) + v[i]= i + offset; +} + +}} // namespace mtl::vector + +#endif // MTL_VECTOR_IOTA_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/is_negative.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/is_negative.hpp new file mode 100644 index 0000000000000000000000000000000000000000..88653b90f42ee3c960a0ff41658dcb353a8956b0 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/is_negative.hpp @@ -0,0 +1,31 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_IS_NEGATIVE_INCLUDE +#define MTL_IS_NEGATIVE_INCLUDE + +#include <boost/type_traits/is_unsigned.hpp> +#include <boost/utility/enable_if.hpp> + +namespace mtl { + +template <typename T> +typename boost::enable_if<boost::is_unsigned<T>, bool>::type +inline is_negative(T) { return false; } + +template <typename T> +typename boost::disable_if<boost::is_unsigned<T>, bool>::type +inline is_negative(T x) { return x < 0; } + +} // namespace mtl + +#endif // MTL_IS_NEGATIVE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/lazy.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/lazy.hpp new file mode 100644 index 0000000000000000000000000000000000000000..34ece75560b022ecac7b17e9b04d6d20a8cc3545 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/lazy.hpp @@ -0,0 +1,55 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_LAZY_INCLUDE +#define MTL_LAZY_INCLUDE + +#include <boost/numeric/mtl/operation/assign_mode.hpp> + +namespace mtl { + +/// Helper class for lazy evaluation +template <typename T> +struct lazy_t +{ + lazy_t(T& data) : data(data) {} + + template <typename U> + lazy_assign<T, U, assign::assign_sum> operator=(const U& other) + { return lazy_assign<T, U, assign::assign_sum>(data, other); } + + template <typename U> + lazy_assign<T, U, assign::plus_sum> operator+=(const U& other) + { return lazy_assign<T, U, assign::plus_sum>(data, other); } + + template <typename U> + lazy_assign<T, U, assign::minus_sum> operator-=(const U& other) + { return lazy_assign<T, U, assign::minus_sum>(data, other); } + + T& data; +}; + +/// Do not compute or assign x immediately but delay it until explicitly performed +template <typename T> +inline lazy_t<T> lazy(T& x) +{ return lazy_t<T>(x); } + +/// Do not compute or assign x immediately but delay it until explicitly performed +template <typename T> +inline lazy_t<const T> lazy(const T& x) +{ return lazy_t<const T>(x); } + + + +} // namespace mtl + +#endif // MTL_LAZY_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/lazy_assign.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/lazy_assign.hpp new file mode 100644 index 0000000000000000000000000000000000000000..f0173e72c9e640eba47d83af4f86a064e076389e --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/lazy_assign.hpp @@ -0,0 +1,35 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_LAZY_ASSIGN_INCLUDE +#define MTL_LAZY_ASSIGN_INCLUDE + +namespace mtl { + + +/// Helper class for lazy assignment semantics +template <typename T, typename U, typename Assign> +struct lazy_assign +{ + typedef Assign assign_type; + + lazy_assign(T& first, const U& second) : first(first), second(second) {} + void delay_assign() const {} + + T& first; + const U& second; + +}; + +} // namespace mtl + +#endif // MTL_LAZY_ASSIGN_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/left_scale_inplace.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/left_scale_inplace.hpp new file mode 100644 index 0000000000000000000000000000000000000000..29da77a6483e7590b0a7efc859d4f348d0613e99 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/left_scale_inplace.hpp @@ -0,0 +1,76 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_LEFT_SCALE_INPLACE_INCLUDE +#define MTL_LEFT_SCALE_INPLACE_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/enable_if.hpp> +#include <boost/numeric/mtl/operation/assign_each_nonzero.hpp> +#include <boost/numeric/mtl/operation/mult.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { + + namespace impl { + + template <typename Factor, typename Coll> + inline Coll& left_scale_inplace(const Factor& alpha, tag::scalar, Coll& c) + { + vampir_trace<3014> tracer; + assign_each_nonzero(c, tfunctor::scale<Factor, typename Collection<Coll>::value_type>(alpha)); + + return c; + } + + template <typename Factor, typename Collection> + inline Collection& left_scale_inplace(const Factor& alpha, tag::matrix, Collection& c) + { + vampir_trace<3014> tracer; + Collection tmp(alpha * c); + swap(tmp, c); + return c; + } + } + + namespace matrix { + + /// Scale matrix \p c from left with scalar or matrix factor \p alpha; \p c is altered + template <typename Factor, typename Matrix> + typename mtl::traits::enable_if_matrix<Matrix, Matrix&>::type + inline left_scale_inplace(const Factor& alpha, Matrix& A) + { + return mtl::impl::left_scale_inplace(alpha, typename mtl::traits::category<Factor>::type(), A); + } + } + + namespace vector { + + /// Scale vector \p c from left with scalar or matrix factor \p alpha; \p c is altered + template <typename Factor, typename Vector> + typename mtl::traits::enable_if_vector<Vector, Vector&>::type + inline left_scale_inplace(const Factor& alpha, Vector& v) + { + return mtl::impl::left_scale_inplace(alpha, typename mtl::traits::category<Factor>::type(), v); + } + } + + using vector::left_scale_inplace; + using matrix::left_scale_inplace; + +} // namespace mtl + +#endif // MTL_LEFT_SCALE_INPLACE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/look_at_each_nonzero.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/look_at_each_nonzero.hpp new file mode 100644 index 0000000000000000000000000000000000000000..9f20bbd3859cee62c95c347ade9d9c60260426e2 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/look_at_each_nonzero.hpp @@ -0,0 +1,96 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_FOR_EACH_NONZERO_INCLUDE +#define MTL_FOR_EACH_NONZERO_INCLUDE + +#include <utility> + +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/enable_if.hpp> +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/utility/property_map.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { + + namespace vector { + + /// Perform \p f(v[i]) on each non-zero i in constant vector \p v; thus the must keep the result in its state + template <typename Vector, typename Functor> + inline void look_at_each_nonzero(const Vector& v, Functor& f) + { + vampir_trace<2007> tracer; + typedef typename mtl::traits::range_generator<tag::const_iter::nz, Vector>::type iterator; + for (iterator i= begin<tag::iter::nz>(v), iend= end<tag::iter::nz>(v); i != iend; ++i) + f(*i); + } + + /// Perform \p f(v[i], i) on each non-zero i in constant vector \p v; thus the must keep the result in its state + template <typename Vector, typename Functor> + typename mtl::traits::enable_if_vector<Vector>::type // to be called for vectors only + inline look_at_each_nonzero_pos(const Vector& v, Functor& f) + { + vampir_trace<2008> tracer; + typename mtl::traits::index<Vector>::type index(v); + typename mtl::traits::const_value<Vector>::type value(v); + + typedef typename traits::range_generator<tag::nz, Vector>::type iterator; + for (iterator i= begin<tag::nz>(v), iend= end<tag::nz>(v); i != iend; ++i) + f(value(*i), index(*i)); + } + + } // namespace vector + + namespace matrix { + + /// Perform a potentially mutating \p f(A[i][j]) on each non-zero entry in matrix \p A + template <typename Matrix, typename Functor> + inline void look_at_each_nonzero(const Matrix& A, Functor& f) + { + vampir_trace<3016> tracer; + typename mtl::traits::const_value<Matrix>::type value(A); + + typedef typename mtl::traits::range_generator<tag::major, Matrix>::type cursor_type; + typedef typename mtl::traits::range_generator<tag::nz, cursor_type>::type icursor_type; + + for (cursor_type cursor = begin<tag::major>(A), cend = end<tag::major>(A); cursor != cend; ++cursor) + for (icursor_type icursor = begin<tag::nz>(cursor), icend = end<tag::nz>(cursor); + icursor != icend; ++icursor) + f(value(*icursor)); + } + + /// Perform a potentially mutating \p f(A[i][j], make_pair(i, j)) on each non-zero entry in matrix \p A + template <typename Matrix, typename Functor> + typename mtl::traits::enable_if_matrix<Matrix>::type // to be called for matrices only + inline look_at_each_nonzero_pos(const Matrix& A, Functor& f) + { + vampir_trace<3017> tracer; + typename mtl::traits::row<Matrix>::type row(A); + typename mtl::traits::col<Matrix>::type col(A); + typename mtl::traits::const_value<Matrix>::type value(A); + + typedef typename mtl::traits::range_generator<tag::major, Matrix>::type cursor_type; + typedef typename mtl::traits::range_generator<tag::nz, cursor_type>::type icursor_type; + + for (cursor_type cursor = begin<tag::major>(A), cend = end<tag::major>(A); cursor != cend; ++cursor) + for (icursor_type icursor = begin<tag::nz>(cursor), icend = end<tag::nz>(cursor); + icursor != icend; ++icursor) + f(value(*icursor), std::make_pair(row(*icursor), col(*icursor))); + } + + } // namespace matrix + +} // namespace mtl + +#endif // MTL_FOR_EACH_NONZERO_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/lower_trisolve.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/lower_trisolve.hpp new file mode 100644 index 0000000000000000000000000000000000000000..d42ba9ce1cc809119b3ea78353bfe3f77ec4aaa7 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/lower_trisolve.hpp @@ -0,0 +1,292 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_LOWER_TRISOLVE_INCLUDE +#define MTL_LOWER_TRISOLVE_INCLUDE + +#include <boost/mpl/int.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/property_map.hpp> +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/utility/static_assert.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> + +#include <boost/numeric/linear_algebra/identity.hpp> +#include <boost/numeric/linear_algebra/inverse.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace mtl { namespace matrix { + + +namespace detail { + + /// Class that implements lower trisolver + /** DiaTag can be tag::regular_diagonal, tag::unit_diagonal, or tag::inverse_diagonal. + CompactStorage means that matrix contains only lower entries (strict lower when DiaTag == unit_diagonal). \sa \ref trisolve_object **/ + template <typename Matrix, typename DiaTag, bool CompactStorage= false> + struct lower_trisolve_t + { + MTL_STATIC_ASSERT((boost::is_same<DiaTag, tag::regular_diagonal>::value + || boost::is_same<DiaTag, tag::unit_diagonal>::value + || boost::is_same<DiaTag, tag::inverse_diagonal>::value), + "DiaTag must be either tag::regular_diagonal, tag::unit_diagonal, or tag::inverse_diagonal."); + + typedef typename Collection<Matrix>::value_type value_type; + typedef typename Collection<Matrix>::size_type size_type; + typedef typename OrientedCollection<Matrix>::orientation my_orientation; + typedef typename mtl::traits::category<Matrix>::type my_category; + typedef typename mtl::traits::range_generator<tag::major, Matrix>::type a_cur_type; // row or col depending on Matrix + typedef typename mtl::traits::range_generator<tag::nz, a_cur_type>::type a_icur_type; + + /// Construction from matrix \p A + lower_trisolve_t(const Matrix& A) : A(A), value_a(A), col_a(A), row_a(A) + { MTL_THROW_IF(num_rows(A) != num_cols(A), matrix_not_square()); } + + template <typename M, typename D, bool C> + struct generic_version + : boost::mpl::int_<(mtl::traits::is_row_major<M>::value ? 0 : 2) + + (boost::is_same<D, tag::unit_diagonal>::value ? 1 : 2) + > {}; + + template <typename M, typename D, bool C> + struct version + : generic_version<M, D, C> {}; + + + template <typename Value, typename Para, typename D> + struct version<compressed2D<Value, Para>, D, true> + : boost::mpl::if_<mtl::traits::is_row_major<Para>, + typename boost::mpl::if_<boost::is_same<D, tag::unit_diagonal>, + boost::mpl::int_<5>, + boost::mpl::int_<6> >::type, + generic_version<compressed2D<Value, Para>, D, true> + >::type {}; + + /// Solve \p w = A * \p v + template <typename VectorIn, typename VectorOut> + void operator()(const VectorIn& v, VectorOut& w) const + { vampir_trace<5022> tracer; apply(v, w, version<Matrix, DiaTag, CompactStorage>()); } + + + private: + template <typename Value> + Value inline lower_trisolve_diavalue(const Value& v, tag::regular_diagonal) const + { using math::reciprocal; return reciprocal(v); } + + template <typename Value> + Value lower_trisolve_diavalue(const Value& v, tag::inverse_diagonal) const + { return v; } + + template <typename Tag> int dia_inc(Tag) { return 0; } + int dia_inc(tag::unit_diagonal) { return 1; } + + // Generic row-major unit_diagonal + template <typename VectorIn, typename VectorOut> + void apply(const VectorIn& v, VectorOut& w, boost::mpl::int_<1>) const + { + using namespace tag; + a_cur_type ac= begin<row>(A), aend= end<row>(A); + for (size_type r= 0; ac != aend; ++r, ++ac) { + a_icur_type aic= begin<nz>(ac), aiend= CompactStorage ? end<nz>(ac) : lower_bound<nz>(ac, r); + typename Collection<VectorOut>::value_type rr= v[r]; + for (; aic != aiend; ++aic) { + MTL_DEBUG_THROW_IF(col_a(*aic) >= r, logic_error("Matrix entries must be sorted for this.")); + rr-= value_a(*aic) * w[col_a(*aic)]; + } + w[r]= rr; + } + } + + // Generic row-major not unit_diagonal + template <typename VectorIn, typename VectorOut> + void apply(const VectorIn& v, VectorOut& w, boost::mpl::int_<2>) const + { + using namespace tag; + a_cur_type ac= begin<row>(A), aend= end<row>(A); + for (size_type r= 0; ac != aend; ++r, ++ac) { + a_icur_type aic= begin<nz>(ac), aiend= CompactStorage ? end<nz>(ac) : lower_bound<nz>(ac, r+1); + MTL_THROW_IF(aic == aiend, missing_diagonal()); + --aiend; + MTL_THROW_IF(col_a(*aiend) != r, missing_diagonal()); + + value_type dia= value_a(*aiend); + typename Collection<VectorOut>::value_type rr= v[r]; + + for (; aic != aiend; ++aic) { + MTL_DEBUG_THROW_IF(col_a(*aic) >= r, logic_error("Matrix entries must be sorted for this.")); + rr-= value_a(*aic) * w[col_a(*aic)]; + } + w[r]= rr * lower_trisolve_diavalue(dia, DiaTag()); + } + } + + // Generic column-major unit_diagonal + template <typename VectorIn, typename VectorOut> + void apply(const VectorIn& v, VectorOut& w, boost::mpl::int_<3>) const + { + using namespace tag; + w= v; + a_cur_type ac= begin<col>(A), aend= end<col>(A); + for (size_type r= 0; ac != aend; ++r, ++ac) { + a_icur_type aic= CompactStorage ? begin<nz>(ac) : lower_bound<nz>(ac, r+1), aiend= end<nz>(ac); + typename Collection<VectorOut>::value_type rr= w[r]; + + for (; aic != aiend; ++aic) { + MTL_DEBUG_THROW_IF(row_a(*aic) <= r, logic_error("Matrix entries must be sorted for this.")); + w[row_a(*aic)]-= value_a(*aic) * rr; + } + } + } + + // Generic column-major not unit_diagonal + template <typename VectorIn, typename VectorOut> + void apply(const VectorIn& v, VectorOut& w, boost::mpl::int_<4>) const + { + using namespace tag; + w= v; + a_cur_type ac= begin<col>(A), aend= end<col>(A); + for (size_type r= 0; ac != aend; ++r, ++ac) { + a_icur_type aic= CompactStorage ? begin<nz>(ac) : lower_bound<nz>(ac, r), aiend= end<nz>(ac); + MTL_DEBUG_THROW_IF(aic == aiend || row_a(*aic) != r, missing_diagonal()); + typename Collection<VectorOut>::value_type rr= w[r]*= lower_trisolve_diavalue(value_a(*aic), DiaTag()); + + for (++aic; aic != aiend; ++aic) { + MTL_DEBUG_THROW_IF(row_a(*aic) <= r, logic_error("Matrix entries must be sorted for this.")); + w[row_a(*aic)]-= value_a(*aic) * rr; + } + } + } + + // Tuning for IC_0 and similar using compressed2D row-major compact with implicit unit diagonal + template <typename VectorIn, typename VectorOut> + void apply(const VectorIn& v, VectorOut& w, boost::mpl::int_<5>) const + { + vampir_trace<5048> tracer; + if (num_rows(A) == 0) return; + size_type j1= A.ref_major()[1]; + for (size_type r= 0, rend= num_rows(A); r != rend; ++r) { + size_type j0= j1; + j1= A.ref_major()[r+1]; + typename Collection<VectorOut>::value_type rr= v[r]; + for (; j0 != j1; ++j0) { + MTL_DEBUG_THROW_IF(A.ref_minor()[j0] > r, logic_error("Matrix entries from U in lower triangular.")); + rr-= A.data[j0] * w[A.ref_minor()[j0]]; + } + w[r]= rr; + } + } + + // Tuning for IC_0 and similar using compressed2D row-major compact with explicitly stored diagonal (possibly already inverted) + template <typename VectorIn, typename VectorOut> + void apply(const VectorIn& v, VectorOut& w, boost::mpl::int_<6>) const + { + vampir_trace<5047> tracer; + for (size_type r= 0, rend= num_rows(A); r != rend; ++r) { + size_type j0= A.ref_major()[r], j1= A.ref_major()[r+1]; + MTL_THROW_IF(j0 == j1, missing_diagonal()); + --j1; + MTL_THROW_IF(A.ref_minor()[j1] != r, missing_diagonal()); + value_type dia= A.data[j1]; + typename Collection<VectorOut>::value_type rr= v[r]; + for (; j0 != j1; ++j0) { + MTL_DEBUG_THROW_IF(A.ref_minor()[j0] > r, logic_error("Matrix entries from U in lower triangular.")); + rr-= A.data[j0] * w[A.ref_minor()[j0]]; + } + w[r]= rr * lower_trisolve_diavalue(dia, DiaTag()); + } + } + + const Matrix& A; + typename mtl::traits::const_value<Matrix>::type value_a; + typename mtl::traits::col<Matrix>::type col_a; + typename mtl::traits::row<Matrix>::type row_a; + }; + +} // detail + + +/// Solves the lower triangular matrix A with the rhs v and returns the solution vector +template <typename Matrix, typename Vector> +Vector inline lower_trisolve(const Matrix& A, const Vector& v) +{ + Vector w(resource(v)); + detail::lower_trisolve_t<Matrix, tag::regular_diagonal> solver(A); + solver(v, w); + return w; +} + +/// Solves the lower triangular matrix A with the rhs v +template <typename Matrix, typename VectorIn, typename VectorOut> +inline void lower_trisolve(const Matrix& A, const VectorIn& v, VectorOut& w) +{ + detail::lower_trisolve_t<Matrix, tag::regular_diagonal> solver(A); + solver(v, w); +} + +/// Solves the lower triangular matrix A (only one's in the diagonal) with the rhs v and returns the solution vector +template <typename Matrix, typename Vector> +Vector inline unit_lower_trisolve(const Matrix& A, const Vector& v) +{ + Vector w(resource(v)); + detail::lower_trisolve_t<Matrix, tag::unit_diagonal> solver(A); + solver(v, w); + return w; +} + +/// Solves the lower triangular matrix A (only one's in the diagonal) with the rhs v and returns the solution vector +template <typename Matrix, typename VectorIn, typename VectorOut> +inline void unit_lower_trisolve(const Matrix& A, const VectorIn& v, VectorOut& w) +{ + detail::lower_trisolve_t<Matrix, tag::unit_diagonal> solver(A); + solver(v, w); +} + +/// Solves the lower triangular matrix A (inverse the diagonal) with the rhs v and returns the solution vector +template <typename Matrix, typename Vector> +Vector inline inverse_lower_trisolve(const Matrix& A, const Vector& v) +{ + Vector w(resource(v)); + detail::lower_trisolve_t<Matrix, tag::inverse_diagonal> solver(A); + solver(v, w); + return w; +} + +/// Solves the lower triangular matrix A (inverse the diagonal) with the rhs v and returns the solution vector +template <typename Matrix, typename VectorIn, typename VectorOut> +inline void inverse_lower_trisolve(const Matrix& A, const VectorIn& v, VectorOut& w) +{ + detail::lower_trisolve_t<Matrix, tag::inverse_diagonal> solver(A); + solver(v, w); +} + +template <typename Matrix, typename Vector, typename DiaTag> +Vector inline lower_trisolve(const Matrix& A, const Vector& v, DiaTag) +{ + Vector w(resource(v)); + detail::lower_trisolve_t<Matrix, DiaTag> solver(A); + solver(v, w); + return w; +} + +template <typename Matrix, typename VectorIn, typename VectorOut, typename DiaTag> +inline void lower_trisolve(const Matrix& A, const VectorIn& v, VectorOut& w, DiaTag) +{ + detail::lower_trisolve_t<Matrix, DiaTag> solver(A); + solver(v, w); +} + +}} // namespace mtl::matrix + +#endif // MTL_LOWER_TRISOLVE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/lu.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/lu.hpp new file mode 100644 index 0000000000000000000000000000000000000000..a80c60f86d4a5bbc48a9be245c6c9d00e9d979e1 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/lu.hpp @@ -0,0 +1,241 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +// With contributions from Cornelius Steinhardt + +#ifndef MTL_MATRIX_LU_INCLUDE +#define MTL_MATRIX_LU_INCLUDE + +#include <cmath> +#include <boost/numeric/linear_algebra/identity.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/irange.hpp> +#include <boost/numeric/mtl/utility/lu_matrix_type.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/matrix/upper.hpp> +#include <boost/numeric/mtl/matrix/lower.hpp> +#include <boost/numeric/mtl/matrix/permutation.hpp> +#include <boost/numeric/mtl/operation/adjoint.hpp> +#include <boost/numeric/mtl/operation/lower_trisolve.hpp> +#include <boost/numeric/mtl/operation/upper_trisolve.hpp> +#include <boost/numeric/mtl/operation/max_pos.hpp> +#include <boost/numeric/mtl/operation/swap_row.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { namespace matrix { + +/// LU factorization in place (without pivoting and optimization so far) +/** eps is tolerance for pivot element. If less or equal the matrix is considered singular. + eps is given as double right now, might be refactored to the magnitude type of the value type in the future. **/ +template <typename Matrix> +void inline lu(Matrix& LU, double eps= 0) +{ + vampir_trace<5023> tracer; + using std::abs; + MTL_THROW_IF(num_rows(LU) != num_cols(LU), matrix_not_square()); + + for (std::size_t k= 0; k < num_rows(LU)-1; k++) { + if(abs(LU[k][k]) <= eps) throw matrix_singular(); + irange r(k+1, imax); // Interval [k+1, n-1] + LU[r][k]/= LU[k][k]; + LU[r][r]-= LU[r][k] * LU[k][r]; + } +} + +/// LU factorization in place (with pivoting and without optimization so far) +/** eps is tolerance for pivot element. If less or equal the matrix is considered singular. + eps is given as double right now, might be refactored to the magnitude type of the value type in the future. **/ +template <typename Matrix, typename PermuationVector> +void inline lu(Matrix& A, PermuationVector& P, double eps= 0) +{ + vampir_trace<5024> tracer; + using math::zero; using std::abs; + typedef typename Collection<Matrix>::size_type size_type; + size_type ncols = num_cols(A), nrows = num_rows(A); + + MTL_THROW_IF(ncols != nrows , matrix_not_square()); + P.change_dim(nrows); + + for (size_type i= 0; i < nrows; i++) + P[i]= i; + + for (size_type i= 0; i < nrows-1; i++) { + irange r(i+1, imax), ir(i, i+1); // Intervals [i+1, n-1], [i, i] + size_type rmax= max_abs_pos(A[irange(i, imax)][ir]).first + i; + swap_row(A, i, rmax); + swap_row(P, i, rmax); + + if(abs(A[i][i]) <= eps) throw matrix_singular(); // other gmres test doesn't work + + A[r][i]/= A[i][i]; // Scale column i + A[r][r]-= A[r][i] * A[i][r]; // Decrease bottom right block of matrix + } +} + + +/// LU factorization without factorization that returns the matrix +/** eps is tolerance for pivot element. If less or equal the matrix is considered singular. + eps is given as double right now, might be refactored to the magnitude type of the value type in the future. **/ +template <typename Matrix> +Matrix inline lu_f(const Matrix& A, double eps= 0) +{ + vampir_trace<5025> tracer; + Matrix LU(A); + lu(LU, eps); + return LU; +} + +/// Solve Ax = b by LU factorization without pivoting; vector x is returned +template <typename Matrix, typename Vector> +Vector inline lu_solve_straight(const Matrix& A, const Vector& b, double eps= 0) +{ + vampir_trace<5026> tracer; + Matrix LU(A); + lu(LU, eps); + return upper_trisolve(upper(LU), unit_lower_trisolve(strict_lower(LU), b)); +} + +/// Solve LUx = b by with forward and backward-LU subsitution, lu(LU) was allready done +template <typename Matrix, typename Vector> +Vector inline lu_solve_apply(const Matrix& LU, const Vector& b) +{ + vampir_trace<5026> tracer; + return upper_trisolve(upper(LU), unit_lower_trisolve(strict_lower(LU), b)); +} + +/// Apply the factorization L*U with permutation P on vector b to solve Ax = b +template <typename Matrix, typename PermVector, typename Vector> +Vector inline lu_apply(const Matrix& LU, const PermVector& P, const Vector& b) +{ + vampir_trace<5027> tracer; + return upper_trisolve(upper(LU), unit_lower_trisolve(strict_lower(LU), Vector(matrix::permutation(P) * b))); +} + + +/// Solve Ax = b by LU factorization with column pivoting; vector x is returned +template <typename Matrix, typename Vector> +Vector inline lu_solve(const Matrix& A, const Vector& b, double eps= 0) +{ + vampir_trace<5028> tracer; + mtl::vector::dense_vector<std::size_t, vector::parameters<> > P(num_rows(A)); + Matrix LU(A); + + lu(LU, P, eps); + return lu_apply(LU, P, b); +} + + +/// Apply the factorization L*U with permutation P on vector b to solve adjoint(A)x = b +/** That is \f$P^{-1}(LU)^H x = b\f$ --> \f$x= P^{-1}L^{-H} U^{-H} b\f$ where \f$P^{{-1}^{{-1}^H}} = P^{-1}\f$ **/ +template <typename Matrix, typename PermVector, typename Vector> +Vector inline lu_adjoint_apply(const Matrix& LU, const PermVector& P, const Vector& b) +{ + vampir_trace<5029> tracer; + return Vector(trans(matrix::permutation(P)) * unit_upper_trisolve(adjoint(LU), lower_trisolve(adjoint(LU), b))); +} + + +/// Solve \f$adjoint(A)x = b\f$ by LU factorization with column pivoting; vector x is returned +template <typename Matrix, typename Vector> +Vector inline lu_adjoint_solve(const Matrix& A, const Vector& b, double eps= 0) +{ + vampir_trace<5030> tracer; + mtl::vector::dense_vector<std::size_t, vector::parameters<> > P(num_rows(A)); + Matrix LU(A); + + lu(LU, P, eps); + return lu_adjoint_apply(LU, P, b); +} + +/// Class that keeps LU factorization (and permutation); using column pivoting +template <typename Matrix> +class lu_solver +{ + typedef typename mtl::traits::lu_matrix_type<Matrix>::type matrix_type; + typedef mtl::vector::dense_vector<std::size_t, vector::parameters<> > permutation_type; + public: + /// Construct from matrix \p A and use optionally threshold \p eps in factorization + explicit lu_solver(const Matrix& A, double eps= 0) + : LU(A), P(num_rows(A)) + { + lu(LU, P, eps); + } + + /// Solve A*x = b with factorization from constructor + template <typename VectorIn, typename VectorOut> + void solve(const VectorIn& b, VectorOut& x) const + { + x= upper_trisolve(upper(LU), unit_lower_trisolve(strict_lower(LU), VectorIn(matrix::permutation(P) * b))); + } + /// Solve \f$adjoint(A)x = b\f$ using LU factorization + template <typename VectorIn, typename VectorOut> + void adjoint_solve(const VectorIn& b, VectorOut& x) const + { + x= trans(matrix::permutation(P)) * unit_upper_trisolve(adjoint(LU), lower_trisolve(adjoint(LU), b)); + } + + private: + matrix_type LU; + permutation_type P; +}; + + +}} // namespace mtl::matrix + + + + + + + + + + + + + + + + + +// ### For illustration purposes +#if 0 + +namespace mtl { namespace matrix { + +template <typename Matrix> +void inline lu(Matrix& LU) +{ + MTL_THROW_IF(num_rows(LU) != num_cols(LU), matrix_not_square()); + + typedef typename Collection<Matrix>::value_type value_type; + typedef typename Collection<Matrix>::size_type size_type; + + size_type n= num_rows(LU); + for (size_type k= 0; k < num_rows(LU); k++) { + value_type pivot= LU[k][k]; + for (size_type j= k+1; j < n; j++) { + value_type alpha= LU[j][k]/= pivot; + for (size_type i= k+1; i < n; i++) + LU[j][i]-= alpha * LU[k][i]; + } + } +} + + + +}} // namespace mtl::matrix + +#endif + +#endif // MTL_MATRIX_LU_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/make_sparse.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/make_sparse.hpp new file mode 100644 index 0000000000000000000000000000000000000000..fef68f3c33ebd6be47b96f1366dfc6e779d100c8 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/make_sparse.hpp @@ -0,0 +1,118 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_VECTOR_MAKE_SPARSE_INCLUDE +#define MTL_VECTOR_MAKE_SPARSE_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/operation/size.hpp> +#include <boost/numeric/mtl/operation/update.hpp> +#include <boost/numeric/mtl/matrix/compressed2D.hpp> +#include <boost/numeric/mtl/matrix/inserter.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> + +namespace mtl { namespace vector { + +// Commands in Matlab +// S = sparse(i,j,s,m,n,nzmax) +// S = sparse(i,j,s,m,n) +// S = sparse(i,j,s) +// S = sparse(m,n) + +template <typename SizeVector, typename ValueVector> +struct make_sparse_trait +{ + typedef typename Collection<SizeVector>::value_type size_type; + typedef typename Collection<ValueVector>::value_type value_type; + typedef matrix::parameters<row_major, index::c_index, mtl::non_fixed::dimensions, false, size_type> paras; + typedef matrix::compressed2D<value_type, paras> type; +}; + +/// Generates an \p m by \p n matrix from the vectors \p rows, \p cols, and \p values. +/** A sparse matrix is created (compressed2D). The value type is the same as the element type + of the value vector and the size type the same as the entries of the vectors with the row indices. + Zero entries in \p values are ignored. Entries with same coordinates are added. + Same as <a href="http://www.mathworks.de/de/help/matlab/ref/sparse.html">Matlab's sparse</a> function besides that it is zero-indexed. + **/ +template <typename SizeVector1, typename SizeVector2, typename ValueVector> +inline typename make_sparse_trait<SizeVector1, ValueVector>::type +make_sparse(const SizeVector1& rows, const SizeVector2& cols, const ValueVector& values, + std::size_t m, std::size_t n) +{ + MTL_THROW_IF(size(rows) != size(cols), incompatible_size()); + MTL_THROW_IF(size(rows) != size(values), incompatible_size()); + + typedef make_sparse_trait<SizeVector1, ValueVector> traits; + typedef typename traits::type matrix_type; + typedef typename traits::value_type value_type; + typedef typename traits::size_type size_type; + + size_type ms(m), ns(n); // shouldn't be needed :-! + matrix_type A(ms, ns); + matrix::inserter<matrix_type, update_plus<value_type> > ins(A, size_type(size(rows) / m + 1)); + + for (std::size_t i= 0; i < size(rows); i++) + if (values[i] != value_type(0)) + ins[rows[i]][cols[i]] << values[i]; + return A; +} + +/// Generates an \p m by \p n matrix from the vectors \p rows, \p cols, and \p values. +/** A sparse matrix is created (compressed2D). The value type is the same as the element type + of the value vector and the size type the same as the entries of the vectors with the row indices. + Zero entries in \p values are ignored. Entries with same coordinates are added. Last parameter + is ignored and can be omitted. + Same as <a href="http://www.mathworks.de/de/help/matlab/ref/sparse.html">Matlab's sparse</a> function besides that it is zero-indexed. + **/ +template <typename SizeVector1, typename SizeVector2, typename ValueVector> +inline typename make_sparse_trait<SizeVector1, ValueVector>::type +make_sparse(const SizeVector1& rows, const SizeVector2& cols, const ValueVector& values, + std::size_t m, std::size_t n, std::size_t) +{ + return make_sparse(rows, cols, values, m, n); +} + +/// Generates a matrix from the vectors \p rows, \p cols, and \p values. +/** A sparse matrix is created (compressed2D). + The number of rows/columns is one plus the maximum of the entries of \p rows and \p cols. + The value type is the same as the element type + of the value vector and the size type the same as the entries of the vectors with the row indices. + Zero entries in \p values are ignored. Entries with same coordinates are added. + Same as <a href="http://www.mathworks.de/de/help/matlab/ref/sparse.html">Matlab's sparse</a> function besides that it is zero-indexed. + **/ +template <typename SizeVector1, typename SizeVector2, typename ValueVector> +inline typename make_sparse_trait<SizeVector1, ValueVector>::type +make_sparse(const SizeVector1& rows, const SizeVector2& cols, const ValueVector& values) +{ + return make_sparse(rows, cols, values, max(rows)+1, max(cols)+1); +} + +/// Generates an empty \p m by \p n matrix. +/** A sparse matrix is created (compressed2D<double>). + Same as <a href="http://www.mathworks.de/de/help/matlab/ref/sparse.html">Matlab's sparse</a> function besides that it is zero-indexed. + **/ +inline matrix::compressed2D<double> make_sparse(std::size_t m, std::size_t n) +{ + return matrix::compressed2D<double>(m, n); +} + + + + + +} // namespace :vector + + using vector::make_sparse; + +} // namespace mtl + +#endif // MTL_VECTOR_MAKE_SPARSE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/make_tag_vector.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/make_tag_vector.hpp new file mode 100644 index 0000000000000000000000000000000000000000..b41d2db73c3ebd03bfebf5f4dc582c54269d8e6a --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/make_tag_vector.hpp @@ -0,0 +1,34 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_MAKE_TAG_VECTOR_INCLUDE +#define MTL_MAKE_TAG_VECTOR_INCLUDE + +#include <boost/numeric/mtl/utility/irange.hpp> +#include <boost/numeric/mtl/utility/srange.hpp> +#include <boost/numeric/mtl/vector/dense_vector.hpp> + +namespace mtl { + + template <typename Range> + inline vector::dense_vector<bool> + make_tag_vector(std::size_t n, const Range& r) + { + vector::dense_vector<bool> v(n); + for (std::size_t i= 0; i < n; i++) + v[i]= r.in_range(i); + return v; + } + +} // namespace mtl + +#endif // MTL_MAKE_TAG_VECTOR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/mat_cvec_times_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/mat_cvec_times_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..5eb8d8f81befd017762865b624f5df663c874540 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/mat_cvec_times_expr.hpp @@ -0,0 +1,46 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MAT_CVEC_TIMES_EXPR_INCLUDE +#define MTL_MAT_CVEC_TIMES_EXPR_INCLUDE + +#include <boost/numeric/mtl/operation/bin_op_expr.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/concept/std_concept.hpp> +#include <boost/numeric/mtl/mtl_fwd.hpp> + +namespace mtl { + +template <typename E1, typename E2> +struct mat_cvec_times_expr + : public bin_op_expr< E1, E2 >, + public mtl::vector::vec_expr< mat_cvec_times_expr<E1, E2> > +{ + typedef bin_op_expr< E1, E2 > base; + typedef mat_cvec_times_expr<E1, E2> self; + + typedef typename Multiplicable<typename Collection<E1>::value_type, + typename Collection<E2>::value_type>::result_type value_type; + typedef typename Collection<E2>::size_type size_type; + + mat_cvec_times_expr( E1 const& matrix, E2 const& vector ) : base(matrix, vector) {} +}; + + namespace vector { + template <typename E1, typename E2> + std::size_t inline size(const mat_cvec_times_expr<E1, E2>& x) + { return num_rows(x.first); } + } + +} // namespace mtl + +#endif // MTL_MAT_CVEC_TIMES_EXPR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/mat_vec_mult.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/mat_vec_mult.hpp new file mode 100644 index 0000000000000000000000000000000000000000..184cd648fba97a6dfdbd4328ace314f4030375d4 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/mat_vec_mult.hpp @@ -0,0 +1,843 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MAT_VEC_MULT_INCLUDE +#define MTL_MAT_VEC_MULT_INCLUDE + +#include <cassert> +// #include <iostream> +#include <boost/mpl/bool.hpp> + +#include <boost/numeric/mtl/config.hpp> +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/utility/property_map.hpp> +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/is_static.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/enable_if.hpp> +#include <boost/numeric/mtl/utility/multi_tmp.hpp> +#include <boost/numeric/mtl/utility/static_assert.hpp> +#include <boost/numeric/mtl/vector/dense_vector.hpp> +#include <boost/numeric/mtl/utility/omp_size_type.hpp> +#include <boost/numeric/mtl/operation/set_to_zero.hpp> +#include <boost/numeric/mtl/operation/update.hpp> +#include <boost/numeric/linear_algebra/identity.hpp> +#include <boost/numeric/meta_math/loop.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { namespace matrix { + +namespace impl { + + template <std::size_t Index0, std::size_t Max0, std::size_t Index1, std::size_t Max1, typename Assign> + struct fully_unroll_mat_cvec_mult + : public meta_math::loop2<Index0, Max0, Index1, Max1> + { + typedef meta_math::loop2<Index0, Max0, Index1, Max1> base; + typedef fully_unroll_mat_cvec_mult<base::next_index0, Max0, base::next_index1, Max1, Assign> next_t; + + template <typename Matrix, typename VectorIn, typename VectorOut> + static inline void apply(const Matrix& A, const VectorIn& v, VectorOut& w) + { + Assign::update(w[base::index0], A[base::index0][base::index1] * v[base::index1]); + next_t::apply(A, v, w); + } + }; + + // need specialization here for not going back to column 0 but column 1 + template <std::size_t Index0, std::size_t Max0, std::size_t Max1, typename Assign> + struct fully_unroll_mat_cvec_mult<Index0, Max0, Max1, Max1, Assign> + : public meta_math::loop2<Index0, Max0, Max1, Max1> + { + typedef meta_math::loop2<Index0, Max0, Max1, Max1> base; + typedef fully_unroll_mat_cvec_mult<base::next_index0, Max0, 2, Max1, Assign> next_t; + + template <typename Matrix, typename VectorIn, typename VectorOut> + static inline void apply(const Matrix& A, const VectorIn& v, VectorOut& w) + { + Assign::update(w[base::index0], A[base::index0][base::index1] * v[base::index1]); + next_t::apply(A, v, w); + } + }; + + template <std::size_t Max0, std::size_t Max1, typename Assign> + struct fully_unroll_mat_cvec_mult<Max0, Max0, Max1, Max1, Assign> + : public meta_math::loop2<Max0, Max0, Max1, Max1> + { + typedef meta_math::loop2<Max0, Max0, Max1, Max1> base; + + template <typename Matrix, typename VectorIn, typename VectorOut> + static inline void apply(const Matrix& A, const VectorIn& v, VectorOut& w) + { + Assign::update(w[base::index0], A[base::index0][base::index1] * v[base::index1]); + } + }; + + struct noop + { + template <typename Matrix, typename VectorIn, typename VectorOut> + static inline void apply(const Matrix&, const VectorIn&, VectorOut&) {} + }; +} // impl + +// Dense matrix vector multiplication with run-time matrix size +template <typename Matrix, typename VectorIn, typename VectorOut, typename Assign> +inline void dense_mat_cvec_mult(const Matrix& A, const VectorIn& v, VectorOut& w, Assign, boost::mpl::true_) +{ + vampir_trace<3017> tracer; + typedef typename static_num_rows<Matrix>::type size_type; + static const size_type rows_a= static_num_rows<Matrix>::value, cols_a= static_num_cols<Matrix>::value; + + assert(rows_a > 0 && cols_a > 0); + // w= A[all][0] * v[0]; N.B.: 1D is unrolled by the compiler faster (at least on gcc) + for (size_type i= 0; i < rows_a; i++) + Assign::first_update(w[i], A[i][0] * v[0]); + + // corresponds to w+= A[all][1:] * v[1:]; if necessary + typedef impl::fully_unroll_mat_cvec_mult<1, rows_a, 2, cols_a, Assign> f2; + typedef typename boost::mpl::if_c<(cols_a > 1), f2, impl::noop>::type f3; + f3::apply(A, v, w); +} + +template <unsigned Index, unsigned Size> +struct init_ptrs +{ + template <typename Matrix, typename Ptrs> + inline static void apply(const Matrix& A, Ptrs& ptrs) + { + ptrs.value= &A[Index][0]; + init_ptrs<Index+1, Size>::apply(A, ptrs.sub); + } +}; + +template <unsigned Size> +struct init_ptrs<Size, Size> +{ + template <typename Matrix, typename Ptrs> + inline static void apply(const Matrix&, Ptrs&) {} +}; + +template <unsigned Index, unsigned Size> +struct square_cvec_mult_rows +{ + template <typename Tmps, typename Ptrs, typename ValueIn> + inline static void compute(Tmps& tmps, Ptrs& ptrs, ValueIn vi) + { + tmps.value+= *ptrs.value++ * vi; + square_cvec_mult_rows<Index+1, Size>::compute(tmps.sub, ptrs.sub, vi); + } + + template <typename As, typename VectorOut, typename Tmps> + inline static void update(As, VectorOut& w, const Tmps& tmps) + { + As::first_update(w[Index], tmps.value); + square_cvec_mult_rows<Index+1, Size>::update(As(), w, tmps.sub); + } +}; + +template <unsigned Size> +struct square_cvec_mult_rows<Size, Size> +{ + template <typename Tmps, typename Ptrs, typename ValueIn> + inline static void compute(Tmps&, Ptrs&, ValueIn) {} + + template <typename As, typename VectorOut, typename Tmps> + inline static void update(As, VectorOut&, const Tmps&) {} +}; + +template <unsigned Index, unsigned Size> +struct square_cvec_mult_cols +{ + template <typename Tmps, typename Ptrs, typename VPtr> + inline static void compute(Tmps& tmps, Ptrs& ptrs, VPtr vp) + { + square_cvec_mult_rows<0, Size>::compute(tmps, ptrs, *vp); + square_cvec_mult_cols<Index+1, Size>::compute(tmps, ptrs, ++vp); + } +}; + +template <unsigned Size> +struct square_cvec_mult_cols<Size, Size> +{ + template <typename Tmps, typename Ptrs, typename VPtr> + inline static void compute(Tmps&, Ptrs&, VPtr) {} +}; + + +// Dense matrix vector multiplication with run-time matrix size +template <unsigned Size, typename MValue, typename MPara, typename ValueIn, typename ParaIn, + typename VectorOut, typename Assign> +inline void square_cvec_mult(const dense2D<MValue, MPara>& A, const mtl::vector::dense_vector<ValueIn, ParaIn>& v, VectorOut& w, Assign) +{ + // vampir_trace<3067> tracer; + MTL_STATIC_ASSERT((mtl::traits::is_row_major<MPara>::value), "Only row-major matrices supported in this function."); + + typedef typename Collection<VectorOut>::value_type value_type; + multi_tmp<Size, value_type> tmps(math::zero(w[0])); + + multi_tmp<Size, const MValue*> ptrs; + init_ptrs<0, Size>::apply(A, ptrs); + + const ValueIn* vp= &v[0]; + + square_cvec_mult_cols<0, Size>::compute(tmps, ptrs, vp); // outer loop over columns + square_cvec_mult_rows<0, Size>::update(Assign(), w, tmps); // update rows +} + + +// Dense matrix vector multiplication with run-time matrix size +template <typename MValue, typename MPara, typename ValueIn, typename ParaIn, typename VectorOut, typename Assign> +typename boost::enable_if<mtl::traits::is_row_major<MPara> >::type +inline dense_mat_cvec_mult(const dense2D<MValue, MPara>& A, const mtl::vector::dense_vector<ValueIn, ParaIn>& v, VectorOut& w, Assign, boost::mpl::false_) +{ + // vampir_trace<3066> tracer; + + using math::zero; + if (mtl::vector::size(w) == 0) return; + + typedef typename Collection<VectorOut>::value_type value_type; + // typedef ValueIn value_in_type; + typedef typename MPara::size_type size_type; + + const size_type nr= num_rows(A), nc= num_cols(A); + if (nr == nc && nr <= 8) + switch (nr) { + case 1: Assign::first_update(w[0], A[0][0] * v[0]); return; + case 2: square_cvec_mult<2>(A, v, w, Assign()); return; + case 3: square_cvec_mult<3>(A, v, w, Assign()); return; + case 4: square_cvec_mult<4>(A, v, w, Assign()); return; + case 5: square_cvec_mult<5>(A, v, w, Assign()); return; + case 6: square_cvec_mult<6>(A, v, w, Assign()); return; + case 7: square_cvec_mult<7>(A, v, w, Assign()); return; + case 8: square_cvec_mult<8>(A, v, w, Assign()); return; + } + + + const size_type nrb= nr / 4 * 4; + const value_type z(math::zero(w[0])); + + for (size_type i= 0; i < nrb; i+= 4) { + value_type tmp0(z), tmp1(z), tmp2(z), tmp3(z); + const MValue *p0= &A[i][0], *pe= p0 + nc, *p1= &A[i+1][0], *p2= &A[i+2][0], *p3= &A[i+3][0]; + const ValueIn* vp= &v[0]; + for (; p0 != pe; ) { + const ValueIn vj= *vp++; + tmp0+= *p0++ * vj; + tmp1+= *p1++ * vj; + tmp2+= *p2++ * vj; + tmp3+= *p3++ * vj; + } + Assign::first_update(w[i], tmp0); + Assign::first_update(w[i+1], tmp1); + Assign::first_update(w[i+2], tmp2); + Assign::first_update(w[i+3], tmp3); + } + + for (size_type i= nrb; i < nr; i++) { + value_type tmp= z; + const ValueIn* vp= &v[0]; + for (const MValue *p0= &A[i][0], *pe= p0 + nc; p0 != pe; ) + tmp+= *p0++ * *vp++; + Assign::first_update(w[i], tmp); + } +} + + +// Dense matrix vector multiplication with run-time matrix size +template <typename Matrix, typename VectorIn, typename VectorOut, typename Assign> +inline void dense_mat_cvec_mult(const Matrix& A, const VectorIn& v, VectorOut& w, Assign, boost::mpl::false_) +{ + vampir_trace<3018> tracer; + // Naive implementation, will be moved to a functor and complemented with more efficient ones + + using math::zero; + if (mtl::vector::size(w) == 0) return; + // std::cout << "Bin in richtiger Funktion\n"; + + // if (Assign::init_to_zero) set_to_zero(w); // replace update with first_update insteda + + typedef typename Collection<VectorOut>::value_type value_type; + typedef typename Collection<VectorIn>::value_type value_in_type; + typedef typename Collection<Matrix>::size_type size_type; + + const value_type z(math::zero(w[0])); + const size_type nr= num_rows(A), nrb= nr / 4 * 4, nc= num_cols(A); + + for (size_type i= 0; i < nrb; i+= 4) { + value_type tmp0(z), tmp1(z), tmp2(z), tmp3(z); + for (size_type j= 0; j < nc; j++) { + const value_in_type vj= v[j]; + tmp0+= A[i][j] * vj; + tmp1+= A[i+1][j] * vj; + tmp2+= A[i+2][j] * vj; + tmp3+= A[i+3][j] * vj; + } + Assign::first_update(w[i], tmp0); + Assign::first_update(w[i+1], tmp1); + Assign::first_update(w[i+2], tmp2); + Assign::first_update(w[i+3], tmp3); + } + + for (size_type i= nrb; i < nr; i++) { + value_type tmp= z; + for (size_type j= 0; j < nc; j++) + tmp+= A[i][j] * v[j]; + Assign::first_update(w[i], tmp); + } +} + +// Dense matrix vector multiplication +template <typename Matrix, typename VectorIn, typename VectorOut, typename Assign> +inline void mat_cvec_mult(const Matrix& A, const VectorIn& v, VectorOut& w, Assign, tag::flat<tag::dense>) +{ +# ifdef MTL_NOT_UNROLL_FSIZE_MAT_VEC_MULT + boost::mpl::false_ selector; +# else + mtl::traits::is_static<Matrix> selector; +# endif + dense_mat_cvec_mult(A, v, w, Assign(), selector); +} + +// Element structure vector multiplication +template <typename Matrix, typename VectorIn, typename VectorOut, typename Assign> +inline void mat_cvec_mult(const Matrix& A, const VectorIn& v, VectorOut& w, Assign, tag::flat<tag::element_structure>) +{ + vampir_trace<3048> tracer; + if (mtl::vector::size(w) == 0) return; + + typedef typename Collection<VectorOut>::value_type value_type; + typedef typename Collection<VectorIn>::value_type value_in_type; + + value_in_type varray[1024]; + value_type warray[1024]; + + if (Assign::init_to_zero) set_to_zero(w); + for(int elmi= 0; elmi < A.m_total_elements; elmi++){ + const typename Matrix::element_type& elementi= A.m_elements[elmi]; + const typename Matrix::element_type::index_type& indices= elementi.get_indices(); + unsigned int n(size(indices)); + + if (n <= 1024) { + VectorIn vtmp(n, varray); + for (unsigned int i= 0; i < n; i++) + vtmp[i]= v[indices[i]]; + VectorOut wtmp(n, warray); + wtmp= elementi.get_values() * vtmp; + for (unsigned int i= 0; i < n; i++) + Assign::update(w[indices[i]], wtmp[i]); + } else { + VectorIn vtmp(n); + for (unsigned int i= 0; i < n; i++) + vtmp[i]= v[indices[i]]; + VectorOut wtmp(elementi.get_values() * vtmp); + for (unsigned int i= 0; i < n; i++) + Assign::update(w[indices[i]], wtmp[i]); + } + } +} + +// Multi-vector vector multiplication (tag::multi_vector is derived from dense) +template <typename Matrix, typename VectorIn, typename VectorOut, typename Assign> +inline void mat_cvec_mult(const Matrix& A, const VectorIn& v, VectorOut& w, Assign, tag::flat<tag::multi_vector>) +{ + vampir_trace<3019> tracer; + if (Assign::init_to_zero) set_to_zero(w); + for (unsigned i= 0; i < num_cols(A); i++) + Assign::update(w, A.vector(i) * v[i]); +} + +// Transposed multi-vector vector multiplication (tag::transposed_multi_vector is derived from dense) +template <typename TransposedMatrix, typename VectorIn, typename VectorOut, typename Assign> +inline void mat_cvec_mult(const TransposedMatrix& A, const VectorIn& v, VectorOut& w, Assign, tag::flat<tag::transposed_multi_vector>) +{ + vampir_trace<3020> tracer; + typename TransposedMatrix::const_ref_type B= A.ref; // Referred matrix + + if (Assign::init_to_zero) set_to_zero(w); + for (unsigned i= 0; i < num_cols(B); i++) + Assign::update(w[i], dot_real(B.vector(i), v)); +} + +// Hermitian multi-vector vector multiplication (tag::hermitian_multi_vector is derived from dense) +template <typename HermitianMatrix, typename VectorIn, typename VectorOut, typename Assign> +inline void mat_cvec_mult(const HermitianMatrix& A, const VectorIn& v, VectorOut& w, Assign, tag::flat<tag::hermitian_multi_vector>) +{ + vampir_trace<3021> tracer; + typename HermitianMatrix::const_ref_type B= A.const_ref(); // Referred matrix + + if (Assign::init_to_zero) set_to_zero(w); + for (unsigned i= 0; i < num_cols(B); i++) + Assign::update(w[i], dot(B.vector(i), v)); +} + + + +// Sparse row-major matrix vector multiplication +template <typename Matrix, typename VectorIn, typename VectorOut, typename Assign> +inline void smat_cvec_mult(const Matrix& A, const VectorIn& v, VectorOut& w, Assign, tag::row_major) +{ + vampir_trace<3022> tracer; + using namespace tag; + using mtl::traits::range_generator; + using math::zero; + using mtl::vector::set_to_zero; + + typedef typename range_generator<row, Matrix>::type a_cur_type; + typedef typename range_generator<nz, a_cur_type>::type a_icur_type; + typename mtl::traits::col<Matrix>::type col_a(A); + typename mtl::traits::const_value<Matrix>::type value_a(A); + + if (Assign::init_to_zero) set_to_zero(w); + + typedef typename Collection<VectorOut>::value_type value_type; + a_cur_type ac= begin<row>(A), aend= end<row>(A); + for (unsigned i= 0; ac != aend; ++ac, ++i) { + value_type tmp= zero(w[i]); + for (a_icur_type aic= begin<nz>(ac), aiend= end<nz>(ac); aic != aiend; ++aic) + tmp+= value_a(*aic) * v[col_a(*aic)]; + Assign::update(w[i], tmp); + } +} + +// Row-major compressed2D with very few entries (i.e. Very Sparse MATrix) times vector +template <typename MValue, typename MPara, typename VectorIn, typename VectorOut, typename Assign> +inline void vsmat_cvec_mult(const compressed2D<MValue, MPara>& A, const VectorIn& v, VectorOut& w, Assign, tag::row_major) +{ + vampir_trace<3064> tracer; + using math::zero; + + typedef compressed2D<MValue, MPara> Matrix; + typedef typename Collection<Matrix>::size_type size_type; + typedef typename Collection<VectorOut>::value_type value_type; + + if (size(w) == 0) return; + const value_type z(math::zero(w[0])); + + // std::cout << "very sparse: nnz = " << A.nnz() << ", num_rows = " << num_rows(A) << '\n'; + + size_type nr= num_rows(A); + for (size_type i1= 0, i2= std::min<size_type>(1024, nr); i1 < i2; i1= i2, i2= std::min<size_type>(i2 + 1024, nr)) { + // std::cout << "range = " << i1 << " .. " << i2 << "\n"; + if (A.ref_major()[i1] < A.ref_major()[i2]) + for (size_type i= i1; i < i2; ++i) { + const size_type cj0= A.ref_major()[i], cj1= A.ref_major()[i+1]; + value_type tmp0(z); + for (size_type j0= cj0; j0 != cj1; ++j0) + tmp0+= A.data[j0] * v[A.ref_minor()[j0]]; + Assign::first_update(w[i], tmp0); + } + } +} + +#ifdef MTL_CRS_CVEC_MULT_TUNING +template <unsigned Index, unsigned BSize, typename SizeType> +struct crs_cvec_mult_block +{ + template <typename Matrix, typename VectorIn, typename CBlock, typename TBlock> + void operator()(const Matrix& A, const VectorIn& v, const CBlock& cj, TBlock& tmp) const + { + for (SizeType j= cj.value; j != cj.sub.value; ++j) // cj is one index larger + tmp.value+= A.data[j] * v[A.ref_minor()[j]]; + sub(A, v, cj.sub, tmp.sub); + } + + template <typename VectorOut, typename TBlock, typename Assign> + void first_update(VectorOut& w, SizeType i, const TBlock& tmp, Assign as) const + { + Assign::first_update(w[i + Index], tmp.value); + sub.first_update(w, i, tmp.sub, as); + } + + crs_cvec_mult_block<Index+1, BSize, SizeType> sub; +}; + + +template <unsigned BSize, typename SizeType> +struct crs_cvec_mult_block<BSize, BSize, SizeType> +{ + template <typename Matrix, typename VectorIn, typename CBlock, typename TBlock> + void operator()(const Matrix& A, const VectorIn& v, const CBlock& cj, TBlock& tmp) const + { + for (SizeType j= cj.value; j != cj.sub.value; ++j)// cj is one index larger + tmp.value+= A.data[j] * v[A.ref_minor()[j]]; + } + + template <typename VectorOut, typename TBlock, typename Assign> + void first_update(VectorOut& w, SizeType i, const TBlock& tmp, Assign) const + { + Assign::first_update(w[i + BSize], tmp.value); + } +}; + + +// Row-major compressed2D vector multiplication +template <unsigned BSize, typename MValue, typename MPara, typename VectorIn, typename VectorOut, typename Assign> +inline void smat_cvec_mult(const compressed2D<MValue, MPara>& A, const VectorIn& v, VectorOut& w, Assign as, tag::row_major) +{ + vampir_trace<3049> tracer; + using math::zero; + + if (A.nnz() < num_rows(A)) { + vsmat_cvec_mult(A, v, w, as, tag::row_major()); + return; + } + + typedef compressed2D<MValue, MPara> Matrix; + typedef typename Collection<VectorOut>::value_type value_type; + typedef typename mtl::traits::omp_size_type<typename Collection<Matrix>::size_type>::type size_type; + + if (size(w) == 0) return; + const value_type z(math::zero(w[0])); + + size_type nr= num_rows(A), nrb= nr / BSize * BSize; + + #ifdef MTL_WITH_OPENMP + # pragma omp parallel + #endif + { + #ifdef MTL_WITH_OPENMP + vampir_trace<8004> tracer; + # pragma omp for + #endif + for (size_type i= 0; i < nrb; i+= BSize) { + multi_constant_from_array<0, BSize+1, size_type> cj(A.ref_major(), i); + multi_tmp<BSize, value_type> tmp(z); + crs_cvec_mult_block<0, BSize-1, size_type> block; + + block(A, v, cj, tmp); + block.first_update(w, i, tmp, as); + } + } + + for (size_type i= nrb; i < nr; ++i) { + const size_type cj0= A.ref_major()[i], cj1= A.ref_major()[i+1]; + value_type tmp0(z); + for (size_type j0= cj0; j0 != cj1; ++j0) + tmp0+= A.data[j0] * v[A.ref_minor()[j0]]; + Assign::first_update(w[i], tmp0); + } +} + +template <typename MValue, typename MPara, typename VectorIn, typename VectorOut, typename Assign> +typename mtl::traits::enable_if_scalar<typename Collection<VectorOut>::value_type>::type +inline smat_cvec_mult(const compressed2D<MValue, MPara>& A, const VectorIn& v, VectorOut& w, Assign, tag::row_major) +{ + smat_cvec_mult<crs_cvec_mult_block_size>(A, v, w, Assign(), tag::row_major()); +} +#endif + + +#if !defined(MTL_CRS_CVEC_MULT_NO_ACCEL) && !defined(MTL_CRS_CVEC_MULT_TUNING) + +template <typename MValue, typename MPara, typename VectorIn, typename VectorOut, typename Assign> +typename mtl::traits::enable_if_scalar<typename Collection<VectorOut>::value_type>::type +inline adapt_crs_cvec_mult(const compressed2D<MValue, MPara>& A, const VectorIn& v, VectorOut& w, Assign) +{ + vampir_trace<3065> tracer; + using math::zero; + assert(!Assign::init_to_zero); + + typedef compressed2D<MValue, MPara> Matrix; + typedef typename Collection<Matrix>::size_type size_type; + typedef typename Collection<VectorOut>::value_type value_type; + + const value_type z(math::zero(w[0])); + size_type nr= num_rows(A), nrb= nr / 4 * 4, nrb2= nr / 64 * 64; + + for (size_type i1= 0; i1 < nrb2; i1+= 64) + if (A.ref_major()[i1] != A.ref_major()[i1 + 64]) + for (size_type i2= i1, i2e= i1+64; i2 < i2e; i2+= 16) + if (A.ref_major()[i2] != A.ref_major()[i2 + 16]) + for (size_type i= i2, i3e= i2+16; i < i3e; i+= 4) + if (A.ref_major()[i] != A.ref_major()[i + 4]) { + const size_type cj0= A.ref_major()[i], cj1= A.ref_major()[i+1], cj2= A.ref_major()[i+2], + cj3= A.ref_major()[i+3], cj4= A.ref_major()[i+4]; + value_type tmp0(z), tmp1(z), tmp2(z), tmp3(z); + for (size_type j0= cj0; j0 != cj1; ++j0) + tmp0+= A.data[j0] * v[A.ref_minor()[j0]]; + for (size_type j1= cj1; j1 != cj2; ++j1) + tmp1+= A.data[j1] * v[A.ref_minor()[j1]]; + for (size_type j2= cj2; j2 != cj3; ++j2) + tmp2+= A.data[j2] * v[A.ref_minor()[j2]]; + for (size_type j3= cj3; j3 != cj4; ++j3) + tmp3+= A.data[j3] * v[A.ref_minor()[j3]]; + + Assign::first_update(w[i], tmp0); + Assign::first_update(w[i+1], tmp1); + Assign::first_update(w[i+2], tmp2); + Assign::first_update(w[i+3], tmp3); + } + + for (size_type i= nrb2; i < nrb; i+= 4) + if (A.ref_major()[i] != A.ref_major()[i + 4]) { + const size_type cj0= A.ref_major()[i], cj1= A.ref_major()[i+1], cj2= A.ref_major()[i+2], + cj3= A.ref_major()[i+3], cj4= A.ref_major()[i+4]; + value_type tmp0(z), tmp1(z), tmp2(z), tmp3(z); + for (size_type j0= cj0; j0 != cj1; ++j0) + tmp0+= A.data[j0] * v[A.ref_minor()[j0]]; + for (size_type j1= cj1; j1 != cj2; ++j1) + tmp1+= A.data[j1] * v[A.ref_minor()[j1]]; + for (size_type j2= cj2; j2 != cj3; ++j2) + tmp2+= A.data[j2] * v[A.ref_minor()[j2]]; + for (size_type j3= cj3; j3 != cj4; ++j3) + tmp3+= A.data[j3] * v[A.ref_minor()[j3]]; + + Assign::first_update(w[i], tmp0); + Assign::first_update(w[i+1], tmp1); + Assign::first_update(w[i+2], tmp2); + Assign::first_update(w[i+3], tmp3); + } + + for (size_type i= nrb; i < nr; ++i) { + const size_type cj0= A.ref_major()[i], cj1= A.ref_major()[i+1]; + value_type tmp0(z); + for (size_type j0= cj0; j0 != cj1; ++j0) + tmp0+= A.data[j0] * v[A.ref_minor()[j0]]; + Assign::first_update(w[i], tmp0); + } +} + +// Row-major compressed2D vector multiplication +template <typename MValue, typename MPara, typename VectorIn, typename VectorOut, typename Assign> +typename mtl::traits::enable_if_scalar<typename Collection<VectorOut>::value_type>::type +inline smat_cvec_mult(const compressed2D<MValue, MPara>& A, const VectorIn& v, VectorOut& w, Assign as, tag::row_major) +{ + vampir_trace<3049> tracer; + // vampir_trace<5056> tttracer; + using math::zero; + + if (A.nnz() < num_rows(A) && !as.init_to_zero) { + vsmat_cvec_mult(A, v, w, as, tag::row_major()); + return; + } + + typedef compressed2D<MValue, MPara> Matrix; + typedef typename Collection<VectorOut>::value_type value_type; + typedef typename mtl::traits::omp_size_type<typename Collection<Matrix>::size_type>::type size_type; + + if (size(w) == 0) return; + const value_type z(math::zero(w[0])); + + size_type nr= num_rows(A), nrb= nr / 4 * 4; + if (nr > 10) { + size_type nh= nr / 2, nq= nr / 4, nt= nr - nq; + if (!as.init_to_zero && + (A.ref_major()[1] == A.ref_major()[0] + || A.ref_major()[nq] == A.ref_major()[nq+1] + || A.ref_major()[nh] == A.ref_major()[nh+1] + || A.ref_major()[nt] == A.ref_major()[nt+1] + || A.ref_major()[nr-1] == A.ref_major()[nr])) { + adapt_crs_cvec_mult(A, v, w, as); + return; + } + } + + #ifdef MTL_WITH_OPENMP + # pragma omp parallel + #endif + { + #ifdef MTL_WITH_OPENMP + vampir_trace<8004> tracer; + # pragma omp for + #endif + for (size_type i= 0; i < nrb; i+= 4) { + const size_type cj0= A.ref_major()[i], cj1= A.ref_major()[i+1], cj2= A.ref_major()[i+2], + cj3= A.ref_major()[i+3], cj4= A.ref_major()[i+4]; + value_type tmp0(z), tmp1(z), tmp2(z), tmp3(z); + for (size_type j0= cj0; j0 != cj1; ++j0) + tmp0+= A.data[j0] * v[A.ref_minor()[j0]]; + for (size_type j1= cj1; j1 != cj2; ++j1) + tmp1+= A.data[j1] * v[A.ref_minor()[j1]]; + for (size_type j2= cj2; j2 != cj3; ++j2) + tmp2+= A.data[j2] * v[A.ref_minor()[j2]]; + for (size_type j3= cj3; j3 != cj4; ++j3) + tmp3+= A.data[j3] * v[A.ref_minor()[j3]]; + + Assign::first_update(w[i], tmp0); + Assign::first_update(w[i+1], tmp1); + Assign::first_update(w[i+2], tmp2); + Assign::first_update(w[i+3], tmp3); + } + } + + for (size_type i= nrb; i < nr; ++i) { + const size_type cj0= A.ref_major()[i], cj1= A.ref_major()[i+1]; + value_type tmp0(z); + for (size_type j0= cj0; j0 != cj1; ++j0) + tmp0+= A.data[j0] * v[A.ref_minor()[j0]]; + Assign::first_update(w[i], tmp0); + } +} +#endif + +// Row-major ell_matrix vector multiplication +template <typename MValue, typename MPara, typename VectorIn, typename VectorOut, typename Assign> +typename mtl::traits::enable_if_scalar<typename Collection<VectorOut>::value_type>::type +inline smat_cvec_mult(const ell_matrix<MValue, MPara>& A, const VectorIn& v, VectorOut& w, Assign, tag::row_major) +{ + typedef typename MPara::size_type size_type; + + const size_type stride= A.stride(), slots= A.slots(); + for (size_type r= 0; r < A.dim1(); ++r) { + MValue s(0); + for (size_type k= r, i= 0; i < slots; ++i, k+= stride) + s+= A.ref_data()[k] * v[A.ref_minor()[k]]; + Assign::first_update(w[r], s); + } + } + + +// Row-major sparse_banded vector multiplication +template <typename MValue, typename MPara, typename VectorIn, typename VectorOut, typename Assign> +typename mtl::traits::enable_if_scalar<typename Collection<VectorOut>::value_type>::type +inline smat_cvec_mult(const sparse_banded<MValue, MPara>& A, const VectorIn& v, VectorOut& w, Assign, tag::row_major) +{ + vampir_trace<3069> tracer; + typedef sparse_banded<MValue, MPara> Matrix; + typedef typename Collection<VectorOut>::value_type value_type; + typedef typename Matrix::band_size_type band_size_type; + typedef typename MPara::size_type size_type; + typedef mtl::vector::dense_vector<band_size_type, vector::parameters<> > vector_type; + + if (size(w) == 0) return; + const value_type z(math::zero(w[0])); + + size_type nr= num_rows(A), nc= num_cols(A), nb= A.ref_bands().size(); + if (nb == size_type(0) && Assign::init_to_zero) { + set_to_zero(w); + return; + } + + vector_type bands(A.ref_bands()), begin_rows(max(0, -bands)), end_rows(min(nr, nc - bands)); + assert(end_rows[nb-1] > 0); + + // std::cout << "bands = " << bands << ", begin_rows = " << begin_rows << ", end_rows = " << end_rows << "\n"; + size_type begin_pos= 0, end_pos= nb - 1; + + // find lowest diagonal in row 0 + while (begin_pos < nb && begin_rows[begin_pos] > 0) begin_pos++; + // if at the end, the first rows are empty + if (begin_pos == nb && Assign::init_to_zero) { + w[irange(begin_rows[--begin_pos])]= z; + // std::cout << "w[0.." << begin_rows[begin_pos] << "] <- 0\n"; + } + + band_size_type from= begin_rows[begin_pos]; + // find first entry with same value + while (begin_pos > 0 && begin_rows[begin_pos - 1] == from) { + assert(from == 0); // should only happen when multiple bands start in row 0 + begin_pos--; + } + for (bool active= true; active; ) { + // search backwards for the next-largest entry + band_size_type to= begin_pos > 0 && begin_rows[begin_pos - 1] <= end_rows[end_pos] ? begin_rows[begin_pos - 1] : end_rows[end_pos]; + + // std::cout << "rows " << from << ".." << to << ": with bands "; + // for (size_type i= begin_pos; i <= end_pos; i++) + // std::cout << bands[i] << (i < end_pos ? ", " : "\n"); + + const MValue* Aps= A.ref_data() + (from * nb + begin_pos); + + const band_size_type blocked_to= ((to - from) & -4) + from; + assert((blocked_to - from) % 4 == 0 && blocked_to >= band_size_type(from) && blocked_to <= band_size_type(to)); + for (band_size_type r= from; r < blocked_to; r+= 4) { + value_type tmp0(z), tmp1(z), tmp2(z), tmp3(z); + const MValue *Ap0= Aps, *Ap1= Aps + nb, *Ap2= Ap1 + nb, *Ap3= Ap2 + nb; + for (size_type b= begin_pos; b <= end_pos; ++b, ++Ap0, ++Ap1, ++Ap2, ++Ap3) { + tmp0+= *Ap0 * v[r + bands[b]]; + tmp1+= *Ap1 * v[r + bands[b] + 1]; + tmp2+= *Ap2 * v[r + bands[b] + 2]; + tmp3+= *Ap3 * v[r + bands[b] + 3]; + } + Assign::first_update(w[r], tmp0); + Assign::first_update(w[r+1], tmp1); + Assign::first_update(w[r+2], tmp2); + Assign::first_update(w[r+3], tmp3); + Aps+= 4 * nb; + } + + for (band_size_type r= blocked_to; r < band_size_type(to); r++) { + value_type tmp(z); + const MValue* Ap= Aps; + for (size_type b= begin_pos; b <= end_pos; ++b, ++Ap) + tmp+= *Ap * v[r + bands[b]]; + Assign::first_update(w[r], tmp); + Aps+= nb; + } + + if (begin_pos > 0) { + if (begin_rows[begin_pos-1] == to) + begin_pos--; + if (end_rows[end_pos] == to) + end_pos--; + } else { // begin == 0 -> decrement end_pos or finish + if (end_rows[0] == to) { + active= false; + assert(end_rows[0] = end_rows[end_pos]); + } else { + assert(end_pos > 0); + end_pos--; + } + } + assert(begin_pos <= end_pos); + from= to; + } + + if (size_type(end_rows[0]) < nr && Assign::init_to_zero) { + w[irange(end_rows[0], nr)]= z; + // std::cout << "w[" << end_rows[0] << ".." << nr << "] <- 0\n"; + } +} + +// Sparse column-major matrix vector multiplication +template <typename Matrix, typename VectorIn, typename VectorOut, typename Assign> +inline void smat_cvec_mult(const Matrix& A, const VectorIn& v, VectorOut& w, Assign, tag::col_major) +{ + vampir_trace<3023> tracer; + using namespace tag; namespace traits = mtl::traits; + using traits::range_generator; + using mtl::vector::set_to_zero; + typedef typename range_generator<col, Matrix>::type a_cur_type; + typedef typename range_generator<nz, a_cur_type>::type a_icur_type; + + typename traits::row<Matrix>::type row_a(A); + typename traits::const_value<Matrix>::type value_a(A); + + if (Assign::init_to_zero) set_to_zero(w); + + unsigned rv= 0; // traverse all rows of v + for (a_cur_type ac= begin<col>(A), aend= end<col>(A); ac != aend; ++ac, ++rv) { + typename Collection<VectorIn>::value_type vv= v[rv]; + for (a_icur_type aic= begin<nz>(ac), aiend= end<nz>(ac); aic != aiend; ++aic) + Assign::update(w[row_a(*aic)], value_a(*aic) * vv); + } +} + +// Sparse matrix vector multiplication +template <typename Matrix, typename VectorIn, typename VectorOut, typename Assign> +inline void mat_cvec_mult(const Matrix& A, const VectorIn& v, VectorOut& w, Assign, tag::flat<tag::sparse>) +{ + smat_cvec_mult(A, v, w, Assign(), typename OrientedCollection<Matrix>::orientation()); +} + + + +}} // namespace mtl::matrix + + + + +#endif // MTL_MAT_VEC_MULT_INCLUDE + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/matrix_bracket.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/matrix_bracket.hpp new file mode 100644 index 0000000000000000000000000000000000000000..22648dd835d0edb88a930c7bd6bbd1b56f3f40fd --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/matrix_bracket.hpp @@ -0,0 +1,101 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_BRACKETS_INCLUDE +#define MTL_MATRIX_BRACKETS_INCLUDE + +#include <algorithm> +#include <boost/utility/enable_if.hpp> +#include <boost/type_traits/is_integral.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/type_traits/remove_reference.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/utility/irange.hpp> +#include <boost/numeric/mtl/utility/iset.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/operation/column_in_matrix.hpp> +#include <boost/numeric/mtl/operation/row_in_matrix.hpp> + +namespace mtl { namespace operations { + + template <typename Matrix, typename Ref, typename ValueRef> + struct bracket_proxy + { + typedef typename Matrix::value_type value_type; + typedef typename Matrix::size_type size_type; + typedef RowInMatrix<typename boost::remove_reference<Ref>::type> row_traits; + + explicit bracket_proxy(Ref matrix, size_type row) : matrix(matrix), row(row) {} + + ValueRef operator[] (size_type col) { return matrix(row, col); } + + template <typename T> struct my_traits { static const bool value= boost::is_same<T, mtl::irange>::value && row_traits::exists; }; + + template <typename T> + typename boost::lazy_enable_if_c<my_traits<T>::value, row_traits>::type + operator[] (const T& col_range) + { + return row_traits::apply(matrix, row, col_range); + } + protected: + Ref matrix; + size_type row; + }; + + + + template <typename Matrix, typename Ref, typename ValueRef> + struct range_bracket_proxy + { + typedef typename Matrix::size_type size_type; + typedef ColumnInMatrix<typename boost::remove_reference<Ref>::type> col_traits; + + explicit range_bracket_proxy(Ref matrix, const irange& row_range) : matrix(matrix), row_range(row_range) {} + + ValueRef operator[] (const irange& col_range) + { + return sub_matrix(matrix, row_range.start(), row_range.finish(), + col_range.start(), col_range.finish()); + } + + template <typename T> struct my_traits { static const bool value = boost::is_integral<T>::value && col_traits::exists; }; + + template <typename T> + typename boost::lazy_enable_if_c<my_traits<T>::value, col_traits>::type + operator[] (T col) { return col_traits::apply(matrix, row_range, col); } + + protected: + Ref matrix; + irange row_range; + }; + + template <typename Matrix, typename Ref, typename ValueRef> + struct set_bracket_proxy + { + set_bracket_proxy(Ref matrix, const iset& row_set) : matrix(matrix), row_set(row_set) {} + + mtl::matrix::indirect<Matrix> operator[] (const iset& col_set) + { + return mtl::matrix::indirect<Matrix>(matrix, row_set, col_set); + } + + protected: + Ref matrix; + iset row_set; + }; + +} // namespace operations + +} // NAMESPACE mtl + +#endif // MTL_MATRIX_BRACKETS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/max.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/max.hpp new file mode 100644 index 0000000000000000000000000000000000000000..f5d932bea111da1751c6e5db14eb98d873f45b61 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/max.hpp @@ -0,0 +1,66 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MAX_INCLUDE +#define MTL_MAX_INCLUDE + +#include <iostream> +#include <cmath> + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/vector/reduction.hpp> +#include <boost/numeric/mtl/vector/reduction_functors.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { namespace vector { + + namespace impl { + + // Do we really need this for matrices? + // Then we need a different dispatching + + template <unsigned long Unroll, typename Vector> + typename Collection<Vector>::value_type + inline max(const Vector& vector, tag::vector) + { + typedef typename Collection<Vector>::value_type result_type; + return vector::reduction<Unroll, vector::max_functor, result_type>::apply(vector); + } + + } // namespace impl + +///Returns maximal entry of %vector v +template <unsigned long Unroll, typename Value> +typename Collection<Value>::value_type +inline max(const Value& value) +{ + vampir_trace<2010> tracer; + return impl::max<Unroll>(value, typename traits::category<Value>::type()); +} + +template <typename Value> +typename Collection<Value>::value_type +inline max(const Value& value) +{ + return max<8>(value); +} + +} // namespace vector + +using vector::max; + +} // namespace mtl::vector + +#endif // MTL_MAX_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/max_abs_pos.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/max_abs_pos.hpp new file mode 100644 index 0000000000000000000000000000000000000000..36863a793a823c06118c23ee298678a09239ffb0 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/max_abs_pos.hpp @@ -0,0 +1,90 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_MAX_ABS_POS_INCLUDE +#define MTL_MATRIX_MAX_ABS_POS_INCLUDE + +#include <utility> +#include <cmath> +#include <boost/numeric/linear_algebra/identity.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/concept/magnitude.hpp> +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace mtl { + +namespace matrix { +///Returns pair (row, col) from absolut maximal entry of %matrix A + template <typename Matrix> + typename mtl::traits::enable_if_matrix<Matrix, std::pair<typename Collection<Matrix>::size_type, typename Collection<Matrix>::size_type> >::type + inline max_abs_pos(const Matrix& A) + { + vampir_trace<3024> tracer; + namespace traits = mtl::traits; + using std::abs; + typedef typename Collection<Matrix>::value_type value_type; + typedef typename Collection<Matrix>::size_type size_type; + + typename RealMagnitude<value_type>::type max(abs(A[0][0])); + size_type r= 0, c= 0; + + typename traits::row<Matrix>::type row(A); + typename traits::col<Matrix>::type col(A); + typename traits::const_value<Matrix>::type value(A); + typedef typename traits::range_generator<tag::major, Matrix>::type cursor_type; + + for (cursor_type cursor = begin<tag::major>(A), cend = end<tag::major>(A); cursor != cend; ++cursor) { + typedef typename traits::range_generator<tag::nz, cursor_type>::type icursor_type; + for (icursor_type icursor = begin<tag::nz>(cursor), icend = end<tag::nz>(cursor); icursor != icend; ++icursor) + if (abs(value(*icursor)) > max) { + max= abs(value(*icursor)); + r= row(*icursor); + c= col(*icursor); + } + } + + return std::make_pair(r, c); + } + +} // namespace matrix + +namespace vector { +///Returns position from absolut maximal entry of %vector v + template <typename Vector> + typename mtl::traits::enable_if_vector<Vector, typename Collection<Vector>::size_type>::type + inline max_abs_pos(const Vector& v) + { + vampir_trace<2011> tracer; + using std::abs; + typedef typename Collection<Vector>::size_type size_type; + typedef typename Collection<Vector>::value_type value_type; + + size_type i= 0; + size_type max_col= size(v); + value_type max(abs(v[0])); + + for(size_type j= 1; j < max_col; j++) + if(abs(v[j]) > max) { + max = abs(v[j]); + i= j; + } + return i; + } + +} // namespace vector + +} // namespace mtl + +#endif // MTL_MATRIX_MAX_ABS_POS_INCLUDE + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/max_of_sums.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/max_of_sums.hpp new file mode 100644 index 0000000000000000000000000000000000000000..5e1f862ad794b1b80b0ded7c95c37cc5e05b71b9 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/max_of_sums.hpp @@ -0,0 +1,74 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MAX_OF_SUMS_INCLUDE +#define MTL_MAX_OF_SUMS_INCLUDE + +#include <boost/numeric/mtl/concept/magnitude.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/linear_algebra/operators.hpp> +#include <boost/numeric/linear_algebra/identity.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/vector/dense_vector.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +#include <numeric> +#include <cmath> + + +namespace mtl { namespace impl { + +// We need property map of the minor index +template <typename Matrix, typename MinorIndex> +typename RealMagnitude<typename Collection<Matrix>::value_type>::type +inline max_of_sums(const Matrix& matrix, bool aligned, MinorIndex minor_index, unsigned dim2) +{ + vampir_trace<2012> tracer; + using std::max; using std::abs; using math::zero; + + typedef typename Collection<Matrix>::value_type value_type; + typedef typename RealMagnitude<value_type>::type real_type; + real_type ref, my_zero= zero(ref); + + // If matrix is empty then the result is the identity from the default-constructed value + if (num_rows(matrix) == 0 || num_cols(matrix) == 0) + return my_zero; + + typedef typename traits::range_generator<tag::major, Matrix>::type cursor_type; + typedef typename traits::range_generator<tag::nz, cursor_type>::type icursor_type; + typename traits::const_value<Matrix>::type value(matrix); + + if (aligned) { + real_type maxv= my_zero; + for (cursor_type cursor = begin<tag::major>(matrix), cend = end<tag::major>(matrix); cursor != cend; ++cursor) { + real_type sum= my_zero; + for (icursor_type icursor = begin<tag::nz>(cursor), icend = end<tag::nz>(cursor); icursor != icend; ++icursor) + sum+= abs(value(*icursor)); + maxv= max(maxv, sum); + } + return maxv; + } + + // If matrix has other orientation, we compute all sums in a vector + vector::dense_vector<real_type> sums(dim2, my_zero); + for (cursor_type cursor = begin<tag::major>(matrix), cend = end<tag::major>(matrix); cursor != cend; ++cursor) + for (icursor_type icursor = begin<tag::nz>(cursor), icend = end<tag::nz>(cursor); icursor != icend; ++icursor) + sums[minor_index(*icursor)]+= abs(value(*icursor)); + // replace by mtl::accumulate<8> + return std::accumulate(sums.begin(), sums.end(), my_zero, math::max<real_type>()); +} + + +}} // namespace mtl::impl + +#endif // MTL_MAX_OF_SUMS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/max_pos.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/max_pos.hpp new file mode 100644 index 0000000000000000000000000000000000000000..3126c6683be32d7d3b9c13d18d1b2c6ce7f7f78c --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/max_pos.hpp @@ -0,0 +1,146 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_MAX_POS +#define MTL_MATRIX_MAX_POS + +#include <cmath> +#include <utility> +#include <boost/numeric/linear_algebra/identity.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/pos_type.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/operation/look_at_each_nonzero.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +#if 0 +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/property_map.hpp> +#endif + + + +namespace mtl { + + namespace vector { + + template <typename Vector> + struct max_pos_functor + { + typedef typename Collection<Vector>::value_type value_type; + typedef typename mtl::traits::pos_type<Vector>::type pos_type; + typedef std::pair<value_type, pos_type> result_type; + + // initialize with max value and max position + max_pos_functor() + { + value.first= math::identity(math::max<value_type>(), value_type()); // minimal value for comparison + value.second= math::identity(math::min<pos_type>(), pos_type()); // maximal position to check if changed + } + + void operator()(const value_type& x, const pos_type& p) + { + if (x > value.first) + value= std::make_pair(x, p); + } + + bool unchanged() const { return value.second == math::identity(math::min<pos_type>(), pos_type()); } + + result_type value; + }; + ///Returns position of maximal entry of %vector v + template <typename Vector> + typename max_pos_functor<Vector>::pos_type + inline max_pos(const Vector& v) + { + vampir_trace<2013> tracer; + max_pos_functor<Vector> f; + look_at_each_nonzero_pos(v, f); + + MTL_DEBUG_THROW_IF(f.unchanged(), runtime_error("max_pos cannot be applied on empty container")); + return f.value.second; + } + + } // namespace vector + + namespace matrix { + ///Returns pair (row, col) from maximal entry of %matrix A + using mtl::vector::max_pos; + } + + +#if 0 +namespace matrix { +///Returns pair (row, col) from maximal entry of %matrix A + template <typename Matrix> + std::pair<typename Collection<Matrix>::size_type, typename Collection<Matrix>::size_type> + inline max_pos(const Matrix& A) + { + namespace traits = mtl::traits; + typedef typename Collection<Matrix>::value_type value_type; + typedef typename Collection<Matrix>::size_type size_type; + + value_type max(A[0][0]); + size_type r= 0, c= 0; + + typename traits::row<Matrix>::type row(A); + typename traits::col<Matrix>::type col(A); + typename traits::const_value<Matrix>::type value(A); + typedef typename traits::range_generator<tag::major, Matrix>::type cursor_type; + + for (cursor_type cursor = begin<tag::major>(A), cend = end<tag::major>(A); cursor != cend; ++cursor) { + typedef typename traits::range_generator<tag::nz, cursor_type>::type icursor_type; + for (icursor_type icursor = begin<tag::nz>(cursor), icend = end<tag::nz>(cursor); icursor != icend; ++icursor) + if (value(*icursor) > max) { + max= value(*icursor); + r= row(*icursor); + c= col(*icursor); + } + } + + return std::make_pair(r, c); +} + +} // namespace matrix + +namespace vector { +///Returns position from maximal entry of %vector v + template <typename Vector> + typename Collection<Vector>::size_type + inline max_pos(const Vector& v) + { + typedef typename Collection<Vector>::size_type size_type; + typedef typename Collection<Vector>::value_type value_type; + + size_type i= 0; + + size_type max_col= size(v); + value_type max(v[0]); + + for(size_type j= 1;i < max_col; j++) + if(v[j] > max) { + max = v[j]; + i= j; + } + return i; + } + +} // namespace vector + +#endif + + +} // namespace mtl + +#endif // MTL_MATRIX_MAX_POS + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/merge_complex_matrix.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/merge_complex_matrix.hpp new file mode 100644 index 0000000000000000000000000000000000000000..6b846d1b5fe38a8a21dba2c3611ff91565f277b5 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/merge_complex_matrix.hpp @@ -0,0 +1,23 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_MERGE_COMPLEX_MATRIX_INCLUDE +#define MTL_MATRIX_MERGE_COMPLEX_MATRIX_INCLUDE + +namespace mtl { namespace matrix { + + + + +}} // namespace mtl::matrix + +#endif // MTL_MATRIX_MERGE_COMPLEX_MATRIX_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/merge_complex_vector.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/merge_complex_vector.hpp new file mode 100644 index 0000000000000000000000000000000000000000..efb08f62b1ca7cc0a0e367e73609c1d29038b09b --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/merge_complex_vector.hpp @@ -0,0 +1,44 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_VECTOR_MERGE_COMPLEX_VECTOR_INCLUDE +#define MTL_VECTOR_MERGE_COMPLEX_VECTOR_INCLUDE + +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace mtl { namespace vector { + +/// Merge two real-valued vectors into one complex-valued vector. +/** Elements of the complex vector must be constructible from two real elements. + Complex vector is resized if its size is 0 otherwise the vectors must have + the same length. **/ +template <typename VectorReal, typename VectorImaginary, typename VectorComplex> +inline void merge_complex_vector(const VectorReal& r, const VectorImaginary& i, VectorComplex& c) +{ + vampir_trace<2014> tracer; + typedef typename Collection<VectorComplex>::value_type value_type; + + MTL_THROW_IF(size(r) != size(i), incompatible_size()); + c.checked_change_dim(size(r)); + + for (std::size_t j= 0; j < size(r); ++j) + c[j]= value_type(r[j], i[j]); +} + + + + +}} // namespace mtl::vector + +#endif // MTL_VECTOR_MERGE_COMPLEX_VECTOR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/min.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/min.hpp new file mode 100644 index 0000000000000000000000000000000000000000..2b2e9e882c69de7d7f5c55cf26b6b7a4d1533bba --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/min.hpp @@ -0,0 +1,64 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MIN_INCLUDE +#define MTL_MIN_INCLUDE + +#include <iostream> +#include <cmath> + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/vector/reduction.hpp> +#include <boost/numeric/mtl/vector/reduction_functors.hpp> + + +namespace mtl { namespace vector { + + namespace impl { + + // Do we really need this for matrices? + // Then we need a different dispatching + + template <unsigned long Unroll, typename Vector> + typename Collection<Vector>::value_type + inline min(const Vector& vector, tag::vector) + { + typedef typename Collection<Vector>::value_type result_type; + return vector::reduction<Unroll, vector::min_functor, result_type>::apply(vector); + } + + } // namespace impl + +///Returns minimal value of %vector v +template <unsigned long Unroll, typename Value> +typename Collection<Value>::value_type +inline min(const Value& value) +{ + return impl::min<Unroll>(value, typename traits::category<Value>::type()); +} + +template <typename Value> +typename Collection<Value>::value_type +inline min(const Value& value) +{ + return min<8>(value); +} + +} // namespace vector + +using vector::min; + +} // namespace mtl + +#endif // MTL_MIN_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/min_pos.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/min_pos.hpp new file mode 100644 index 0000000000000000000000000000000000000000..4074dbd8eabb2d4a26a0247480c6b2a833e52d77 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/min_pos.hpp @@ -0,0 +1,71 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MIN_POS_INCLUDE +#define MTL_MIN_POS_INCLUDE + +#include <utility> + +#include <boost/numeric/linear_algebra/identity.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/pos_type.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/operation/look_at_each_nonzero.hpp> + + +namespace mtl { + + namespace vector { + + template <typename Vector> + struct min_pos_functor + { + typedef typename Collection<Vector>::value_type value_type; + typedef typename mtl::traits::pos_type<Vector>::type pos_type; + typedef std::pair<value_type, pos_type> result_type; + + // initialize with max value and max position + min_pos_functor() : value(math::identity(math::min<result_type>(), result_type())) {} + + void operator()(const value_type& x, const pos_type& p) + { + if (x < value.first) + value= std::make_pair(x, p); + } + + bool unchanged() const { return value.second == math::identity(math::min<pos_type>(), pos_type()); } + + result_type value; + }; + ///Returns position of minimal entry of %vector v + template <typename Vector> + typename min_pos_functor<Vector>::pos_type + inline min_pos(const Vector& v) + { + min_pos_functor<Vector> f; + look_at_each_nonzero_pos(v, f); + + MTL_DEBUG_THROW_IF(f.unchanged(), runtime_error("min_pos cannot be applied on empty container")); + return f.value.second; + } + + } // namespace vector + + namespace matrix { + + using mtl::vector::min_pos; + } + + +} // namespace mtl + +#endif // MTL_MIN_POS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/minimal_increase.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/minimal_increase.hpp new file mode 100644 index 0000000000000000000000000000000000000000..1e6a13e05926cddaeff9ba0a7ca828a62ab036a1 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/minimal_increase.hpp @@ -0,0 +1,35 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MINIMAL_INCREASE_INCLUDE +#define MTL_MINIMAL_INCREASE_INCLUDE + +#include <limits> + +namespace mtl { + +/// Increase x minimally: if x == 0 take minimal value, if x > 0 multiply by (1+2eps) otherwise divide by +template <typename T> +T inline minimal_increase(const T& x) +{ + const T factor= T(1) + T(2) * std::numeric_limits<T>::epsilon(); + if (x == T(0)) + return std::numeric_limits<T>::denorm_min(); + else + return x > T(0) ? x * factor : x / factor; +} + + + +} // namespace mtl + +#endif // MTL_MINIMAL_INCREASE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/misc.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/misc.hpp new file mode 100644 index 0000000000000000000000000000000000000000..51b262db2d284ac0a2ce718675a792ec8952c0f4 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/misc.hpp @@ -0,0 +1,28 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +// With contributions from Cornelius Steinhardt + +#ifndef MTL_MISC_INCLUDE +#define MTL_MISC_INCLUDE + +namespace mtl { + + template <typename T> + T square(const T& x) + { return x * x; } + +}// namespace mtl + + +#endif // MTL_MISC_INCLUDE + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/mult.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/mult.hpp new file mode 100644 index 0000000000000000000000000000000000000000..7d41425bdf6d0431b38fc71fb960718ebc9f4b4b --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/mult.hpp @@ -0,0 +1,335 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MULT_INCLUDE +#define MTL_MULT_INCLUDE + +#include <boost/numeric/mtl/config.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/utility/flatcat.hpp> +#include <boost/numeric/mtl/utility/ashape.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/static_assert.hpp> +#include <boost/numeric/mtl/operation/dmat_dmat_mult.hpp> +#include <boost/numeric/mtl/operation/smat_smat_mult.hpp> +#include <boost/numeric/mtl/operation/smat_dmat_mult.hpp> +#include <boost/numeric/mtl/operation/mat_vec_mult.hpp> +#include <boost/numeric/mtl/operation/rvec_mat_mult.hpp> // Row vector times matrix +#include <boost/numeric/mtl/operation/mult_specialize.hpp> +#include <boost/numeric/mtl/operation/assign_mode.hpp> +#include <boost/numeric/mtl/operation/mult_assign_mode.hpp> +#include <boost/numeric/mtl/utility/enable_if.hpp> + +#include <boost/mpl/if.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { namespace matrix { + + +/// Multiplication: mult(a, b, c) computes c= a * b; +/** The 3 types must be compatible, e.g. all three matrices or b and c are column vectors and a is a matrix. + The dimensions are checked at compile time. **/ +template <typename A, typename B, typename C> +typename mtl::traits::enable_if_matrix<A>::type +inline mult(const A& a, const B& b, C& c) +{ + vampir_trace<4010> tracer; + MTL_DEBUG_THROW_IF(static_cast<const void*>(&a) == static_cast<const void*>(&c) + || static_cast<const void*>(&b) == static_cast<const void*>(&c), + argument_result_conflict()); + + // dispatch between matrices, vectors, and scalars + using mtl::traits::shape_flatcat; + gen_mult(a, b, c, assign::assign_sum(), shape_flatcat<A>(), shape_flatcat<B>(), shape_flatcat<C>()); + // typename category<A>::type(), typename category<B>::type(), typename category<C>::type()); +} + + +/// Multiplication: mult_add(a, b, c) computes c+= a * b; +/** The 3 types must be compatible, e.g. all three matrices or b and c are column vectors and a is a matrix. + The dimensions are checked at compile time. **/ +template <typename A, typename B, typename C> +typename mtl::traits::enable_if_matrix<A>::type +inline mult_add(const A& a, const B& b, C& c) +{ + vampir_trace<4010> tracer; + // dispatch between matrices, vectors, and scalars + using mtl::traits::shape_flatcat; + gen_mult(a, b, c, assign::plus_sum(), shape_flatcat<A>(), shape_flatcat<B>(), shape_flatcat<C>()); + // typename category<A>::type(), typename category<B>::type(), typename category<C>::type()); +} + + +/// Four term multiplication: mult(a, x, y, z) computes z= a * x + y; +/** The 4 types must be compatible, i.e. a*x must be assignable to z and z must be incrementable by y. + Right now, it is not more efficient than z= a * x; z+= y. For compatibility with MTL2. **/ +template <typename A, typename X, typename Y, typename Z> +inline void mult(const A& a, const X& x, const Y& y, Z& z) +{ + vampir_trace<4010> tracer; + mult(a, x, z); + z+= y; +} + + +// Matrix multiplication +template <typename MatrixA, typename MatrixB, typename MatrixC, typename Assign> +inline void gen_mult(const MatrixA& a, const MatrixB& b, MatrixC& c, Assign, tag::flat<tag::matrix>, tag::flat<tag::matrix>, tag::flat<tag::matrix>) +{ + vampir_trace<4011> tracer; +#if 1 + MTL_DEBUG_THROW_IF((const void*)&a == (const void*)&c || (const void*)&b == (const void*)&c, argument_result_conflict()); +#else + if ((const void*)&a == (const void*)&c || (const void*)&b == (const void*)&c) { + C tmp(num_rows(c), num_cols(c)); + mult(a, b, tmp); + swap(C, tmp); + return; + } +#endif + + MTL_DEBUG_THROW_IF(num_rows(a) != num_rows(c) || num_cols(a) != num_rows(b) || num_cols(b) != num_cols(c), incompatible_size()); + // dispatch between dense and sparse + using mtl::traits::sparsity_flatcat; + mat_mat_mult(a, b, c, Assign(), sparsity_flatcat<MatrixA>(), sparsity_flatcat<MatrixB>(), sparsity_flatcat<MatrixC>()); + // typename category<MatrixA>::type(), typename category<MatrixB>::type(), typename category<MatrixC>::type()); +} + + +/// Dense matrix multiplication +/** The function for dense matrix multiplication defines a default multiplication functor. + Alternatively the user can define his own functors for specific triplets of matrix types, + see detail::dmat_dmat_mult_specialize. + The default functor for dense matrix multiplication is: + -# Use BLAS if available, otherwise + -# Recursive multiplication with: + -# Platform optimized mult on blocks if available, otherwise + -# Tiled multiplication on blocks if available, otherwise + -# Naive multiplication on blocks + -# Naive multiplication on entire matrices if recursion is not available +**/ +template <typename MatrixA, typename MatrixB, typename MatrixC, typename Assign> +inline void mat_mat_mult(const MatrixA& A, const MatrixB& b, MatrixC& c, Assign, tag::flat<tag::dense>, tag::flat<tag::dense>, tag::flat<tag::dense>) +{ + vampir_trace<4012> tracer; + using assign::plus_sum; using assign::assign_sum; + + static const unsigned long tiling1= detail::dmat_dmat_mult_tiling1<MatrixA, MatrixB, MatrixC>::value; + static const unsigned long tiling2= detail::dmat_dmat_mult_tiling2<MatrixA, MatrixB, MatrixC>::value; + typedef gen_tiling_dmat_dmat_mult_t<tiling1, tiling2, plus_sum> tiling_mult_t; + + typedef gen_platform_dmat_dmat_mult_t<plus_sum, tiling_mult_t> platform_mult_t; + typedef gen_recursive_dmat_dmat_mult_t<platform_mult_t> recursive_mult_t; + typedef gen_blas_dmat_dmat_mult_t<assign_sum, recursive_mult_t> blas_mult_t; + typedef size_switch_dmat_dmat_mult_t<straight_dmat_dmat_mult_limit, tiling_mult_t, blas_mult_t> variable_size_t; + + typedef fully_unroll_fixed_size_dmat_dmat_mult_t<Assign> fully_unroll_t; + typedef size_switch_dmat_dmat_mult_t<fully_unroll_dmat_dmat_mult_limit, fully_unroll_t, tiling_mult_t> fixed_size_t; + + static const bool all_static= mtl::traits::is_static<MatrixA>::value && mtl::traits::is_static<MatrixB>::value + && mtl::traits::is_static<MatrixC>::value; + typedef static_switch_dmat_dmat_mult_t<all_static, fixed_size_t, variable_size_t> default_functor_t; + + /// Use user-defined functor if provided (assign mode can be arbitrary) + typedef typename boost::mpl::if_< + detail::dmat_dmat_mult_specialize<MatrixA, MatrixB, MatrixC> + , typename detail::dmat_dmat_mult_specialize<MatrixA, MatrixB, MatrixC>::type + , default_functor_t + >::type raw_functor_type; + + /// Finally substitute assign mode (consistently) + typename assign::mult_assign_mode<raw_functor_type, Assign>::type functor; + + functor(A, b, c); +} + +template <typename MatrixA, typename MatrixB, typename MatrixC, typename Assign> +inline void mat_mat_mult(const MatrixA& A, const MatrixB& b, MatrixC& c, Assign, tag::flat<tag::dense>, tag::flat<tag::dense>, tag::flat<tag::sparse>) +{ + vampir_trace<4012> tracer; + // This is a useless and extremely inefficient operation!!!! + // We compute this with a dense matrix and copy the result back + dense2D<typename Collection<MatrixC>::value_type, matrix::parameters<> > c_copy(num_rows(c), num_cols(c)); + c_copy= c; + mat_mat_mult(A, b, c_copy, Assign(), tag::flat<tag::dense>(), tag::flat<tag::dense>(), tag::flat<tag::dense>()); + c= c_copy; +} + +/// Sparse matrix multiplication +template <typename MatrixA, typename MatrixB, typename MatrixC, typename Assign> +inline void mat_mat_mult(const MatrixA& A, const MatrixB& b, MatrixC& c, Assign, tag::flat<tag::sparse>, tag::flat<tag::sparse>, tag::flat<tag::sparse>) +{ + vampir_trace<4012> tracer; + smat_smat_mult(A, b, c, Assign(), typename OrientedCollection<MatrixA>::orientation(), + typename OrientedCollection<MatrixB>::orientation()); +} + +template <typename MatrixA, typename MatrixB, typename MatrixC, typename Assign> +inline void mat_mat_mult(const MatrixA& A, const MatrixB& b, MatrixC& c, Assign, tag::flat<tag::sparse>, tag::flat<tag::sparse>, tag::flat<tag::dense>) +{ + vampir_trace<4012> tracer; + // This is a useless and extremely inefficient operation!!!! + // We compute this with a sparse matrix and copy the result back + compressed2D<typename Collection<MatrixC>::value_type, matrix::parameters<> > c_copy(num_rows(c), num_cols(c)); + c_copy= c; + smat_smat_mult(A, b, c_copy, Assign(), typename OrientedCollection<MatrixA>::orientation(), + typename OrientedCollection<MatrixB>::orientation()); + c= c_copy; +} + +/// Product of sparse times dense matrix +/** This function (specialization of mult) is intended to multiply sparse matrices with multiple matrices + gathered into a dense matrix. Likewise, the resulting dense matrix corresponds to multiple vectors. + The default functor for this operation is: + -# Use tiled multiplication if available, otherwise + -# Naive multiplication +**/ +template <typename MatrixA, typename MatrixB, typename MatrixC, typename Assign> +inline void mat_mat_mult(const MatrixA& A, const MatrixB& b, MatrixC& c, Assign, tag::flat<tag::sparse>, tag::flat<tag::dense>, tag::flat<tag::dense>) +{ + vampir_trace<4012> tracer; + using assign::plus_sum; using assign::assign_sum; + using namespace functor; + + // static const unsigned long tiling1= detail::dmat_dmat_mult_tiling1<MatrixA, MatrixB, MatrixC>::value; + + //typedef gen_smat_dmat_mult<Assign> default_functor_t; + typedef gen_tiling_smat_dmat_mult<8, Assign> default_functor_t; + + // Finally substitute assign mode (consistently) + // typename assign::mult_assign_mode<raw_functor_type, Assign>::type functor; + + default_functor_t functor; + functor(A, b, c); +} + +template <typename MatrixA, typename MatrixB, typename MatrixC, typename Assign> +inline void mat_mat_mult(const MatrixA& A, const MatrixB& b, MatrixC& c, Assign, tag::flat<tag::sparse>, tag::flat<tag::dense>, tag::flat<tag::sparse>) +{ + vampir_trace<4012> tracer; + // This is a useless and extremely inefficient operation!!!! + // We compute this with a sparse matrix and copy the result back + dense2D<typename Collection<MatrixC>::value_type, matrix::parameters<> > c_copy(num_rows(c), num_cols(c)); + c_copy= c; + mat_mat_mult(A, b, c_copy, Assign(), tag::flat<tag::sparse>(), tag::flat<tag::dense>(), tag::flat<tag::dense>()); + c= c_copy; +} + + +template <typename MatrixA, typename MatrixB, typename MatrixC, typename Assign> +inline void mat_mat_mult(const MatrixA& A, const MatrixB& b, MatrixC& c, Assign, tag::flat<tag::dense>, tag::flat<tag::sparse>, tag::flat<tag::dense>) +{ + vampir_trace<4012> tracer; + // This is could be a usefull operation, i.e. multiplying multiple row vectors with a sparse matrix + // Might be supported in future + // Now we compute this with a sparse matrix as first argument + compressed2D<typename Collection<MatrixA>::value_type, matrix::parameters<> > A_copy(num_rows(A), num_cols(A)); + A_copy= A; + compressed2D<typename Collection<MatrixC>::value_type, matrix::parameters<> > c_copy(num_rows(c), num_cols(c)); + c_copy= c; + mat_mat_mult(A_copy, b, c_copy, Assign(), tag::flat<tag::sparse>(), tag::flat<tag::sparse>(), tag::flat<tag::sparse>()); + c= c_copy; +} + + + +template <typename MatrixA, typename MatrixB, typename MatrixC, typename Assign> +inline void mat_mat_mult(const MatrixA& A, const MatrixB& b, MatrixC& c, Assign, tag::flat<tag::dense>, tag::flat<tag::sparse>, tag::flat<tag::sparse>) +{ + vampir_trace<4012> tracer; + // This is not a usefull operation, because the result is dense + // Now we compute this with a sparse matrix as first argument + compressed2D<typename Collection<MatrixA>::value_type, matrix::parameters<> > A_copy(num_rows(A), num_cols(A)); + A_copy= A; + mat_mat_mult(A_copy, b, c, Assign(), tag::flat<tag::sparse>(), tag::flat<tag::sparse>(), tag::flat<tag::sparse>()); +} + + + +// Matrix vector multiplication +template <typename Matrix, typename VectorIn, typename VectorOut, typename Assign> +inline void gen_mult(const Matrix& A, const VectorIn& v, VectorOut& w, Assign, tag::flat<tag::matrix>, tag::flat<tag::col_vector>, tag::flat<tag::col_vector>) +{ + vampir_trace<4011> tracer; + // Vector must be column vector + // If vector is row vector then matrix must have one column and the operation is a outer product + // -> result should be a matrix too + + // Check if element types are compatible (in contrast to tag dispatching, nesting is considered here) + MTL_STATIC_ASSERT((boost::is_same< typename ashape::mult_op<typename ashape::ashape<Matrix>::type, + typename ashape::ashape<VectorIn>::type >::type, + ::mtl::ashape::mat_cvec_mult + >::value), + "The type nesting of the arguments does not allow for a consistent matrix vector product."); + + +#if 1 + MTL_DEBUG_THROW_IF((void*)&v == (void*)&w, argument_result_conflict()); +#else + if ((void*)&v == (void*)&w) { + VectorOut tmp(size(w)); + mult(A, b, tmp); + swap(w, tmp); + return; + } +#endif + // w.checked_change_dim(num_rows(A)); // destroys distribution in parallel -> dimension changed in assignment + MTL_DEBUG_THROW_IF(num_rows(A) != mtl::vector::size(w), incompatible_size()); + MTL_DEBUG_THROW_IF(num_cols(A) != mtl::vector::size(v), incompatible_size()); + + mat_cvec_mult(A, v, w, Assign(), mtl::traits::mat_cvec_flatcat<Matrix>()); +} + + +// Vector matrix multiplication +template <typename VectorIn, typename Matrix, typename VectorOut, typename Assign> +inline void gen_mult(const VectorIn& v, const Matrix& A, VectorOut& w, Assign, tag::flat<tag::row_vector>, tag::flat<tag::matrix>, tag::flat<tag::row_vector>) +{ + vampir_trace<4011> tracer; + // Vector must be column vector + // If vector is row vector then matrix must have one column and the operation is a outer product + // -> result should be a matrix too + + // Check if element types are compatible (in contrast to tag dispatching, nesting is considered here) + MTL_STATIC_ASSERT((boost::is_same< typename ashape::mult_op<typename ashape::ashape<VectorIn>::type, + typename ashape::ashape<Matrix>::type >::type, + ::mtl::ashape::rvec_mat_mult + >::value), + "The type nesting of the arguments does not allow for a consistent matrix vector product."); + +#if 1 + MTL_DEBUG_THROW_IF((void*)&v == (void*)&w, argument_result_conflict()); +#else + if ((void*)&v == (void*)&w) { + VectorOut tmp(size(w)); + mult(A, b, tmp); + swap(w, tmp); + return; + } +#endif + // w.checked_change_dim(num_cols(A)); + w.checked_change_resource(v); + MTL_DEBUG_THROW_IF(num_cols(v) != num_rows(A), incompatible_size()); + + // same dispatching criterion as mat_cvec_mult (until now) + rvec_mat_mult(v, A, w, Assign(), typename mtl::traits::mat_cvec_flatcat<Matrix>::type()); +} + + + + + +}} // namespace mtl::matrix + +#endif // MTL_MULT_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/mult_assign_mode.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/mult_assign_mode.hpp new file mode 100644 index 0000000000000000000000000000000000000000..9e656bc1afef22408faa59a3db3b3ce9fafc91e1 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/mult_assign_mode.hpp @@ -0,0 +1,148 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MULT_ASSIGN_MODE_INCLUDE +#define MTL_MULT_ASSIGN_MODE_INCLUDE + +#include <boost/numeric/mtl/operation/assign_mode.hpp> +#include <boost/numeric/mtl/operation/dmat_dmat_mult.hpp> +#include <boost/numeric/mtl/operation/no_op.hpp> + +namespace mtl { namespace assign { + +namespace detail { + + template <typename Assign> + struct subm_assign + { + typedef Assign type; + }; + + template<> + struct subm_assign<assign_sum> + { + typedef plus_sum type; + }; + +} + +// Set assign_mode of functor 'Mult' to 'Assign' +// including assign_mode of backup functors and functors for sub-matrices +template <typename Mult, typename Assign> +struct mult_assign_mode +{}; + + +#if 0 +// Omit the fully typed functors; they shouldn't be used directly +template <typename MatrixA, typename MatrixB, typename MatrixC, typename OldAssign, typename Backup, + typename Assign> +struct mult_assign_mode<gen_dmat_dmat_mult_ft<MatrixA, MatrixB, MatrixC, OldAssign, Backup>, + Assign> +{ + typedef gen_dmat_dmat_mult_ft<MatrixA, MatrixB, MatrixC, Assign, Backup> type; +}; +#endif + + +template <typename Assign> +struct mult_assign_mode<no_op, Assign> +{ + typedef no_op type; +}; + +template <typename OldAssign, typename Backup, typename Assign> +struct mult_assign_mode<gen_dmat_dmat_mult_t<OldAssign, Backup>, Assign> +{ + typedef typename mult_assign_mode<Backup, Assign>::type backup_type; + typedef gen_dmat_dmat_mult_t<Assign, backup_type> type; +}; + +template <typename OldAssign, typename Backup, typename Assign> +struct mult_assign_mode<gen_cursor_dmat_dmat_mult_t<OldAssign, Backup>, Assign> +{ + typedef typename mult_assign_mode<Backup, Assign>::type backup_type; + typedef gen_cursor_dmat_dmat_mult_t<Assign, backup_type> type; +}; + +template <unsigned long Tiling1, unsigned long Tiling2, typename OldAssign, typename Backup, typename Assign> +struct mult_assign_mode<gen_tiling_dmat_dmat_mult_t<Tiling1, Tiling2, OldAssign, Backup>, Assign> +{ + typedef typename mult_assign_mode<Backup, Assign>::type backup_type; + typedef gen_tiling_dmat_dmat_mult_t<Tiling1, Tiling2, Assign, backup_type> type; +}; + +template <typename OldAssign, typename Backup, typename Assign> +struct mult_assign_mode<gen_tiling_44_dmat_dmat_mult_t<OldAssign, Backup>, Assign> +{ + typedef typename mult_assign_mode<Backup, Assign>::type backup_type; + typedef gen_tiling_44_dmat_dmat_mult_t<Assign, backup_type> type; +}; + +template <typename OldAssign, typename Backup, typename Assign> +struct mult_assign_mode<gen_tiling_22_dmat_dmat_mult_t<OldAssign, Backup>, Assign> +{ + typedef typename mult_assign_mode<Backup, Assign>::type backup_type; + typedef gen_tiling_22_dmat_dmat_mult_t<Assign, backup_type> type; +}; + +template <typename BaseMult, typename BaseTest, typename OldAssign, typename Backup, typename Assign> +struct mult_assign_mode<gen_recursive_dmat_dmat_mult_t<BaseMult, BaseTest, OldAssign, Backup>, Assign> +{ + typedef typename mult_assign_mode<Backup, Assign>::type backup_type; + + // Corresponding assignment type for sub-matrices + typedef typename detail::subm_assign<Assign>::type base_assign_type; + typedef typename mult_assign_mode<BaseMult, base_assign_type>::type base_mult_type; + + typedef gen_recursive_dmat_dmat_mult_t<base_mult_type, BaseTest, Assign, backup_type> type; +}; + +template <typename OldAssign, typename Backup, typename Assign> +struct mult_assign_mode<gen_platform_dmat_dmat_mult_t<OldAssign, Backup>, Assign> +{ + typedef typename mult_assign_mode<Backup, Assign>::type backup_type; + typedef gen_platform_dmat_dmat_mult_t<Assign, backup_type> type; +}; + +template <typename OldAssign, typename Backup, typename Assign> +struct mult_assign_mode<gen_blas_dmat_dmat_mult_t<OldAssign, Backup>, Assign> +{ + typedef typename mult_assign_mode<Backup, Assign>::type backup_type; + typedef gen_blas_dmat_dmat_mult_t<Assign, backup_type> type; +}; + +template <std::size_t SizeLimit, typename FunctorSmall, typename FunctorLarge, typename Assign> +struct mult_assign_mode<size_switch_dmat_dmat_mult_t<SizeLimit, FunctorSmall, FunctorLarge>, Assign> +{ + typedef typename mult_assign_mode<FunctorSmall, Assign>::type small_type; + typedef typename mult_assign_mode<FunctorLarge, Assign>::type large_type; + typedef size_switch_dmat_dmat_mult_t<SizeLimit, small_type, large_type> type; +}; + +template <bool IsStatic, typename FunctorStatic, typename FunctorDynamic, typename Assign> +struct mult_assign_mode<static_switch_dmat_dmat_mult_t<IsStatic, FunctorStatic, FunctorDynamic>, Assign> +{ + typedef typename mult_assign_mode<FunctorStatic, Assign>::type static_type; + typedef typename mult_assign_mode<FunctorDynamic, Assign>::type dynamic_type; + typedef static_switch_dmat_dmat_mult_t<IsStatic, static_type, dynamic_type> type; +}; + +template <typename OldAssign, typename Backup, typename Assign> +struct mult_assign_mode<fully_unroll_fixed_size_dmat_dmat_mult_t<OldAssign, Backup>, Assign> +{ + typedef fully_unroll_fixed_size_dmat_dmat_mult_t<Assign, Backup> type; +}; + +}} // namespace mtl::assign + +#endif // MTL_MULT_ASSIGN_MODE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/mult_result.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/mult_result.hpp new file mode 100644 index 0000000000000000000000000000000000000000..3c996e627bb98066e651a33fa8ace61c1a30b3ab --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/mult_result.hpp @@ -0,0 +1,156 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MULT_RESULT_INCLUDE +#define MTL_MULT_RESULT_INCLUDE + +#include <boost/numeric/mtl/utility/ashape.hpp> +#include <boost/numeric/mtl/mtl_fwd.hpp> + +#if 0 +#include <boost/numeric/mtl/matrix/map_view.hpp> +#include <boost/numeric/mtl/matrix/mat_mat_times_expr.hpp> +#include <boost/numeric/mtl/matrix/implicit_dense.hpp> +#include <boost/numeric/mtl/vector/map_view.hpp> +#include <boost/numeric/mtl/operation/mat_cvec_times_expr.hpp> +#include <boost/numeric/mtl/vector/rvec_mat_times_expr.hpp> +#endif + +namespace mtl { namespace traits { + +template <typename Op1, typename Op2, typename MultOp> struct mult_result_aux; +template <typename Op1, typename Op2, typename MultOp> struct vec_mult_result_aux; + //template <typename Op1, typename Op2, typename MultOp1, typename MultOp2> struct mult_result_if_equal_aux; + +/// Result type for multiplying arguments of types Op1 and Op2 +/** Can be used in enable-if-style as type is only defined when appropriate. + This one is used if at least one argument is a matrix. +**/ +template <typename Op1, typename Op2> +struct mult_result + : public mult_result_aux<Op1, Op2, typename ashape::mult_op<typename ashape::ashape<Op1>::type, + typename ashape::ashape<Op2>::type >::type> +{}; + + +/// Result type for multiplying arguments of types Op1 and Op2 +/** Can be used in enable-if-style as type is only defined when appropriate. + This one is used if at least one argument is a vector and none is a matrix. +**/ +template <typename Op1, typename Op2> +struct vec_mult_result + : public vec_mult_result_aux<Op1, Op2, typename ashape::mult_op<typename ashape::ashape<Op1>::type, + typename ashape::ashape<Op2>::type >::type> +{}; + + +/// Result type for multiplying arguments of types Op1 and Op2 +/** MultOp according to the algebraic shapes **/ +template <typename Op1, typename Op2, typename MultOp> +struct mult_result_aux {}; + +/// Scale matrix from left +template <typename Op1, typename Op2> +struct mult_result_aux<Op1, Op2, ::mtl::ashape::scal_mat_mult> +{ + typedef matrix::scaled_view<Op1, Op2> type; +}; + + +/// Scale matrix from right needs functor for scaling from right +template <typename Op1, typename Op2> +struct mult_result_aux<Op1, Op2, ::mtl::ashape::mat_scal_mult> +{ + typedef matrix::rscaled_view<Op1, Op2> type; +}; + +/// Multiply matrices +template <typename Op1, typename Op2> +struct mult_result_aux<Op1, Op2, ::mtl::ashape::mat_mat_mult> +{ + typedef matrix::mat_mat_times_expr<Op1, Op2> type; +}; + +/// Multiply matrix with column vector +template <typename Op1, typename Op2> +struct mult_result_aux<Op1, Op2, ::mtl::ashape::mat_cvec_mult> +{ + typedef mat_cvec_times_expr<Op1, Op2> type; +}; + +/// Multiply column with row vector and return implicit matrix +template <typename Op1, typename Op2> +struct vec_mult_result_aux<Op1, Op2, ::mtl::ashape::cvec_rvec_mult> +{ + typedef mtl::matrix::outer_product_matrix<Op1, Op2> type; +}; + +/// Result type for multiplying arguments of types Op1 and Op2 +/** MultOp according to the algebraic shapes **/ +template <typename Op1, typename Op2, typename MultOp> +struct vec_mult_result_aux {}; + +/// Scale row vector from left +template <typename Op1, typename Op2> +struct vec_mult_result_aux<Op1, Op2, ::mtl::ashape::scal_rvec_mult> +{ + typedef vector::scaled_view<Op1, Op2> type; +}; + + + + +/// Scale column vector from left +template <typename Op1, typename Op2> +struct vec_mult_result_aux<Op1, Op2, ::mtl::ashape::scal_cvec_mult> +{ + typedef vector::scaled_view<Op1, Op2> type; +}; + +/// Multiply row vector with matrix +// added by Cornelius and Peter +template <typename Op1, typename Op2> +struct vec_mult_result_aux<Op1, Op2, ::mtl::ashape::rvec_mat_mult> +{ + typedef vector::rvec_mat_times_expr<Op1, Op2> type; +}; + +/// Scale row vector from right +// added by Hui Li +template <typename Op1, typename Op2> +struct vec_mult_result_aux<Op1, Op2, ::mtl::ashape::rvec_scal_mult> +{ + typedef vector::rscaled_view<Op1, Op2> type; +}; + +/// Scale column vector from right +// added by Hui Li +template <typename Op1, typename Op2> +struct vec_mult_result_aux<Op1, Op2, ::mtl::ashape::cvec_scal_mult> +{ + typedef vector::rscaled_view<Op1, Op2> type; +}; + + +/// Enabler if operation is rvec_cvec_mult +template <typename Op1, typename Op2, typename Result> +struct lazy_enable_if_rvec_cvec_mult + : boost::lazy_enable_if<boost::is_same<typename ashape::mult_op<typename ashape::ashape<Op1>::type, + typename ashape::ashape<Op2>::type >::type, + ashape::rvec_cvec_mult>, + Result> +{}; + + +}} // namespace mtl::traits + +#endif // MTL_MULT_RESULT_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/mult_specialize.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/mult_specialize.hpp new file mode 100644 index 0000000000000000000000000000000000000000..b59958c6cf63660e323322a45b282d2370769aa5 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/mult_specialize.hpp @@ -0,0 +1,54 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MULT_SPECIALIZE_INCLUDE +#define MTL_MULT_SPECIALIZE_INCLUDE + +#include <boost/numeric/mtl/operation/dmat_dmat_mult.hpp> +#include <boost/mpl/bool.hpp> + +namespace mtl { namespace matrix {namespace detail { + +template <typename MatrixA, typename MatrixB, typename MatrixC> +struct dmat_dmat_mult_tiling1 +{ + static const unsigned long value= 2; +}; + +template <typename MatrixA, typename MatrixB, typename MatrixC> +struct dmat_dmat_mult_tiling2 +{ + static const unsigned long value= 4; +}; + +template <typename MatrixA, typename MatrixB, typename MatrixC> +struct dmat_dmat_mult_specialize + : public boost::mpl::false_ +{}; + +/* + In order to specialize the functor, write for instance: + +template <typename MatrixA, typename MatrixB, typename MatrixC> +struct dmat_dmat_mult_specialize + : public boost::mpl::true_ +{ + typedef gen_dmat_dmat_mult_t<> type; +}; +*/ + + + + +}}} // namespace mtl::matrix::detail + +#endif // MTL_MULT_SPECIALIZE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/multi_action_block.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/multi_action_block.hpp new file mode 100644 index 0000000000000000000000000000000000000000..b6929b190cf7faa5bef056987fa96abd51727767 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/multi_action_block.hpp @@ -0,0 +1,80 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MULTI_ACTION_BLOCK_INCLUDE +#define MTL_MULTI_ACTION_BLOCK_INCLUDE + +namespace mtl { + +/* + Functor for unrolling arbitrary loops with independent operations + ... + + */ +template <typename MultiAction, unsigned Steps> struct multi_action_block; + + +template <typename MultiAction, unsigned MaxSteps, unsigned RemainingSteps> +struct multi_action_helper +{ + static unsigned const step= MaxSteps - RemainingSteps; + + void operator() (MultiAction const& action) const + { + action(step); + multi_action_helper<MultiAction, MaxSteps, RemainingSteps-1>()(action); + } + + void operator() (MultiAction& action) const + { + action(step); + multi_action_helper<MultiAction, MaxSteps, RemainingSteps-1>()(action); + } +}; + + +template <typename MultiAction, unsigned MaxSteps> +struct multi_action_helper<MultiAction, MaxSteps, 1> +{ + static unsigned const step= MaxSteps - 1; + + void operator() (MultiAction const& action) const + { + action(step); + } + + void operator() (MultiAction& action) const + { + action(step); + } +}; + + +template <typename MultiAction, unsigned Steps> +struct multi_action_block +{ + void operator() (MultiAction const& action) const + { + multi_action_helper<MultiAction, Steps, Steps>()(action); + } + + void operator() (MultiAction& action) const + { + multi_action_helper<MultiAction, Steps, Steps>()(action); + } +}; + + + +} // namespace mtl + +#endif // MTL_MULTI_ACTION_BLOCK_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/no_op.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/no_op.hpp new file mode 100644 index 0000000000000000000000000000000000000000..b517402cd277dcb45ed402255003a21628421b5f --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/no_op.hpp @@ -0,0 +1,22 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_NO_OP_INCLUDE +#define MTL_NO_OP_INCLUDE + +namespace mtl { + +struct no_op {}; + +} // namespace mtl + +#endif // MTL_NO_OP_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/norms.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/norms.hpp new file mode 100644 index 0000000000000000000000000000000000000000..83e11934b8a02e47fdb599496d0c56644a0448e1 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/norms.hpp @@ -0,0 +1,21 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_NORMS_INCLUDE +#define MTL_NORMS_INCLUDE + +#include <boost/numeric/mtl/operation/one_norm.hpp> +#include <boost/numeric/mtl/operation/two_norm.hpp> +#include <boost/numeric/mtl/operation/infinity_norm.hpp> +#include <boost/numeric/mtl/operation/frobenius_norm.hpp> + +#endif // MTL_NORMS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/num_cols.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/num_cols.hpp new file mode 100644 index 0000000000000000000000000000000000000000..2f8858fa544bca3d1a4c4270b4308fd027af0bad --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/num_cols.hpp @@ -0,0 +1,63 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_NUM_COLS_INCLUDE +#define MTL_NUM_COLS_INCLUDE + +#include <vector> + +namespace mtl { + +namespace traits { + + /// General declaration, used to disable unsupported types + template <typename Collection> + struct num_cols {}; + + /// num_cols implementation for STL vectors + template <typename Value> + struct num_cols< std::vector<Value> > + { + typedef std::size_t type; + type operator()(const std::vector<Value>& ) { return 1; } + }; + + /// num_cols implementation for (1D) arrays interpreted as vectors + template <typename Value, unsigned Size> + struct num_cols<Value[Size]> + { + typedef std::size_t type; + type operator()(const Value[Size]) { return 1; } + }; + + /// num_cols implementation for (2D and higher) arrays interpreted as matrices + template <typename Value, unsigned Rows, unsigned Cols> + struct num_cols<Value[Rows][Cols]> + { + typedef std::size_t type; + type operator()(const Value[Rows][Cols]) { return Cols; } + }; +} + + +/// num_cols function for non-MTL types (uses implicit enable_if), 1D interpreted as Column vector +template <typename Collection> +typename traits::num_cols<Collection>::type +inline num_cols(const Collection& c) +{ + return traits::num_cols<Collection>()(c); +} + + +} // namespace mtl + +#endif // MTL_NUM_COLS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/num_rows.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/num_rows.hpp new file mode 100644 index 0000000000000000000000000000000000000000..7b337553c5aae7eab7fb52af1c0851c9ece96f27 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/num_rows.hpp @@ -0,0 +1,63 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_NUM_ROWS_INCLUDE +#define MTL_NUM_ROWS_INCLUDE + +#include <vector> + +namespace mtl { + +namespace traits { + + /// General declaration, used to disable unsupported types + template <typename Collection> + struct num_rows {}; + + /// num_rows implementation for STL vectors + template <typename Value> + struct num_rows< std::vector<Value> > + { + typedef std::size_t type; + type operator()(const std::vector<Value>& v) { return v.size(); } + }; + + /// num_rows implementation for (1D) arrays interpreted as vectors + template <typename Value, unsigned Size> + struct num_rows<Value[Size]> + { + typedef std::size_t type; + type operator()(const Value[Size]) { return Size; } + }; + + /// num_rows implementation for (2D and higher) arrays interpreted as matrices + template <typename Value, unsigned Rows, unsigned Cols> + struct num_rows<Value[Rows][Cols]> + { + typedef std::size_t type; + type operator()(const Value[Rows][Cols]) { return Rows; } + }; +} + + +/// num_rows function for non-MTL types (uses implicit enable_if), 1D interpreted as Column vector +template <typename Collection> +typename traits::num_rows<Collection>::type +inline num_rows(const Collection& c) +{ + return traits::num_rows<Collection>()(c); +} + + +} // namespace mtl + +#endif // MTL_NUM_ROWS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/one_norm.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/one_norm.hpp new file mode 100644 index 0000000000000000000000000000000000000000..539ad0723be00ca0d89ee8dca26e39b9054292d8 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/one_norm.hpp @@ -0,0 +1,96 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_ONE_NORM_INCLUDE +#define MTL_ONE_NORM_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/enable_if.hpp> +#include <boost/numeric/mtl/utility/is_row_major.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/utility/property_map.hpp> +#include <boost/numeric/mtl/operation/max_of_sums.hpp> +#include <boost/numeric/mtl/vector/lazy_reduction.hpp> +#include <boost/numeric/mtl/vector/reduction.hpp> +#include <boost/numeric/mtl/vector/reduction_functors.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { + + namespace vector { + + template <unsigned long Unroll, typename Vector> + typename traits::enable_if_vector<Vector, typename RealMagnitude<typename Collection<Vector>::value_type>::type>::type + inline one_norm(const Vector& vector) + { + vampir_trace<2014> tracer; + typedef typename RealMagnitude<typename Collection<Vector>::value_type>::type result_type; + return reduction<Unroll, one_norm_functor, result_type>::apply(vector); + } + + /*! One-norm for vectors: one_norm(x) \f$\rightarrow |x|_1\f$. + \retval The magnitude type of the respective value type, see Magnitude. + + The norms are defined as \f$|v|_1=\sum_i |v_i|\f$. + Vector norms are unrolled 8-fold by default. + An n-fold unrolling can be generated with one_norm<n>(x). + The maximum for n is 8 (it might be increased later). + **/ + template <typename Vector> + typename traits::enable_if_vector<Vector, typename RealMagnitude<typename Collection<Vector>::value_type>::type>::type + inline one_norm(const Vector& vector) + { + return one_norm<8>(vector); + } + + template <typename Vector> + lazy_reduction<Vector, one_norm_functor> inline lazy_one_norm(const Vector& v) + { return lazy_reduction<Vector, one_norm_functor>(v); } + } + + namespace matrix { + + // Ignore unrolling for matrices + template <unsigned long Unroll, typename Matrix> + typename mtl::traits::enable_if_matrix<Matrix, typename RealMagnitude<typename Collection<Matrix>::value_type>::type>::type + inline one_norm(const Matrix& matrix) + { + vampir_trace<3025> tracer; + using mtl::impl::max_of_sums; + typename mtl::traits::col<Matrix>::type col(matrix); + return max_of_sums(matrix, !mtl::traits::is_row_major<typename OrientedCollection<Matrix>::orientation>(), + col, num_cols(matrix)); + } + + /*! One-norm for matrices: one_norm(x) \f$\rightarrow |x|_1\f$. + \retval The magnitude type of the respective value type, see Magnitude. + + The norms are defined as \f$|A|_1=\max_j\{\sum_i(|A_{ij}|)\}\f$. + Matrix norms are not optimized by unrolling (yet). + **/ + template <typename Matrix> + typename mtl::traits::enable_if_matrix<Matrix, typename RealMagnitude<typename Collection<Matrix>::value_type>::type>::type + inline one_norm(const Matrix& matrix) + { + return one_norm<8>(matrix); + } + } + + using vector::one_norm; + using vector::lazy_one_norm; + using matrix::one_norm; + +} // namespace mtl + +#endif // MTL_ONE_NORM_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/ones.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/ones.hpp new file mode 100644 index 0000000000000000000000000000000000000000..44c93a534c3c531dfe2b368b5fa5519cd014b4aa --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/ones.hpp @@ -0,0 +1,42 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_ONES_INCLUDE +#define MTL_ONES_INCLUDE + +#include <boost/numeric/mtl/matrix/implicit_dense.hpp> + +namespace mtl { + + namespace matrix { + + /// Return r by c matrix with ones of type Value in all entries + template <typename Value> + ones_matrix<Value> inline ones(std::size_t r, std::size_t c) + { + return ones_matrix<Value>(r, c); + } + + /// Return r by c matrix with ones of type Value in all entries + ones_matrix<> inline ones(std::size_t r, std::size_t c) + { + return ones_matrix<>(r, c); + } + + } + + using matrix::ones; + + +} // namespace mtl + +#endif // MTL_ONES_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/operators.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/operators.hpp new file mode 100644 index 0000000000000000000000000000000000000000..9c47a15d886972d71717d188119857ea330946c8 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/operators.hpp @@ -0,0 +1,125 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_OPERATORS_INCLUDE +#define MTL_OPERATORS_INCLUDE + +#include <boost/utility/enable_if.hpp> +#include <boost/mpl/and.hpp> + +#include <boost/numeric/mtl/utility/ashape.hpp> +#include <boost/numeric/mtl/matrix/operators.hpp> +//#include <boost/numeric/mtl/vector/operators.hpp> +#include <boost/numeric/mtl/operation/mult_result.hpp> +#include <boost/numeric/mtl/operation/div_result.hpp> +#include <boost/numeric/mtl/operation/dot.hpp> +#include <boost/numeric/mtl/operation/mat_cvec_times_expr.hpp> +#include <boost/numeric/mtl/matrix/all_mat_expr.hpp> +#include <boost/numeric/mtl/utility/enable_if.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/utility/true_copy.hpp> +#include <boost/numeric/mtl/vector/rvec_mat_times_expr.hpp> + + +namespace mtl { + +namespace matrix { + + /// Multiplication for all supported types of operations + /** Enable-if-like technique make sure that only called when properly defined **/ + template <typename Op1, typename Op2> + typename mtl::traits::mult_result<typename mtl::traits::true_copy<Op1>::type, Op2>::type + inline operator*(const Op1& op1, const Op2& op2) + { + + return typename mtl::traits::mult_result<typename mtl::traits::true_copy<Op1>::type, Op2>::type(op1, op2); + } + + + + /// Division of matrices and vectors by salars + /** Enable-if-like technique make sure that only called when properly defined **/ + // added by Hui Li + // enable_if_matrix shouldn't be needed but was nessecary in cuppen.hpp + template < typename Op1, typename Op2 > + typename mtl::traits::enable_if_matrix<Op1, typename mtl::traits::div_result<Op1,Op2>::type>::type + inline operator/(const Op1& op1, const Op2& op2) + { + return typename mtl::traits::div_result<Op1,Op2>::type(op1,op2); + } + +} // namespace matrix + + +namespace vector { + + /// Multiplication for all supported types of operations + /** Enable-if-like technique make sure that only called when properly defined **/ + template <typename Op1, typename Op2> + typename mtl::traits::vec_mult_result<typename mtl::traits::true_copy<Op1>::type, Op2>::type + inline operator*(const Op1& op1, const Op2& op2) + { + return typename mtl::traits::vec_mult_result<typename mtl::traits::true_copy<Op1>::type, Op2>::type(op1, op2); + } + + /// Multiply row vector with column vector; result is scalar + template <typename Op1, typename Op2> + typename traits::lazy_enable_if_rvec_cvec_mult<Op1, Op2, detail::dot_result<Op1, Op2> >::type + inline operator*(const Op1& op1, const Op2& op2) + { + return dot_real(op1, op2); + } + + /// Division of matrices and vectors by salars + /** Enable-if-like technique make sure that only called when properly defined **/ + // added by Hui Li + template < typename Op1, typename Op2 > + typename traits::div_result<Op1,Op2>::type + inline operator/(const Op1& op1, const Op2& op2) + { + return typename traits::div_result<Op1,Op2>::type(op1,op2); + } + + /// Compare two vectors for equality + /** Enable-if makes sure that only called when properly defined **/ + template < typename Op1, typename Op2 > + typename boost::enable_if<boost::mpl::and_<mtl::traits::is_vector<Op1>, + mtl::traits::is_vector<Op2> >, + bool>::type + inline operator==(const Op1& op1, const Op2& op2) + { + unsigned s1= num_rows(op1) * num_cols(op1), s2= num_rows(op2) * num_cols(op2); // ugly hack to fight with ADL + if (s1 != s2) + return false; + for (unsigned i= 0; i < s1; i++) + if (op1[i] != op2[i]) + return false; + return true; + } + + /// Compare two vectors for unequality + /** Enable-if makes sure that only called when properly defined **/ + template < typename Op1, typename Op2 > + typename boost::enable_if<boost::mpl::and_<mtl::traits::is_vector<Op1>, + mtl::traits::is_vector<Op2> >, + bool>::type + inline operator!=(const Op1& op1, const Op2& op2) + { + return !(op1 == op2); + } + +} // namespace vector + + +} // namespace mtl + +#endif // MTL_OPERATORS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/opteron/matrix_mult.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/opteron/matrix_mult.hpp new file mode 100644 index 0000000000000000000000000000000000000000..ae734a5b61a2f072ddbc1523cc221c1d1e2f02ee --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/opteron/matrix_mult.hpp @@ -0,0 +1,1562 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +// Written mostly by Michael Adams +// Modified by Peter Gottschling + +#ifndef MTL_OPTERON_MATRIX_MULT_INCLUDE +#define MTL_OPTERON_MATRIX_MULT_INCLUDE + +#if defined MTL_USE_OPTERON_OPTIMIZATION && defined __GNUC__ && !defined __INTEL_COMPILER + +#include <boost/numeric/mtl/operation/assign_mode.hpp> +#include <boost/numeric/mtl/operation/set_to_zero.hpp> +#include <boost/numeric/mtl/recursion/bit_masking.hpp> + + +namespace mtl { + +namespace detail { + template <unsigned long MaskA, unsigned long MaskB, unsigned long MaskC> + struct opteron_shark_teeth + { + static const unsigned long base_case_bits= 5, tooth_length = 1; + static const bool value= is_k_power_base_case_row_major_t_shark<base_case_bits, tooth_length, MaskA>::value + && is_k_power_base_case_col_major_t_shark<base_case_bits, tooth_length, MaskB>::value + && is_k_power_base_case_row_major_t_shark<base_case_bits, tooth_length, MaskC>::value; + }; + + template <typename Assign, unsigned long MaskA, typename PA, + unsigned long MaskB, typename PB, + unsigned long MaskC, typename PC> + inline void + opteron_shark_teeth_mult(const morton_dense<double, MaskA, PA>& a, const morton_dense<double, MaskB, PB>& b, + morton_dense<double, MaskC, PC>& c) + { + // Never sets the matrix to zero; this is supposed to be done before if necessary + + typedef typename morton_dense<double, MaskA, PA>::size_type size_type; + size_type i_max= c.num_rows(), i_block= 2 * (i_max / 2), + j_max= c.num_cols(), j_block= 2 * (j_max / 2), + k_max= a.num_cols(); + const int stride= 32; + + double *ap= &const_cast<morton_dense<double, MaskA, PA>&>(a)[0][0], + *bp= &const_cast<morton_dense<double, MaskB, PB>&>(b)[0][0], *cp= &c[0][0]; + + // C_nw += A_n * B_n + for (size_type i= 0; i < i_block; i+=2) + for (int j = 0; j < j_block; j+=2) { + double tmp00= 0.0, tmp01= 0.0, tmp10= 0.0, tmp11= 0.0; + for (int k = 0; k < k_max; k++) { + tmp00 += ap[0+(i)*stride+2*k] * bp[0+(j)*stride+2*k]; + tmp01 += ap[0+(i)*stride+2*k] * bp[1+(j)*stride+2*k]; + tmp10 += ap[1+(i)*stride+2*k] * bp[0+(j)*stride+2*k]; + tmp11 += ap[1+(i)*stride+2*k] * bp[1+(j)*stride+2*k]; + } + Assign::update(cp[0+(i)*stride+2*(j+0)], tmp00); + Assign::update(cp[0+(i)*stride+2*(j+1)], tmp01); + Assign::update(cp[1+(i)*stride+2*(j+0)], tmp10); + Assign::update(cp[1+(i)*stride+2*(j+1)], tmp11); + } + + // C_ne += A_n * B_e + for (size_type i= 0; i < i_block; i+=2) + for (int j = j_block; j < j_max; j++) { + double tmp00= 0.0, tmp10= 0.0; + for (int k = 0; k < k_max; k++) { + tmp00 += ap[0+(i)*stride+2*k] * bp[0+(j)*stride+2*k]; + tmp10 += ap[1+(i)*stride+2*k] * bp[0+(j)*stride+2*k]; + } + Assign::update(cp[0+(i)*stride+2*(j+0)], tmp00); + Assign::update(cp[1+(i)*stride+2*(j+0)], tmp10); + } + + // C_s += A_s * B + for (size_type i= i_block; i < i_max; i++) + for (int j = 0; j < j_max; j++) { + double tmp00= 0.0; + for (int k = 0; k < k_max; k++) + tmp00 += ap[0+(i)*stride+2*k] * bp[0+(j)*stride+2*k]; + Assign::update(cp[0+(i)*stride+2*(j+0)], tmp00); + } + } + +} // namespace detail + + +// for C= AB and C+= AB +template <unsigned long MaskA, typename PA, + unsigned long MaskB, typename PB, + unsigned long MaskC, typename PC, + typename Assign, typename Backup> +struct gen_platform_dmat_dmat_mult_ft<morton_dense<double, MaskA, PA>, morton_dense<double, MaskB, PB>, + morton_dense<double, MaskC, PC>, Assign, Backup> +{ + void mult_ass(double * D, double * C, double * BT) const; + + void operator()(const morton_dense<double, MaskA, PA>& a, const morton_dense<double, MaskB, PB>& b, + morton_dense<double, MaskC, PC>& c) const + { + // std::cout << "use Assembly\n"; + + if (detail::opteron_shark_teeth<MaskA, MaskB, MaskC>::value) { + if (Assign::init_to_zero) + set_to_zero(c); + if (a.num_rows() == 32 && a.num_cols() == 32 && b.num_cols() == 32) { + double *ap= const_cast<morton_dense<double, MaskA, PA>&>(a).elements(), + *bp= const_cast<morton_dense<double, MaskB, PB>&>(b).elements(), cp= &c.elements(); + mult_ass(cp, ap, bp); + } else + detail::opteron_shark_teeth_mult<Assign>(a, b, c); + return; + } + Backup()(a, b, c); + } +}; + + +// for C-= AB +template <unsigned long MaskA, typename PA, + unsigned long MaskB, typename PB, + unsigned long MaskC, typename PC, + typename Backup> +struct gen_platform_dmat_dmat_mult_ft<morton_dense<double, MaskA, PA>, morton_dense<double, MaskB, PB>, + morton_dense<double, MaskC, PC>, assign::minus_sum, Backup> +{ + void mult_ass(double * D, double * C, double * BT) const; + + void operator()(const morton_dense<double, MaskA, PA>& a, const morton_dense<double, MaskB, PB>& b, + morton_dense<double, MaskC, PC>& c) const + { + // std::cout << "use Assembly\n"; + + if (detail::opteron_shark_teeth<MaskA, MaskB, MaskC>::value) { + if (a.num_rows() == 32 && a.num_cols() == 32 && b.num_cols() == 32) { + double ap= &const_cast<morton_dense<double, MaskA, PA>&>(a).elements(), + bp= &const_cast<morton_dense<double, MaskB, PB>&>(b).elements(), cp= &c.elements(); + mult_ass(cp, ap, bp); + } else + detail::opteron_shark_teeth_mult<assign::minus_sum>(a, b, c); + return; + } + Backup()(a, b, c); + } +}; + + + + + +template <unsigned long MaskA, typename PA, + unsigned long MaskB, typename PB, + unsigned long MaskC, typename PC, + typename Assign, typename Backup> +void gen_platform_dmat_dmat_mult_ft<morton_dense<double, MaskA, PA>, morton_dense<double, MaskB, PB>, + morton_dense<double, MaskC, PC>, Assign, Backup>:: +mult_ass(double * D, double * C, double * BT) const +{ + // std::cout << "in Assembly\n"; + const int baseOrder= 32, + stride = baseOrder; + /* + double * restrict D = aa + ((d*baseSize)&(rowMask|colMask)); + double * restrict C = aa + ((c*baseSize)&(rowMask|colMask)); + double * restrict BT = aa + ((d*baseSize)&colMask)/2 + + ((c*baseSize)&colMask); + */ + + #if 0 + for (int i = 0; i < baseOrder; i+=2) + for (int j = 0; j < baseOrder; j+=2) + for (int k = 0; k < baseOrder; k++) + { + D[0+(i)*stride+2*(j+0)] += C[0+(i)*stride+2*k] * BT[0+(j)*stride+2*k]; + D[0+(i)*stride+2*(j+1)] += C[0+(i)*stride+2*k] * BT[1+(j)*stride+2*k]; + D[1+(i)*stride+2*(j+0)] += C[1+(i)*stride+2*k] * BT[0+(j)*stride+2*k]; + D[1+(i)*stride+2*(j+1)] += C[1+(i)*stride+2*k] * BT[1+(j)*stride+2*k]; + } + #endif + + #if 0 + // Reorder loops (Ordering based on where the target code is going). + for (int j = 0; j < baseOrder; j+=2) + for (int i = 0; i < baseOrder; i+=16) + { + for (int k = 0; k < baseOrder; k++) + { + for (int i2 = i; i2 < i+16; i2+=2) + { + D[0+(i2)*stride+2*(j+0)] += C[0+(i2)*stride+2*k] * BT[0+(j)*stride+2*k]; + D[1+(i2)*stride+2*(j+0)] += C[1+(i2)*stride+2*k] * BT[0+(j)*stride+2*k]; + } + } + for (int k = 0; k < baseOrder; k++) + { + for (int i2 = i; i2 < i+16; i2+=2) + { + D[0+(i2)*stride+2*(j+1)] += C[0+(i2)*stride+2*k] * BT[1+(j)*stride+2*k]; + D[1+(i2)*stride+2*(j+1)] += C[1+(i2)*stride+2*k] * BT[1+(j)*stride+2*k]; + } + } + } + #endif + + #if 0 + // Unroll i2 + + for (int j = 0; j < baseOrder; j+=2) + for (int i = 0; i < baseOrder; i+=16) + { + for (int k = 0; k < baseOrder; k++) + { + D[0+(i+ 0)*stride+2*(j+0)]+=C[0+(i+ 0)*stride+2*k]*BT[0+j*stride+2*k]; + D[1+(i+ 0)*stride+2*(j+0)]+=C[1+(i+ 0)*stride+2*k]*BT[0+j*stride+2*k]; + D[0+(i+ 2)*stride+2*(j+0)]+=C[0+(i+ 2)*stride+2*k]*BT[0+j*stride+2*k]; + D[1+(i+ 2)*stride+2*(j+0)]+=C[1+(i+ 2)*stride+2*k]*BT[0+j*stride+2*k]; + D[0+(i+ 4)*stride+2*(j+0)]+=C[0+(i+ 4)*stride+2*k]*BT[0+j*stride+2*k]; + D[1+(i+ 4)*stride+2*(j+0)]+=C[1+(i+ 4)*stride+2*k]*BT[0+j*stride+2*k]; + D[0+(i+ 6)*stride+2*(j+0)]+=C[0+(i+ 6)*stride+2*k]*BT[0+j*stride+2*k]; + D[1+(i+ 6)*stride+2*(j+0)]+=C[1+(i+ 6)*stride+2*k]*BT[0+j*stride+2*k]; + D[0+(i+ 8)*stride+2*(j+0)]+=C[0+(i+ 8)*stride+2*k]*BT[0+j*stride+2*k]; + D[1+(i+ 8)*stride+2*(j+0)]+=C[1+(i+ 8)*stride+2*k]*BT[0+j*stride+2*k]; + D[0+(i+10)*stride+2*(j+0)]+=C[0+(i+10)*stride+2*k]*BT[0+j*stride+2*k]; + D[1+(i+10)*stride+2*(j+0)]+=C[1+(i+10)*stride+2*k]*BT[0+j*stride+2*k]; + D[0+(i+12)*stride+2*(j+0)]+=C[0+(i+12)*stride+2*k]*BT[0+j*stride+2*k]; + D[1+(i+12)*stride+2*(j+0)]+=C[1+(i+12)*stride+2*k]*BT[0+j*stride+2*k]; + D[0+(i+14)*stride+2*(j+0)]+=C[0+(i+14)*stride+2*k]*BT[0+j*stride+2*k]; + D[1+(i+14)*stride+2*(j+0)]+=C[1+(i+14)*stride+2*k]*BT[0+j*stride+2*k]; + } + for (int k = 0; k < baseOrder; k++) + { + D[0+(i+ 0)*stride+2*(j+1)]+=C[0+(i+ 0)*stride+2*k]*BT[1+j*stride+2*k]; + D[1+(i+ 0)*stride+2*(j+1)]+=C[1+(i+ 0)*stride+2*k]*BT[1+j*stride+2*k]; + D[0+(i+ 2)*stride+2*(j+1)]+=C[0+(i+ 2)*stride+2*k]*BT[1+j*stride+2*k]; + D[1+(i+ 2)*stride+2*(j+1)]+=C[1+(i+ 2)*stride+2*k]*BT[1+j*stride+2*k]; + D[0+(i+ 4)*stride+2*(j+1)]+=C[0+(i+ 4)*stride+2*k]*BT[1+j*stride+2*k]; + D[1+(i+ 4)*stride+2*(j+1)]+=C[1+(i+ 4)*stride+2*k]*BT[1+j*stride+2*k]; + D[0+(i+ 6)*stride+2*(j+1)]+=C[0+(i+ 6)*stride+2*k]*BT[1+j*stride+2*k]; + D[1+(i+ 6)*stride+2*(j+1)]+=C[1+(i+ 6)*stride+2*k]*BT[1+j*stride+2*k]; + D[0+(i+ 8)*stride+2*(j+1)]+=C[0+(i+ 8)*stride+2*k]*BT[1+j*stride+2*k]; + D[1+(i+ 8)*stride+2*(j+1)]+=C[1+(i+ 8)*stride+2*k]*BT[1+j*stride+2*k]; + D[0+(i+10)*stride+2*(j+1)]+=C[0+(i+10)*stride+2*k]*BT[1+j*stride+2*k]; + D[1+(i+10)*stride+2*(j+1)]+=C[1+(i+10)*stride+2*k]*BT[1+j*stride+2*k]; + D[0+(i+12)*stride+2*(j+1)]+=C[0+(i+12)*stride+2*k]*BT[1+j*stride+2*k]; + D[1+(i+12)*stride+2*(j+1)]+=C[1+(i+12)*stride+2*k]*BT[1+j*stride+2*k]; + D[0+(i+14)*stride+2*(j+1)]+=C[0+(i+14)*stride+2*k]*BT[1+j*stride+2*k]; + D[1+(i+14)*stride+2*(j+1)]+=C[1+(i+14)*stride+2*k]*BT[1+j*stride+2*k]; + } + } + #endif + + #if 0 + // Prep k + for (int j = 0; j < baseOrder; j+=2) + for (int i = 0; i < baseOrder; i+=16) + { + { + double d00 = D[0+(i+ 0)*stride+2*(j+0)]; + double d01 = D[1+(i+ 0)*stride+2*(j+0)]; + double d02 = D[0+(i+ 2)*stride+2*(j+0)]; + double d03 = D[1+(i+ 2)*stride+2*(j+0)]; + double d04 = D[0+(i+ 4)*stride+2*(j+0)]; + double d05 = D[1+(i+ 4)*stride+2*(j+0)]; + double d06 = D[0+(i+ 6)*stride+2*(j+0)]; + double d07 = D[1+(i+ 6)*stride+2*(j+0)]; + double d08 = D[0+(i+ 8)*stride+2*(j+0)]; + double d09 = D[1+(i+ 8)*stride+2*(j+0)]; + double d10 = D[0+(i+10)*stride+2*(j+0)]; + double d11 = D[1+(i+10)*stride+2*(j+0)]; + double d12 = D[0+(i+12)*stride+2*(j+0)]; + double d13 = D[1+(i+12)*stride+2*(j+0)]; + double d14 = D[0+(i+14)*stride+2*(j+0)]; + double d15 = D[1+(i+14)*stride+2*(j+0)]; + for (int k = 0; k < baseOrder; k++) + { + d00+=C[0+(i+ 0)*stride+2*k]*BT[0+j*stride+2*k]; + d01+=C[1+(i+ 0)*stride+2*k]*BT[0+j*stride+2*k]; + d02+=C[0+(i+ 2)*stride+2*k]*BT[0+j*stride+2*k]; + d03+=C[1+(i+ 2)*stride+2*k]*BT[0+j*stride+2*k]; + d04+=C[0+(i+ 4)*stride+2*k]*BT[0+j*stride+2*k]; + d05+=C[1+(i+ 4)*stride+2*k]*BT[0+j*stride+2*k]; + d06+=C[0+(i+ 6)*stride+2*k]*BT[0+j*stride+2*k]; + d07+=C[1+(i+ 6)*stride+2*k]*BT[0+j*stride+2*k]; + d08+=C[0+(i+ 8)*stride+2*k]*BT[0+j*stride+2*k]; + d09+=C[1+(i+ 8)*stride+2*k]*BT[0+j*stride+2*k]; + d10+=C[0+(i+10)*stride+2*k]*BT[0+j*stride+2*k]; + d11+=C[1+(i+10)*stride+2*k]*BT[0+j*stride+2*k]; + d12+=C[0+(i+12)*stride+2*k]*BT[0+j*stride+2*k]; + d13+=C[1+(i+12)*stride+2*k]*BT[0+j*stride+2*k]; + d14+=C[0+(i+14)*stride+2*k]*BT[0+j*stride+2*k]; + d15+=C[1+(i+14)*stride+2*k]*BT[0+j*stride+2*k]; + } + D[0+(i+ 0)*stride+2*(j+0)] = d00; + D[1+(i+ 0)*stride+2*(j+0)] = d01; + D[0+(i+ 2)*stride+2*(j+0)] = d02; + D[1+(i+ 2)*stride+2*(j+0)] = d03; + D[0+(i+ 4)*stride+2*(j+0)] = d04; + D[1+(i+ 4)*stride+2*(j+0)] = d05; + D[0+(i+ 6)*stride+2*(j+0)] = d06; + D[1+(i+ 6)*stride+2*(j+0)] = d07; + D[0+(i+ 8)*stride+2*(j+0)] = d08; + D[1+(i+ 8)*stride+2*(j+0)] = d09; + D[0+(i+10)*stride+2*(j+0)] = d10; + D[1+(i+10)*stride+2*(j+0)] = d11; + D[0+(i+12)*stride+2*(j+0)] = d12; + D[1+(i+12)*stride+2*(j+0)] = d13; + D[0+(i+14)*stride+2*(j+0)] = d14; + D[1+(i+14)*stride+2*(j+0)] = d15; + } + + { + double d00 = D[0+(i+ 0)*stride+2*(j+1)]; + double d01 = D[1+(i+ 0)*stride+2*(j+1)]; + double d02 = D[0+(i+ 2)*stride+2*(j+1)]; + double d03 = D[1+(i+ 2)*stride+2*(j+1)]; + double d04 = D[0+(i+ 4)*stride+2*(j+1)]; + double d05 = D[1+(i+ 4)*stride+2*(j+1)]; + double d06 = D[0+(i+ 6)*stride+2*(j+1)]; + double d07 = D[1+(i+ 6)*stride+2*(j+1)]; + double d08 = D[0+(i+ 8)*stride+2*(j+1)]; + double d09 = D[1+(i+ 8)*stride+2*(j+1)]; + double d10 = D[0+(i+10)*stride+2*(j+1)]; + double d11 = D[1+(i+10)*stride+2*(j+1)]; + double d12 = D[0+(i+12)*stride+2*(j+1)]; + double d13 = D[1+(i+12)*stride+2*(j+1)]; + double d14 = D[0+(i+14)*stride+2*(j+1)]; + double d15 = D[1+(i+14)*stride+2*(j+1)]; + for (int k = 0; k < baseOrder; k++) + { + d00+=C[0+(i+ 0)*stride+2*k]*BT[1+j*stride+2*k]; + d01+=C[1+(i+ 0)*stride+2*k]*BT[1+j*stride+2*k]; + d02+=C[0+(i+ 2)*stride+2*k]*BT[1+j*stride+2*k]; + d03+=C[1+(i+ 2)*stride+2*k]*BT[1+j*stride+2*k]; + d04+=C[0+(i+ 4)*stride+2*k]*BT[1+j*stride+2*k]; + d05+=C[1+(i+ 4)*stride+2*k]*BT[1+j*stride+2*k]; + d06+=C[0+(i+ 6)*stride+2*k]*BT[1+j*stride+2*k]; + d07+=C[1+(i+ 6)*stride+2*k]*BT[1+j*stride+2*k]; + d08+=C[0+(i+ 8)*stride+2*k]*BT[1+j*stride+2*k]; + d09+=C[1+(i+ 8)*stride+2*k]*BT[1+j*stride+2*k]; + d10+=C[0+(i+10)*stride+2*k]*BT[1+j*stride+2*k]; + d11+=C[1+(i+10)*stride+2*k]*BT[1+j*stride+2*k]; + d12+=C[0+(i+12)*stride+2*k]*BT[1+j*stride+2*k]; + d13+=C[1+(i+12)*stride+2*k]*BT[1+j*stride+2*k]; + d14+=C[0+(i+14)*stride+2*k]*BT[1+j*stride+2*k]; + d15+=C[1+(i+14)*stride+2*k]*BT[1+j*stride+2*k]; + } + D[0+(i+ 0)*stride+2*(j+1)] = d00; + D[1+(i+ 0)*stride+2*(j+1)] = d01; + D[0+(i+ 2)*stride+2*(j+1)] = d02; + D[1+(i+ 2)*stride+2*(j+1)] = d03; + D[0+(i+ 4)*stride+2*(j+1)] = d04; + D[1+(i+ 4)*stride+2*(j+1)] = d05; + D[0+(i+ 6)*stride+2*(j+1)] = d06; + D[1+(i+ 6)*stride+2*(j+1)] = d07; + D[0+(i+ 8)*stride+2*(j+1)] = d08; + D[1+(i+ 8)*stride+2*(j+1)] = d09; + D[0+(i+10)*stride+2*(j+1)] = d10; + D[1+(i+10)*stride+2*(j+1)] = d11; + D[0+(i+12)*stride+2*(j+1)] = d12; + D[1+(i+12)*stride+2*(j+1)] = d13; + D[0+(i+14)*stride+2*(j+1)] = d14; + D[1+(i+14)*stride+2*(j+1)] = d15; + } + } + #endif + + #if 0 + // Begin SSE + for (int j = 0; j < baseOrder; j+=2) + for (int i = 0; i < baseOrder; i+=16) + { + { + __m128d d00 = _mm_load_pd(&D[0+(i+ 0)*stride+2*(j+0)]); + __m128d d02 = _mm_load_pd(&D[0+(i+ 2)*stride+2*(j+0)]); + __m128d d04 = _mm_load_pd(&D[0+(i+ 4)*stride+2*(j+0)]); + __m128d d06 = _mm_load_pd(&D[0+(i+ 6)*stride+2*(j+0)]); + __m128d d08 = _mm_load_pd(&D[0+(i+ 8)*stride+2*(j+0)]); + __m128d d10 = _mm_load_pd(&D[0+(i+10)*stride+2*(j+0)]); + __m128d d12 = _mm_load_pd(&D[0+(i+12)*stride+2*(j+0)]); + __m128d d14 = _mm_load_pd(&D[0+(i+14)*stride+2*(j+0)]); + for (int k = 0; k < baseOrder; k++) + { + __m128d bt0 = _mm_load1_pd(&BT[0+j*stride+2*k]); + d00+=_mm_load_pd(&C[0+(i+ 0)*stride+2*k])*bt0; + d02+=_mm_load_pd(&C[0+(i+ 2)*stride+2*k])*bt0; + d04+=_mm_load_pd(&C[0+(i+ 4)*stride+2*k])*bt0; + d06+=_mm_load_pd(&C[0+(i+ 6)*stride+2*k])*bt0; + d08+=_mm_load_pd(&C[0+(i+ 8)*stride+2*k])*bt0; + d10+=_mm_load_pd(&C[0+(i+10)*stride+2*k])*bt0; + d12+=_mm_load_pd(&C[0+(i+12)*stride+2*k])*bt0; + d14+=_mm_load_pd(&C[0+(i+14)*stride+2*k])*bt0; + } + _mm_store_pd(&D[0+(i+ 0)*stride+2*(j+0)], d00); + _mm_store_pd(&D[0+(i+ 2)*stride+2*(j+0)], d02); + _mm_store_pd(&D[0+(i+ 4)*stride+2*(j+0)], d04); + _mm_store_pd(&D[0+(i+ 6)*stride+2*(j+0)], d06); + _mm_store_pd(&D[0+(i+ 8)*stride+2*(j+0)], d08); + _mm_store_pd(&D[0+(i+10)*stride+2*(j+0)], d10); + _mm_store_pd(&D[0+(i+12)*stride+2*(j+0)], d12); + _mm_store_pd(&D[0+(i+14)*stride+2*(j+0)], d14); + } + + { + __m128d d00 = _mm_load_pd(&D[0+(i+ 0)*stride+2*(j+1)]); + __m128d d02 = _mm_load_pd(&D[0+(i+ 2)*stride+2*(j+1)]); + __m128d d04 = _mm_load_pd(&D[0+(i+ 4)*stride+2*(j+1)]); + __m128d d06 = _mm_load_pd(&D[0+(i+ 6)*stride+2*(j+1)]); + __m128d d08 = _mm_load_pd(&D[0+(i+ 8)*stride+2*(j+1)]); + __m128d d10 = _mm_load_pd(&D[0+(i+10)*stride+2*(j+1)]); + __m128d d12 = _mm_load_pd(&D[0+(i+12)*stride+2*(j+1)]); + __m128d d14 = _mm_load_pd(&D[0+(i+14)*stride+2*(j+1)]); + for (int k = 0; k < baseOrder; k++) + { + __m128d bt0 = _mm_load1_pd(&BT[1+j*stride+2*k]); + d00+=_mm_load_pd(&C[0+(i+ 0)*stride+2*k])*bt0; + d02+=_mm_load_pd(&C[0+(i+ 2)*stride+2*k])*bt0; + d04+=_mm_load_pd(&C[0+(i+ 4)*stride+2*k])*bt0; + d06+=_mm_load_pd(&C[0+(i+ 6)*stride+2*k])*bt0; + d08+=_mm_load_pd(&C[0+(i+ 8)*stride+2*k])*bt0; + d10+=_mm_load_pd(&C[0+(i+10)*stride+2*k])*bt0; + d12+=_mm_load_pd(&C[0+(i+12)*stride+2*k])*bt0; + d14+=_mm_load_pd(&C[0+(i+14)*stride+2*k])*bt0; + } + _mm_store_pd(&D[0+(i+ 0)*stride+2*(j+1)], d00); + _mm_store_pd(&D[0+(i+ 2)*stride+2*(j+1)], d02); + _mm_store_pd(&D[0+(i+ 4)*stride+2*(j+1)], d04); + _mm_store_pd(&D[0+(i+ 6)*stride+2*(j+1)], d06); + _mm_store_pd(&D[0+(i+ 8)*stride+2*(j+1)], d08); + _mm_store_pd(&D[0+(i+10)*stride+2*(j+1)], d10); + _mm_store_pd(&D[0+(i+12)*stride+2*(j+1)], d12); + _mm_store_pd(&D[0+(i+14)*stride+2*(j+1)], d14); + } + } + #endif + + #if 0 + // Tweak SSE + #define MM_LOAD1_PD(a,b) \ + { \ + __asm__("movlpd %1, %0" : "=x" (a) : "m"(*b)); \ + __asm__("movhpd %1, %0" : "=x" (a) : "m"(*b), "0" (a)); \ + } + #define MM_LOAD1U_PD(a,b) \ + { \ + __asm__("movlpd %1, %0" : "=x" (a) : "m"(*b)); \ + __asm__("movhpd %1, %0" : "=x" (a) : "m"(*b), "0" (a)); \ + } + #define MM_MUL_PD(out,addr) \ + { out = _mm_mul_pd(out, *(__m128d*)addr); } + for (int j = 0; j < baseOrder; j+=2) + for (int i = 0; i < baseOrder; i+=16) + { + { + __m128d d00 = _mm_load_pd(&D[0+(i+ 0)*stride+2*(j+0)]); + __m128d d02 = _mm_load_pd(&D[0+(i+ 2)*stride+2*(j+0)]); + __m128d d04 = _mm_load_pd(&D[0+(i+ 4)*stride+2*(j+0)]); + __m128d d06 = _mm_load_pd(&D[0+(i+ 6)*stride+2*(j+0)]); + __m128d d08 = _mm_load_pd(&D[0+(i+ 8)*stride+2*(j+0)]); + __m128d d10 = _mm_load_pd(&D[0+(i+10)*stride+2*(j+0)]); + __m128d d12 = _mm_load_pd(&D[0+(i+12)*stride+2*(j+0)]); + __m128d d14 = _mm_load_pd(&D[0+(i+14)*stride+2*(j+0)]); + for (int k = 0; k < baseOrder; k++) + { + __m128d bt0; + MM_LOAD1_PD(bt0, &BT[0+j*stride+2*k]); + d00+=_mm_load_pd(&C[0+(i+ 0)*stride+2*k])*bt0; + d02+=_mm_load_pd(&C[0+(i+ 2)*stride+2*k])*bt0; + d04+=_mm_load_pd(&C[0+(i+ 4)*stride+2*k])*bt0; + d06+=_mm_load_pd(&C[0+(i+ 6)*stride+2*k])*bt0; + d08+=_mm_load_pd(&C[0+(i+ 8)*stride+2*k])*bt0; + d10+=_mm_load_pd(&C[0+(i+10)*stride+2*k])*bt0; + d12+=_mm_load_pd(&C[0+(i+12)*stride+2*k])*bt0; + MM_MUL_PD(bt0, &C[0+(i+14)*stride+2*k]); + d14+=bt0; + } + _mm_store_pd(&D[0+(i+ 0)*stride+2*(j+0)], d00); + _mm_store_pd(&D[0+(i+ 2)*stride+2*(j+0)], d02); + _mm_store_pd(&D[0+(i+ 4)*stride+2*(j+0)], d04); + _mm_store_pd(&D[0+(i+ 6)*stride+2*(j+0)], d06); + _mm_store_pd(&D[0+(i+ 8)*stride+2*(j+0)], d08); + _mm_store_pd(&D[0+(i+10)*stride+2*(j+0)], d10); + _mm_store_pd(&D[0+(i+12)*stride+2*(j+0)], d12); + _mm_store_pd(&D[0+(i+14)*stride+2*(j+0)], d14); + } + + { + __m128d d00 = _mm_load_pd(&D[0+(i+ 0)*stride+2*(j+1)]); + __m128d d02 = _mm_load_pd(&D[0+(i+ 2)*stride+2*(j+1)]); + __m128d d04 = _mm_load_pd(&D[0+(i+ 4)*stride+2*(j+1)]); + __m128d d06 = _mm_load_pd(&D[0+(i+ 6)*stride+2*(j+1)]); + __m128d d08 = _mm_load_pd(&D[0+(i+ 8)*stride+2*(j+1)]); + __m128d d10 = _mm_load_pd(&D[0+(i+10)*stride+2*(j+1)]); + __m128d d12 = _mm_load_pd(&D[0+(i+12)*stride+2*(j+1)]); + __m128d d14 = _mm_load_pd(&D[0+(i+14)*stride+2*(j+1)]); + for (int k = 0; k < baseOrder; k++) + { + __m128d bt1; + MM_LOAD1U_PD(bt1, &BT[1+j*stride+2*k]); + d00+=_mm_load_pd(&C[0+(i+ 0)*stride+2*k])*bt1; + d02+=_mm_load_pd(&C[0+(i+ 2)*stride+2*k])*bt1; + d04+=_mm_load_pd(&C[0+(i+ 4)*stride+2*k])*bt1; + d06+=_mm_load_pd(&C[0+(i+ 6)*stride+2*k])*bt1; + d08+=_mm_load_pd(&C[0+(i+ 8)*stride+2*k])*bt1; + d10+=_mm_load_pd(&C[0+(i+10)*stride+2*k])*bt1; + d12+=_mm_load_pd(&C[0+(i+12)*stride+2*k])*bt1; + MM_MUL_PD(bt1, &C[0+(i+14)*stride+2*k]); + d14+=bt1; + } + _mm_store_pd(&D[0+(i+ 0)*stride+2*(j+1)], d00); + _mm_store_pd(&D[0+(i+ 2)*stride+2*(j+1)], d02); + _mm_store_pd(&D[0+(i+ 4)*stride+2*(j+1)], d04); + _mm_store_pd(&D[0+(i+ 6)*stride+2*(j+1)], d06); + _mm_store_pd(&D[0+(i+ 8)*stride+2*(j+1)], d08); + _mm_store_pd(&D[0+(i+10)*stride+2*(j+1)], d10); + _mm_store_pd(&D[0+(i+12)*stride+2*(j+1)], d12); + _mm_store_pd(&D[0+(i+14)*stride+2*(j+1)], d14); + } + } + #endif + + #if 0 + // Factor and unroll k + #define MM_LOAD1_PD(a,b) \ + { \ + __asm__("movlpd %1, %0" : "=x" (a) : "m"(*b)); \ + + __asm__("movhpd %1, %0" : "=x" (a) : "m"(*b), "0" (a)); \ + } + #define MM_LOAD1U_PD(a,b) \ + { \ + __asm__("movlpd %1, %0" : "=x" (a) : "m"(*b)); \ + __asm__("movhpd %1, %0" : "=x" (a) : "m"(*b), "0" (a)); \ + } + #define MM_MUL_PD(out,addr) \ + { out = _mm_mul_pd(out, *(__m128d*)addr); } + #define BLOCK0_0(i,j,k) \ + { \ + __m128d bt0; \ + MM_LOAD1_PD(bt0, &BT[0+j*stride+2*k]); \ + d00+=_mm_load_pd(&C[0+(i+ 0)*stride+2*k])*bt0; \ + d02+=_mm_load_pd(&C[0+(i+ 2)*stride+2*k])*bt0; \ + d04+=_mm_load_pd(&C[0+(i+ 4)*stride+2*k])*bt0; \ + d06+=_mm_load_pd(&C[0+(i+ 6)*stride+2*k])*bt0; \ + d08+=_mm_load_pd(&C[0+(i+ 8)*stride+2*k])*bt0; \ + d10+=_mm_load_pd(&C[0+(i+10)*stride+2*k])*bt0; \ + d12+=_mm_load_pd(&C[0+(i+12)*stride+2*k])*bt0; \ + MM_MUL_PD(bt0, &C[0+(i+14)*stride+2*k]); \ + d14+=bt0; \ + } + #define BLOCK0_1(i,j,k) \ + { \ + __m128d bt1; \ + MM_LOAD1U_PD(bt1, &BT[1+j*stride+2*k]); \ + d00+=_mm_load_pd(&C[0+(i+ 0)*stride+2*k])*bt1; \ + d02+=_mm_load_pd(&C[0+(i+ 2)*stride+2*k])*bt1; \ + d04+=_mm_load_pd(&C[0+(i+ 4)*stride+2*k])*bt1; \ + d06+=_mm_load_pd(&C[0+(i+ 6)*stride+2*k])*bt1; \ + d08+=_mm_load_pd(&C[0+(i+ 8)*stride+2*k])*bt1; \ + d10+=_mm_load_pd(&C[0+(i+10)*stride+2*k])*bt1; \ + d12+=_mm_load_pd(&C[0+(i+12)*stride+2*k])*bt1; \ + MM_MUL_PD(bt1, &C[0+(i+14)*stride+2*k]); \ + d14+=bt1; \ + } + for (int j = 0; j < baseOrder; j+=2) + for (int i = 0; i < baseOrder; i+=16) + { + { + __m128d d00 = _mm_load_pd(&D[0+(i+ 0)*stride+2*(j+0)]); + __m128d d02 = _mm_load_pd(&D[0+(i+ 2)*stride+2*(j+0)]); + __m128d d04 = _mm_load_pd(&D[0+(i+ 4)*stride+2*(j+0)]); + __m128d d06 = _mm_load_pd(&D[0+(i+ 6)*stride+2*(j+0)]); + __m128d d08 = _mm_load_pd(&D[0+(i+ 8)*stride+2*(j+0)]); + __m128d d10 = _mm_load_pd(&D[0+(i+10)*stride+2*(j+0)]); + __m128d d12 = _mm_load_pd(&D[0+(i+12)*stride+2*(j+0)]); + __m128d d14 = _mm_load_pd(&D[0+(i+14)*stride+2*(j+0)]); + for (int k = 0; k < baseOrder; k+=32) + { + BLOCK0_0(i,j,(k+ 0)); + BLOCK0_0(i,j,(k+ 1)); + BLOCK0_0(i,j,(k+ 2)); + BLOCK0_0(i,j,(k+ 3)); + BLOCK0_0(i,j,(k+ 4)); + BLOCK0_0(i,j,(k+ 5)); + BLOCK0_0(i,j,(k+ 6)); + BLOCK0_0(i,j,(k+ 7)); + BLOCK0_0(i,j,(k+ 8)); + BLOCK0_0(i,j,(k+ 9)); + BLOCK0_0(i,j,(k+10)); + BLOCK0_0(i,j,(k+11)); + BLOCK0_0(i,j,(k+12)); + BLOCK0_0(i,j,(k+13)); + BLOCK0_0(i,j,(k+14)); + BLOCK0_0(i,j,(k+15)); + BLOCK0_0(i,j,(k+16)); + BLOCK0_0(i,j,(k+17)); + BLOCK0_0(i,j,(k+18)); + BLOCK0_0(i,j,(k+19)); + BLOCK0_0(i,j,(k+20)); + BLOCK0_0(i,j,(k+21)); + BLOCK0_0(i,j,(k+22)); + BLOCK0_0(i,j,(k+23)); + BLOCK0_0(i,j,(k+24)); + BLOCK0_0(i,j,(k+25)); + BLOCK0_0(i,j,(k+26)); + BLOCK0_0(i,j,(k+27)); + BLOCK0_0(i,j,(k+28)); + BLOCK0_0(i,j,(k+29)); + BLOCK0_0(i,j,(k+30)); + BLOCK0_0(i,j,(k+31)); + } + _mm_store_pd(&D[0+(i+ 0)*stride+2*(j+0)], d00); + _mm_store_pd(&D[0+(i+ 2)*stride+2*(j+0)], d02); + _mm_store_pd(&D[0+(i+ 4)*stride+2*(j+0)], d04); + _mm_store_pd(&D[0+(i+ 6)*stride+2*(j+0)], d06); + _mm_store_pd(&D[0+(i+ 8)*stride+2*(j+0)], d08); + _mm_store_pd(&D[0+(i+10)*stride+2*(j+0)], d10); + _mm_store_pd(&D[0+(i+12)*stride+2*(j+0)], d12); + _mm_store_pd(&D[0+(i+14)*stride+2*(j+0)], d14); + } + + { + __m128d d00 = _mm_load_pd(&D[0+(i+ 0)*stride+2*(j+1)]); + __m128d d02 = _mm_load_pd(&D[0+(i+ 2)*stride+2*(j+1)]); + __m128d d04 = _mm_load_pd(&D[0+(i+ 4)*stride+2*(j+1)]); + __m128d d06 = _mm_load_pd(&D[0+(i+ 6)*stride+2*(j+1)]); + __m128d d08 = _mm_load_pd(&D[0+(i+ 8)*stride+2*(j+1)]); + __m128d d10 = _mm_load_pd(&D[0+(i+10)*stride+2*(j+1)]); + __m128d d12 = _mm_load_pd(&D[0+(i+12)*stride+2*(j+1)]); + __m128d d14 = _mm_load_pd(&D[0+(i+14)*stride+2*(j+1)]); + for (int k = 0; k < baseOrder; k+=32) + { + BLOCK0_1(i,j,(k+ 0)); + BLOCK0_1(i,j,(k+ 1)); + BLOCK0_1(i,j,(k+ 2)); + BLOCK0_1(i,j,(k+ 3)); + BLOCK0_1(i,j,(k+ 4)); + BLOCK0_1(i,j,(k+ 5)); + BLOCK0_1(i,j,(k+ 6)); + BLOCK0_1(i,j,(k+ 7)); + BLOCK0_1(i,j,(k+ 8)); + BLOCK0_1(i,j,(k+ 9)); + BLOCK0_1(i,j,(k+10)); + BLOCK0_1(i,j,(k+11)); + BLOCK0_1(i,j,(k+12)); + BLOCK0_1(i,j,(k+13)); + BLOCK0_1(i,j,(k+14)); + BLOCK0_1(i,j,(k+15)); + BLOCK0_1(i,j,(k+16)); + BLOCK0_1(i,j,(k+17)); + BLOCK0_1(i,j,(k+18)); + BLOCK0_1(i,j,(k+19)); + BLOCK0_1(i,j,(k+20)); + BLOCK0_1(i,j,(k+21)); + BLOCK0_1(i,j,(k+22)); + BLOCK0_1(i,j,(k+23)); + BLOCK0_1(i,j,(k+24)); + BLOCK0_1(i,j,(k+25)); + BLOCK0_1(i,j,(k+26)); + BLOCK0_1(i,j,(k+27)); + BLOCK0_1(i,j,(k+28)); + BLOCK0_1(i,j,(k+29)); + BLOCK0_1(i,j,(k+30)); + BLOCK0_1(i,j,(k+31)); + } + _mm_store_pd(&D[0+(i+ 0)*stride+2*(j+1)], d00); + _mm_store_pd(&D[0+(i+ 2)*stride+2*(j+1)], d02); + _mm_store_pd(&D[0+(i+ 4)*stride+2*(j+1)], d04); + _mm_store_pd(&D[0+(i+ 6)*stride+2*(j+1)], d06); + _mm_store_pd(&D[0+(i+ 8)*stride+2*(j+1)], d08); + _mm_store_pd(&D[0+(i+10)*stride+2*(j+1)], d10); + _mm_store_pd(&D[0+(i+12)*stride+2*(j+1)], d12); + _mm_store_pd(&D[0+(i+14)*stride+2*(j+1)], d14); + } + } + #endif + + #if 1 + // Factor and unroll i + #define MM_LOAD1_PD(a,b) \ + { \ + __asm__("movlpd %1, %0" : "=x" (a) : "m"(*b)); \ + __asm__("movhpd %1, %0" : "=x" (a) : "m"(*b), "0" (a)); \ + } + #define MM_LOAD1U_PD(a,b) \ + { \ + __asm__("movlpd %1, %0" : "=x" (a) : "m"(*b)); \ + __asm__("movhpd %1, %0" : "=x" (a) : "m"(*b), "0" (a)); \ + } + #define MM_MUL_PD(out,addr) \ + { out = _mm_mul_pd(out, *(__m128d*)addr); } + #define BLOCK0_0(i,j,k) \ + { \ + __m128d bt0; \ + MM_LOAD1_PD(bt0, &BT[0+j*stride+2*k]); \ + d00+=_mm_load_pd(&C[0+(i+ 0)*stride+2*k])*bt0; \ + d02+=_mm_load_pd(&C[0+(i+ 2)*stride+2*k])*bt0; \ + d04+=_mm_load_pd(&C[0+(i+ 4)*stride+2*k])*bt0; \ + d06+=_mm_load_pd(&C[0+(i+ 6)*stride+2*k])*bt0; \ + d08+=_mm_load_pd(&C[0+(i+ 8)*stride+2*k])*bt0; \ + d10+=_mm_load_pd(&C[0+(i+10)*stride+2*k])*bt0; \ + d12+=_mm_load_pd(&C[0+(i+12)*stride+2*k])*bt0; \ + MM_MUL_PD(bt0, &C[0+(i+14)*stride+2*k]); \ + d14+=bt0; \ + } + #define BLOCK0_1(i,j,k) \ + { \ + __m128d bt1; \ + MM_LOAD1U_PD(bt1, &BT[1+j*stride+2*k]); \ + d00+=_mm_load_pd(&C[0+(i+ 0)*stride+2*k])*bt1; \ + d02+=_mm_load_pd(&C[0+(i+ 2)*stride+2*k])*bt1; \ + d04+=_mm_load_pd(&C[0+(i+ 4)*stride+2*k])*bt1; \ + d06+=_mm_load_pd(&C[0+(i+ 6)*stride+2*k])*bt1; \ + d08+=_mm_load_pd(&C[0+(i+ 8)*stride+2*k])*bt1; \ + d10+=_mm_load_pd(&C[0+(i+10)*stride+2*k])*bt1; \ + d12+=_mm_load_pd(&C[0+(i+12)*stride+2*k])*bt1; \ + MM_MUL_PD(bt1, &C[0+(i+14)*stride+2*k]); \ + d14+=bt1; \ + } + #define BLOCK1_0(i,j) \ + { \ + __m128d d00 = _mm_load_pd(&D[0+(i+ 0)*stride+2*(j+0)]); \ + __m128d d02 = _mm_load_pd(&D[0+(i+ 2)*stride+2*(j+0)]); \ + __m128d d04 = _mm_load_pd(&D[0+(i+ 4)*stride+2*(j+0)]); \ + __m128d d06 = _mm_load_pd(&D[0+(i+ 6)*stride+2*(j+0)]); \ + __m128d d08 = _mm_load_pd(&D[0+(i+ 8)*stride+2*(j+0)]); \ + __m128d d10 = _mm_load_pd(&D[0+(i+10)*stride+2*(j+0)]); \ + __m128d d12 = _mm_load_pd(&D[0+(i+12)*stride+2*(j+0)]); \ + __m128d d14 = _mm_load_pd(&D[0+(i+14)*stride+2*(j+0)]); \ + for (int k = 0; k < baseOrder; k+=32) \ + { \ + BLOCK0_0(i,j,(k+ 0)); \ + BLOCK0_0(i,j,(k+ 1)); \ + BLOCK0_0(i,j,(k+ 2)); \ + BLOCK0_0(i,j,(k+ 3)); \ + BLOCK0_0(i,j,(k+ 4)); \ + BLOCK0_0(i,j,(k+ 5)); \ + BLOCK0_0(i,j,(k+ 6)); \ + BLOCK0_0(i,j,(k+ 7)); \ + BLOCK0_0(i,j,(k+ 8)); \ + BLOCK0_0(i,j,(k+ 9)); \ + BLOCK0_0(i,j,(k+10)); \ + BLOCK0_0(i,j,(k+11)); \ + BLOCK0_0(i,j,(k+12)); \ + BLOCK0_0(i,j,(k+13)); \ + BLOCK0_0(i,j,(k+14)); \ + BLOCK0_0(i,j,(k+15)); \ + BLOCK0_0(i,j,(k+16)); \ + BLOCK0_0(i,j,(k+17)); \ + BLOCK0_0(i,j,(k+18)); \ + BLOCK0_0(i,j,(k+19)); \ + BLOCK0_0(i,j,(k+20)); \ + BLOCK0_0(i,j,(k+21)); \ + BLOCK0_0(i,j,(k+22)); \ + BLOCK0_0(i,j,(k+23)); \ + BLOCK0_0(i,j,(k+24)); \ + BLOCK0_0(i,j,(k+25)); \ + BLOCK0_0(i,j,(k+26)); \ + BLOCK0_0(i,j,(k+27)); \ + BLOCK0_0(i,j,(k+28)); \ + BLOCK0_0(i,j,(k+29)); \ + BLOCK0_0(i,j,(k+30)); \ + BLOCK0_0(i,j,(k+31)); \ + } \ + _mm_store_pd(&D[0+(i+ 0)*stride+2*(j+0)], d00); \ + _mm_store_pd(&D[0+(i+ 2)*stride+2*(j+0)], d02); \ + _mm_store_pd(&D[0+(i+ 4)*stride+2*(j+0)], d04); \ + _mm_store_pd(&D[0+(i+ 6)*stride+2*(j+0)], d06); \ + _mm_store_pd(&D[0+(i+ 8)*stride+2*(j+0)], d08); \ + _mm_store_pd(&D[0+(i+10)*stride+2*(j+0)], d10); \ + _mm_store_pd(&D[0+(i+12)*stride+2*(j+0)], d12); \ + _mm_store_pd(&D[0+(i+14)*stride+2*(j+0)], d14); \ + } + #define BLOCK1_1(i,j) \ + { \ + __m128d d00 = _mm_load_pd(&D[0+(i+ 0)*stride+2*(j+1)]); \ + __m128d d02 = _mm_load_pd(&D[0+(i+ 2)*stride+2*(j+1)]); \ + __m128d d04 = _mm_load_pd(&D[0+(i+ 4)*stride+2*(j+1)]); \ + __m128d d06 = _mm_load_pd(&D[0+(i+ 6)*stride+2*(j+1)]); \ + __m128d d08 = _mm_load_pd(&D[0+(i+ 8)*stride+2*(j+1)]); \ + __m128d d10 = _mm_load_pd(&D[0+(i+10)*stride+2*(j+1)]); \ + __m128d d12 = _mm_load_pd(&D[0+(i+12)*stride+2*(j+1)]); \ + __m128d d14 = _mm_load_pd(&D[0+(i+14)*stride+2*(j+1)]); \ + for (int k = 0; k < baseOrder; k+=32) \ + { \ + BLOCK0_1(i,j,(k+ 0)); \ + BLOCK0_1(i,j,(k+ 1)); \ + BLOCK0_1(i,j,(k+ 2)); \ + BLOCK0_1(i,j,(k+ 3)); \ + BLOCK0_1(i,j,(k+ 4)); \ + BLOCK0_1(i,j,(k+ 5)); \ + BLOCK0_1(i,j,(k+ 6)); \ + BLOCK0_1(i,j,(k+ 7)); \ + BLOCK0_1(i,j,(k+ 8)); \ + BLOCK0_1(i,j,(k+ 9)); \ + BLOCK0_1(i,j,(k+10)); \ + BLOCK0_1(i,j,(k+11)); \ + BLOCK0_1(i,j,(k+12)); \ + BLOCK0_1(i,j,(k+13)); \ + BLOCK0_1(i,j,(k+14)); \ + BLOCK0_1(i,j,(k+15)); \ + BLOCK0_1(i,j,(k+16)); \ + BLOCK0_1(i,j,(k+17)); \ + BLOCK0_1(i,j,(k+18)); \ + BLOCK0_1(i,j,(k+19)); \ + BLOCK0_1(i,j,(k+20)); \ + BLOCK0_1(i,j,(k+21)); \ + BLOCK0_1(i,j,(k+22)); \ + BLOCK0_1(i,j,(k+23)); \ + BLOCK0_1(i,j,(k+24)); \ + BLOCK0_1(i,j,(k+25)); \ + BLOCK0_1(i,j,(k+26)); \ + BLOCK0_1(i,j,(k+27)); \ + BLOCK0_1(i,j,(k+28)); \ + BLOCK0_1(i,j,(k+29)); \ + BLOCK0_1(i,j,(k+30)); \ + BLOCK0_1(i,j,(k+31)); \ + } \ + _mm_store_pd(&D[0+(i+ 0)*stride+2*(j+1)], d00); \ + _mm_store_pd(&D[0+(i+ 2)*stride+2*(j+1)], d02); \ + _mm_store_pd(&D[0+(i+ 4)*stride+2*(j+1)], d04); \ + _mm_store_pd(&D[0+(i+ 6)*stride+2*(j+1)], d06); \ + _mm_store_pd(&D[0+(i+ 8)*stride+2*(j+1)], d08); \ + _mm_store_pd(&D[0+(i+10)*stride+2*(j+1)], d10); \ + _mm_store_pd(&D[0+(i+12)*stride+2*(j+1)], d12); \ + _mm_store_pd(&D[0+(i+14)*stride+2*(j+1)], d14); \ + } + + for (int j = 0; j < baseOrder; j+=2) + { + BLOCK1_0( 0,j); + BLOCK1_1( 0,j); + BLOCK1_0(16,j); + BLOCK1_1(16,j); + } + #endif + +} + +// Avoid conflicts with further defitions + +#undef MM_LOAD1_PD +#undef MM_LOAD1U_PD +#undef MM_MUL_PD +#undef BLOCK0_0 +#undef BLOCK0_1 +#undef BLOCK1_0 +#undef BLOCK1_1 + + +template <unsigned long MaskA, typename PA, + unsigned long MaskB, typename PB, + unsigned long MaskC, typename PC, + typename Backup> +void gen_platform_dmat_dmat_mult_ft<morton_dense<double, MaskA, PA>, morton_dense<double, MaskB, PB>, + morton_dense<double, MaskC, PC>, assign::minus_sum, Backup>:: +mult_ass(double * D, double * C, double * BT) const +{ + // std::cout << "in Assembly\n"; + const int baseOrder= 32, + stride = baseOrder; + + /* + double * restrict D = aa + ((d*baseSize)&(rowMask|colMask)); + double * restrict C = aa + ((c*baseSize)&(rowMask|colMask)); + double * restrict BT = aa + ((d*baseSize)&colMask)/2 + + ((c*baseSize)&colMask); + */ + +#if 0 + for (int i = 0; i < baseOrder; i+=2) + for (int j = 0; j < baseOrder; j+=2) + for (int k = 0; k < baseOrder; k++) + { + D[0+(i)*stride+2*(j+0)] -= C[0+(i)*stride+2*k] * BT[0+(j)*stride+2*k]; + D[0+(i)*stride+2*(j+1)] -= C[0+(i)*stride+2*k] * BT[1+(j)*stride+2*k]; + D[1+(i)*stride+2*(j+0)] -= C[1+(i)*stride+2*k] * BT[0+(j)*stride+2*k]; + D[1+(i)*stride+2*(j+1)] -= C[1+(i)*stride+2*k] * BT[1+(j)*stride+2*k]; + } +#endif + +#if 0 + // Reorder loops (Ordering based on where the target code is going). + for (int j = 0; j < baseOrder; j+=2) + for (int i = 0; i < baseOrder; i+=16) + { + for (int k = 0; k < baseOrder; k++) + { + for (int i2 = i; i2 < i+16; i2+=2) + { + D[0+(i2)*stride+2*(j+0)] -= C[0+(i2)*stride+2*k] * BT[0+(j)*stride+2*k]; + D[1+(i2)*stride+2*(j+0)] -= C[1+(i2)*stride+2*k] * BT[0+(j)*stride+2*k]; + } + } + for (int k = 0; k < baseOrder; k++) + { + for (int i2 = i; i2 < i+16; i2+=2) + { + D[0+(i2)*stride+2*(j+1)] -= C[0+(i2)*stride+2*k] * BT[1+(j)*stride+2*k]; + D[1+(i2)*stride+2*(j+1)] -= C[1+(i2)*stride+2*k] * BT[1+(j)*stride+2*k]; + } + } + } +#endif + +#if 0 + // Unroll i2 + + for (int j = 0; j < baseOrder; j+=2) + for (int i = 0; i < baseOrder; i+=16) + { + for (int k = 0; k < baseOrder; k++) + { + D[0+(i+ 0)*stride+2*(j+0)]-=C[0+(i+ 0)*stride+2*k]*BT[0+j*stride+2*k]; + D[1+(i+ 0)*stride+2*(j+0)]-=C[1+(i+ 0)*stride+2*k]*BT[0+j*stride+2*k]; + D[0+(i+ 2)*stride+2*(j+0)]-=C[0+(i+ 2)*stride+2*k]*BT[0+j*stride+2*k]; + D[1+(i+ 2)*stride+2*(j+0)]-=C[1+(i+ 2)*stride+2*k]*BT[0+j*stride+2*k]; + D[0+(i+ 4)*stride+2*(j+0)]-=C[0+(i+ 4)*stride+2*k]*BT[0+j*stride+2*k]; + D[1+(i+ 4)*stride+2*(j+0)]-=C[1+(i+ 4)*stride+2*k]*BT[0+j*stride+2*k]; + D[0+(i+ 6)*stride+2*(j+0)]-=C[0+(i+ 6)*stride+2*k]*BT[0+j*stride+2*k]; + D[1+(i+ 6)*stride+2*(j+0)]-=C[1+(i+ 6)*stride+2*k]*BT[0+j*stride+2*k]; + D[0+(i+ 8)*stride+2*(j+0)]-=C[0+(i+ 8)*stride+2*k]*BT[0+j*stride+2*k]; + D[1+(i+ 8)*stride+2*(j+0)]-=C[1+(i+ 8)*stride+2*k]*BT[0+j*stride+2*k]; + D[0+(i+10)*stride+2*(j+0)]-=C[0+(i+10)*stride+2*k]*BT[0+j*stride+2*k]; + D[1+(i+10)*stride+2*(j+0)]-=C[1+(i+10)*stride+2*k]*BT[0+j*stride+2*k]; + D[0+(i+12)*stride+2*(j+0)]-=C[0+(i+12)*stride+2*k]*BT[0+j*stride+2*k]; + D[1+(i+12)*stride+2*(j+0)]-=C[1+(i+12)*stride+2*k]*BT[0+j*stride+2*k]; + D[0+(i+14)*stride+2*(j+0)]-=C[0+(i+14)*stride+2*k]*BT[0+j*stride+2*k]; + D[1+(i+14)*stride+2*(j+0)]-=C[1+(i+14)*stride+2*k]*BT[0+j*stride+2*k]; + } + for (int k = 0; k < baseOrder; k++) + { + D[0+(i+ 0)*stride+2*(j+1)]-=C[0+(i+ 0)*stride+2*k]*BT[1+j*stride+2*k]; + D[1+(i+ 0)*stride+2*(j+1)]-=C[1+(i+ 0)*stride+2*k]*BT[1+j*stride+2*k]; + D[0+(i+ 2)*stride+2*(j+1)]-=C[0+(i+ 2)*stride+2*k]*BT[1+j*stride+2*k]; + D[1+(i+ 2)*stride+2*(j+1)]-=C[1+(i+ 2)*stride+2*k]*BT[1+j*stride+2*k]; + D[0+(i+ 4)*stride+2*(j+1)]-=C[0+(i+ 4)*stride+2*k]*BT[1+j*stride+2*k]; + D[1+(i+ 4)*stride+2*(j+1)]-=C[1+(i+ 4)*stride+2*k]*BT[1+j*stride+2*k]; + D[0+(i+ 6)*stride+2*(j+1)]-=C[0+(i+ 6)*stride+2*k]*BT[1+j*stride+2*k]; + D[1+(i+ 6)*stride+2*(j+1)]-=C[1+(i+ 6)*stride+2*k]*BT[1+j*stride+2*k]; + D[0+(i+ 8)*stride+2*(j+1)]-=C[0+(i+ 8)*stride+2*k]*BT[1+j*stride+2*k]; + D[1+(i+ 8)*stride+2*(j+1)]-=C[1+(i+ 8)*stride+2*k]*BT[1+j*stride+2*k]; + D[0+(i+10)*stride+2*(j+1)]-=C[0+(i+10)*stride+2*k]*BT[1+j*stride+2*k]; + D[1+(i+10)*stride+2*(j+1)]-=C[1+(i+10)*stride+2*k]*BT[1+j*stride+2*k]; + D[0+(i+12)*stride+2*(j+1)]-=C[0+(i+12)*stride+2*k]*BT[1+j*stride+2*k]; + D[1+(i+12)*stride+2*(j+1)]-=C[1+(i+12)*stride+2*k]*BT[1+j*stride+2*k]; + D[0+(i+14)*stride+2*(j+1)]-=C[0+(i+14)*stride+2*k]*BT[1+j*stride+2*k]; + D[1+(i+14)*stride+2*(j+1)]-=C[1+(i+14)*stride+2*k]*BT[1+j*stride+2*k]; + } + } +#endif + +#if 0 + // Prep k + for (int j = 0; j < baseOrder; j+=2) + for (int i = 0; i < baseOrder; i+=16) + { + { + double d00 = D[0+(i+ 0)*stride+2*(j+0)]; + double d01 = D[1+(i+ 0)*stride+2*(j+0)]; + double d02 = D[0+(i+ 2)*stride+2*(j+0)]; + double d03 = D[1+(i+ 2)*stride+2*(j+0)]; + double d04 = D[0+(i+ 4)*stride+2*(j+0)]; + double d05 = D[1+(i+ 4)*stride+2*(j+0)]; + double d06 = D[0+(i+ 6)*stride+2*(j+0)]; + double d07 = D[1+(i+ 6)*stride+2*(j+0)]; + double d08 = D[0+(i+ 8)*stride+2*(j+0)]; + double d09 = D[1+(i+ 8)*stride+2*(j+0)]; + double d10 = D[0+(i+10)*stride+2*(j+0)]; + double d11 = D[1+(i+10)*stride+2*(j+0)]; + double d12 = D[0+(i+12)*stride+2*(j+0)]; + double d13 = D[1+(i+12)*stride+2*(j+0)]; + double d14 = D[0+(i+14)*stride+2*(j+0)]; + double d15 = D[1+(i+14)*stride+2*(j+0)]; + for (int k = 0; k < baseOrder; k++) + { + d00-=C[0+(i+ 0)*stride+2*k]*BT[0+j*stride+2*k]; + d01-=C[1+(i+ 0)*stride+2*k]*BT[0+j*stride+2*k]; + d02-=C[0+(i+ 2)*stride+2*k]*BT[0+j*stride+2*k]; + d03-=C[1+(i+ 2)*stride+2*k]*BT[0+j*stride+2*k]; + d04-=C[0+(i+ 4)*stride+2*k]*BT[0+j*stride+2*k]; + d05-=C[1+(i+ 4)*stride+2*k]*BT[0+j*stride+2*k]; + d06-=C[0+(i+ 6)*stride+2*k]*BT[0+j*stride+2*k]; + d07-=C[1+(i+ 6)*stride+2*k]*BT[0+j*stride+2*k]; + d08-=C[0+(i+ 8)*stride+2*k]*BT[0+j*stride+2*k]; + d09-=C[1+(i+ 8)*stride+2*k]*BT[0+j*stride+2*k]; + d10-=C[0+(i+10)*stride+2*k]*BT[0+j*stride+2*k]; + d11-=C[1+(i+10)*stride+2*k]*BT[0+j*stride+2*k]; + d12-=C[0+(i+12)*stride+2*k]*BT[0+j*stride+2*k]; + d13-=C[1+(i+12)*stride+2*k]*BT[0+j*stride+2*k]; + d14-=C[0+(i+14)*stride+2*k]*BT[0+j*stride+2*k]; + d15-=C[1+(i+14)*stride+2*k]*BT[0+j*stride+2*k]; + } + D[0+(i+ 0)*stride+2*(j+0)] = d00; + D[1+(i+ 0)*stride+2*(j+0)] = d01; + D[0+(i+ 2)*stride+2*(j+0)] = d02; + D[1+(i+ 2)*stride+2*(j+0)] = d03; + D[0+(i+ 4)*stride+2*(j+0)] = d04; + D[1+(i+ 4)*stride+2*(j+0)] = d05; + D[0+(i+ 6)*stride+2*(j+0)] = d06; + D[1+(i+ 6)*stride+2*(j+0)] = d07; + D[0+(i+ 8)*stride+2*(j+0)] = d08; + D[1+(i+ 8)*stride+2*(j+0)] = d09; + D[0+(i+10)*stride+2*(j+0)] = d10; + D[1+(i+10)*stride+2*(j+0)] = d11; + D[0+(i+12)*stride+2*(j+0)] = d12; + D[1+(i+12)*stride+2*(j+0)] = d13; + D[0+(i+14)*stride+2*(j+0)] = d14; + D[1+(i+14)*stride+2*(j+0)] = d15; + } + + { + double d00 = D[0+(i+ 0)*stride+2*(j+1)]; + double d01 = D[1+(i+ 0)*stride+2*(j+1)]; + double d02 = D[0+(i+ 2)*stride+2*(j+1)]; + double d03 = D[1+(i+ 2)*stride+2*(j+1)]; + double d04 = D[0+(i+ 4)*stride+2*(j+1)]; + double d05 = D[1+(i+ 4)*stride+2*(j+1)]; + double d06 = D[0+(i+ 6)*stride+2*(j+1)]; + double d07 = D[1+(i+ 6)*stride+2*(j+1)]; + double d08 = D[0+(i+ 8)*stride+2*(j+1)]; + double d09 = D[1+(i+ 8)*stride+2*(j+1)]; + double d10 = D[0+(i+10)*stride+2*(j+1)]; + double d11 = D[1+(i+10)*stride+2*(j+1)]; + double d12 = D[0+(i+12)*stride+2*(j+1)]; + double d13 = D[1+(i+12)*stride+2*(j+1)]; + double d14 = D[0+(i+14)*stride+2*(j+1)]; + double d15 = D[1+(i+14)*stride+2*(j+1)]; + for (int k = 0; k < baseOrder; k++) + { + d00-=C[0+(i+ 0)*stride+2*k]*BT[1+j*stride+2*k]; + d01-=C[1+(i+ 0)*stride+2*k]*BT[1+j*stride+2*k]; + d02-=C[0+(i+ 2)*stride+2*k]*BT[1+j*stride+2*k]; + d03-=C[1+(i+ 2)*stride+2*k]*BT[1+j*stride+2*k]; + d04-=C[0+(i+ 4)*stride+2*k]*BT[1+j*stride+2*k]; + d05-=C[1+(i+ 4)*stride+2*k]*BT[1+j*stride+2*k]; + d06-=C[0+(i+ 6)*stride+2*k]*BT[1+j*stride+2*k]; + d07-=C[1+(i+ 6)*stride+2*k]*BT[1+j*stride+2*k]; + d08-=C[0+(i+ 8)*stride+2*k]*BT[1+j*stride+2*k]; + d09-=C[1+(i+ 8)*stride+2*k]*BT[1+j*stride+2*k]; + d10-=C[0+(i+10)*stride+2*k]*BT[1+j*stride+2*k]; + d11-=C[1+(i+10)*stride+2*k]*BT[1+j*stride+2*k]; + d12-=C[0+(i+12)*stride+2*k]*BT[1+j*stride+2*k]; + d13-=C[1+(i+12)*stride+2*k]*BT[1+j*stride+2*k]; + d14-=C[0+(i+14)*stride+2*k]*BT[1+j*stride+2*k]; + d15-=C[1+(i+14)*stride+2*k]*BT[1+j*stride+2*k]; + } + D[0+(i+ 0)*stride+2*(j+1)] = d00; + D[1+(i+ 0)*stride+2*(j+1)] = d01; + D[0+(i+ 2)*stride+2*(j+1)] = d02; + D[1+(i+ 2)*stride+2*(j+1)] = d03; + D[0+(i+ 4)*stride+2*(j+1)] = d04; + D[1+(i+ 4)*stride+2*(j+1)] = d05; + D[0+(i+ 6)*stride+2*(j+1)] = d06; + D[1+(i+ 6)*stride+2*(j+1)] = d07; + D[0+(i+ 8)*stride+2*(j+1)] = d08; + D[1+(i+ 8)*stride+2*(j+1)] = d09; + D[0+(i+10)*stride+2*(j+1)] = d10; + D[1+(i+10)*stride+2*(j+1)] = d11; + D[0+(i+12)*stride+2*(j+1)] = d12; + D[1+(i+12)*stride+2*(j+1)] = d13; + D[0+(i+14)*stride+2*(j+1)] = d14; + D[1+(i+14)*stride+2*(j+1)] = d15; + } + } +#endif + +#if 0 + // Begin SSE + for (int j = 0; j < baseOrder; j+=2) + for (int i = 0; i < baseOrder; i+=16) + { + { + __m128d d00 = _mm_load_pd(&D[0+(i+ 0)*stride+2*(j+0)]); + __m128d d02 = _mm_load_pd(&D[0+(i+ 2)*stride+2*(j+0)]); + __m128d d04 = _mm_load_pd(&D[0+(i+ 4)*stride+2*(j+0)]); + __m128d d06 = _mm_load_pd(&D[0+(i+ 6)*stride+2*(j+0)]); + __m128d d08 = _mm_load_pd(&D[0+(i+ 8)*stride+2*(j+0)]); + __m128d d10 = _mm_load_pd(&D[0+(i+10)*stride+2*(j+0)]); + __m128d d12 = _mm_load_pd(&D[0+(i+12)*stride+2*(j+0)]); + __m128d d14 = _mm_load_pd(&D[0+(i+14)*stride+2*(j+0)]); + for (int k = 0; k < baseOrder; k++) + { + __m128d bt0 = _mm_load1_pd(&BT[0+j*stride+2*k]); + d00-=_mm_load_pd(&C[0+(i+ 0)*stride+2*k])*bt0; + d02-=_mm_load_pd(&C[0+(i+ 2)*stride+2*k])*bt0; + d04-=_mm_load_pd(&C[0+(i+ 4)*stride+2*k])*bt0; + d06-=_mm_load_pd(&C[0+(i+ 6)*stride+2*k])*bt0; + d08-=_mm_load_pd(&C[0+(i+ 8)*stride+2*k])*bt0; + d10-=_mm_load_pd(&C[0+(i+10)*stride+2*k])*bt0; + d12-=_mm_load_pd(&C[0+(i+12)*stride+2*k])*bt0; + d14-=_mm_load_pd(&C[0+(i+14)*stride+2*k])*bt0; + } + _mm_store_pd(&D[0+(i+ 0)*stride+2*(j+0)], d00); + _mm_store_pd(&D[0+(i+ 2)*stride+2*(j+0)], d02); + _mm_store_pd(&D[0+(i+ 4)*stride+2*(j+0)], d04); + _mm_store_pd(&D[0+(i+ 6)*stride+2*(j+0)], d06); + _mm_store_pd(&D[0+(i+ 8)*stride+2*(j+0)], d08); + _mm_store_pd(&D[0+(i+10)*stride+2*(j+0)], d10); + _mm_store_pd(&D[0+(i+12)*stride+2*(j+0)], d12); + _mm_store_pd(&D[0+(i+14)*stride+2*(j+0)], d14); + } + + { + __m128d d00 = _mm_load_pd(&D[0+(i+ 0)*stride+2*(j+1)]); + __m128d d02 = _mm_load_pd(&D[0+(i+ 2)*stride+2*(j+1)]); + __m128d d04 = _mm_load_pd(&D[0+(i+ 4)*stride+2*(j+1)]); + __m128d d06 = _mm_load_pd(&D[0+(i+ 6)*stride+2*(j+1)]); + __m128d d08 = _mm_load_pd(&D[0+(i+ 8)*stride+2*(j+1)]); + __m128d d10 = _mm_load_pd(&D[0+(i+10)*stride+2*(j+1)]); + __m128d d12 = _mm_load_pd(&D[0+(i+12)*stride+2*(j+1)]); + __m128d d14 = _mm_load_pd(&D[0+(i+14)*stride+2*(j+1)]); + for (int k = 0; k < baseOrder; k++) + { + __m128d bt0 = _mm_load1_pd(&BT[1+j*stride+2*k]); + d00-=_mm_load_pd(&C[0+(i+ 0)*stride+2*k])*bt0; + d02-=_mm_load_pd(&C[0+(i+ 2)*stride+2*k])*bt0; + d04-=_mm_load_pd(&C[0+(i+ 4)*stride+2*k])*bt0; + d06-=_mm_load_pd(&C[0+(i+ 6)*stride+2*k])*bt0; + d08-=_mm_load_pd(&C[0+(i+ 8)*stride+2*k])*bt0; + d10-=_mm_load_pd(&C[0+(i+10)*stride+2*k])*bt0; + d12-=_mm_load_pd(&C[0+(i+12)*stride+2*k])*bt0; + d14-=_mm_load_pd(&C[0+(i+14)*stride+2*k])*bt0; + } + _mm_store_pd(&D[0+(i+ 0)*stride+2*(j+1)], d00); + _mm_store_pd(&D[0+(i+ 2)*stride+2*(j+1)], d02); + _mm_store_pd(&D[0+(i+ 4)*stride+2*(j+1)], d04); + _mm_store_pd(&D[0+(i+ 6)*stride+2*(j+1)], d06); + _mm_store_pd(&D[0+(i+ 8)*stride+2*(j+1)], d08); + _mm_store_pd(&D[0+(i+10)*stride+2*(j+1)], d10); + _mm_store_pd(&D[0+(i+12)*stride+2*(j+1)], d12); + _mm_store_pd(&D[0+(i+14)*stride+2*(j+1)], d14); + } + } +#endif + +#if 0 + // Tweak SSE +#define MM_LOAD1_PD(a,b) \ +{ \ + __asm__("movlpd %1, %0" : "=x" (a) : "m"(*b)); \ + __asm__("movhpd %1, %0" : "=x" (a) : "m"(*b), "0" (a)); \ +} +#define MM_LOAD1U_PD(a,b) \ +{ \ + __asm__("movlpd %1, %0" : "=x" (a) : "m"(*b)); \ + __asm__("movhpd %1, %0" : "=x" (a) : "m"(*b), "0" (a)); \ +} +#define MM_MUL_PD(out,addr) \ +{ out = _mm_mul_pd(out, *(__m128d*)addr); } + for (int j = 0; j < baseOrder; j+=2) + for (int i = 0; i < baseOrder; i+=16) + { + { + __m128d d00 = _mm_load_pd(&D[0+(i+ 0)*stride+2*(j+0)]); + __m128d d02 = _mm_load_pd(&D[0+(i+ 2)*stride+2*(j+0)]); + __m128d d04 = _mm_load_pd(&D[0+(i+ 4)*stride+2*(j+0)]); + __m128d d06 = _mm_load_pd(&D[0+(i+ 6)*stride+2*(j+0)]); + __m128d d08 = _mm_load_pd(&D[0+(i+ 8)*stride+2*(j+0)]); + __m128d d10 = _mm_load_pd(&D[0+(i+10)*stride+2*(j+0)]); + __m128d d12 = _mm_load_pd(&D[0+(i+12)*stride+2*(j+0)]); + __m128d d14 = _mm_load_pd(&D[0+(i+14)*stride+2*(j+0)]); + for (int k = 0; k < baseOrder; k++) + { + __m128d bt0; + MM_LOAD1_PD(bt0, &BT[0+j*stride+2*k]); + d00-=_mm_load_pd(&C[0+(i+ 0)*stride+2*k])*bt0; + d02-=_mm_load_pd(&C[0+(i+ 2)*stride+2*k])*bt0; + d04-=_mm_load_pd(&C[0+(i+ 4)*stride+2*k])*bt0; + d06-=_mm_load_pd(&C[0+(i+ 6)*stride+2*k])*bt0; + d08-=_mm_load_pd(&C[0+(i+ 8)*stride+2*k])*bt0; + d10-=_mm_load_pd(&C[0+(i+10)*stride+2*k])*bt0; + d12-=_mm_load_pd(&C[0+(i+12)*stride+2*k])*bt0; + MM_MUL_PD(bt0, &C[0+(i+14)*stride+2*k]); + d14-=bt0; + } + _mm_store_pd(&D[0+(i+ 0)*stride+2*(j+0)], d00); + _mm_store_pd(&D[0+(i+ 2)*stride+2*(j+0)], d02); + _mm_store_pd(&D[0+(i+ 4)*stride+2*(j+0)], d04); + _mm_store_pd(&D[0+(i+ 6)*stride+2*(j+0)], d06); + _mm_store_pd(&D[0+(i+ 8)*stride+2*(j+0)], d08); + _mm_store_pd(&D[0+(i+10)*stride+2*(j+0)], d10); + _mm_store_pd(&D[0+(i+12)*stride+2*(j+0)], d12); + _mm_store_pd(&D[0+(i+14)*stride+2*(j+0)], d14); + } + + { + __m128d d00 = _mm_load_pd(&D[0+(i+ 0)*stride+2*(j+1)]); + __m128d d02 = _mm_load_pd(&D[0+(i+ 2)*stride+2*(j+1)]); + __m128d d04 = _mm_load_pd(&D[0+(i+ 4)*stride+2*(j+1)]); + __m128d d06 = _mm_load_pd(&D[0+(i+ 6)*stride+2*(j+1)]); + __m128d d08 = _mm_load_pd(&D[0+(i+ 8)*stride+2*(j+1)]); + __m128d d10 = _mm_load_pd(&D[0+(i+10)*stride+2*(j+1)]); + __m128d d12 = _mm_load_pd(&D[0+(i+12)*stride+2*(j+1)]); + __m128d d14 = _mm_load_pd(&D[0+(i+14)*stride+2*(j+1)]); + for (int k = 0; k < baseOrder; k++) + { + __m128d bt1; + MM_LOAD1U_PD(bt1, &BT[1+j*stride+2*k]); + d00-=_mm_load_pd(&C[0+(i+ 0)*stride+2*k])*bt1; + d02-=_mm_load_pd(&C[0+(i+ 2)*stride+2*k])*bt1; + d04-=_mm_load_pd(&C[0+(i+ 4)*stride+2*k])*bt1; + d06-=_mm_load_pd(&C[0+(i+ 6)*stride+2*k])*bt1; + d08-=_mm_load_pd(&C[0+(i+ 8)*stride+2*k])*bt1; + d10-=_mm_load_pd(&C[0+(i+10)*stride+2*k])*bt1; + d12-=_mm_load_pd(&C[0+(i+12)*stride+2*k])*bt1; + MM_MUL_PD(bt1, &C[0+(i+14)*stride+2*k]); + d14-=bt1; + } + _mm_store_pd(&D[0+(i+ 0)*stride+2*(j+1)], d00); + _mm_store_pd(&D[0+(i+ 2)*stride+2*(j+1)], d02); + _mm_store_pd(&D[0+(i+ 4)*stride+2*(j+1)], d04); + _mm_store_pd(&D[0+(i+ 6)*stride+2*(j+1)], d06); + _mm_store_pd(&D[0+(i+ 8)*stride+2*(j+1)], d08); + _mm_store_pd(&D[0+(i+10)*stride+2*(j+1)], d10); + _mm_store_pd(&D[0+(i+12)*stride+2*(j+1)], d12); + _mm_store_pd(&D[0+(i+14)*stride+2*(j+1)], d14); + } + } +#endif + +#if 0 + // Factor and unroll k +#define MM_LOAD1_PD(a,b) \ +{ \ + __asm__("movlpd %1, %0" : "=x" (a) : "m"(*b)); \ + __asm__("movhpd %1, %0" : "=x" (a) : "m"(*b), "0" (a)); \ +} +#define MM_LOAD1U_PD(a,b) \ +{ \ + __asm__("movlpd %1, %0" : "=x" (a) : "m"(*b)); \ + __asm__("movhpd %1, %0" : "=x" (a) : "m"(*b), "0" (a)); \ +} +#define MM_MUL_PD(out,addr) \ +{ out = _mm_mul_pd(out, *(__m128d*)addr); } +#define BLOCK0_0(i,j,k) \ + { \ + __m128d bt0; \ + MM_LOAD1_PD(bt0, &BT[0+j*stride+2*k]); \ + d00-=_mm_load_pd(&C[0+(i+ 0)*stride+2*k])*bt0; \ + d02-=_mm_load_pd(&C[0+(i+ 2)*stride+2*k])*bt0; \ + d04-=_mm_load_pd(&C[0+(i+ 4)*stride+2*k])*bt0; \ + d06-=_mm_load_pd(&C[0+(i+ 6)*stride+2*k])*bt0; \ + d08-=_mm_load_pd(&C[0+(i+ 8)*stride+2*k])*bt0; \ + d10-=_mm_load_pd(&C[0+(i+10)*stride+2*k])*bt0; \ + d12-=_mm_load_pd(&C[0+(i+12)*stride+2*k])*bt0; \ + MM_MUL_PD(bt0, &C[0+(i+14)*stride+2*k]); \ + d14-=bt0; \ + } +#define BLOCK0_1(i,j,k) \ + { \ + __m128d bt1; \ + MM_LOAD1U_PD(bt1, &BT[1+j*stride+2*k]); \ + d00-=_mm_load_pd(&C[0+(i+ 0)*stride+2*k])*bt1; \ + d02-=_mm_load_pd(&C[0+(i+ 2)*stride+2*k])*bt1; \ + d04-=_mm_load_pd(&C[0+(i+ 4)*stride+2*k])*bt1; \ + d06-=_mm_load_pd(&C[0+(i+ 6)*stride+2*k])*bt1; \ + d08-=_mm_load_pd(&C[0+(i+ 8)*stride+2*k])*bt1; \ + d10-=_mm_load_pd(&C[0+(i+10)*stride+2*k])*bt1; \ + d12-=_mm_load_pd(&C[0+(i+12)*stride+2*k])*bt1; \ + MM_MUL_PD(bt1, &C[0+(i+14)*stride+2*k]); \ + d14-=bt1; \ + } + for (int j = 0; j < baseOrder; j+=2) + for (int i = 0; i < baseOrder; i+=16) + { + { + __m128d d00 = _mm_load_pd(&D[0+(i+ 0)*stride+2*(j+0)]); + __m128d d02 = _mm_load_pd(&D[0+(i+ 2)*stride+2*(j+0)]); + __m128d d04 = _mm_load_pd(&D[0+(i+ 4)*stride+2*(j+0)]); + __m128d d06 = _mm_load_pd(&D[0+(i+ 6)*stride+2*(j+0)]); + __m128d d08 = _mm_load_pd(&D[0+(i+ 8)*stride+2*(j+0)]); + __m128d d10 = _mm_load_pd(&D[0+(i+10)*stride+2*(j+0)]); + __m128d d12 = _mm_load_pd(&D[0+(i+12)*stride+2*(j+0)]); + __m128d d14 = _mm_load_pd(&D[0+(i+14)*stride+2*(j+0)]); + for (int k = 0; k < baseOrder; k+=32) + { + BLOCK0_0(i,j,(k+ 0)); + BLOCK0_0(i,j,(k+ 1)); + BLOCK0_0(i,j,(k+ 2)); + BLOCK0_0(i,j,(k+ 3)); + BLOCK0_0(i,j,(k+ 4)); + BLOCK0_0(i,j,(k+ 5)); + BLOCK0_0(i,j,(k+ 6)); + BLOCK0_0(i,j,(k+ 7)); + BLOCK0_0(i,j,(k+ 8)); + BLOCK0_0(i,j,(k+ 9)); + BLOCK0_0(i,j,(k+10)); + BLOCK0_0(i,j,(k+11)); + BLOCK0_0(i,j,(k+12)); + BLOCK0_0(i,j,(k+13)); + BLOCK0_0(i,j,(k+14)); + BLOCK0_0(i,j,(k+15)); + BLOCK0_0(i,j,(k+16)); + BLOCK0_0(i,j,(k+17)); + BLOCK0_0(i,j,(k+18)); + BLOCK0_0(i,j,(k+19)); + BLOCK0_0(i,j,(k+20)); + BLOCK0_0(i,j,(k+21)); + BLOCK0_0(i,j,(k+22)); + BLOCK0_0(i,j,(k+23)); + BLOCK0_0(i,j,(k+24)); + BLOCK0_0(i,j,(k+25)); + BLOCK0_0(i,j,(k+26)); + BLOCK0_0(i,j,(k+27)); + BLOCK0_0(i,j,(k+28)); + BLOCK0_0(i,j,(k+29)); + BLOCK0_0(i,j,(k+30)); + BLOCK0_0(i,j,(k+31)); + } + _mm_store_pd(&D[0+(i+ 0)*stride+2*(j+0)], d00); + _mm_store_pd(&D[0+(i+ 2)*stride+2*(j+0)], d02); + _mm_store_pd(&D[0+(i+ 4)*stride+2*(j+0)], d04); + _mm_store_pd(&D[0+(i+ 6)*stride+2*(j+0)], d06); + _mm_store_pd(&D[0+(i+ 8)*stride+2*(j+0)], d08); + _mm_store_pd(&D[0+(i+10)*stride+2*(j+0)], d10); + _mm_store_pd(&D[0+(i+12)*stride+2*(j+0)], d12); + _mm_store_pd(&D[0+(i+14)*stride+2*(j+0)], d14); + } + + { + __m128d d00 = _mm_load_pd(&D[0+(i+ 0)*stride+2*(j+1)]); + __m128d d02 = _mm_load_pd(&D[0+(i+ 2)*stride+2*(j+1)]); + __m128d d04 = _mm_load_pd(&D[0+(i+ 4)*stride+2*(j+1)]); + __m128d d06 = _mm_load_pd(&D[0+(i+ 6)*stride+2*(j+1)]); + __m128d d08 = _mm_load_pd(&D[0+(i+ 8)*stride+2*(j+1)]); + __m128d d10 = _mm_load_pd(&D[0+(i+10)*stride+2*(j+1)]); + __m128d d12 = _mm_load_pd(&D[0+(i+12)*stride+2*(j+1)]); + __m128d d14 = _mm_load_pd(&D[0+(i+14)*stride+2*(j+1)]); + for (int k = 0; k < baseOrder; k+=32) + { + BLOCK0_1(i,j,(k+ 0)); + BLOCK0_1(i,j,(k+ 1)); + BLOCK0_1(i,j,(k+ 2)); + BLOCK0_1(i,j,(k+ 3)); + BLOCK0_1(i,j,(k+ 4)); + BLOCK0_1(i,j,(k+ 5)); + BLOCK0_1(i,j,(k+ 6)); + BLOCK0_1(i,j,(k+ 7)); + BLOCK0_1(i,j,(k+ 8)); + BLOCK0_1(i,j,(k+ 9)); + BLOCK0_1(i,j,(k+10)); + BLOCK0_1(i,j,(k+11)); + BLOCK0_1(i,j,(k+12)); + BLOCK0_1(i,j,(k+13)); + BLOCK0_1(i,j,(k+14)); + BLOCK0_1(i,j,(k+15)); + BLOCK0_1(i,j,(k+16)); + BLOCK0_1(i,j,(k+17)); + BLOCK0_1(i,j,(k+18)); + BLOCK0_1(i,j,(k+19)); + BLOCK0_1(i,j,(k+20)); + BLOCK0_1(i,j,(k+21)); + BLOCK0_1(i,j,(k+22)); + BLOCK0_1(i,j,(k+23)); + BLOCK0_1(i,j,(k+24)); + BLOCK0_1(i,j,(k+25)); + BLOCK0_1(i,j,(k+26)); + BLOCK0_1(i,j,(k+27)); + BLOCK0_1(i,j,(k+28)); + BLOCK0_1(i,j,(k+29)); + BLOCK0_1(i,j,(k+30)); + BLOCK0_1(i,j,(k+31)); + } + _mm_store_pd(&D[0+(i+ 0)*stride+2*(j+1)], d00); + _mm_store_pd(&D[0+(i+ 2)*stride+2*(j+1)], d02); + _mm_store_pd(&D[0+(i+ 4)*stride+2*(j+1)], d04); + _mm_store_pd(&D[0+(i+ 6)*stride+2*(j+1)], d06); + _mm_store_pd(&D[0+(i+ 8)*stride+2*(j+1)], d08); + _mm_store_pd(&D[0+(i+10)*stride+2*(j+1)], d10); + _mm_store_pd(&D[0+(i+12)*stride+2*(j+1)], d12); + _mm_store_pd(&D[0+(i+14)*stride+2*(j+1)], d14); + } + } +#endif + +#if 1 + // Factor and unroll i +#define MM_LOAD1_PD(a,b) \ +{ \ + __asm__("movlpd %1, %0" : "=x" (a) : "m"(*b)); \ + __asm__("movhpd %1, %0" : "=x" (a) : "m"(*b), "0" (a)); \ +} +#define MM_LOAD1U_PD(a,b) \ +{ \ + __asm__("movlpd %1, %0" : "=x" (a) : "m"(*b)); \ + __asm__("movhpd %1, %0" : "=x" (a) : "m"(*b), "0" (a)); \ +} +#define MM_MUL_PD(out,addr) \ +{ out = _mm_mul_pd(out, *(__m128d*)addr); } +#define BLOCK0_0(i,j,k) \ + { \ + __m128d bt0; \ + MM_LOAD1_PD(bt0, &BT[0+j*stride+2*k]); \ + d00-=_mm_load_pd(&C[0+(i+ 0)*stride+2*k])*bt0; \ + d02-=_mm_load_pd(&C[0+(i+ 2)*stride+2*k])*bt0; \ + d04-=_mm_load_pd(&C[0+(i+ 4)*stride+2*k])*bt0; \ + d06-=_mm_load_pd(&C[0+(i+ 6)*stride+2*k])*bt0; \ + d08-=_mm_load_pd(&C[0+(i+ 8)*stride+2*k])*bt0; \ + d10-=_mm_load_pd(&C[0+(i+10)*stride+2*k])*bt0; \ + d12-=_mm_load_pd(&C[0+(i+12)*stride+2*k])*bt0; \ + MM_MUL_PD(bt0, &C[0+(i+14)*stride+2*k]); \ + d14-=bt0; \ + } +#define BLOCK0_1(i,j,k) \ + { \ + __m128d bt1; \ + MM_LOAD1U_PD(bt1, &BT[1+j*stride+2*k]); \ + d00-=_mm_load_pd(&C[0+(i+ 0)*stride+2*k])*bt1; \ + d02-=_mm_load_pd(&C[0+(i+ 2)*stride+2*k])*bt1; \ + d04-=_mm_load_pd(&C[0+(i+ 4)*stride+2*k])*bt1; \ + d06-=_mm_load_pd(&C[0+(i+ 6)*stride+2*k])*bt1; \ + d08-=_mm_load_pd(&C[0+(i+ 8)*stride+2*k])*bt1; \ + d10-=_mm_load_pd(&C[0+(i+10)*stride+2*k])*bt1; \ + d12-=_mm_load_pd(&C[0+(i+12)*stride+2*k])*bt1; \ + MM_MUL_PD(bt1, &C[0+(i+14)*stride+2*k]); \ + d14-=bt1; \ + } +#define BLOCK1_0(i,j) \ + { \ + __m128d d00 = _mm_load_pd(&D[0+(i+ 0)*stride+2*(j+0)]); \ + __m128d d02 = _mm_load_pd(&D[0+(i+ 2)*stride+2*(j+0)]); \ + __m128d d04 = _mm_load_pd(&D[0+(i+ 4)*stride+2*(j+0)]); \ + __m128d d06 = _mm_load_pd(&D[0+(i+ 6)*stride+2*(j+0)]); \ + __m128d d08 = _mm_load_pd(&D[0+(i+ 8)*stride+2*(j+0)]); \ + __m128d d10 = _mm_load_pd(&D[0+(i+10)*stride+2*(j+0)]); \ + __m128d d12 = _mm_load_pd(&D[0+(i+12)*stride+2*(j+0)]); \ + __m128d d14 = _mm_load_pd(&D[0+(i+14)*stride+2*(j+0)]); \ + for (int k = 0; k < baseOrder; k+=32) \ + { \ + BLOCK0_0(i,j,(k+ 0)); \ + BLOCK0_0(i,j,(k+ 1)); \ + BLOCK0_0(i,j,(k+ 2)); \ + BLOCK0_0(i,j,(k+ 3)); \ + BLOCK0_0(i,j,(k+ 4)); \ + BLOCK0_0(i,j,(k+ 5)); \ + BLOCK0_0(i,j,(k+ 6)); \ + BLOCK0_0(i,j,(k+ 7)); \ + BLOCK0_0(i,j,(k+ 8)); \ + BLOCK0_0(i,j,(k+ 9)); \ + BLOCK0_0(i,j,(k+10)); \ + BLOCK0_0(i,j,(k+11)); \ + BLOCK0_0(i,j,(k+12)); \ + BLOCK0_0(i,j,(k+13)); \ + BLOCK0_0(i,j,(k+14)); \ + BLOCK0_0(i,j,(k+15)); \ + BLOCK0_0(i,j,(k+16)); \ + BLOCK0_0(i,j,(k+17)); \ + BLOCK0_0(i,j,(k+18)); \ + BLOCK0_0(i,j,(k+19)); \ + BLOCK0_0(i,j,(k+20)); \ + BLOCK0_0(i,j,(k+21)); \ + BLOCK0_0(i,j,(k+22)); \ + BLOCK0_0(i,j,(k+23)); \ + BLOCK0_0(i,j,(k+24)); \ + BLOCK0_0(i,j,(k+25)); \ + BLOCK0_0(i,j,(k+26)); \ + BLOCK0_0(i,j,(k+27)); \ + BLOCK0_0(i,j,(k+28)); \ + BLOCK0_0(i,j,(k+29)); \ + BLOCK0_0(i,j,(k+30)); \ + BLOCK0_0(i,j,(k+31)); \ + } \ + _mm_store_pd(&D[0+(i+ 0)*stride+2*(j+0)], d00); \ + _mm_store_pd(&D[0+(i+ 2)*stride+2*(j+0)], d02); \ + _mm_store_pd(&D[0+(i+ 4)*stride+2*(j+0)], d04); \ + _mm_store_pd(&D[0+(i+ 6)*stride+2*(j+0)], d06); \ + _mm_store_pd(&D[0+(i+ 8)*stride+2*(j+0)], d08); \ + _mm_store_pd(&D[0+(i+10)*stride+2*(j+0)], d10); \ + _mm_store_pd(&D[0+(i+12)*stride+2*(j+0)], d12); \ + _mm_store_pd(&D[0+(i+14)*stride+2*(j+0)], d14); \ + } +#define BLOCK1_1(i,j) \ + { \ + __m128d d00 = _mm_load_pd(&D[0+(i+ 0)*stride+2*(j+1)]); \ + __m128d d02 = _mm_load_pd(&D[0+(i+ 2)*stride+2*(j+1)]); \ + __m128d d04 = _mm_load_pd(&D[0+(i+ 4)*stride+2*(j+1)]); \ + __m128d d06 = _mm_load_pd(&D[0+(i+ 6)*stride+2*(j+1)]); \ + __m128d d08 = _mm_load_pd(&D[0+(i+ 8)*stride+2*(j+1)]); \ + __m128d d10 = _mm_load_pd(&D[0+(i+10)*stride+2*(j+1)]); \ + __m128d d12 = _mm_load_pd(&D[0+(i+12)*stride+2*(j+1)]); \ + __m128d d14 = _mm_load_pd(&D[0+(i+14)*stride+2*(j+1)]); \ + for (int k = 0; k < baseOrder; k+=32) \ + { \ + BLOCK0_1(i,j,(k+ 0)); \ + BLOCK0_1(i,j,(k+ 1)); \ + BLOCK0_1(i,j,(k+ 2)); \ + BLOCK0_1(i,j,(k+ 3)); \ + BLOCK0_1(i,j,(k+ 4)); \ + BLOCK0_1(i,j,(k+ 5)); \ + BLOCK0_1(i,j,(k+ 6)); \ + BLOCK0_1(i,j,(k+ 7)); \ + BLOCK0_1(i,j,(k+ 8)); \ + BLOCK0_1(i,j,(k+ 9)); \ + BLOCK0_1(i,j,(k+10)); \ + BLOCK0_1(i,j,(k+11)); \ + BLOCK0_1(i,j,(k+12)); \ + BLOCK0_1(i,j,(k+13)); \ + BLOCK0_1(i,j,(k+14)); \ + BLOCK0_1(i,j,(k+15)); \ + BLOCK0_1(i,j,(k+16)); \ + BLOCK0_1(i,j,(k+17)); \ + BLOCK0_1(i,j,(k+18)); \ + BLOCK0_1(i,j,(k+19)); \ + BLOCK0_1(i,j,(k+20)); \ + BLOCK0_1(i,j,(k+21)); \ + BLOCK0_1(i,j,(k+22)); \ + BLOCK0_1(i,j,(k+23)); \ + BLOCK0_1(i,j,(k+24)); \ + BLOCK0_1(i,j,(k+25)); \ + BLOCK0_1(i,j,(k+26)); \ + BLOCK0_1(i,j,(k+27)); \ + BLOCK0_1(i,j,(k+28)); \ + BLOCK0_1(i,j,(k+29)); \ + BLOCK0_1(i,j,(k+30)); \ + BLOCK0_1(i,j,(k+31)); \ + } \ + _mm_store_pd(&D[0+(i+ 0)*stride+2*(j+1)], d00); \ + _mm_store_pd(&D[0+(i+ 2)*stride+2*(j+1)], d02); \ + _mm_store_pd(&D[0+(i+ 4)*stride+2*(j+1)], d04); \ + _mm_store_pd(&D[0+(i+ 6)*stride+2*(j+1)], d06); \ + _mm_store_pd(&D[0+(i+ 8)*stride+2*(j+1)], d08); \ + _mm_store_pd(&D[0+(i+10)*stride+2*(j+1)], d10); \ + _mm_store_pd(&D[0+(i+12)*stride+2*(j+1)], d12); \ + _mm_store_pd(&D[0+(i+14)*stride+2*(j+1)], d14); \ + } + + for (int j = 0; j < baseOrder; j+=2) + { + BLOCK1_0( 0,j); + BLOCK1_1( 0,j); + BLOCK1_0(16,j); + BLOCK1_1(16,j); + } +#endif + +} + +// Avoid name space pollution + +#undef MM_LOAD1_PD +#undef MM_LOAD1U_PD +#undef MM_MUL_PD +#undef BLOCK0_0 +#undef BLOCK0_1 +#undef BLOCK1_0 +#undef BLOCK1_1 + + +} // namespace mtl + +#endif // MTL_USE_OPTERON_OPTIMIZATION + +#endif // MTL_OPTERON_MATRIX_MULT_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/orth.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/orth.hpp new file mode 100644 index 0000000000000000000000000000000000000000..8969b624c82fa0621fd3deda833ab05fb339100d --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/orth.hpp @@ -0,0 +1,172 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_ORTH_INCLUDE +#define MTL_ORTH_INCLUDE + +#include <boost/numeric/linear_algebra/identity.hpp> +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/matrix/parameter.hpp> +#include <boost/numeric/mtl/operation/size.hpp> +#include <boost/numeric/mtl/operation/size1D.hpp> +#include <boost/numeric/mtl/operation/entry1D.hpp> +#include <boost/numeric/mtl/operation/dot.hpp> +#include <boost/numeric/mtl/operation/two_norm.hpp> +#include <boost/numeric/mtl/operation/is_negative.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace mtl { namespace vector { + + namespace impl { + + template <typename VVector> + inline void orth(VVector& v, typename mtl::Collection<VVector>::size_type j, tag::vector) + { + vampir_trace<2018> tracer; + using mtl::two_norm; using mtl::size1D; + MTL_DEBUG_THROW_IF(is_negative(j) || j >= size1D(v), index_out_of_range()); + + typedef typename mtl::Collection<VVector>::size_type Size; + for (Size i= 0; i < j; ++i) + entry1D(v, j)-= dot(entry1D(v, i), entry1D(v, j)) * entry1D(v, i); + entry1D(v, j)/= two_norm(entry1D(v, j)); + } + + template <typename VVector> + inline void orth(VVector& v, tag::vector) + { + typedef typename mtl::Collection<VVector>::size_type Size; + using mtl::size1D; + for (Size j= 0; j < size1D(v); ++j) + orth(v, j, tag::vector()); + } + + + template <typename VVector> + mtl::matrix::dense2D<typename mtl::Collection + <typename mtl::Collection<VVector>::value_type + >::value_type, matrix::parameters<> > + inline orthogonalize_factors(VVector& v, tag::vector) + { + vampir_trace<2019> tracer; + using ::mtl::two_norm; using math::zero; using mtl::size1D; + typedef typename mtl::Collection<VVector>::size_type Size; + typedef typename mtl::Collection<VVector>::value_type Vector; + typedef typename mtl::Collection<Vector>::value_type Scalar; + + mtl::matrix::dense2D<Scalar, matrix::parameters<> > tau(size1D(v), size1D(v)); + tau= zero(Scalar()); + + if (size1D(v) == 0) + return tau; + + tau[0][0]= dot(entry1D(v, 0), entry1D(v, 0)); + + for (Size j= 1; j < size1D(v); ++j) { +#ifdef MTL_WITH_FUSED_ORTHOGONALIZATION + Scalar t= dot(entry1D(v, 0), entry1D(v, j)) / tau[0][0], t2; + tau[0][j]= t; + for (Size i= 1; i < j; ++i) { + (lazy(entry1D(v, j))-= t * entry1D(v, i-1)) || (lazy(t2)= lazy_dot(entry1D(v, i), entry1D(v, j))); + t= tau[i][j]= t2 / tau[i][i]; + } + entry1D(v, j)-= t * entry1D(v, j-1); +#else + for (Size i= 0; i < j; ++i) { + Scalar t= dot(entry1D(v, i), entry1D(v, j)) / tau[i][i]; + tau[i][j]= t; + entry1D(v, j)-= t * entry1D(v, i); + } +#endif + tau[j][j]= dot(entry1D(v, j), entry1D(v, j)); + } + return tau; + } + + } // impl + + + +/*! Orthonormalize a vector of vectors. + + The outer type must be a random access collection and + the vector type must provide a dot function. + For instance dense_vector<dense_vector<double> > or + std::vector<dense_vector<std::complex<double> > > are eligible. + It is planned to implement the function for matrices as well + where the columns will be ortho-normalized. +**/ +template <typename Value> +inline void orth(Value& value) +{ + impl::orth(value, typename traits::category<Value>::type()); +} + +/*! Orthonormalize the i-th entry of a vector of vectors. + + The i-th vector is orthogonalized w.r.t. to the preceeding ones and + consecutively normalized. + The outer type must be a random access collection and + the vector type must provide a dot function. + For instance dense_vector<dense_vector<double> > or + std::vector<dense_vector<std::complex<double> > > are eligible. + It is planned to implement the function for matrices as well + where the columns will be ortho-normalized. +**/ +template <typename Value> +inline void orth(Value& value, typename mtl::Collection<Value>::size_type i) +{ + impl::orth(value, i, typename traits::category<Value>::type()); +} + + +/*! Orthogonalize a vector of vectors. + + Opposed to orth the vectors are not normalized. + An upper matrix with the factors used in the orthogonalization is returned. + The diagonal contains dot(v[i], v[i]). + The returned factors are for instance used in bicgstab_ell. + The outer type must be a random access collection and + the vector type must provide a dot function. + For instance dense_vector<dense_vector<double> > or + std::vector<dense_vector<std::complex<double> > > are eligible. +**/ +template <typename Value> +mtl::matrix::dense2D<typename mtl::Collection + <typename mtl::Collection<Value>::value_type + >::value_type, matrix::parameters<> > +inline orthogonalize_factors(Value& v) +{ + return impl::orthogonalize_factors(v, typename traits::category<Value>::type()); +} + +} // namespace vector + +namespace matrix { + + // If other matrix types will be supported within a template function, it needs reimplementation!!! + template <typename Vector> + inline void orth(multi_vector<Vector>& A) + { + mtl::vector::impl::orth(A, mtl::tag::vector()); + } +} + +using vector::orth; +using vector::orthogonalize_factors; + +} // namespace mtl + +#endif // MTL_ORTH_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/print.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/print.hpp new file mode 100644 index 0000000000000000000000000000000000000000..2f17c2d40d4399114bf72ef0b420b89162b5f5ca --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/print.hpp @@ -0,0 +1,100 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_PRINT_INCLUDE +#define MTL_PRINT_INCLUDE + +#include <iostream> +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/operation/print_size.hpp> +#include <boost/numeric/mtl/operation/print_matrix.hpp> +#include <boost/numeric/mtl/operation/print_vector.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> + + +namespace mtl { + +namespace detail { + + template <typename Collection> + struct with_format_t + { + explicit with_format_t(const Collection& collection, int width, int precision) + : collection(collection), width(width), precision(precision) + {} + + const Collection& collection; + int width, precision; + }; + + template <typename Collection> + inline std::ostream& operator<< (std::ostream& out, with_format_t<Collection> const& value) + { + return print(value.collection, out, value.width, value.precision); + } + + +} // namespace detail + +namespace matrix { + + template <typename Matrix> + inline std::ostream& operator<< (std::ostream& out, const mat_expr<Matrix>& expr) + { + const Matrix& A= static_cast<const Matrix&>(expr); + return print_matrix(A, out, print_size(A), 0); + } + + template <typename Value> + inline std::ostream& + print(Value const& value, std::ostream& out= std::cout, int width= 3, int precision= 2) + { + return print_matrix(value, out, width, precision); + } + + template <typename Collection> + inline mtl::detail::with_format_t<Collection> with_format(const Collection& collection, int width= 3, int precision= 2) + { + return mtl::detail::with_format_t<Collection>(collection, width, precision); + } +} // namespace matrix + +namespace vector { + + + template <typename Vector> + inline std::ostream& operator<< (std::ostream& out, const vector::vec_expr<Vector>& expr) + { + return print_vector(static_cast<const Vector&>(expr), out, 0, 0); + } + + + template <typename Value> + inline std::ostream& + print(Value const& value, std::ostream& out= std::cout, int width= 3, int precision= 2) + { + return print_vector(value, out, width, precision); + } + + template <typename Collection> + inline mtl::detail::with_format_t<Collection> with_format(const Collection& collection, int width= 3, int precision= 2) + { + return mtl::detail::with_format_t<Collection>(collection, width, precision); + } + +} // namespace vector + + +} // mtl + + +#endif // MTL_PRINT_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/print_matrix.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/print_matrix.hpp new file mode 100644 index 0000000000000000000000000000000000000000..19e455ce1086c2723d5f1fd02dca97765f7179ec --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/print_matrix.hpp @@ -0,0 +1,52 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_PRINT_MATRIX_INCLUDE +#define MTL_PRINT_MATRIX_INCLUDE + +#include <cstddef> +#include <iostream> +#include <sstream> +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/utility/range_generator.hpp> + +namespace mtl { namespace matrix { + +template <typename Matrix> +std::ostream& print_matrix(Matrix const& matrix, std::ostream& out= std::cout, int width= 3, int precision= 2) +{ + // typedef typename Collection<Matrix>::size_type size_type; + // all indices will start from 0; otherwise wrong + for (std::size_t r= 0, nr= num_rows(matrix); r < nr; ++r) { + out << '['; + for (std::size_t c= 0, nc= num_cols(matrix); c < nc; ++c) { + if (precision) + out.precision(precision); + out.fill (' '); out.width (width); +#ifdef MTL_PRINT_STRING_TMP // probably very slow but looks better for certain types + std::ostringstream st; + st << matrix(r, c) << (c + 1 < nc ? " " : "]\n"); + out << std::right << st.str(); +#else + out << matrix(r, c) << (c + 1 < nc ? " " : "]\n"); +#endif + } + } + return out; +} + +}} // namespace mtl::matrix + +#endif // MTL_PRINT_MATRIX_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/print_size.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/print_size.hpp new file mode 100644 index 0000000000000000000000000000000000000000..4a224000e6f017575dd4b6f27c7bdfee8df7b2f8 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/print_size.hpp @@ -0,0 +1,55 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_PRINT_SIZE_INCLUDE +#define MTL_PRINT_SIZE_INCLUDE + +#include <sstream> + +#include <boost/numeric/mtl/operation/look_at_each_nonzero.hpp> + +namespace mtl { + + struct print_size_max + { + print_size_max() : max(0) {} + + template <typename T> + void operator()(const T& x) + { + std::ostringstream st; + st << x; + int s= st.str().size(); + // std::cout << "Size is " << s << ": " << st.str() << '\n'; + if (s > max) max= s; + } + + int max; + }; + + namespace matrix { + + template <typename Matrix> + int inline print_size(const Matrix& A) + { + print_size_max p; + // look_at_each_nonzero(A, p); // Doesn't work on all expressions yet + for (size_t r = 0, nr = num_rows(A); r < nr; ++r) + for (size_t c = 0, nc= num_cols(A); c < nc; ++c) + p(A(r, c)); + return p.max; + } + } + +} // namespace mtl + +#endif // MTL_PRINT_SIZE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/print_vector.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/print_vector.hpp new file mode 100644 index 0000000000000000000000000000000000000000..98ca53aa867809db3b79b188028ac21837e58d7b --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/print_vector.hpp @@ -0,0 +1,42 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_PRINT_VECTOR_INCLUDE +#define MTL_PRINT_VECTOR_INCLUDE + +#include <iostream> +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/utility/is_row_major.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> + +namespace mtl { namespace vector { + +template <typename Vector> +std::ostream& print_vector(Vector const& vector, std::ostream& out= std::cout, int width= 0, int precision= 0) +{ + using mtl::vector::size; + out << '{' << mtl::vector::size(vector) + << (traits::is_row_major< typename OrientedCollection<Vector>::orientation >::value ? "R" : "C") + << "}[" ; + for (size_t r = 0; r < mtl::vector::size(vector); ++r) { + out.fill (' '); + if (width) out.width (width); + // out.flags (std::ios_base::right); + if (precision) out.precision(precision); + out << vector[r] << (r+1 < mtl::vector::size(vector) ? "," : ""); + } + return out << ']'; +} + +}} // namespace mtl::vector + +#endif // MTL_PRINT_VECTOR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/product.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/product.hpp new file mode 100644 index 0000000000000000000000000000000000000000..168a6aba6954957ea428d592a893ff0b4a8f0774 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/product.hpp @@ -0,0 +1,71 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_PRODUCT_INCLUDE +#define MTL_PRODUCT_INCLUDE + +#include <iostream> +#include <cmath> + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/vector/lazy_reduction.hpp> +#include <boost/numeric/mtl/vector/reduction.hpp> +#include <boost/numeric/mtl/vector/reduction_functors.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace mtl { + + namespace vector { + + namespace impl { + + // Do we really need this for matrices? + + template <unsigned long Unroll, typename Vector> + typename Collection<Vector>::value_type + inline product(const Vector& vector, tag::vector) + { + typedef typename Collection<Vector>::value_type result_type; + return vector::reduction<Unroll, vector::product_functor, result_type>::apply(vector); + } + + } // namespace impl + + ///Returns product of all collection-entries (%vector-entries) + template <unsigned long Unroll, typename Value> + typename Collection<Value>::value_type + inline product(const Value& value) + { vampir_trace<2020> tracer; + return impl::product<Unroll>(value, typename traits::category<Value>::type()); + } + + template <typename Value> + typename Collection<Value>::value_type + inline product(const Value& value) + { + return product<8>(value); + } + + template <typename Vector> + lazy_reduction<Vector, product_functor> inline lazy_product(const Vector& v) + { return lazy_reduction<Vector, product_functor>(v); } + + } // namespace vector + + using vector::lazy_product; + using vector::product; + +} // namespace mtl + +#endif // MTL_PRODUCT_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/qr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/qr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..f75de404e24ab3a01009507ccb9928c3d0d47435 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/qr.hpp @@ -0,0 +1,110 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// With contributions from Cornelius Steinhardt +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + + +#ifndef MTL_MATRIX_QR_INCLUDE +#define MTL_MATRIX_QR_INCLUDE + +#include <cmath> +#include <boost/numeric/linear_algebra/identity.hpp> +#include <boost/numeric/linear_algebra/inverse.hpp> +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/vector/parameter.hpp> +#include <boost/numeric/mtl/matrix/parameter.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/irange.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/concept/magnitude.hpp> +#include <boost/numeric/mtl/operation/householder.hpp> +#include <boost/numeric/mtl/operation/rank_one_update.hpp> +#include <boost/numeric/mtl/operation/trans.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace mtl { namespace matrix { + + +/// QR-Factorization of matrix A(m x n) +/** Return pair R upper triangel matrix and Q= orthogonal matrix. R and Q are always dense2D **/ +template <typename Matrix, typename MatrixQ, typename MatrixR> +void qr(const Matrix& A, MatrixQ& Q, MatrixR& R) +{ + vampir_trace<4013> tracer; + typedef typename Collection<Matrix>::value_type value_type; + typedef typename Collection<Matrix>::size_type size_type; + typedef typename Magnitude<value_type>::type magnitude_type; + typedef mtl::vector::dense_vector<value_type, vector::parameters<> > vector_type; + + size_type ncols = num_cols(A), nrows = num_rows(A), + mini= ncols == nrows ? ncols - 1 : (nrows >= ncols ? ncols : nrows); + magnitude_type factor= magnitude_type(2); + + Q= 1; + for (size_type i = 0; i < mini; i++) { + irange r(i, imax); // Intervals [i, n-1] + vector_type w(R[r][i]), v(householder_s(w)); + + // R-= 2*v*(v'*R) + MatrixR Rsub(R[r][r]); + vector_type tmp(-factor * trans(Rsub) * v); + rank_one_update(Rsub, v, tmp); + + //update Q: Q-= 2*(v*Q)*v' + MatrixQ Qsub(Q[iall][r]); + vector_type qtmp(-factor * Qsub * v); + rank_one_update(Qsub, qtmp, v); + } //end for +} + +/// QR-Factorization of matrix A(m x n) +template <typename Matrix> +std::pair<mtl::matrix::dense2D<typename Collection<Matrix>::value_type, matrix::parameters<> >, + mtl::matrix::dense2D<typename Collection<Matrix>::value_type, matrix::parameters<> > > +inline qr(const Matrix& A) +{ + mtl::matrix::dense2D<typename Collection<Matrix>::value_type, matrix::parameters<> > R(A), Q(num_rows(A),num_rows(A)); + qr(A, Q, R); + return std::make_pair(Q,R); +} + + + +// QR-Factorization of matrix A +// Return Q and R with A = Q*R R upper triangle and Q othogonal +template <typename Matrix> +std::pair<typename mtl::matrix::dense2D<typename Collection<Matrix>::value_type, matrix::parameters<> >, + typename mtl::matrix::dense2D<typename Collection<Matrix>::value_type, matrix::parameters<> > > +inline qr_factors(const Matrix& A) +{ + vampir_trace<4014> tracer; + using std::abs; + typedef typename Collection<Matrix>::value_type value_type; + // typedef typename Magnitude<value_type>::type magnitude_type; // to multiply with 2 not 2+0i + typedef typename Collection<Matrix>::size_type size_type; + size_type ncols = num_cols(A), nrows = num_rows(A); + value_type zero= math::zero(A[0][0]), one= math::one(A[0][0]); + + //evaluation of Q + Matrix Q(nrows, nrows), Qk(nrows, nrows), HEL(nrows, ncols), R(nrows, ncols), R_tmp(nrows, ncols); + Q= one; R= zero; HEL= zero; + + boost::tie(Q, R_tmp)= qr(A); + R= upper(R_tmp); + + return std::make_pair(Q,R); +} + +}} // namespace mtl::matrix + + +#endif // MTL_MATRIX_QR_INCLUDE + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/qr_givens.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/qr_givens.hpp new file mode 100644 index 0000000000000000000000000000000000000000..0e242a1e2a9226d490f92afe7a31ded086e22d36 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/qr_givens.hpp @@ -0,0 +1,159 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +// Author: Marc Hartung + +#ifndef MTL_MATRIX_QR_GIVENS_INCLUDE +#define MTL_MATRIX_QR_GIVENS_INCLUDE + +#include <cmath> +#include <utility> + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/irange.hpp> +#include <boost/numeric/mtl/operation/conj.hpp> +#include <boost/numeric/linear_algebra/identity.hpp> + + +namespace mtl { namespace matrix { + + +/// General Given's transformator +/** + * Input-matrix A will be splitted in A = Q*R. Q and R are accessible from getQ() and getR(). + * \sa givens + */ +template <typename Matrix> +class qr_givens_solver { + + typedef typename Collection<Matrix>::value_type value_type; + typedef typename Collection<Matrix>::size_type size_type; + +public: + + /** \brief Constructor needs a sqare-matrix as input + * \param MTL-Matrix type + * + */ + + qr_givens_solver(const Matrix& IN) : R(IN), G(2,2), Q(num_cols(IN), num_rows(IN)) { + value_type one = math::one(c); + Q = one; + eps = 1.0e-8; + } + + /** \brief Returns Q as the input-matrix-type + * + * \return Matrix Q + */ + + Matrix& getQ() { + return Q; + } + + /** \brief Returns R as the input-matrix-type + * + * \return Matrix R + */ + Matrix& getR() { + return R; + } + + /** \brief Sets the distance to zero + * + * \param value_type tolerance to zero + */ + void setTolerance(value_type tol) { + eps = tol; + } + + /** \brief Starts QR decompostion + */ + void calc() + { + value_type zero= math::zero(c); + Matrix RIter(2, num_rows(R)), Iter(2, num_rows(R)); + for(size_type i= 0; i < R.num_cols() - 1; i++) { + irange r(i, num_cols(R)); + for(size_type j= num_rows(R)-1;j>i;j--) { + if (std::abs(R[j][i]) > eps) { + set_rotation(R[i][i], R[j][i]); + Iter[0][r] = R[i][r]; + Iter[1][r] = R[j][r]; + RIter[iall][r] = G*Iter[iall][r]; + R[i][r] = RIter[0][r]; + R[j][r] = RIter[1][r]; + Iter[0][iall] = Q[i][iall]; + Iter[1][iall] = Q[j][iall]; + RIter = G*Iter; + Q[i][iall] = RIter[0][iall]; + Q[j][iall] = RIter[1][iall]; + } + R[j][i] = zero; + } + + } + + for(size_type i= 0; i < num_cols(R) - 1; i++) + R[i+1][i] = zero; + + } + + private: + + Matrix R, G, Q; + value_type c, s, eps; + + template <typename T> + inline T square(T x) const { return x * x; } + + /// Coefficients for Given's rotation + void set_rotation(value_type a, value_type b) + { + using std::abs; + using mtl::conj; + + value_type zero= math::zero(a), one= math::one(b), t; + + if ( b == zero ) { + c= one; s= zero; + } else if ( abs(b) > abs(a) ) { + t = a / abs(b); + s = one/ sqrt(one + square(abs(t))); + c = s * t; + s *= (b/abs(b)); + } else { + t = b / abs(a); + c = one / sqrt(one + square(abs(t))); + s = c * t; + c = (a/abs(a))*c; + } + + G= conj(c), conj(s), + -s, c; + } + +}; + +/// QR-Factorization of matrix A(m x n) based on Givens' rotation +template <typename Matrix> +std::pair<Matrix, Matrix> +inline qr_givens(const Matrix& A) +{ + qr_givens_solver<Matrix> solver(A); + solver.calc(); + return std::make_pair(solver.getQ(), solver.getR()); +} + +}} // namespace mtl::matrix + +#endif // MTL_MATRIX_QR_GIVENS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/random.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/random.hpp new file mode 100644 index 0000000000000000000000000000000000000000..ac64f3a492d087cad7be7fbca787a50f2f21c284 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/random.hpp @@ -0,0 +1,117 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_RANDOM_INCLUDE +#define MTL_RANDOM_INCLUDE + +// Provisional implementation, do not use in production code!!! +// Will be reimplemented with boost::random + +#include <cstdlib> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/matrix/inserter.hpp> +#include <boost/numeric/mtl/utility/enable_if.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { + +template <typename T> +struct seed +{ + seed() { srand(17 * ++counter); } + T operator()() const { return rand(); } + + static int counter; +}; + +template <typename T> +int seed<T>::counter= 0; + +namespace impl { + + // all non-distributed matrices except multi-vectors + template <typename Coll, typename Generator> + void inline random(Coll& A, Generator& generator, tag::universe, tag::matrix) + { + typedef typename Collection<Coll>::size_type size_type; + matrix::inserter<Coll> ins(A, A.dim2()); + for (size_type r= 0; r < num_rows(A); r++) + for (size_type c= 0; c < num_cols(A); c++) + ins[r][c] << generator(); + } + + template <typename Coll, typename Generator> + void inline random(Coll& A, Generator&, tag::universe, tag::multi_vector) + { + for (typename Collection<Coll>::size_type i= 0; i < num_cols(A); ++i) + random(A.vector(i)); + } + +} // namespace impl + + +namespace vector { + + /// Fill vector with random values; generator must be a nullary function. + template <typename Vector, typename Generator> + typename mtl::traits::enable_if_vector<Vector>::type + inline random(Vector& v, Generator& generator) + { + vampir_trace<2021> tracer; + typedef typename Collection<Vector>::size_type size_type; + for (size_type i= 0; i < size(v); i++) + v[i]= generator(); + } + + /// Fill vector with random values. + /** Currently done with rand(). Will be improved one day. You can provide + your own generator as second argument. **/ + template <typename Vector> + typename mtl::traits::enable_if_vector<Vector>::type + inline random(Vector& v) + { + seed<typename Collection<Vector>::value_type> s; + random(v, s); + } + + +} // namespace vector + +namespace matrix { + + /// Fill matrix with random values; generator must be a nullary function. + template <typename Matrix, typename Generator> + typename mtl::traits::enable_if_matrix<Matrix>::type + inline random(Matrix& A, Generator& generator) + { + vampir_trace<4015> tracer; + typename mtl::traits::category<Matrix>::type cat; + mtl::impl::random(A, generator, cat, cat); + } + + /// Fill matrix with random values. + /** Currently done with rand(). Will be improved one day. You can provide + your own generator as second argument. **/ + template <typename Matrix> + typename mtl::traits::enable_if_matrix<Matrix>::type + inline random(Matrix& A) + { + seed<typename Collection<Matrix>::value_type> s; + random(A, s); + } + +} // namespace matrix + +} // namespace mtl + +#endif // MTL_RANDOM_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/rank_one_update.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/rank_one_update.hpp new file mode 100644 index 0000000000000000000000000000000000000000..99c84b9f2aa962cd758c3b3b965c41ab4076b501 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/rank_one_update.hpp @@ -0,0 +1,56 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_RANK_ONE_UPDATE_INCLUDE +#define MTL_RANK_ONE_UPDATE_INCLUDE + +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/property_map.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/matrix/inserter.hpp> +#include <boost/numeric/mtl/operation/update.hpp> +#include <boost/numeric/mtl/operation/conj.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace mtl { namespace matrix { + + +/// Rank-one update: rank_one_update(A, x, y) computes A+= x * conj(y)^T +/** The current implementation works for column and row vectors (although + the notation above refers to column vectors). **/ +template <typename Matrix, typename VectorX, typename VectorY> +inline void rank_one_update(Matrix& matrix, const VectorX& x, const VectorY& y) +{ + using mtl::conj; + vampir_trace<2022> tracer; + MTL_THROW_IF(num_rows(matrix) != size(x) || num_cols(matrix) != size(y), incompatible_size()); + namespace traits = mtl::traits; + typedef typename traits::range_generator<tag::nz, VectorX>::type x_cursor; + typename traits::index<VectorX>::type index_x(x); + typename traits::const_value<VectorX>::type value_x(x); + + typedef typename traits::range_generator<tag::nz, VectorY>::type y_cursor; + typename traits::index<VectorY>::type index_y(y); + typename traits::const_value<VectorY>::type value_y(y); + + matrix::inserter<Matrix, operations::update_plus<typename Collection<Matrix>::value_type> > ins(matrix); + + for (x_cursor xc= begin<tag::nz>(x), xend= end<tag::nz>(x); xc != xend; ++xc) + for (y_cursor yc= begin<tag::nz>(y), yend= end<tag::nz>(y); yc != yend; ++yc) + ins(index_x(*xc), index_y(*yc)) << value_x(*xc) * conj(value_y(*yc)); +} + + +}} // namespace mtl::matrix + +#endif // MTL_RANK_ONE_UPDATE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/rank_two_update.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/rank_two_update.hpp new file mode 100644 index 0000000000000000000000000000000000000000..c8d87dc7b04dc5594fb382eaa0264a22963ca194 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/rank_two_update.hpp @@ -0,0 +1,32 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_RANK_TWO_UPDATE_INCLUDE +#define MTL_RANK_TWO_UPDATE_INCLUDE + +#include <boost/numeric/mtl/operation/rank_one_update.hpp> + +namespace mtl { namespace matrix { + +/// Rank-two update: rank_two_update(A, x, y) computes A+= x * conj(y)^T + y * conj(x)^T +/** The current implementation works for column and row vectors (although + the notation above refers to column vectors). **/ +template <typename Matrix, typename VectorX, typename VectorY> +inline void rank_two_update(Matrix& matrix, const VectorX& x, const VectorY& y) +{ + rank_one_update(matrix, x, y); + rank_one_update(matrix, y, x); +} + +}} // namespace mtl::matrix + +#endif // MTL_RANK_TWO_UPDATE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/raw_copy.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/raw_copy.hpp new file mode 100644 index 0000000000000000000000000000000000000000..84fc8070c23ecb466f1796d7db4c748053ecd5be --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/raw_copy.hpp @@ -0,0 +1,35 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_RAW_COPY_INCLUDE +#define MTL_RAW_COPY_INCLUDE +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace mtl { + +// Copies range of values into elements +// As name says it is a raw operation and to used with uttermost care +template <typename Matrix, typename InputIterator> +void raw_copy(InputIterator first, InputIterator last, Matrix& matrix) +{ + using std::copy; + vampir_trace<2> tracer; + copy(first, last, matrix.elements()); +} + +// Temporary solution +// will be replaced by sequences and cursors generated by begin<all>(ma) and end<all>(ma) +// Using segmented cursors, matrices with non-contigous element storing can be handled + +} // namespace mtl + +#endif // MTL_RAW_COPY_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/real.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/real.hpp new file mode 100644 index 0000000000000000000000000000000000000000..1d277bac8e39646a86da652d5381d661a8ede728 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/real.hpp @@ -0,0 +1,93 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_REAL_INCLUDE +#define MTL_REAL_INCLUDE + +#include <complex> +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/utility/enable_if.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> +#include <boost/numeric/mtl/vector/map_view.hpp> + +namespace mtl { + +namespace sfunctor { + + template <typename Value> + struct real + { + typedef Value result_type; + + static inline Value apply(const Value& v) + { + return v; + } + + Value operator()(const Value& v) const + { + return v; + } + }; + + template <typename Value> + struct real<std::complex<Value> > + { + typedef Value result_type; + + static inline result_type apply(const std::complex<Value>& v) + { + return std::real(v); + } + result_type operator()(const std::complex<Value>& v) const + { + return std::real(v); + } + }; +} + +/// real part of scalars (including non-complex) +template <typename Value> +typename mtl::traits::enable_if_scalar<Value, typename sfunctor::real<Value>::result_type>::type +inline real(const Value& v) +{ + vampir_trace<3> tracer; + return sfunctor::real<Value>::apply(v); +} + +namespace vector { + + /// Real part of a vector + template <typename Vector> + typename mtl::traits::enable_if_vector<Vector, real_view<Vector> >::type + inline real(const Vector& v) + { + return real_view<Vector>(v); + } +} + +namespace matrix { + + /// Real part of a matrix + template <typename Matrix> + typename mtl::traits::enable_if_matrix<Matrix, real_view<Matrix> >::type + inline real(const Matrix& v) + { + return real_view<Matrix>(v); + } +} + +} // namespace mtl + +#endif // MTL_REAL_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/resource.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/resource.hpp new file mode 100644 index 0000000000000000000000000000000000000000..a005a13f9ba977586b0bbb9b0aada58b432c9ae1 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/resource.hpp @@ -0,0 +1,54 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_RESOURCE_INCLUDE +#define MTL_RESOURCE_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { + + namespace traits { + + template <typename Vector> + struct vector_resource + { + typedef typename Collection<Vector>::size_type type; + type inline static apply(const Vector& v) { using mtl::vector::size; return size(v); } + }; + } + + namespace vector { + + /// Describes the resources need for a certain vector. + /** All necessary information to construct appropriate/consistent temporary vectors. + Normally, this is just the size of the vector. + For distributed vector we also need its distribution. **/ + template <typename Vector> + typename mtl::traits::vector_resource<Vector>::type + inline resource(const Vector& v) + { + vampir_trace<4> tracer; + return mtl::traits::vector_resource<Vector>::apply(v); + } + + } // namespace vector + + namespace matrix { + // maybe a pair of size_type? like position + } + +} // namespace mtl + +#endif // MTL_RESOURCE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/right_scale_inplace.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/right_scale_inplace.hpp new file mode 100644 index 0000000000000000000000000000000000000000..8ac652abe89366af2589ee71c6e5fd8432d11695 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/right_scale_inplace.hpp @@ -0,0 +1,80 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_RIGHT_SCALE_INPLACE_INCLUDE +#define MTL_RIGHT_SCALE_INPLACE_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/operation/assign_each_nonzero.hpp> +#include <boost/numeric/mtl/operation/mult.hpp> +#include <boost/numeric/mtl/operation/rscale.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { + + +/// Scale collection \p c from right with scalar factor \p alpha; \p c is altered +template <typename Factor, typename Coll> +void right_scale_inplace(Coll& c, const Factor& alpha, tag::scalar) +{ + vampir_trace<5> tracer; + assign_each_nonzero(c, tfunctor::rscale<typename Collection<Coll>::value_type, Factor>(alpha)); +} + +template <typename Factor, typename Matrix> +void right_scale_inplace(Matrix& m, tag::matrix, const Factor& alpha, tag::matrix) +{ + using mtl::swap; + + vampir_trace<4016> tracer; + Matrix tmp(num_rows(m), num_cols(m)); + mult(m, alpha, tmp); + swap(m, tmp); +} + +#if 0 // Row vector times Matrix is not yet implemented +template <typename Factor, typename Vector> +void right_scale_inplace(Vector& v, tag::vector, const Factor& alpha, tag::matrix) +{ + using mtl::swap; + + Vector tmp(size(v)); + gen_mult(v, alpha, tmp, assign::assign_sum(), tag::row_vector(), tag::matrix(), tag::row_vector()); + swap(v, tmp); +} +#endif + +/// Scale collection \p c from right with matrix factor \p alpha; \p c is altered +template <typename Factor, typename Collection> +void right_scale_inplace(Collection& c, const Factor& alpha, tag::matrix) +{ + // Need to dispatch further to use different constructors for temporary + right_scale_inplace(c, typename traits::category<Collection>::type(), alpha, tag::matrix()); +} + +/// Scale collection \p c from right with factor \p alpha; \p c is altered +template <typename Factor, typename Collection> +void right_scale_inplace(Collection& c, const Factor& alpha) +{ + // Dispatch between scalar and matrix factors + right_scale_inplace(c, alpha, typename traits::category<Factor>::type()); +} + + + + +} // namespace mtl + +#endif // MTL_RIGHT_SCALE_INPLACE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/row_in_matrix.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/row_in_matrix.hpp new file mode 100644 index 0000000000000000000000000000000000000000..7f639d6465401633ffa8e3356c3ad75449c27987 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/row_in_matrix.hpp @@ -0,0 +1,105 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_ROW_IN_MATRIX_INCLUDE +#define MTL_ROW_IN_MATRIX_INCLUDE + +#include <boost/mpl/if.hpp> +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/vector/parameter.hpp> +#include <boost/numeric/mtl/utility/irange.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { + +/// Type of row in matrix as vector if accessible +template <typename Matrix> +struct RowInMatrix +{ + static const bool exists= false; +}; + +template <typename Value, typename Parameters> +struct RowInMatrix<mtl::matrix::dense2D<Value, Parameters> > +{ + typedef mtl::matrix::dense2D<Value, Parameters> ref_type; + typedef typename ref_type::size_type size_type; + typedef typename ref_type::value_type value_type; + typedef mtl::vector::parameters<row_major> vec_para; + + static const bool aligned= boost::is_same<typename Parameters::orientation, row_major>::value; + static const bool exists= true; + + typedef typename boost::mpl::if_c< + aligned + , mtl::vector::dense_vector<Value, vec_para> + , mtl::vector::strided_vector_ref<Value, vec_para> + >::type type; + + static inline type apply(ref_type& A, size_type row, const irange& col_range) + { + return dispatch<type, ref_type>(A, row, col_range, boost::mpl::bool_<aligned>()); + } + + template <typename Ref> + static inline size_type vector_size(const Ref& A, const irange& col_range) + { + using std::min; + + vampir_trace<1003> tracer; + size_type finish= min(col_range.finish(), num_cols(A)); + return col_range.start() < finish ? finish - col_range.start() : 0; + } + + template <typename Return, typename Ref> + static inline Return dispatch(Ref& A, size_type row, const irange& col_range, boost::mpl::true_) + { + vampir_trace<2023> tracer; + return Return(vector_size(A, col_range), const_cast<value_type*>(&A[row][col_range.start()])); // TODO make work without const cast + } + + template <typename Return, typename Ref> + static inline Return dispatch(Ref& A, size_type row, const irange& col_range, boost::mpl::false_) + { + vampir_trace<1004> tracer; + return Return(vector_size(A, col_range), &A[row][col_range.start()], num_rows(A)); + } +}; + +template <typename Value, typename Parameters> +struct RowInMatrix<const mtl::matrix::dense2D<Value, Parameters> > +{ + typedef mtl::matrix::dense2D<Value, Parameters> const ref_type; + typedef mtl::matrix::dense2D<Value, Parameters> ref2_type; + typedef typename ref2_type::size_type size_type; + typedef vector::parameters<row_major> vec_para; + + static const bool aligned= boost::is_same<typename Parameters::orientation, row_major>::value; + static const bool exists= true; + + typedef typename boost::mpl::if_c< + aligned + , vector::dense_vector<Value, vec_para> // TODO needs constification !!! + , vector::strided_vector_ref<const Value, vec_para> + >::type type; + + static inline type apply(ref_type& A, size_type row, const irange& col_range) + { + return RowInMatrix<ref2_type>::template dispatch<type, ref_type>(A, row, col_range, boost::mpl::bool_<aligned>()); + } +}; + + +} // namespace mtl + +#endif // MTL_ROW_IN_MATRIX_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/rscale.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/rscale.hpp new file mode 100644 index 0000000000000000000000000000000000000000..a679086bc3cf2c987359ee900e9a6bab4bd6a498 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/rscale.hpp @@ -0,0 +1,112 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. +/* + * rscale.hpp + * MTL4 + * + * Created by Hui Li (huil@Princeton.EDU) + * + */ + +#ifndef MTL_RSCALE_INCLUDE +#define MTL_RSCALE_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/concept/std_concept.hpp> +#include <boost/numeric/mtl/matrix/map_view.hpp> +#include <boost/numeric/mtl/vector/map_view.hpp> +#include <boost/numeric/mtl/utility/algebraic_category.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { namespace tfunctor { + + // AlgebraicCategory is by default tag::scalar + template <typename Value1, typename Value2, typename AlgebraicCategory> + struct rscale + { + typedef typename Multiplicable<Value1, Value2>::result_type result_type; + + explicit rscale(const Value2& v2) : v2(v2) {} + + result_type operator() (const Value1& v1) const + { + return v1 * v2; + } + + Value2 value() const { return v2; } + private: + Value2 v2; + }; + + + template <typename Matrix, typename Value2> + struct rscale<Matrix, Value2, tag::matrix> + { + typedef matrix::rscaled_view<Matrix,Value2> result_type; + + explicit rscale(const Value2& v2) : v2(v2) {} + + result_type operator() (const Matrix& matrix) const + { + return result_type(matrix, v2); + } + private: + Value2 v2; + }; + + + template <typename Vector, typename Value2> + struct rscale<Vector, Value2, tag::vector> + { + typedef vector::rscaled_view<Vector, Value2> result_type; + + explicit rscale(const Value2& v2) : v2(v2) {} + + result_type operator() (const Vector& vector) const + { + return result_type(vector, v2); + } + private: + Value2 v2; + }; + + +} // namespace tfunctor + + +namespace matrix { + + template <typename Value1, typename Value2> + typename tfunctor::rscale<Value1, Value2, typename traits::algebraic_category<Value1>::type>::result_type + inline rscale(const Value1& value1, const Value2& value2) + { + vampir_trace<4017> tracer; + return tfunctor::rscale<Value1, Value2, typename traits::algebraic_category<Value1>::type>(value2)(value1); + } +} + +namespace vector { + + template <typename Value1, typename Value2> + typename tfunctor::rscale<Value1, Value2, typename traits::algebraic_category<Value1>::type>::result_type + inline rscale(const Value1& value1, const Value2& value2) + { + vampir_trace<2024> tracer; + return tfunctor::rscale<Value1, Value2, typename traits::algebraic_category<Value1>::type>(value2)(value1); + } +} + + +} // namespace mtl + +#endif // MTL_RSCALE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/rvec_mat_mult.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/rvec_mat_mult.hpp new file mode 100644 index 0000000000000000000000000000000000000000..ad60d5338ed1a6d98d89351ee10b4df3590dccd6 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/rvec_mat_mult.hpp @@ -0,0 +1,218 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_VECTOR_RVEC_MAT_MULT_INCLUDE +#define MTL_VECTOR_RVEC_MAT_MULT_INCLUDE + +#include <cassert> +#include <boost/mpl/bool.hpp> + +#include <boost/numeric/mtl/utility/property_map.hpp> +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/is_static.hpp> +#include <boost/numeric/mtl/operation/set_to_zero.hpp> +#include <boost/numeric/mtl/operation/update.hpp> +#include <boost/numeric/mtl/operation/conj.hpp> +#include <boost/numeric/linear_algebra/identity.hpp> +#include <boost/numeric/meta_math/loop.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { namespace vector { + +namespace impl { + + template <std::size_t Index0, std::size_t Max0, std::size_t Index1, std::size_t Max1, typename Assign> + struct fully_unroll_rvec_mat_mult + : public meta_math::loop2<Index0, Max0, Index1, Max1> + { + typedef meta_math::loop2<Index0, Max0, Index1, Max1> base; + typedef fully_unroll_rvec_mat_mult<base::next_index0, Max0, base::next_index1, Max1, Assign> next_t; + + template <typename VectorIn, typename Matrix, typename VectorOut> + static inline void apply(const VectorIn& v, const Matrix& A, VectorOut& w) + { + Assign::update(w[base::index0], v[base::index1] * A[base::index1][base::index0]); + next_t::apply(v, A, w); + } + }; + + template <std::size_t Max0, std::size_t Max1, typename Assign> + struct fully_unroll_rvec_mat_mult<Max0, Max0, Max1, Max1, Assign> + : public meta_math::loop2<Max0, Max0, Max1, Max1> + { + typedef meta_math::loop2<Max0, Max0, Max1, Max1> base; + + template <typename VectorIn, typename Matrix, typename VectorOut> + static inline void apply(const VectorIn& v, const Matrix& A, VectorOut& w) + { + Assign::update(w[base::index0], v[base::index1] * A[base::index1][base::index0]); + } + }; + + struct rvec_mat_noop + { + template <typename VectorIn, typename Matrix, typename VectorOut> + static inline void apply(const VectorIn&, const Matrix&, VectorOut&) {} + }; +} // impl + +// Dense matrix vector multiplication with run-time matrix size +template <typename VectorIn, typename Matrix, typename VectorOut, typename Assign> +inline void dense_rvec_mat_mult(const VectorIn& v, const Matrix& A, VectorOut& w, Assign, boost::mpl::true_) +{ + vampir_trace<1008> tracer; + typedef typename static_num_rows<Matrix>::type size_type; + static const size_type rows_a= static_num_rows<Matrix>::value, cols_a= static_num_cols<Matrix>::value; + + assert(rows_a > 0 && cols_a > 0); + // w= A[all][0] * v[0]; N.B.: 1D is unrolled by the compiler faster (at least on gcc) + for (size_type i= 0; i < cols_a; i++) + Assign::first_update(w[i], v[0] * A[0][i]); + + // corresponds to w+= v[1:] * A[1:][all]; if necessary + typedef impl::fully_unroll_rvec_mat_mult<1, cols_a, 2, rows_a, Assign> f2; + typedef typename boost::mpl::if_c<(rows_a > 1), f2, impl::rvec_mat_noop>::type f3; + f3::apply(v, A, w); +} + +// Dense matrix vector multiplication with run-time matrix size +template <typename VectorIn, typename Matrix, typename VectorOut, typename Assign> +inline void dense_rvec_mat_mult(const VectorIn& v, const Matrix& A, VectorOut& w, Assign, boost::mpl::false_) +{ + // Naive implementation, will be moved to a functor and complemented with more efficient ones + vampir_trace<3027> tracer; + using math::zero; using mtl::vector::set_to_zero; + if (size(w) == 0) return; + + if (Assign::init_to_zero) set_to_zero(w); + + typedef typename Collection<VectorOut>::value_type value_type; + typedef typename Collection<Matrix>::size_type size_type; + + for (size_type i= 0; i < num_cols(A); i++) { + value_type tmp= zero(w[i]); + for (size_type j= 0; j < num_rows(A); j++) + tmp+= v[j] * A[j][i]; + Assign::update(w[i], tmp); + } +} + +// Dense vector matrix multiplication +template <typename VectorIn, typename Matrix, typename VectorOut, typename Assign> +inline void rvec_mat_mult(const VectorIn& v, const Matrix& A, VectorOut& w, Assign, tag::flat<tag::dense>) +{ +# ifdef MTL_NOT_UNROLL_FSIZE_MAT_VEC_MULT + boost::mpl::false_ selector; +# else + mtl::traits::is_static<Matrix> selector; +# endif + dense_rvec_mat_mult(v, A, w, Assign(), selector); +} + +// Multi-vector vector multiplication (tag::multi_vector is derived from dense) +template <typename VectorIn, typename Matrix, typename VectorOut, typename Assign> +inline void rvec_mat_mult(const VectorIn& v, const Matrix& A, VectorOut& w, Assign, tag::flat<tag::multi_vector>) +{ + vampir_trace<2025> tracer; + if (Assign::init_to_zero) set_to_zero(w); + for (unsigned i= 0; i < num_cols(A); i++) + Assign::update(w[i], dot_real(v, A.vector(i))); +} + +// Transposed multi-vector vector multiplication (tag::transposed_multi_vector is derived from dense) +template <typename VectorIn, typename TransposedMatrix, typename VectorOut, typename Assign> +inline void rvec_mat_mult(const VectorIn& v, const TransposedMatrix& A, VectorOut& w, Assign, tag::flat<tag::transposed_multi_vector>) +{ + vampir_trace<2026> tracer; + typename TransposedMatrix::const_ref_type B= A.ref; // Referred matrix + + if (Assign::init_to_zero) set_to_zero(w); + for (unsigned i= 0; i < num_cols(B); i++) + Assign::update(w, v[i] * trans(B.vector(i))); +} + +// Hermitian multi-vector vector multiplication (tag::hermitian_multi_vector is derived from dense) +template <typename VectorIn, typename HermitianMatrix, typename VectorOut, typename Assign> +inline void rvec_mat_mult(const VectorIn& v, const HermitianMatrix& A, VectorOut& w, Assign, tag::flat<tag::hermitian_multi_vector>) +{ + vampir_trace<2027> tracer; + typename HermitianMatrix::const_ref_type B= A.const_ref(); // Referred matrix + + if (Assign::init_to_zero) set_to_zero(w); + for (unsigned i= 0; i < num_cols(B); i++) + Assign::update(w, v[i] * mtl::vector::conj(trans(B.vector(i)))); +} + + +// Vector sparse matrix multiplication +template <typename VectorIn, typename Matrix, typename VectorOut, typename Assign> +inline void rvec_mat_mult(const VectorIn& v, const Matrix& A, VectorOut& w, Assign, tag::flat<tag::sparse>) +{ + vampir_trace<3028> tracer; + rvec_smat_mult(v, A, w, Assign(), typename OrientedCollection<Matrix>::orientation()); +} + + + +template <typename VectorIn, typename Matrix, typename VectorOut, typename Assign> +inline void rvec_smat_mult(const VectorIn& v, const Matrix& A, VectorOut& w, Assign, tag::row_major) +{ + using namespace tag; namespace traits = mtl::traits; + using traits::range_generator; + using mtl::vector::set_to_zero; + typedef typename range_generator<row, Matrix>::type a_cur_type; + typedef typename range_generator<nz, a_cur_type>::type a_icur_type; + + typename traits::col<Matrix>::type col_a(A); + typename traits::const_value<Matrix>::type value_a(A); + + if (Assign::init_to_zero) set_to_zero(w); + + unsigned cv= 0; // traverse all columns of v + for (a_cur_type ac= begin<row>(A), aend= end<row>(A); ac != aend; ++ac, ++cv) { + typename Collection<VectorIn>::value_type vv= v[cv]; + for (a_icur_type aic= begin<nz>(ac), aiend= end<nz>(ac); aic != aiend; ++aic) + Assign::update(w[col_a(*aic)], vv * value_a(*aic)); + } +} + +template <typename VectorIn, typename Matrix, typename VectorOut, typename Assign> +inline void rvec_smat_mult(const VectorIn& v, const Matrix& A, VectorOut& w, Assign, tag::col_major) +{ + using namespace tag; + using mtl::traits::range_generator; + using math::zero; + using mtl::vector::set_to_zero; + + typedef typename range_generator<col, Matrix>::type a_cur_type; + typedef typename range_generator<nz, a_cur_type>::type a_icur_type; + typename mtl::traits::row<Matrix>::type row_a(A); + typename mtl::traits::const_value<Matrix>::type value_a(A); + + if (Assign::init_to_zero) set_to_zero(w); + + typedef typename Collection<VectorOut>::value_type value_type; + + a_cur_type ac= begin<col>(A), aend= end<col>(A); + for (unsigned i= 0; ac != aend; ++ac, ++i) { + value_type tmp= zero(w[i]); + for (a_icur_type aic= begin<nz>(ac), aiend= end<nz>(ac); aic != aiend; ++aic) + tmp+= v[row_a(*aic)] * value_a(*aic); + Assign::update(w[i], tmp); + } +} + +}} // namespace mtl::vector + +#endif // MTL_VECTOR_RVEC_MAT_MULT_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/scale.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/scale.hpp new file mode 100644 index 0000000000000000000000000000000000000000..8d2eee3eb2b055f0db5cb1c59da58ff2b5a41199 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/scale.hpp @@ -0,0 +1,108 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_SCALE_INCLUDE +#define MTL_SCALE_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/concept/std_concept.hpp> +#include <boost/numeric/mtl/matrix/map_view.hpp> +#include <boost/numeric/mtl/vector/map_view.hpp> +#include <boost/numeric/mtl/utility/enable_if.hpp> +#include <boost/numeric/mtl/utility/true_copy.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { + + namespace vector { + + template <typename Value1, typename Vector> + typename traits::enable_if_vector<Vector, scaled_view<typename mtl::traits::true_copy<Value1>::type, Vector> >::type + inline scale(const Value1& value1, const Vector& vector) + { + vampir_trace<2028> tracer; + return scaled_view<typename mtl::traits::true_copy<Value1>::type, Vector>(value1, vector); + } + } + + namespace matrix { + + template <typename Value1, typename Matrix> + typename traits::enable_if_matrix<Matrix, scaled_view<Value1, Matrix> >::type + inline scale(const Value1& value1, const Matrix& matrix) + { + vampir_trace<3029> tracer; + return scaled_view<Value1, Matrix> (value1, matrix); + } + } + + using vector::scale; + using matrix::scale; + + + namespace tfunctor { + + // AlgebraicCategory is by default tag::scalar + template <typename Value1, typename Value2, typename AlgebraicCategory> + struct scale + { + typedef typename Multiplicable<Value1, Value2>::result_type result_type; + explicit scale(const Value1& v1) : v1(v1) {} + + result_type operator() (const Value2& v2) const + { + return v1 * v2; + } + + Value1 value() const { return v1; } + private: + Value1 v1; + }; + + + template <typename Value1, typename Matrix> + struct scale<Value1, Matrix, tag::matrix> + { + typedef matrix::scaled_view<Value1, Matrix> result_type; + explicit scale(const Value1& v1) : v1(v1) {} + + result_type operator() (const Matrix& matrix) const + { + return result_type(v1, matrix); + } + private: + typename mtl::traits::true_copy<Value1>::type v1; + }; + + + template <typename Value1, typename Vector> + struct scale<Value1, Vector, tag::vector> + { + typedef typename mtl::traits::true_copy<Value1>::type type1; + + typedef vector::scaled_view<type1, Vector> result_type; + explicit scale(const Value1& v1) : v1(type1(v1)) {} + + result_type operator() (const Vector& vector) const + { + return result_type(v1, vector); + } + private: + type1 v1; + }; + + } // namespace tfunctor + +} // namespace mtl + +#endif // MTL_SCALE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/secular.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/secular.hpp new file mode 100644 index 0000000000000000000000000000000000000000..90c5898149be8479429ea737889260acb1b9c00e --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/secular.hpp @@ -0,0 +1,117 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +// With contributions from Cornelius Steinhardt + +#ifndef MTL_VECTOR_SECULAR_INCLUDE +#define MTL_VECTOR_SECULAR_INCLUDE + +#include <cmath> +#include <boost/utility.hpp> +#include <boost/numeric/linear_algebra/identity.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/vector/dense_vector.hpp> +#include <boost/numeric/mtl/operation/resource.hpp> +#include <boost/numeric/mtl/operation/minimal_increase.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { namespace vector { + +/// Class for the secular equation( to solve eigenvalue problems) +template <typename Vector> +class secular_f +{ + typedef typename Collection<Vector>::value_type value_type; + typedef typename Collection<Vector>::size_type size_type; + + public: + /// Constructor needs 2 Vectors z(nummerator), d(dominator) and sigma as factor before the sum + secular_f(const Vector& z, const Vector& d, value_type sigma) + : z(z), d(d), sigma(sigma) {} + + /// secular_f equation as function, evaluates the function value + /** \f$f(x)=1+\sigma * sum_{i=1}^{n}\frac{z_i}{d_i-x} \f$**/ + value_type f(const value_type& lamb) + { + value_type fw= 1; + for(size_type i=0; i<size(z); i++) + fw+= sigma*z[i]*z[i]/(d[i]-lamb); + return fw; + } + + value_type square(value_type x) const { return x*x; } + + /// gradient of secular_f equation as function, evaluates the gradientfunction value + /** \f$gradf(x)=\sigma * sum_{i=1}^{n}\frac{z_i}{(d_i-x)^2} \f$**/ + value_type grad_f(const value_type& lamb) + { + value_type gfw= 0.0; + for(size_type i=0; i<size(z); i++) + gfw+= square(z[i] / (d[i] - lamb)); // , std::cout << "gfw = " << gfw << '\n'; //TODO + return sigma*gfw; + } + + /// Evaluates the roots of secular_f equation =0 with newton algo. + /** Computes mixed Newton and interval nesting. d must be sorted. **/ + Vector roots() + { + assert(size(z) > 1); + const double tol= 1.0e-6; + Vector start(resource(z)), lambda(resource(z)); + + for (size_type i= 0; i < size(z); i++) { + // Equal poles -> eigenvalue + if (i < size(z) - 1 && d[i] == d[i+1]) { + lambda[i]= d[i]; continue; } + + // Check if root is too close to pole (i.e. d[i]+eps > 0) then take this because we can't reach the root + value_type next= minimal_increase(d[i]), lamb, old; + if (f(next) >= value_type(0)){ + lambda[i]= next; continue; } + + if (i < size(z) - 1) + old= lamb= start[i]= (d[i] + d[i+1]) / 2; //start points between pols + else + old= lamb= start[i]= 1.5 * d[i] - 0.5 * d[i-1]; // last start point plus half the distance to second-last + + while (std::abs(f(lamb)) > tol) { + if (lamb <= d[i]) + start[i]= lamb= (d[i] + start[i]) / 2; + else + lamb-= f(lamb) / grad_f(lamb); + if (old == lamb) break; + old= lamb; + } + lambda[i]= lamb; + } + return lambda; + } + + private: + Vector z, d; + value_type sigma; +}; + +template <typename Vector, typename Value> +inline Vector secular(const Vector& z, const Vector& d, Value sigma) +{ + vampir_trace<3030> tracer; + secular_f<Vector> functor(z, d, sigma); + return functor.roots(); +} + +}}// namespace vector + + +#endif // MTL_VECTOR_SECULAR_INCLUDE + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/set_to_zero.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/set_to_zero.hpp new file mode 100644 index 0000000000000000000000000000000000000000..0ae79e6631083857a130086fc6a0a1a5adcd7a86 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/set_to_zero.hpp @@ -0,0 +1,178 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_SET_TO_0_INCLUDE +#define MTL_SET_TO_0_INCLUDE + +#include <algorithm> +#include <cassert> +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/utility/enable_if.hpp> +#include <boost/numeric/mtl/utility/ashape.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/linear_algebra/identity.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace mtl { + + // Forward declarations + namespace matrix { + template <typename Coll> + typename mtl::traits::enable_if_matrix<Coll>::type + set_to_zero(Coll& collection); + } + namespace vector { + template <typename Coll> + typename mtl::traits::enable_if_vector<Coll>::type + set_to_zero(Coll& collection); + } + + namespace impl { + + template <typename Coll> + void set_to_zero(Coll& collection, tag::vector_ref, ashape::scal) + { + using math::zero; + typename Collection<Coll>::value_type ref, my_zero(zero(ref)); + for (typename Collection<Coll>::size_type i= 0; i < size(collection); ++i) + collection[i]= my_zero; + } + + template <typename Coll> + void set_to_zero(Coll& collection, tag::contiguous_dense, ashape::scal) + { + using math::zero; + typename Collection<Coll>::value_type ref, my_zero(zero(ref)); + + std::fill(collection.elements(), collection.elements()+collection.used_memory(), my_zero); + } + + template <typename Coll> + void set_to_zero(Coll& collection, tag::std_vector, ashape::scal) + { + using math::zero; + typename Collection<Coll>::value_type ref, my_zero(zero(ref)); + + std::fill(collection.begin(), collection.end(), my_zero); + } + + template <typename Matrix> + void set_to_zero(Matrix& matrix, tag::morton_dense, ashape::scal) + { + using math::zero; + typename Collection<Matrix>::value_type ref, my_zero(zero(ref)); + // maybe faster to do it straight + // if performance problems we'll take care of the holes + // std::cout << "set_to_zero: used_memory = " << matrix.used_memory() << "\n"; + std::fill(matrix.elements(), matrix.elements() + matrix.used_memory(), my_zero); + +#if 0 + for (int i= 0; i < matrix.num_rows(); i++) + for (int j= 0; j < matrix.num_cols(); j++) + matrix[i][j]= my_zero; +#endif + } + + // For nested collection, we must consider the dimensions of the elements + // (Morton-order is included in contiguous_dense) + template <typename Coll> + void set_to_zero(Coll& collection, tag::contiguous_dense, ashape::nonscal) + { + for (typename Collection<Coll>::size_type i= 0; i < collection.used_memory(); ++i) + set_to_zero(collection.value_n(i)); + } + + + // Is approbriate for all sparse matrices and vectors (including collections as value_type) + template <typename Coll> + void set_to_zero(Coll& collection, tag::sparse, ashape::universe) + { + collection.make_empty(); + } + + // Special treatment for multi_vector + template <typename Coll> + void set_to_zero(Coll& collection, tag::multi_vector, ashape::universe) + { + using mtl::vector::set_to_zero; + for (typename Collection<Coll>::size_type i= 0; i < num_cols(collection); ++i) + set_to_zero(collection.vector(i)); + } + + template <typename Coll> + bool has_strided_data(const Coll&) + { return false; } + + template <typename Value, typename Parameter> + bool has_strided_data(const matrix::dense2D<Value, Parameter>& A) + { return A.has_strided_data(); } + + + template <typename Matrix> + void naive_set_to_zero(Matrix& A, tag::matrix, tag::dense) + { + using math::zero; + typename Collection<Matrix>::value_type ref, my_zero(zero(ref)); + + for (unsigned i= 0; i < num_rows(A); i++) + for (unsigned j= 0; j < num_cols(A); j++) + A[i][j]= my_zero; + } + + template <typename Matrix> + void naive_set_to_zero(Matrix&, tag::matrix, tag::sparse) + { + assert(true); // must not be called + } + + } + + +namespace matrix { + + /// Sets all values of a collection to 0 + /// More spefically the defined multiplicative identity element + template <typename Coll> + typename mtl::traits::enable_if_matrix<Coll>::type + set_to_zero(Coll& collection) + { + using mtl::traits::category; + vampir_trace<3031> tracer; + typedef typename Collection<Coll>::value_type value_type; + if (mtl::impl::has_strided_data(collection)) + mtl::impl::naive_set_to_zero(collection, typename category<Coll>::type(), typename category<Coll>::type()); + else + mtl::impl::set_to_zero(collection, typename category<Coll>::type(),typename ashape::ashape<value_type>::type()); // 2. ashape ??? + } +} + +namespace vector { + + /// Sets all values of a collection to 0 + /// More spefically the defined multiplicative identity element + template <typename Coll> + typename mtl::traits::enable_if_vector<Coll>::type + set_to_zero(Coll& collection) + { + using mtl::traits::category; + vampir_trace<2029> tracer; + typedef typename Collection<Coll>::value_type value_type; + mtl::impl::set_to_zero(collection, typename category<Coll>::type(),typename ashape::ashape<value_type>::type()); + } + +} + +} // namespace mtl + +#endif // MTL_SET_TO_0_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/sfunctor.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/sfunctor.hpp new file mode 100644 index 0000000000000000000000000000000000000000..9d01d352c913b280c9cd0669eb45bc8123e3bb59 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/sfunctor.hpp @@ -0,0 +1,431 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_SFUNCTOR_INCLUDE +#define MTL_SFUNCTOR_INCLUDE + +#include <cmath> +#include <boost/numeric/mtl/concept/std_concept.hpp> +#include <boost/numeric/mtl/concept/magnitude.hpp> +#include <boost/numeric/mtl/concept/static_functor.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace mtl { namespace sfunctor { + +template <typename Value1, typename Value2> +struct plus +{ + typedef const Value1& first_argument_type; + typedef const Value2& second_argument_type; + typedef typename Addable<Value1, Value2>::result_type result_type; + + static inline result_type apply(const Value1& v1, const Value2& v2) + { + return v1 + v2; + } + + result_type operator() (const Value1& v1, const Value2& v2) const + { + vampir_trace<23> tracer; + return v1 + v2; + } +}; + +template <typename Value1, typename Value2> +struct minus +{ + typedef const Value1& first_argument_type; + typedef const Value2& second_argument_type; + typedef typename Subtractable<Value1, Value2>::result_type result_type; + + static inline result_type apply(const Value1& v1, const Value2& v2) + { + return v1 - v2; + } + + result_type operator() (const Value1& v1, const Value2& v2) const + { + vampir_trace<24> tracer; + return v1 - v2; + } +}; + +template <typename Value1, typename Value2> +struct times +{ + typedef const Value1& first_argument_type; + typedef const Value2& second_argument_type; + typedef typename Multiplicable<Value1, Value2>::result_type result_type; + + static inline result_type apply(const Value1& v1, const Value2& v2) + { + return v1 * v2; + } + + result_type operator() (const Value1& v1, const Value2& v2) const + { + vampir_trace<25> tracer; + return v1 * v2; + } +}; + +template <typename Value1, typename Value2> +struct divide +{ + typedef const Value1& first_argument_type; + typedef const Value2& second_argument_type; + typedef typename Divisible<Value1, Value2>::result_type result_type; + + static inline result_type apply(const Value1& v1, const Value2& v2) + { + return v1 / v2; + } + + result_type operator() (const Value1& v1, const Value2& v2) const + { + vampir_trace<26> tracer; + return v1 / v2; + } +}; + +template <typename Value1, typename Value2> +struct assign +{ + typedef Value1& first_argument_type; + typedef const Value2& second_argument_type; + typedef Value1& result_type; + + static inline result_type apply(Value1& v1, const Value2& v2) + { + return v1= v2; + } + + result_type operator() (Value1& v1, const Value2& v2) const + { + vampir_trace<27> tracer; + return v1= v2; + } +}; + +template <typename Value1, typename Value2> +struct plus_assign +{ + typedef Value1& first_argument_type; + typedef const Value2& second_argument_type; + typedef Value1& result_type; + + static inline result_type apply(Value1& v1, const Value2& v2) + { + return v1+= v2; + } + + result_type operator() (Value1& v1, const Value2& v2) const + { + vampir_trace<28> tracer; + return v1+= v2; + } +}; + +template <typename Value1, typename Value2> +struct minus_assign +{ + typedef Value1& first_argument_type; + typedef const Value2& second_argument_type; + typedef Value1& result_type; + + static inline result_type apply(Value1& v1, const Value2& v2) + { + return v1-= v2; + } + + result_type operator() (Value1& v1, const Value2& v2) const + { + vampir_trace<29> tracer; + return v1-= v2; + } +}; + +template <typename Value1, typename Value2> +struct times_assign +{ + typedef Value1& first_argument_type; + typedef const Value2& second_argument_type; + typedef Value1& result_type; + + static inline result_type apply(Value1& v1, const Value2& v2) + { + return v1*= v2; + } + + result_type operator() (Value1& v1, const Value2& v2) const + { + vampir_trace<30> tracer; + return v1*= v2; + } +}; + +template <typename Value1, typename Value2> +struct divide_assign +{ + typedef Value1& first_argument_type; + typedef const Value2& second_argument_type; + typedef Value1& result_type; + + static inline result_type apply(Value1& v1, const Value2& v2) + { + return v1/= v2; + } + + result_type operator() (Value1& v1, const Value2& v2) const + { + vampir_trace<31> tracer; + return v1/= v2; + } +}; + + +// Might be helpful for surplus functor arguments +template <typename Value> +struct identity +{ + typedef const Value& argument_type; + typedef Value result_type; + + static inline result_type apply(const Value& v) + { + return v; + } + + result_type operator() (const Value& v) const + { + vampir_trace<32> tracer; + return v; + } +}; + + +template <typename Value> +struct abs +{ + typedef const Value& argument_type; + typedef typename Magnitude<Value>::type result_type; + + static inline result_type apply(const Value& v) + { + using std::abs; + return abs(v); + } + + result_type operator() (const Value& v) + { + vampir_trace<33> tracer; + return apply(v); + } +}; + +template <typename Value> +struct sqrt +{ + typedef const Value& argument_type; + typedef Value result_type; + + static inline result_type apply(const Value& v) + { + using std::sqrt; + return sqrt(v); + } + + result_type operator() (const Value& v) + { + vampir_trace<34> tracer; + return apply(v); + } +}; + +template <typename Value> +struct square +{ + typedef const Value& argument_type; + typedef Value result_type; + + static inline result_type apply(const Value& v) + { + return v * v; + } + + result_type operator() (const Value& v) + { + vampir_trace<35> tracer; + return apply(v); + } +}; + + +template <typename Value> +struct negate +{ + typedef const Value& argument_type; + typedef Value result_type; + + static inline result_type apply(const Value& v) { return -v; } + result_type operator() (const Value& v) const + { + vampir_trace<36> tracer; + return -v; + } +}; + + +/// Compose functors \p F and \p G, i.e. compute f(g(x)). +/** Functors must be models of StaticUnaryFunctor, + StaticUnaryFunctor<G>::result_type must be convertible to + StaticUnaryFunctor<F>::argument_type. + Under these conditions compose<F, G> will be a model of StaticUnaryFunctor. +**/ +template <typename F, typename G> +struct compose +{ + typedef typename StaticUnaryFunctor<G>::argument_type argument_type; + typedef typename StaticUnaryFunctor<F>::result_type result_type; + + static inline result_type apply(argument_type x) + { + return F::apply(G::apply(x)); + } + + result_type operator()(argument_type x) + { + vampir_trace<37> tracer; + return apply(x); + } +}; + + +/// Compose functors \p F and \p G with G in F's first argument, i.e. compute f(g(x), y). +/** F/G must be models of StaticBinaryFunctor/StaticUnaryFunctor, + StaticUnaryFunctor<G>::result_type must be convertible to + StaticBinaryFunctor<F>::first_argument_type. + Under these conditions compose_first<F, G> will be a model of StaticBinaryFunctor. +**/ +template <typename F, typename G> +struct compose_first +{ + typedef typename StaticUnaryFunctor<G>::argument_type first_argument_type; + typedef typename StaticBinaryFunctor<F>::second_argument_type second_argument_type; + typedef typename StaticBinaryFunctor<F>::result_type result_type; + + static inline result_type apply(first_argument_type x, second_argument_type y) + { + return F::apply(G::apply(x), y); + } + + result_type operator()(first_argument_type x, second_argument_type y) + { + vampir_trace<38> tracer; + return apply(x, y); + } +}; + + +/// Compose functors \p F and \p G with G in F's second argument, i.e. compute f(x, g(y)). +/** F/G must be models of StaticBinaryFunctor/StaticUnaryFunctor, + StaticUnaryFunctor<G>::result_type must be convertible to + StaticBinaryFunctor<F>::second_argument_type. + Under these conditions compose_second<F, G> will be a model of StaticBinaryFunctor. +**/ +template <typename F, typename G> +struct compose_second +{ + typedef typename StaticBinaryFunctor<F>::first_argument_type first_argument_type; + typedef typename StaticUnaryFunctor<G>::argument_type second_argument_type; + typedef typename StaticBinaryFunctor<F>::result_type result_type; + + static inline result_type apply(first_argument_type x, second_argument_type y) + { + return F::apply(x, G::apply(y)); + } + + result_type operator()(first_argument_type x, second_argument_type y) + { + vampir_trace<39> tracer; + return apply(x, y); + } +}; + +/// Compose functors \p F, \p G, and \p H with G/H in F's first/second argument, i.e. compute f(g(x), h(y)). +/** F/G must be models of StaticBinaryFunctor/StaticUnaryFunctor, + StaticUnaryFunctor<G>::result_type must be convertible to + StaticBinaryFunctor<F>::first_argument_type and + StaticUnaryFunctor<H>::result_type must be convertible to + StaticBinaryFunctor<F>::second_argument_type. + Under these conditions compose_both<F, G, H> will be a model of StaticBinaryFunctor. +**/ +template <typename F, typename G, typename H> +struct compose_both +{ + typedef typename StaticUnaryFunctor<G>::argument_type first_argument_type; + typedef typename StaticUnaryFunctor<H>::argument_type second_argument_type; + typedef typename StaticBinaryFunctor<F>::result_type result_type; + + static inline result_type apply(first_argument_type x, second_argument_type y) + { + return F::apply(G::apply(x), H::apply(y)); + } + + result_type operator()(first_argument_type x, second_argument_type y) + { + vampir_trace<40> tracer; + return apply(x, y); + } +}; + +/// Compose unary functor \p F with binary functor \p G, i.e. compute f(g(x, y)). +/** F/G must be models of StaticUnaryFunctor/StaticBinaryFunctor, + StaticBinaryFunctor<G>::result_type must be convertible to + StaticUnaryFunctor<F>::argument_type. + Under these conditions compose_binary<F, G> will be a model of StaticBinaryFunctor. +**/ +template <typename F, typename G> +struct compose_binary +{ + typedef typename StaticBinaryFunctor<G>::first_argument_type first_argument_type; + typedef typename StaticBinaryFunctor<G>::second_argument_type second_argument_type; + typedef typename StaticUnaryFunctor<F>::result_type result_type; + + static inline result_type apply(first_argument_type x, second_argument_type y) + { + return F::apply(G::apply(x, y)); + } + + result_type operator()(first_argument_type x, second_argument_type y) + { + vampir_trace<41> tracer; + return apply(x, y); + } +}; + + +/// Templatized example of composition, computes l_2 norm in 2D, i.e. sqrt(abs(x*x + y*y)) +template <typename T> +struct l_2_2D + : public compose_binary<sqrt<typename abs<T>::result_type>, + compose_binary<abs<T>, + compose_both<plus<T, T>, + square<T>, + square<T> > + > + > +{}; + +}} // namespace mtl::sfunctor + +#endif // MTL_SFUNCTOR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/shift_block.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/shift_block.hpp new file mode 100644 index 0000000000000000000000000000000000000000..aceeba064895807aa984a9c69aa35ddd4934df3f --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/shift_block.hpp @@ -0,0 +1,41 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_SHIFT_BLOCKS_INCLUDE +#define MTL_SHIFT_BLOCKS_INCLUDE + +#include <boost/numeric/mtl/operation/shift_block_detail.hpp> + +namespace mtl { namespace operations { + +// Shift blocks in an 1D array to remove unnecessary holes +// inserting holes in other places where needed (e.g. for inserting new values) +// +// Block 'i' is the half-open interval [starts[i], ends[i]) in data +// It will be copied into [new_starts[i], ...) in place +// Blocks are ordered: start[i] <= start[i+1] +// Data between blocks are considered holes and can be overwritten +// +template <typename Size, typename Starts, typename NewStarts, typename Ends, typename Data> +void shift_blocks(Size blocks, Starts const& starts, NewStarts const& new_starts, + Ends const& ends, Data& data) +{ + for (Size i = 0; i < blocks; ) { + detail::copy_blocks_forward(i, blocks, starts, new_starts, ends, data); + detail::copy_blocks_backward(i, blocks, starts, new_starts, ends, data); + } +} + + +}} // namespace mtl::operations + +#endif // MTL_SHIFT_BLOCKS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/shift_block_detail.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/shift_block_detail.hpp new file mode 100644 index 0000000000000000000000000000000000000000..7a80661dcaf91d2036eb7a34cbf4074959c5e525 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/shift_block_detail.hpp @@ -0,0 +1,58 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_SHIFT_BLOCKS_DETAIL_INCLUDE +#define MTL_SHIFT_BLOCKS_DETAIL_INCLUDE + +#include <algorithm> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { namespace operations { namespace detail { + +// &v[i] is replaced by &v[0]+i to enable past-end addresses for STL copy +// otherwise MSVC complaines + +template <typename Size, typename Starts, typename NewStarts, typename Ends, typename Data> +inline void copy_blocks_forward(Size& i, Size blocks, Starts const& starts, NewStarts const& new_starts, + Ends const& ends, Data& data) +{ + using std::copy; + vampir_trace<1005> tracer; + // Copy forward as long as blocks are not shifted + for (; i < blocks && starts[i] >= new_starts[i]; ++i) + if (starts[i] > new_starts[i]) + copy(&data[0] + starts[i], &data[0] + ends[i], &data[0] + new_starts[i]); +} + +template <typename Size, typename Starts, typename NewStarts, typename Ends, typename Data> +inline void copy_blocks_backward(Size& i, Size blocks, Starts const& starts, NewStarts const& new_starts, + Ends const& ends, Data& data) +{ + using std::copy; + using std::copy_backward; + vampir_trace<1006> tracer; + Size first = i; + // find first block to be copied forward (or end) + while (i < blocks && starts[i] < new_starts[i]) ++i; + + for (Size j = i; j-- > first; ) + if (ends[j] <= new_starts[j]) + copy(&data[0] + starts[j], &data[0] + ends[j], &data[0] + new_starts[j]); + else + copy_backward(&data[0] + starts[j], &data[0] + ends[j], &data[0] + (new_starts[j]+ends[j]-starts[j])); +} + +}}} // namespace mtl::operations::detail + +#endif // MTL_SHIFT_BLOCKS_DETAIL_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/signum.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/signum.hpp new file mode 100644 index 0000000000000000000000000000000000000000..337b6c95c37bbb4f9ccfc58f2201d245152a5bd7 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/signum.hpp @@ -0,0 +1,63 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_SIGNUM_INCLUDE +#define MTL_SIGNUM_INCLUDE + +#include <complex> +#include <boost/numeric/linear_algebra/identity.hpp> +#include <boost/numeric/mtl/operation/real.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { + +namespace sfunctor { + + template <typename Value> + struct signum + { + typedef Value result_type; + + static inline Value apply(const Value& v) + { + using math::zero; using math::one; + return v == zero(v) ? zero(v) : ( v < zero(v) ? -one(v) : one(v) ); + } + }; + + template <typename Value> + struct signum<std::complex<Value> > + { + typedef Value result_type; + + static inline Value apply(const std::complex<Value>& v) + { + return signum<Value>::apply(mtl::real(v)); + } + }; + +} + +/// Sign of scalars +/** For complex numbers, the sign of real part is returned; subject to revision. **/ +template <typename Value> +inline typename sfunctor::signum<Value>::result_type signum(const Value& v) +{ + vampir_trace<6> tracer; + return sfunctor::signum<Value>::apply(v); +} + + +} // namespace mtl + +#endif // MTL_SIGNUM_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/size.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/size.hpp new file mode 100644 index 0000000000000000000000000000000000000000..e9000afc240b408aebbfefa83249ee399acf63ec --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/size.hpp @@ -0,0 +1,68 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_SIZE_INCLUDE +#define MTL_SIZE_INCLUDE + +#include <vector> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { + +namespace traits { + + /// General declaration, used to disable unsupported types + template <typename Collection> + struct size {}; + + /// size implementation for STL vectors + template <typename Value> + struct size< std::vector<Value> > + { + typedef std::size_t type; + type operator()(const std::vector<Value>& v) { return v.size(); } + }; + + /// size implementation for (1D) arrays interpreted as vectors + template <typename Value, unsigned Size> + struct size<Value[Size]> + { + vampir_trace<2031> tracer; + typedef std::size_t type; + type operator()(const Value[Size]) { return Size; } + }; + + /// size implementation for (2D and higher) arrays interpreted as matrices + template <typename Value, unsigned Rows, unsigned Cols> + struct size<Value[Rows][Cols]> + { + typedef std::size_t type; + vampir_trace<3033> tracer; + type operator()(const Value[Rows][Cols]) { return Rows * Cols; } + }; +} + + +/// size function for non-MTL types (uses implicit enable_if) +template <typename Collection> +typename traits::size<Collection>::type +inline size(const Collection& c) +{ + + return traits::size<Collection>()(c); +} + + +} // namespace mtl + +#endif // MTL_SIZE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/size1D.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/size1D.hpp new file mode 100644 index 0000000000000000000000000000000000000000..d6d541eecfdc7b68e6a5d414a810a58cfcc1c53b --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/size1D.hpp @@ -0,0 +1,70 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_SIZE1D_INCLUDE +#define MTL_SIZE1D_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/operation/size.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +// #include <boost/utility/enable_if.hpp> + +namespace mtl { + + namespace vector { + +#if 0 + template <typename Vector> + typename Collection<Vector>::size_type + inline size1D(const Vector& v) + { + return size(v); + } +#endif + + // Very ugly hack, very ungeneric + template <typename Value, typename P> + std::size_t inline size1D(const dense_vector<Value, P>& v) + { + return size(v); + } + } + + namespace matrix { + + template <typename Vector> + typename Collection<multi_vector<Vector> >::size_type + inline size1D(multi_vector<Vector>& A) + { + vampir_trace<3032> tracer; + return num_cols(A); + } + } + +/// One-dimensional size function +/** Returns size for MTL vectors, STL vector and C arrays. + For multi_vector the number of vectors is returned. + Not defined for other matrix types. + Implementation for standard types uses implicit enable_if to avoid ambiguities. **/ +template <typename Vector> +typename traits::size<Vector>::type +inline size1D(const Vector& v) +{ + vampir_trace<2030> tracer; + return traits::size<Vector>()(v); +} + +} // namespace mtl + +#endif // MTL_SIZE1D_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/smat_dmat_mult.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/smat_dmat_mult.hpp new file mode 100644 index 0000000000000000000000000000000000000000..9c8c00aa8978bd31b0d71d9691674dff15a43f74 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/smat_dmat_mult.hpp @@ -0,0 +1,271 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_SMAT_DMAT_MULT_INCLUDE +#define MTL_SMAT_DMAT_MULT_INCLUDE + +#include <boost/numeric/mtl/operation/set_to_zero.hpp> +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/utility/flatcat.hpp> +#include <boost/numeric/meta_math/loop1.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { namespace functor { + +template <typename Assign= assign::assign_sum, + typename Backup= no_op> // To allow 2nd parameter, is ignored +struct gen_smat_dmat_mult +{ + template <typename MatrixA, typename MatrixB, typename MatrixC> + void operator()(MatrixA const& a, MatrixB const& b, MatrixC& c) + { + vampir_trace<4018> tracer; + apply(a, b, c, typename OrientedCollection<MatrixA>::orientation()); + } + +private: + template <typename MatrixA, typename MatrixB, typename MatrixC> + void apply(MatrixA const& a, MatrixB const& b, MatrixC& c, tag::row_major) + { + using namespace tag; + using traits::range_generator; + typedef typename range_generator<row, MatrixA>::type a_cur_type; + typedef typename range_generator<row, MatrixC>::type c_cur_type; + typedef typename range_generator<col, MatrixB>::type b_cur_type; + + typedef typename range_generator<nz, a_cur_type>::type a_icur_type; + typedef typename range_generator<all, b_cur_type>::type b_icur_type; + typedef typename range_generator<iter::all, c_cur_type>::type c_icur_type; + + typename traits::col<MatrixA>::type col_a(a); + typename traits::const_value<MatrixA>::type value_a(a); + typename traits::const_value<MatrixB>::type value_b(b); + + if (Assign::init_to_zero) set_to_zero(c); + + a_cur_type ac= begin<row>(a), aend= end<row>(a); + for (c_cur_type cc= begin<row>(c); ac != aend; ++ac, ++cc) { + + b_cur_type bc= begin<col>(b), bend= end<col>(b); + for (c_icur_type cic= begin<iter::all>(cc); bc != bend; ++bc, ++cic) { + + typename MatrixC::value_type c_tmp(*cic); + for (a_icur_type aic= begin<nz>(ac), aiend= end<nz>(ac); aic != aiend; ++aic) { + + typename Collection<MatrixA>::size_type ca= col_a(*aic); // column of non-zero + + b_icur_type bic= begin<all>(bc); + bic+= ca; + Assign::update(c_tmp, value_a(*aic) * value_b(*bic)); + } + *cic= c_tmp; + } + } + } + + + template <typename MatrixA, typename MatrixB, typename MatrixC> + void apply(MatrixA const& a, MatrixB const& b, MatrixC& c, tag::col_major) + { + using namespace tag; + using traits::range_generator; + typedef typename range_generator<col, MatrixA>::type a_cur_type; + typedef typename range_generator<nz, a_cur_type>::type a_icur_type; + + typename traits::row<MatrixA>::type row_a(a); + typename traits::const_value<MatrixA>::type value_a(a); + + if (Assign::init_to_zero) set_to_zero(c); + + unsigned rb= 0; // traverse all rows of b + for (a_cur_type ac= begin<col>(a), aend= end<col>(a); ac != aend; ++ac, ++rb) + for (a_icur_type aic= begin<nz>(ac), aiend= end<nz>(ac); aic != aiend; ++aic) { + typename Collection<MatrixA>::size_type ra= row_a(*aic); // row in A and C + typename Collection<MatrixA>::value_type va= value_a(*aic); // value of non-zero + + for (unsigned cb= 0; cb < num_cols(b); ++cb) // column in B and C + Assign::update(c(ra, cb), va * b(rb, cb)); + } + } +}; + + +// ======================= +// Unrolled +// required has_2D_layout +// ======================= + +// Define defaults if not yet given as Compiler flag +#ifndef MTL_SMAT_DMAT_MULT_TILING1 +# define MTL_SMAT_DMAT_MULT_TILING1 8 +#endif + +template <unsigned long Index0, unsigned long Max0, typename Assign> +struct gen_tiling_smat_dmat_mult_block + : public meta_math::loop1<Index0, Max0> +{ + typedef meta_math::loop1<Index0, Max0> base; + typedef gen_tiling_smat_dmat_mult_block<base::next_index0, Max0, Assign> next_t; + + template <typename Value, typename ValueA, typename ValueB, typename Size> + static inline void apply(Value& tmp00, Value& tmp01, Value& tmp02, Value& tmp03, Value& tmp04, + Value& tmp05, Value& tmp06, Value& tmp07, Value& tmp08, Value& tmp09, + Value& tmp10, Value& tmp11, Value& tmp12, Value& tmp13, Value& tmp14, Value& tmp15, + const ValueA& va, ValueB *begin_b, const Size& bci) + { + tmp00+= va * *(begin_b + base::index0 * bci); + next_t::apply(tmp01, tmp02, tmp03, tmp04, tmp05, tmp06, tmp07, tmp08, tmp09, + tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp00, + va, begin_b, bci); + } + + template <typename Value, typename MatrixC, typename SizeC> + static inline void update(Value& tmp00, Value& tmp01, Value& tmp02, Value& tmp03, Value& tmp04, + Value& tmp05, Value& tmp06, Value& tmp07, Value& tmp08, Value& tmp09, + Value& tmp10, Value& tmp11, Value& tmp12, Value& tmp13, Value& tmp14, Value& tmp15, + MatrixC& c, SizeC i, SizeC k) + { + Assign::update(c(i, k + base::index0), tmp00); + next_t::update(tmp01, tmp02, tmp03, tmp04, tmp05, tmp06, tmp07, tmp08, tmp09, + tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp00, + c, i, k); + } +}; + + +template <unsigned long Max0, typename Assign> +struct gen_tiling_smat_dmat_mult_block<Max0, Max0, Assign> + : public meta_math::loop1<Max0, Max0> +{ + typedef meta_math::loop1<Max0, Max0> base; + + template <typename Value, typename ValueA, typename ValueB, typename Size> + static inline void apply(Value& tmp00, Value&, Value&, Value&, Value&, + Value&, Value&, Value&, Value&, Value&, + Value&, Value&, Value&, Value&, Value&, Value&, + const ValueA& va, ValueB *begin_b, const Size& bci) + { + tmp00+= va * *(begin_b + base::index0 * bci); + } + + template <typename Value, typename MatrixC, typename SizeC> + static inline void update(Value& tmp00, Value&, Value&, Value&, Value&, + Value&, Value&, Value&, Value&, Value&, + Value&, Value&, Value&, Value&, Value&, Value&, + MatrixC& c, SizeC i, SizeC k) + { + Assign::update(c(i, k + base::index0), tmp00); + } +}; + + +template <unsigned long Tiling1= MTL_SMAT_DMAT_MULT_TILING1, + typename Assign= assign::assign_sum, + typename Backup= gen_smat_dmat_mult<Assign> > +struct gen_tiling_smat_dmat_mult +{ + template <typename MatrixA, typename MatrixB, typename MatrixC> + void operator()(MatrixA const& a, MatrixB const& b, MatrixC& c) + { + vampir_trace<4019> tracer; + apply(a, b, c, traits::layout_flatcat<MatrixC>()); + } + +private: + template <typename MatrixA, typename MatrixB, typename MatrixC> + void apply(MatrixA const& a, MatrixB const& b, MatrixC& c, tag::universe) + { + Backup()(a, b, c); + } + + template <typename MatrixA, typename MatrixB, typename MatrixC> + void apply(MatrixA const& a, MatrixB const& b, MatrixC& c, tag::flat<tag::has_2D_layout>) + { + apply2(a, b, c, typename OrientedCollection<MatrixA>::orientation()); + } + + template <typename MatrixA, typename MatrixB, typename MatrixC> + void apply2(MatrixA const& a, MatrixB const& b, MatrixC& c, tag::col_major) + { + // may be I'll write an optimized version later + Backup()(a, b, c); + } + + + template <typename MatrixA, typename MatrixB, typename MatrixC> + void apply2(MatrixA const& a, MatrixB const& b, MatrixC& c, tag::row_major) + { + using namespace tag; + using traits::range_generator; + + typedef gen_tiling_smat_dmat_mult_block<1, Tiling1, Assign> block; + typedef typename Collection<MatrixA>::size_type size_type; + typedef typename Collection<MatrixC>::value_type value_type; + const value_type z= math::zero(c[0][0]); // if this are matrices we need their size + + typedef typename range_generator<row, MatrixA>::type a_cur_type; + typedef typename range_generator<nz, a_cur_type>::type a_icur_type; + + typename traits::col<MatrixA>::type col_a(a); + typename traits::const_value<MatrixA>::type value_a(a); + + if (Assign::init_to_zero) set_to_zero(c); + + size_type i_max= num_cols(b), i_block= Tiling1 * (i_max / Tiling1); + size_t bci= i_max > 1 ? &b(0, 1) - &b(0, 0) : 1; // offset of incrementing B's column if more than 1 column + + size_type rc= 0; // start in row 0 + for (a_cur_type ac= begin<row>(a), aend= end<row>(a); ac != aend; ++ac, ++rc) { + + for (size_type i= 0; i < i_block; i+= Tiling1) { + + value_type tmp00= z, tmp01= z, tmp02= z, tmp03= z, tmp04= z, + tmp05= z, tmp06= z, tmp07= z, tmp08= z, tmp09= z, + tmp10= z, tmp11= z, tmp12= z, tmp13= z, tmp14= z, tmp15= z; + + for (a_icur_type aic= begin<nz>(ac), aiend= end<nz>(ac); aic != aiend; ++aic) { + typename Collection<MatrixA>::size_type ca= col_a(*aic); // column of non-zero + typename Collection<MatrixA>::value_type va= value_a(*aic); // value of non-zero + + // Element in first vector in block to be multiplied with va; rb==ca + const typename MatrixB::value_type *begin_b= &b(ca, i); + block::apply(tmp00, tmp01, tmp02, tmp03, tmp04, tmp05, tmp06, tmp07, tmp08, tmp09, + tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, + va, begin_b, bci); + } + block::update(tmp00, tmp01, tmp02, tmp03, tmp04, tmp05, tmp06, tmp07, tmp08, tmp09, + tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, + c, rc, i); + } + + for (size_type i= i_block; i < i_max; i++) { + value_type tmp00= z; + for (a_icur_type aic= begin<nz>(ac), aiend= end<nz>(ac); aic != aiend; ++aic) { + typename Collection<MatrixA>::size_type ca= col_a(aic); // column of non-zero + tmp00+= value_a(*aic) * b(ca, i); + } + Assign::update(c(rc, i), tmp00); + } + } + } +}; + + + + +}} // namespace mtl::functor + +#endif // MTL_SMAT_DMAT_MULT_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/smat_smat_mult.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/smat_smat_mult.hpp new file mode 100644 index 0000000000000000000000000000000000000000..e4756cedb238d3e59057043dfe410ad8ace23c57 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/smat_smat_mult.hpp @@ -0,0 +1,198 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_SMAT_SMAT_MULT_INCLUDE +#define MTL_SMAT_SMAT_MULT_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/matrix/parameter.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/transposed_matrix_type.hpp> +#include <boost/numeric/mtl/operation/mult_assign_mode.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { + +template <typename MatrixA, typename MatrixB, typename MatrixC, typename Assign> +inline void smat_smat_mult(const MatrixA& A, const MatrixB& B, MatrixC& C, Assign, + tag::row_major, // orientation A + tag::row_major) // orientation B +{ + if (Assign::init_to_zero) set_to_zero(C); + + // Average numbers of non-zeros per row + double ava= num_cols(A) ? double(A.nnz()) / num_cols(A) : 0, + avb= num_rows(B) ? double(B.nnz()) / num_rows(B) : 0; + + // Define Updater type corresponding to assign mode + typedef typename Collection<MatrixC>::value_type C_value_type; + typedef typename operations::update_assign_mode<Assign, C_value_type>::type Updater; + + // Reserve 20% over the average's product for entries in C + matrix::inserter<MatrixC, Updater> ins(C, int( ava * avb * 1.4 )); + + typename traits::row<MatrixA>::type row_A(A); + typename traits::col<MatrixA>::type col_A(A); + typename traits::const_value<MatrixA>::type value_A(A); + + typename traits::col<MatrixB>::type col_B(B); + typename traits::const_value<MatrixB>::type value_B(B); + + typedef typename traits::range_generator<tag::row, MatrixA>::type cursor_type; + cursor_type cursor = begin<tag::row>(A), cend = end<tag::row>(A); + for (unsigned ra= 0; cursor != cend; ++ra, ++cursor) { + // Iterate over non-zeros of each row of A + typedef typename traits::range_generator<tag::nz, cursor_type>::type icursor_type; + for (icursor_type icursor = begin<tag::nz>(cursor), icend = end<tag::nz>(cursor); icursor != icend; ++icursor) { + typename Collection<MatrixA>::size_type ca= col_A(*icursor); // column of non-zero + typename Collection<MatrixA>::value_type va= value_A(*icursor); // value of non-zero + + // Get cursor corresponding to row 'ca' in matrix B + typedef typename traits::range_generator<tag::row, MatrixB>::type B_cursor_type; + B_cursor_type B_cursor = begin<tag::row>(B); + B_cursor+= ca; + + // Iterate over non-zeros of this row + typedef typename traits::range_generator<tag::nz, B_cursor_type>::type ib_cursor_type; + for (ib_cursor_type ib_cursor = begin<tag::nz>(B_cursor), ib_cend = end<tag::nz>(B_cursor); + ib_cursor != ib_cend; ++ib_cursor) { + typename Collection<MatrixB>::size_type cb= col_B(*ib_cursor); // column of non-zero + typename Collection<MatrixB>::value_type vb= value_B(*ib_cursor); // value of non-zero + ins(ra, cb) << va * vb; + } + } + } +} + +template <typename MatrixA, typename MatrixB, typename MatrixC, typename Assign> +inline void smat_smat_mult(const MatrixA& A, const MatrixB& B, MatrixC& C, Assign, + tag::col_major, // orientation A + tag::col_major) // orientation B +{ + if (Assign::init_to_zero) set_to_zero(C); + + // Average numbers of non-zeros per column + double ava= double(A.nnz()) / num_cols(A), avb= double(B.nnz()) / num_cols(B); + + // Define Updater type corresponding to assign mode + typedef typename Collection<MatrixC>::value_type C_value_type; + typedef typename operations::update_assign_mode<Assign, C_value_type>::type Updater; + + // Reserve 20% over the average's product for entries in C + matrix::inserter<MatrixC, Updater> ins(C, int( ava * avb * 1.2 )); + + typename traits::row<MatrixA>::type row_A(A); + typename traits::col<MatrixA>::type col_A(A); + typename traits::const_value<MatrixA>::type value_A(A); + + typename traits::row<MatrixB>::type row_B(B); + typename traits::col<MatrixB>::type col_B(B); + typename traits::const_value<MatrixB>::type value_B(B); + + typedef typename traits::range_generator<tag::col, MatrixB>::type cursor_type; + cursor_type cursor = begin<tag::col>(B), cend = end<tag::col>(B); + for (unsigned cb= 0; cursor != cend; ++cb, ++cursor) { + // Iterate over non-zeros of each column of B + typedef typename traits::range_generator<tag::nz, cursor_type>::type icursor_type; + for (icursor_type icursor = begin<tag::nz>(cursor), icend = end<tag::nz>(cursor); icursor != icend; ++icursor) { + typename Collection<MatrixB>::size_type rb= row_B(*icursor); // row of non-zero + typename Collection<MatrixB>::value_type vb= value_B(*icursor); // value of non-zero + + // Get cursor corresponding to column 'rb' in matrix A + typedef typename traits::range_generator<tag::col, MatrixA>::type A_cursor_type; + A_cursor_type A_cursor = begin<tag::col>(A); + A_cursor+= rb; + + // Iterate over non-zeros of this column + typedef typename traits::range_generator<tag::nz, A_cursor_type>::type ia_cursor_type; + for (ia_cursor_type ia_cursor = begin<tag::nz>(A_cursor), ia_cend = end<tag::nz>(A_cursor); + ia_cursor != ia_cend; ++ia_cursor) { + typename Collection<MatrixA>::size_type ra= row_A(*ia_cursor); // row of non-zero + typename Collection<MatrixA>::value_type va= value_A(*ia_cursor); // value of non-zero + ins(ra, cb) << va * vb; + } + } + } +} + + +template <typename MatrixA, typename MatrixB, typename MatrixC, typename Assign> +inline void smat_smat_mult(const MatrixA& A, const MatrixB& B, MatrixC& C, Assign, + tag::col_major, // orientation A + tag::row_major) // orientation B +{ + if (Assign::init_to_zero) set_to_zero(C); + + // Average numbers of non-zeros per row + double ava= double(A.nnz()) / num_rows(A), avb= double(B.nnz()) / num_rows(B); + + // Define Updater type corresponding to assign mode + typedef typename Collection<MatrixC>::value_type C_value_type; + typedef typename operations::update_assign_mode<Assign, C_value_type>::type Updater; + + // Reserve 20% over the average's product for entries in C + matrix::inserter<MatrixC, Updater> ins(C, int( ava * avb * 1.2 )); + + typename traits::row<MatrixA>::type row_A(A); + typename traits::col<MatrixA>::type col_A(A); + typename traits::const_value<MatrixA>::type value_A(A); + + typename traits::row<MatrixB>::type row_B(B); + typename traits::col<MatrixB>::type col_B(B); + typename traits::const_value<MatrixB>::type value_B(B); + + typedef typename traits::range_generator<tag::col, MatrixA>::type A_cursor_type; + A_cursor_type A_cursor = begin<tag::col>(A), A_cend = end<tag::col>(A); + + typedef typename traits::range_generator<tag::row, MatrixB>::type B_cursor_type; + B_cursor_type B_cursor = begin<tag::row>(B); + + for (unsigned ca= 0; A_cursor != A_cend; ++ca, ++A_cursor, ++B_cursor) { + + // Iterate over non-zeros of A's column + typedef typename traits::range_generator<tag::nz, A_cursor_type>::type ia_cursor_type; + for (ia_cursor_type ia_cursor = begin<tag::nz>(A_cursor), ia_cend = end<tag::nz>(A_cursor); + ia_cursor != ia_cend; ++ia_cursor) + { + typename Collection<MatrixA>::size_type ra= row_A(*ia_cursor); // row of non-zero + typename Collection<MatrixA>::value_type va= value_A(*ia_cursor); // value of non-zero + + // Iterate over non-zeros of B's row + typedef typename traits::range_generator<tag::nz, B_cursor_type>::type ib_cursor_type; + for (ib_cursor_type ib_cursor = begin<tag::nz>(B_cursor), ib_cend = end<tag::nz>(B_cursor); + ib_cursor != ib_cend; ++ib_cursor) + { + typename Collection<MatrixB>::size_type cb= col_B(*ib_cursor); // column of non-zero + typename Collection<MatrixB>::value_type vb= value_B(*ib_cursor); // value of non-zero + ins(ra, cb) << va * vb; + } + } + } +} + + +template <typename MatrixA, typename MatrixB, typename MatrixC, typename Assign> +inline void smat_smat_mult(const MatrixA& A, const MatrixB& B, MatrixC& C, Assign, + tag::row_major, // orientation A + tag::col_major) // orientation B +{ + vampir_trace<4020> tracer; + // Copy B into a sparse row-major matrix + typename mtl::traits::transposed_sparse_matrix_type<MatrixB>::type B_copy(num_rows(B), num_cols(B)); + B_copy= B; + smat_smat_mult(A, B_copy, C, Assign(), tag::row_major(), tag::row_major()); +} + +} // namespace mtl + +#endif // MTL_SMAT_SMAT_MULT_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/solve.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/solve.hpp new file mode 100644 index 0000000000000000000000000000000000000000..ede889b83a54fdf7a008950d70df32df1179f820 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/solve.hpp @@ -0,0 +1,55 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_SOLVE_INCLUDE +#define MTL_MATRIX_SOLVE_INCLUDE + +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/operation/lu.hpp> +#include <boost/numeric/mtl/interface/umfpack_solve.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace mtl { namespace matrix { + + namespace detail { + + template <typename Matrix, typename Vector> + Vector inline solve(const Matrix& A, const Vector& b, tag::dense) + { + vampir_trace<3034> tracer; + return lu_solve(A, b); + } + +# ifdef MTL_HAS_UMFPACK + template <typename Value, typename Parameters, typename Vector> + Vector inline solve(const Matrix& A, const Vector& b, tag::compressed2D) + { + vampir_trace<3035> tracer; + Vector x(num_cols(A)); + umfpack_solve(A, x, b); + return x; + } +# endif + } + + +template <typename Matrix, typename Vector> +Vector inline solve(const Matrix& A, const Vector& b) +{ + return detail::solve(A, b, typename category<Coll>::type()); +} + +}} // namespace mtl::matrix + +#endif // MTL_MATRIX_SOLVE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/sort.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/sort.hpp new file mode 100644 index 0000000000000000000000000000000000000000..6a115b0f55708a6f76b965a6d3910483a3a7d860 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/sort.hpp @@ -0,0 +1,204 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_SORT_INCLUDE +#define MTL_SORT_INCLUDE + +#include <algorithm> +#include <boost/numeric/mtl/interface/vpt.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/operation/swap_row.hpp> +#include <boost/numeric/mtl/operation/size.hpp> + +namespace mtl { namespace vector { + +/// sort vector +template <typename Vector> +void inline sort(Vector& x) +{ + std::sort(x.begin(), x.end()); +} + +/// sort vector with qicksort from lo to hi +template <typename Vector> +void quicksort (Vector& a, typename Collection<Vector>::size_type lo, typename Collection<Vector>::size_type hi) +{ + vampir_trace<2032> tracer; + typename Collection<Vector>::size_type i=lo, j=hi; + + // VergleichsÂÂelement x + typename mtl::Collection<Vector>::value_type x=a[(lo+hi)/2]; + // Aufteilung + while (i<=j) + { + while (a[i]<x) i++; + while (a[j]>x) j--; + if (i<=j) + { + swap_row(a, i, j); + i++; j--; + } + } + // Recursion + if (lo<j) quicksort(a, lo, j); + if (i<hi) quicksort(a, i, hi); + std::cout<< "a=" << a << "\n"; +} + +/// sort vector and permutaion with qicksort from lo to hi +template <typename Vector, typename PermVec> +void quicksort (Vector& a, PermVec& p, typename Collection<Vector>::size_type lo, typename Collection<Vector>::size_type hi) +{ + vampir_trace<2033> tracer; + typename Collection<Vector>::size_type i=lo, j=hi; + + // VergleichsÂÂelement x + typename mtl::Collection<Vector>::value_type x=a[(lo+hi)/2]; +// std::cout<< "x=" << x << "\n"; + // Aufteilung + while (i<=j) + { + while (a[i]<x) i++; + while (a[j]>x) j--; + + if (i<=j) + { + swap_row(a, i, j); + swap_row(p, i, j); +// std::cout<< "a=" << a <<"\n"; + i++; + if( j == 0){ + break; + } else { + j--; + } + +// std::cout<< "i=" << i << "\n"; +// std::cout<< "j=" << j << "\n"; + } +// std::cout<< "j=" << j << "\n"; + } +// std::cout<< "aai=" << i << "\n"; +// std::cout<< "aaj=" << j << "\n"; +// std::cout<< "lo=" << lo << "\n"; +// std::cout<< "hi=" << hi << "\n"; + // Recursion + if (lo<j) quicksort(a, p, lo, j); + if (i<hi) quicksort(a, p, i, hi); + + + +} + +template <typename Vector, typename PermVec> +void quicksort (Vector& a, Vector& b, PermVec& p, typename Collection<Vector>::size_type lo, typename Collection<Vector>::size_type hi) +{ + using vector::swap_row; + typename Collection<Vector>::size_type i= lo, j= hi; + + // VergleichsÂÂelement x + typename mtl::Collection<Vector>::value_type x= a[(lo+hi)/2]; +// std::cout<< "x=" << x << "\n"; + // Aufteilung + while (i<=j) + { + while (a[i]<x) i++; + while (a[j]>x) j--; + + if (i<=j) + { + swap_row(a, i, j); + swap_row(b, i, j); + swap_row(p, i, j); + i++; + if( j == 0){ + break; + } else { + j--; + } + } + } + // Recursion + if (lo<j) quicksort(a, b, p, lo, j); + if (i<hi) quicksort(a, b, p, i, hi); +} + +template <typename Vector, typename PermVec> +void quicksort_xy(Vector& a, Vector& b, PermVec& p, typename Collection<Vector>::size_type lo, + typename Collection<Vector>::size_type hi) +{ + using vector::swap_row; + typename Collection<Vector>::size_type i= lo, j= hi; + // pivot element (x, y) + typename mtl::Collection<Vector>::value_type x= a[(lo+hi)/2], y= b[(lo+hi)/2]; + + while (i<=j) { + while (a[i] < x || (a[i] == x && b[i] < y)) i++; + while (a[j] > x || (a[j] == x && b[j] > y)) j--; + + if (i <= j) { + swap_row(a, i, j); + swap_row(b, i, j); + swap_row(p, i, j); + i++; + if (j == 0) + break; + else + j--; + } + } + // Recursion + if (lo < j) quicksort_xy(a, b, p, lo, j); + if (i < hi) quicksort_xy(a, b, p, i, hi); +} + + + +/// sort vector with permutation +template <typename Vector, typename PermVec> +void inline sort(Vector& x, PermVec& p) +{ +// std::cout<< "x=" << x << "\n"; +// std::cout<< "p=" << p << "\n"; + using mtl::size; + assert(size(x) == size(p)); + quicksort(x, p, 0, size(x)-1); + +} + +/// Sort 2 vectors with permutation +template <typename Vector, typename PermVec> +void inline sort(Vector& x, Vector& y, PermVec& p) +{ +// std::cout<< "x=" << x << "\n"; +// std::cout<< "p=" << p << "\n"; + using mtl::size; + assert(size(x) == size(p)); + assert(size(x) == size(y)); + quicksort(x, y, p, 0, size(x)-1); +} + +/// Sort 3 vectors lexicographically after values in x and y +template <typename Vector, typename PermVec> +void inline sort_xy(Vector& x, Vector& y, PermVec& z) +{ + using mtl::size; + assert(size(x) == size(z)); + assert(size(x) == size(y)); + quicksort_xy(x, y, z, 0, size(x)-1); +} + + + +}} // namespace mtl::vector + +#endif // MTL_SORT_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/split_complex_matrix.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/split_complex_matrix.hpp new file mode 100644 index 0000000000000000000000000000000000000000..ca6c2f6d1f66c055f6cd53528cb25de5961e79a6 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/split_complex_matrix.hpp @@ -0,0 +1,40 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_SPLIT_COMPLEX_MATRIX_INCLUDE +#define MTL_MATRIX_SPLIT_COMPLEX_MATRIX_INCLUDE + +#if 0 // Do we really need this??? + +namespace mtl { namespace matrix { + +// Split one complex-valued matrix into two real-valued matrices. +/* Elements of the real matrix must be assignable from the real and imaginary part of the complex elements. + Real matrices are resized if their size is 0 otherwise the matrices must have + the same dimension. **/ +template <typename MatrixComplex, typename MatrixReal, typename MatrixImaginary> +inline void split_complex_matrix(const MatrixComplex& c, MatrixReal& r, MatrixImaginary& i) +{ + r.checked_change_dim(num_rows(c), num_cols(c)); + i.checked_change_dim(num_rows(c), num_cols(c)); + + c= + + +} + + +}} // namespace mtl::matrix + +#endif + +#endif // MTL_MATRIX_SPLIT_COMPLEX_MATRIX_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/split_complex_vector.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/split_complex_vector.hpp new file mode 100644 index 0000000000000000000000000000000000000000..93e63d5556d5145ec64b38963e529ce548e32685 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/split_complex_vector.hpp @@ -0,0 +1,46 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_VECTOR_SPLIT_COMPLEX_VECTOR_INCLUDE +#define MTL_VECTOR_SPLIT_COMPLEX_VECTOR_INCLUDE + +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/operation/size.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { namespace vector { + +/// Split one complex-valued vector into two real-valued vectors. +/** Elements of the real vector must be assignable from the real and imaginary part of the complex elements. + Real vectors are resized if their size is 0 otherwise the vectors must have + the same length. **/ +template <typename VectorComplex, typename VectorReal, typename VectorImaginary> +inline void split_complex_vector(const VectorComplex& c, VectorReal& r, VectorImaginary& i) +{ + using mtl::size; + using mtl::real; + using mtl::imag; + + vampir_trace<2034> tracer; + r.checked_change_dim(size(c)); + i.checked_change_dim(size(c)); + + for (std::size_t j= 0; j < size(c); ++j) + r[j]= real(c[j]), + i[j]= imag(c[j]); +} + +}} // namespace mtl::vector + +#endif // MTL_VECTOR_SPLIT_COMPLEX_VECTOR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/squared_abs.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/squared_abs.hpp new file mode 100644 index 0000000000000000000000000000000000000000..64f0e66bda2eb768685a02247ecacf6c5d284f49 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/squared_abs.hpp @@ -0,0 +1,59 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_SQUARED_ABS_INCLUDE +#define MTL_SQUARED_ABS_INCLUDE + +#include <cmath> +#include <complex> +#include <boost/mpl/or.hpp> +#include <boost/utility/enable_if.hpp> +#include <boost/type_traits/is_floating_point.hpp> +#include <boost/type_traits/is_integral.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { + +/// When squaring magnitudes of intrinsic types the abs can be omitted +template <typename T> +typename boost::enable_if<boost::mpl::or_<boost::is_integral<T>, boost::is_floating_point<T> >, T>::type +inline squared_abs(const T& x) +{ + vampir_trace<10> tracer; + return x * x; +} + +/// Squaring complex numbers can be computed without square root +template <typename T> +T inline squared_abs(const std::complex<T>& z) +{ + vampir_trace<11> tracer; + using std::norm; + return norm(z); +} + +/// When squaring magnitudes of non-intrinsic and non-complex types we use abs for security +template <typename T> +typename boost::disable_if<boost::mpl::or_<boost::is_integral<T>, boost::is_floating_point<T> >, T>::type +inline squared_abs(const T& x) +{ + vampir_trace<12> tracer; + using std::abs; + T a= abs(x); + return a * a; +} + + +} // namespace mtl + +#endif // MTL_SQUARED_ABS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/static_num_cols.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/static_num_cols.hpp new file mode 100644 index 0000000000000000000000000000000000000000..6feafe7000ff3e6adbab6916d4582bc7e90808e7 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/static_num_cols.hpp @@ -0,0 +1,89 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_STATIC_NUM_COLS_INCLUDE +#define MTL_STATIC_NUM_COLS_INCLUDE + +#include <boost/mpl/bool.hpp> +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/utility/is_row_major.hpp> +#include <boost/numeric/mtl/matrix/dimension.hpp> +#include <boost/numeric/mtl/vector/dimension.hpp> + +namespace mtl { + +/// Number of columns given at compile time +/** General declaration, used to disable unsupported types **/ +template <typename Collection> +struct static_num_cols { + // typedef xxx type; + // static const type value= yyy; +}; + + +/// static_num_cols implementation for (1D) arrays interpreted as vectors +template <typename Value, unsigned Size> +struct static_num_cols<Value[Size]> +{ + typedef std::size_t type; + static const type value= 1; +}; + +/// static_num_cols implementation for (2D and higher) arrays interpreted as matrices +template <typename Value, unsigned Rows, unsigned Cols> +struct static_num_cols<Value[Rows][Cols]> +{ + typedef std::size_t type; + static const type value= Cols; +}; + + +template <std::size_t Size> +struct static_num_cols< vector::fixed::dimension<Size> > +{ + typedef std::size_t type; + static const type value= Size; +}; + +template <typename V, typename P> +struct static_num_cols<mtl::vector::dense_vector<V, P> > +{ + typedef std::size_t type; + static const type value= traits::is_row_major<P>::value ? static_num_cols<typename P::dimension>::value : 1; +}; + + +template <std::size_t Rows, std::size_t Cols> +struct static_num_cols< fixed::dimensions<Rows, Cols> > +{ + typedef std::size_t type; + static const type value= Cols; +}; + +template <typename V, typename P> +struct static_num_cols<mtl::matrix::dense2D<V, P> > + : static_num_cols<typename P::dimensions> +{}; + +template <typename V, std::size_t M, typename P> +struct static_num_cols<mtl::matrix::morton_dense<V, M, P> > + : static_num_cols<typename P::dimensions> +{}; + +template <typename V, typename P> +struct static_num_cols<mtl::matrix::compressed2D<V, P> > + : static_num_cols<typename P::dimensions> +{}; + +} // namespace mtl + +#endif // MTL_STATIC_NUM_COLS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/static_num_rows.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/static_num_rows.hpp new file mode 100644 index 0000000000000000000000000000000000000000..fa81865b84bbcced22f49264c5fc2043a71b3a48 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/static_num_rows.hpp @@ -0,0 +1,89 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_STATIC_NUM_ROWS_INCLUDE +#define MTL_STATIC_NUM_ROWS_INCLUDE + +#include <boost/mpl/bool.hpp> +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/utility/is_row_major.hpp> +#include <boost/numeric/mtl/matrix/dimension.hpp> +#include <boost/numeric/mtl/vector/dimension.hpp> + +namespace mtl { + +/// Number of rows given at compile time +/** General declaration, used to disable unsupported types **/ +template <typename Collection> +struct static_num_rows { + // typedef xxx type; + // static const type value= yyy; +}; + + +/// static_num_rows implementation for (1D) arrays interpreted as vectors +template <typename Value, unsigned Size> +struct static_num_rows<Value[Size]> +{ + typedef std::size_t type; + static const type value= Size; +}; + +/// static_num_rows implementation for (2D and higher) arrays interpreted as matrices +template <typename Value, unsigned Rows, unsigned Cols> +struct static_num_rows<Value[Rows][Cols]> +{ + typedef std::size_t type; + static const type value= Rows; +}; + + +template <std::size_t Size> +struct static_num_rows< vector::fixed::dimension<Size> > +{ + typedef std::size_t type; + static const type value= Size; +}; + +template <typename V, typename P> +struct static_num_rows<mtl::vector::dense_vector<V, P> > +{ + typedef std::size_t type; + static const type value= traits::is_row_major<P>::value ? 1 : static_num_rows<typename P::dimension>::value; +}; + + +template <std::size_t Rows, std::size_t Cols> +struct static_num_rows< fixed::dimensions<Rows, Cols> > +{ + typedef std::size_t type; + static const type value= Rows; +}; + +template <typename V, typename P> +struct static_num_rows<mtl::matrix::dense2D<V, P> > + : static_num_rows<typename P::dimensions> +{}; + +template <typename V, std::size_t M, typename P> +struct static_num_rows<mtl::matrix::morton_dense<V, M, P> > + : static_num_rows<typename P::dimensions> +{}; + +template <typename V, typename P> +struct static_num_rows<mtl::matrix::compressed2D<V, P> > + : static_num_rows<typename P::dimensions> +{}; + +} // namespace mtl + +#endif // MTL_STATIC_NUM_ROWS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/static_size.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/static_size.hpp new file mode 100644 index 0000000000000000000000000000000000000000..baf186c43a6462c344488c679668d2999e29e33a --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/static_size.hpp @@ -0,0 +1,33 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_STATIC_SIZE_INCLUDE +#define MTL_STATIC_SIZE_INCLUDE + +#include <boost/numeric/mtl/operation/static_num_rows.hpp> +#include <boost/numeric/mtl/operation/static_num_cols.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace mtl { + +/// Number of rows times columns given at compile time +/** General declaration, relies on static_num_rows and static_num_cols. **/ +template <typename Collection> +struct static_size { + vampir_trace<1007> tracer; + typedef typename static_num_rows<Collection>::type type; // Might not always work + static const type value= static_num_rows<Collection>::value * static_num_cols<Collection>::value; +}; + +} // namespace mtl + +#endif // MTL_STATIC_SIZE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/std_output_operator.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/std_output_operator.hpp new file mode 100644 index 0000000000000000000000000000000000000000..ad9fb6e9caa7d92524d6669913a663ec8442afc3 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/std_output_operator.hpp @@ -0,0 +1,64 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_STD_OUTPUT_OPERATOR_INCLUDE +#define MTL_STD_OUTPUT_OPERATOR_INCLUDE + +#ifdef MTL_HAS_STD_OUTPUT_OPERATOR + +#include <iostream> +#include <map> +#include <utility> +#include <vector> + +namespace std { + + /// Print standard vector + /** Only available when compiled with macro flag MTL_HAS_STD_OUTPUT_OPERATOR + to avoid (reduce) conflicts with other libraries. **/ + template <typename T, typename Alloc> + inline ostream& operator<< (ostream& os, vector<T, Alloc> const& v) + { + os << '['; + for (size_t r = 0; r < v.size(); ++r) + os << v[r] << (r < v.size() - 1 ? "," : ""); + return os << ']'; + } + + /// Print standard map + /** Only available when compiled with macro flag MTL_HAS_STD_OUTPUT_OPERATOR + to avoid (reduce) conflicts with other libraries. **/ + template <typename Key, typename Data, typename Compare, typename Alloc> + inline ostream& operator<< (ostream& os, map<Key, Data, Compare, Alloc> const& m) + { + if (m.empty()) return os << "{}"; + typedef typename map<Key, Data, Compare, Alloc>::const_iterator iter_type; + os << '{'; + for (iter_type it= m.begin(), end= m.end(); it != end; ++it) + os << it->first << ": " << it->second << ", "; + return os << "\b\b} "; + } + + /// Print standard pair + /** Only available when compiled with macro flag MTL_HAS_STD_OUTPUT_OPERATOR + to avoid (reduce) conflicts with other libraries. **/ + template <typename T, typename U> + inline ostream& operator<< (ostream& os, pair<T, U> const& p) + { + return os << '(' << p.first << ',' << p.second << ')'; + } + +} // namespace std + +#endif // MTL_HAS_STD_OUTPUT_OPERATOR + +#endif // MTL_STD_OUTPUT_OPERATOR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/sub_matrix.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/sub_matrix.hpp new file mode 100644 index 0000000000000000000000000000000000000000..6572d10b261d9971e96ee680f37e300f7aafbeb7 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/sub_matrix.hpp @@ -0,0 +1,83 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_SUBMATRIX_INCLUDE +#define MTL_SUBMATRIX_INCLUDE + +#include <cmath> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/operation/is_negative.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace mtl { namespace matrix { + +// Functor type as background for free submatrix function +template <typename Matrix> +struct sub_matrix_t +{ + // typedef *user_defined* sub_matrix_type; + // typedef *user_defined* const_sub_matrix_type; + // typedef *user_defined* size_type; + // sub_matrix_type operator()(Matrix&, size_type, size_type, size_type, size_type); + // const_sub_matrix_type operator()(Matrix const&, size_type, size_type, size_type, size_type); +}; + + namespace impl { + + template <typename Matrix> + inline void correct_sub_matrix_indices(Matrix const& matrix, + typename sub_matrix_t<Matrix>::size_type& begin_row, + typename sub_matrix_t<Matrix>::size_type& end_row, + typename sub_matrix_t<Matrix>::size_type& begin_col, + typename sub_matrix_t<Matrix>::size_type& end_col) + { + vampir_trace<3036> tracer; + using std::min; + MTL_DEBUG_THROW_IF( is_negative(begin_row) || is_negative(end_row), index_out_of_range()); + end_row= min(end_row, num_rows(matrix)); + begin_row= min(begin_row, end_row); // implies min(begin_row, num_rows(matrix)) + + MTL_DEBUG_THROW_IF( is_negative(begin_col) || is_negative(end_col), index_out_of_range()); + end_col= min(end_col, num_cols(matrix)); + begin_col= min(begin_col, end_col); // implies likewise + } + + } // namespace impl + +///Returns sub-matrix B with begin_row, end_row, begin_col, end_col from %matrix A +template <typename Matrix> +inline typename sub_matrix_t<Matrix>::sub_matrix_type +sub_matrix(Matrix& matrix, + typename sub_matrix_t<Matrix>::size_type begin_row, + typename sub_matrix_t<Matrix>::size_type end_row, + typename sub_matrix_t<Matrix>::size_type begin_col, + typename sub_matrix_t<Matrix>::size_type end_col) +{ + impl::correct_sub_matrix_indices(matrix, begin_row, end_row, begin_col, end_col); + return sub_matrix_t<Matrix>()(matrix, begin_row, end_row, begin_col, end_col); +} + +template <typename Matrix> +inline typename sub_matrix_t<Matrix>::const_sub_matrix_type +sub_matrix(Matrix const& matrix, + typename sub_matrix_t<Matrix>::size_type begin_row, + typename sub_matrix_t<Matrix>::size_type end_row, + typename sub_matrix_t<Matrix>::size_type begin_col, + typename sub_matrix_t<Matrix>::size_type end_col) +{ + impl::correct_sub_matrix_indices(matrix, begin_row, end_row, begin_col, end_col); + return sub_matrix_t<Matrix>()(matrix, begin_row, end_row, begin_col, end_col); +} + +}} // namespace mtl::matrix + +#endif // MTL_SUBMATRIX_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/sum.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/sum.hpp new file mode 100644 index 0000000000000000000000000000000000000000..152104a1ce3d20b2142ecceea33e1ebd83fab92b --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/sum.hpp @@ -0,0 +1,70 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_SUM_INCLUDE +#define MTL_SUM_INCLUDE + +#include <iostream> +#include <cmath> + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/vector/lazy_reduction.hpp> +#include <boost/numeric/mtl/vector/reduction.hpp> +#include <boost/numeric/mtl/vector/reduction_functors.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { + + namespace impl { + + // Do we really need this for matrices? + + template <unsigned long Unroll, typename Vector> + typename Collection<Vector>::value_type + inline sum(const Vector& vector, tag::vector) + { + vampir_trace<2035> tracer; + typedef typename Collection<Vector>::value_type result_type; + return vector::reduction<Unroll, vector::sum_functor, result_type>::apply(vector); + } + + } // namespace impl + +///Return sum of all %vector-entries +template <unsigned long Unroll, typename Value> +typename Collection<Value>::value_type +inline sum(const Value& value) +{ + return impl::sum<Unroll>(value, typename traits::category<Value>::type()); +} + +template <typename Value> +typename Collection<Value>::value_type +inline sum(const Value& value) +{ + return sum<8>(value); +} + +namespace vector { + template <typename Vector> + lazy_reduction<Vector, sum_functor> inline lazy_sum(const Vector& v) + { return lazy_reduction<Vector, sum_functor>(v); } +} + +using vector::lazy_sum; + +} // namespace mtl + +#endif // MTL_SUM_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/svd.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/svd.hpp new file mode 100644 index 0000000000000000000000000000000000000000..7b9ad89b7f2ac66932c00791f14bdb522a34f5e2 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/svd.hpp @@ -0,0 +1,99 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +// With contributions from Cornelius Steinhardt + +#ifndef MTL_MATRIX_SVD_INCLUDE +#define MTL_MATRIX_SVD_INCLUDE + +#include <cmath> +#include <limits> +#include <algorithm> +#include <boost/numeric/mtl/matrix/strict_upper.hpp> +#include <boost/numeric/mtl/operation/diagonal.hpp> +#include <boost/numeric/mtl/operation/one_norm.hpp> +#include <boost/numeric/mtl/operation/sub_matrix.hpp> +#include <boost/numeric/mtl/operation/trans.hpp> +#include <boost/numeric/mtl/operation/two_norm.hpp> +#include <boost/tuple/tuple.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace mtl { namespace matrix { + +/// Returns A=S*V*D' for matrix A as references +template <typename Matrix> +inline void svd(const Matrix& A, Matrix& S, Matrix& V, Matrix& D, double tol= 10e-10) +{ + vampir_trace<3037> tracer; + typedef typename Collection<Matrix>::value_type value_type; + typedef typename Collection<Matrix>::size_type size_type; + size_type ncols= num_cols(A), nrows= num_rows(A), loops, col= ncols, row= nrows; + value_type ref, zero= math::zero(ref), one= math::one(ref); + double err(std::numeric_limits<double>::max()), e, f; + + if (nrows != ncols) // important for right dimension + std::swap(row, col); + + //init + Matrix Q(row,row), R(row,col), VT(row,col), E(row,col), + QT(col,col), RT(col,row); + + loops= 100 * std::max(nrows,ncols); + S= one; D= one; E= zero; + for (size_type i= 0; err > tol && i < loops; ++i) { + boost::tie(QT, RT)= qr(V); + S*= QT; + VT= trans(RT); + boost::tie(Q, R)= qr(VT); + D*= Q; + E= triu(R,1); + V= trans(R); + + //ready for exit when upper(R)=0 + f= two_norm(diagonal(R)); + e= one_norm(E); + if ( f== zero ) f= 1; + err= e/f; + } //end for + + V= 0; + mtl::matrix::inserter<Matrix> ins_V(V); + mtl::matrix::inserter<Matrix, mtl::operations::update_times<value_type> > ins_S(S); + + for (size_type i= 0, end= std::min(nrows, ncols); i < end; i++) { + ins_V[i][i] << std::abs(R[i][i]); + if (R[i][i] < zero) + for (size_type j= 0; j < nrows; j++) + ins_S[j][i] << -1; //carefull changing: multiplication with minus one + } +} + +/// Returns A=S*V*D' for matrix A as triplet +template <typename Matrix> +boost::tuple<Matrix, Matrix, Matrix > +inline svd(const Matrix& A, double tol= 10e-10) +{ + vampir_trace<3038> tracer; + typedef typename Collection<Matrix>::size_type size_type; + size_type ncols= num_cols(A), nrows= num_rows(A), col= ncols, row= nrows; + if (nrows != ncols) // important for right dimension + std::swap(row, col); + + Matrix ST(col,col), V(A), D(row,row); + svd(A, ST, V, D, tol); + return boost::make_tuple(ST, V, D); +} + + +}} // namespace mtl::matrix + +#endif // MTL_MATRIX_SVD_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/swap_row.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/swap_row.hpp new file mode 100644 index 0000000000000000000000000000000000000000..4afe19829b1334036dd589222190d41be644bd82 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/swap_row.hpp @@ -0,0 +1,91 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_SWAP_ROW +#define MTL_MATRIX_SWAP_ROW + +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/is_row_major.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/utility/enable_if.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { + +namespace matrix { + + namespace detail { + + template <typename Matrix, typename Orientation> + inline void swap_row(Matrix& A, typename Collection<Matrix>::size_type i, + typename Collection<Matrix>::size_type j, tag::dense, Orientation) + { + // swap(A[irange(i,i+1)][iall], A[irange(j,j+1)][iall]; + using std::swap; + for (typename Collection<Matrix>::size_type k= 0; k < num_cols(A); k++) + swap(A[i][k], A[j][k]); + } + + template <typename Matrix> + inline void swap_row(Matrix&, typename Collection<Matrix>::size_type, + typename Collection<Matrix>::size_type, tag::sparse, boost::mpl::true_) + { + MTL_THROW(logic_error("This is not implemented yet.")); + } + + template <typename Matrix> + inline void swap_row(Matrix&, typename Collection<Matrix>::size_type, + typename Collection<Matrix>::size_type, tag::sparse, boost::mpl::false_) + { + MTL_THROW(logic_error("This is an ugly operation and not implemented yet.")); + } + + } + ///Row i and j are swapped in %matrix A + template <typename Matrix> + typename mtl::traits::enable_if_matrix<Matrix>::type + inline swap_row(Matrix& A, typename Collection<Matrix>::size_type i, + typename Collection<Matrix>::size_type j) + { + vampir_trace<3039> tracer; + if (i == j) return; + detail::swap_row(A, i, j, typename mtl::traits::category<Matrix>::type(), + mtl::traits::is_row_major<Matrix>()); + } + +} // namespace matrix + + +namespace vector { + ///Entry i and j are swapped in %vector v + template <typename Vector> + typename mtl::traits::enable_if_vector<Vector>::type + inline swap_row(Vector& v, typename Collection<Vector>::size_type i, + typename Collection<Vector>::size_type j) + { + vampir_trace<236> tracer; + using std::swap; + if (i == j) return; + swap(v[i], v[j]); + } + +} // vector + +using matrix::swap_row; +using vector::swap_row; + +} // namespace mtl + +#endif // MTL_MATRIX_SWAP_ROW diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/tfunctor.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/tfunctor.hpp new file mode 100644 index 0000000000000000000000000000000000000000..dcb3602c24b1afaacfe837eb2b2ad633318e3424 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/tfunctor.hpp @@ -0,0 +1,21 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_TFUNCTOR_INCLUDE +#define MTL_TFUNCTOR_INCLUDE + +#include <boost/numeric/mtl/operation/scale.hpp> +#include <boost/numeric/mtl/operation/rscale.hpp> // added by Hui Li +#include <boost/numeric/mtl/operation/divide_by.hpp> // added by Hui Li +#include <boost/numeric/mtl/operation/tfunctor_mixed.hpp> + +#endif // MTL_TFUNCTOR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/tfunctor_mixed.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/tfunctor_mixed.hpp new file mode 100644 index 0000000000000000000000000000000000000000..7cf836f46a86164aac2f8da0bc11e13f951523b9 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/tfunctor_mixed.hpp @@ -0,0 +1,154 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_TFUNCTOR_TFUNCTOR_MIXED_INCLUDE +#define MTL_TFUNCTOR_TFUNCTOR_MIXED_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/concept/std_concept.hpp> + +namespace mtl { namespace tfunctor { + +// Currently we define only scalar concepts +// Eventually this will be expanded like "scale" + +/// Plus functor that stores left summand +template <typename Value1, typename Value2> +struct left_plus +{ + typedef typename Addable<Value1, Value2>::result_type result_type; + explicit left_plus(const Value1& v1) : v1(v1) {} + + result_type operator() (const Value2& v2) const + { + return v1 + v2; + } +private: + Value1 v1; +}; + +/// Plus functor that stores right summand +template <typename Value1, typename Value2> +struct right_plus +{ + typedef typename Addable<Value1, Value2>::result_type result_type; + explicit right_plus(const Value2& v2) : v2(v2) {} + + result_type operator() (const Value1& v1) const + { + return v1 + v2; + } +private: + Value2 v2; +}; + +/// Minus functor that stores left summand +template <typename Value1, typename Value2> +struct left_minus +{ + typedef typename Subtractable<Value1, Value2>::result_type result_type; + explicit left_minus(const Value1& v1) : v1(v1) {} + + result_type operator() (const Value2& v2) const + { + return v1 - v2; + } +private: + Value1 v1; +}; + +/// Minus functor that stores right summand +template <typename Value1, typename Value2> +struct right_minus +{ + typedef typename Subtractable<Value1, Value2>::result_type result_type; + explicit right_minus(const Value2& v2) : v2(v2) {} + + result_type operator() (const Value1& v1) const + { + return v1 - v2; + } +private: + Value2 v2; +}; + +/// Minimum functor that stores left operand +/** Result type is right operand. + This way the min of a scalar and a vector keeps the vector type. **/ +template <typename Value1, typename Value2> +struct left_min +{ + typedef Value2 result_type; + explicit left_min(const Value1& v1) : v1(v1) {} + + result_type operator() (const Value2& v2) const + { + return v1 < v2 ? Value2(v1) : v2; + } +private: + Value1 v1; +}; + +/// Minimum functor that stores right operand +/** Result type is left operand. + This way the min of a vector and a scalar keeps the vector type. **/ +template <typename Value1, typename Value2> +struct right_min +{ + typedef Value1 result_type; + explicit right_min(const Value2& v2) : v2(v2) {} + + result_type operator() (const Value1& v1) const + { + return v1 < v2 ? v1 : Value1(v2); + } +private: + Value2 v2; +}; + +/// Maximum functor that stores left operand +/** Result type is right operand. + This way the max of a scalar and a vector keeps the vector type. **/ +template <typename Value1, typename Value2> +struct left_max +{ + typedef Value2 result_type; + explicit left_max(const Value1& v1) : v1(v1) {} + + result_type operator() (const Value2& v2) const + { + return v1 < v2 ? v2 : Value2(v1); + } +private: + Value1 v1; +}; + +/// Maximum functor that stores right operand +/** Result type is left operand. + This way the max of a vector and a scalar keeps the vector type. **/ +template <typename Value1, typename Value2> +struct right_max +{ + typedef Value1 result_type; + explicit right_max(const Value2& v2) : v2(v2) {} + + result_type operator() (const Value1& v1) const + { + return v1 < v2 ? Value1(v2) : v1; + } +private: + Value2 v2; +}; + +}} // namespace mtl::tfunctor + +#endif // MTL_TFUNCTOR_TFUNCTOR_MIXED_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/trace.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/trace.hpp new file mode 100644 index 0000000000000000000000000000000000000000..0a1703b573074068205d7bf8fd3d2987cfb96461 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/trace.hpp @@ -0,0 +1,50 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_TRACE_INCLUDE +#define MTL_TRACE_INCLUDE + +#include <boost/numeric/linear_algebra/identity.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace mtl { namespace matrix { + +template <typename Matrix> +typename Collection<Matrix>::value_type +inline trace(const Matrix& matrix) +{ + vampir_trace<3040> tracer; + using math::zero; + typedef typename Collection<Matrix>::value_type value_type; + + MTL_THROW_IF(num_rows(matrix) != num_cols(matrix), matrix_not_square()); + + // If matrix is empty then the result is the identity from the default-constructed value + if (num_rows(matrix) == 0) { + value_type ref; + return zero(ref); + } + + value_type value= matrix[0][0]; + for (unsigned i= 1; i < num_rows(matrix); i++) + value+= matrix[i][i]; + return value; +} + + +}} // namespace mtl::matrix + +#endif // MTL_TRACE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/trans.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/trans.hpp new file mode 100644 index 0000000000000000000000000000000000000000..ee9f3ff5b760a3f4c20f41f0882ee1fd86e67aa6 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/trans.hpp @@ -0,0 +1,124 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_TRANS_INCLUDE +#define MTL_TRANS_INCLUDE + +#include <boost/mpl/if.hpp> + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/utility/algebraic_category.hpp> +#include <boost/numeric/mtl/utility/transposed_orientation.hpp> +#include <boost/numeric/mtl/utility/view_code.hpp> +#include <boost/numeric/mtl/utility/viewed_collection.hpp> +#include <boost/numeric/mtl/utility/compose_view.hpp> +#include <boost/numeric/mtl/matrix/transposed_view.hpp> +#include <boost/numeric/mtl/matrix/view_ref.hpp> +#include <boost/numeric/mtl/vector/parameter.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace mtl { + +namespace matrix { + + namespace detail { + + // General case is not defined + template <typename Value, typename AlgebraicCategory, unsigned IsConst> + struct trans {}; + + template <typename Matrix, unsigned IsConst> + struct trans<Matrix, tag::matrix, IsConst> + { + static const unsigned code= (mtl::traits::view_code<Matrix>::value | IsConst) ^ 4; + typedef typename mtl::traits::compose_view<code, typename mtl::traits::viewed_collection<Matrix>::type>::type result_type; + + typedef typename boost::mpl::if_c<(IsConst == 1), const Matrix&, Matrix&>::type ref_type; + + static inline result_type apply(ref_type matrix) + { + return result_type(view_ref(matrix)); + } + }; + + } // namespace detail + + + template <typename Value> + typename detail::trans<Value, typename mtl::traits::algebraic_category<Value>::type, 1>::result_type + inline trans(const Value& v) + { + vampir_trace<3041> tracer; + return detail::trans<Value, typename mtl::traits::algebraic_category<Value>::type, 1>::apply(v); + } + + template <typename Value> + typename detail::trans<Value, typename mtl::traits::algebraic_category<Value>::type, 0>::result_type + inline trans(Value& v) + { + vampir_trace<3042> tracer; + return detail::trans<Value, typename mtl::traits::algebraic_category<Value>::type, 0>::apply(v); + } + +} // namespace mtl::matrix + + +namespace vector { + + template <typename Vector> + struct transposed_vector {}; + + template <typename Parameters> + struct transposed_parameters + { + typedef typename mtl::traits::transposed_orientation<typename Parameters::orientation>::type orientation; // switch + typedef parameters<orientation, typename Parameters::dimension, false, typename Parameters::size_type> type; // not on stack!!! + }; + + template <typename Value, typename Parameters> + struct transposed_vector<dense_vector<Value, Parameters> > + { + typedef dense_vector<Value, typename transposed_parameters<Parameters>::type> type; + }; + + template <typename Value, typename Parameters> + struct transposed_vector<strided_vector_ref<Value, Parameters> > + { + typedef strided_vector_ref<Value, typename transposed_parameters<Parameters>::type> type; + }; + +///Returns tranposed view of %vector v + template <typename Vector> + typename transposed_vector<Vector>::type const + inline trans(const Vector& v) + { + vampir_trace<2037> tracer; + typedef typename transposed_vector<Vector>::type type; + return type(size(v), &const_cast<Vector&>(v)[0]); + } + + template <typename Vector> + typename transposed_vector<Vector>::type + inline trans(Vector& v) + { + vampir_trace<2038> tracer; + typedef typename transposed_vector<Vector>::type type; + return type(size(v), &v[0]); + } +} + +} // mtl + + +#endif // MTL_TRANS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/two_norm.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/two_norm.hpp new file mode 100644 index 0000000000000000000000000000000000000000..b9cf7206a4acb33c876768b762a5dcc8fd9dc550 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/two_norm.hpp @@ -0,0 +1,73 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_TWO_NORM_INCLUDE +#define MTL_TWO_NORM_INCLUDE + +#include <iostream> +#include <cmath> + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/concept/magnitude.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/vector/lazy_reduction.hpp> +#include <boost/numeric/mtl/vector/reduction.hpp> +#include <boost/numeric/mtl/vector/reduction_functors.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { + + namespace vector { + + template <unsigned long Unroll, typename Value> + typename RealMagnitude<typename Collection<Value>::value_type>::type + inline two_norm(const Value& value) + { + using std::sqrt; + vampir_trace<2039> tracer; + typedef typename RealMagnitude<typename Collection<Value>::value_type>::type result_type; + return sqrt(reduction<Unroll, two_norm_functor, result_type>::apply(value)); + } + + + /*! Two-norm for vectors: two_norm(x) \f$\rightarrow |x|_2\f$. + \retval The magnitude type of the respective value type, see Magnitude. + The norms are defined as \f$|v|_2=\sqrt{\sum_i |v_i|^2}\f$. + + Vector norms are unrolled 8-fold by default. + An n-fold unrolling can be generated with two_norm<n>(x). + The maximum for n is 8 (it might be increased later). + **/ + template <typename Value> + typename RealMagnitude<typename Collection<Value>::value_type>::type + inline two_norm(const Value& value) + { + return two_norm<4>(value); + } + + template <typename Vector> + lazy_reduction<Vector, two_norm_functor> inline lazy_two_norm(const Vector& v) + { return lazy_reduction<Vector, two_norm_functor>(v); } + + + } // namespace vector + + // two_norm for matrices not implemented (would need enable_if like one_norm) + + using vector::two_norm; + using vector::lazy_two_norm; + +} // namespace mtl + +#endif // MTL_TWO_NORM_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/unary_dot.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/unary_dot.hpp new file mode 100644 index 0000000000000000000000000000000000000000..44d83b4be9272df48d0b2fed834183cdc3a4cce8 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/unary_dot.hpp @@ -0,0 +1,75 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_UNARY_DOT_INCLUDE +#define MTL_UNARY_DOT_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/vector/lazy_reduction.hpp> +#include <boost/numeric/mtl/vector/reduction.hpp> +#include <boost/numeric/mtl/vector/reduction_functors.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { + + namespace vector { + + template <unsigned long Unroll, typename Value> + typename Collection<Value>::value_type + inline unary_dot(const Value& value) + { + vampir_trace<2041> tracer; + typedef typename Collection<Value>::value_type result_type; + return reduction<Unroll, two_norm_functor, result_type>::apply(value); + } + + /*! Dot product of a vector with itself, i.e. unary_dot(v) == dot(v, v). + + Mathematically, it is also identical with the square of the two_norm. + However, unary_dot returns the value_type of v while two_norm yields the + RealMagnitude type, thus + \code + two_norm(v) * two_norm(v) == abs(unary_dot(v)) + \endcode + Internally, the computations are performed in RealMagnitude so that + unary_dot(v) is more efficient than dot(v, v) for complex vectors. + Furthermore, when the dot product is fused with other expressions, + the arguments in dot must be different for the correct semantics of + certain fusions. + + Like vector norms, unary_dot is unrolled 8-fold by default. + An n-fold unrolling can be generated with two_norm<n>(x). + The maximum for n is 8 (it might be increased later). + **/ + template <typename Value> + typename Collection<Value>::value_type + inline unary_dot(const Value& value) + { return unary_dot<8>(value); } + + /// Lazy unary dot product + /** Used for source-to-source transformations. **/ + template <typename Vector> + lazy_reduction<Vector, unary_dot_functor> inline lazy_unary_dot(const Vector& v) + { return lazy_reduction<Vector, unary_dot_functor>(v); } + + + } // namespace vector + + using vector::unary_dot; + using vector::lazy_unary_dot; + +} // namespace mtl + +#endif // MTL_UNARY_DOT_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/unroll.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/unroll.hpp new file mode 100644 index 0000000000000000000000000000000000000000..8c7f1a6b0daa785dcace02dedfdb4b242fb3c093 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/unroll.hpp @@ -0,0 +1,44 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_UNROLL_INCLUDE +#define MTL_UNROLL_INCLUDE + +#include <boost/numeric/mtl/utility/enable_if.hpp> +#include <boost/numeric/mtl/vector/unrolled1.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { + +/// Helper function for customizing loop unrolling in expressions +/** For instance, + \code + unroll<6>(u)= v + 3. * w; + \endcode + will unroll the loop that computes + \code + u= v + 3. * w; + \endcode + with block size 6. +**/ +template <unsigned BSize, typename Coll> +typename mtl::traits::enable_if_vector<Coll, vector::unrolled1<BSize, Coll> >::type +inline unroll(Coll& v) +{ + vampir_trace<7> tracer; + return vector::unrolled1<BSize, Coll>(v); +} + +} // namespace mtl + +#endif // MTL_UNROLL_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/update.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/update.hpp new file mode 100644 index 0000000000000000000000000000000000000000..e37e1f8d0d0157b50febb4fc766e769d9b028c5b --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/update.hpp @@ -0,0 +1,289 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_UPDATE_INCLUDE +#define MTL_UPDATE_INCLUDE + +#include <boost/numeric/mtl/operation/assign_mode.hpp> +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/ashape.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { namespace operations { + +template <typename Element> +struct update_store +{ + template <typename Value> + Element& operator() (Element& x, Value const& y) + { + vampir_trace<13> tracer; + return x= y; + } + + // How to fill empty entries; typically directly with /p y + template <typename Value> + Element init(Value const& y) + { + return y; + } +}; + +template <typename Element> +struct update_plus +{ + template <typename Value> + Element& operator() (Element& x, Value const& y) + { + vampir_trace<14> tracer; + return x+= y; + } + + // How to fill empty entries; typically directly with /p y + template <typename Value> + Element init(Value const& y) + { + return y; + } +}; + +template <typename Element> +struct update_minus +{ + template <typename Value> + Element& operator() (Element& x, Value const& y) + { + vampir_trace<15> tracer; + return x-= y; + } + + // How to fill empty entries. Here the inverse of /p y is needed!!! + template <typename Value> + Element init(Value const& y) + { + return -y; + } +}; + +template <typename Element> +struct update_times +{ + template <typename Value> + Element& operator() (Element& x, Value const& y) + { + vampir_trace<16> tracer; + return x*= y; + } + + // How to fill empty entries; typically directly with /p y + template <typename Value> + Element init(Value const& y) + { + return y; + } +}; + +template <typename Element, typename MonoidOp> +struct update_adapter +{ + template <typename Value> + Element& operator() (Element& x, Value const& y) + { + vampir_trace<17> tracer; + return x= MonoidOp()(x, y); + } + + // How to fill empty entries + template <typename Value> + Element init(Value const& y) + { + return y; + } +}; + + +template <typename Inserter, typename SizeType = std::size_t> +struct update_proxy +{ + typedef update_proxy self; + typedef typename Inserter::value_type value_type; + + explicit update_proxy(Inserter& ins, SizeType row, SizeType col) + : ins(ins), row(row), col(col) {} + + template <typename Value> + self& operator<< (Value const& val) + { + vampir_trace<20> tracer; + return lshift(val, typename ashape::ashape<Value>::type()); + } + + template <typename Value> + self& operator= (Value const& val) + { + vampir_trace<21> tracer; + ins.template modify<update_store<value_type> > (row, col, val); + return *this; + } + + template <typename Value> + self& operator+= (Value const& val) + { + vampir_trace<22> tracer; + ins.template modify<update_plus<value_type> > (row, col, val); + return *this; + } + + private: + + typedef typename Inserter::matrix_type matrix_type; + typedef typename mtl::ashape::ashape<matrix_type>::type matrix_shape; + typedef typename mtl::ashape::ashape<typename matrix_type::value_type>::type value_shape; + + + // Update scalar value as before + template <typename Value> + self& lshift (Value const& val, value_shape) + { + ins.update (row, col, val); + return *this; + } + + // Update an entire matrix considered as block + template <typename MatrixSrc> + self& lshift (const MatrixSrc& src, matrix_shape) + { + namespace traits = mtl::traits; + typename traits::row<MatrixSrc>::type row(src); + typename traits::col<MatrixSrc>::type col(src); + typename traits::const_value<MatrixSrc>::type value(src); + + typedef typename traits::range_generator<tag::major, MatrixSrc>::type cursor_type; + typedef typename traits::range_generator<tag::nz, cursor_type>::type icursor_type; + + for (cursor_type cursor = begin<tag::major>(src), cend = end<tag::major>(src); cursor != cend; ++cursor) + for (icursor_type icursor = begin<tag::nz>(cursor), icend = end<tag::nz>(cursor); icursor != icend; ++icursor) + ins.update(row(*icursor) + this->row, col(*icursor) + this->col, value(*icursor)); + return *this; + } + + Inserter& ins; + SizeType row, col; +}; + +/// Compute updater that corresponds to assign_mode +template <typename Assign, typename Value> +struct update_assign_mode {}; + +template <typename Value> +struct update_assign_mode<assign::assign_sum, Value> +{ + typedef update_plus<Value> type; +}; + +template <typename Value> +struct update_assign_mode<assign::plus_sum, Value> +{ + typedef update_plus<Value> type; +}; + +template <typename Value> +struct update_assign_mode<assign::minus_sum, Value> +{ + typedef update_minus<Value> type; +}; + +} // namespace operations + +using operations::update_store; +using operations::update_plus; +using operations::update_minus; +using operations::update_times; + +} // namespace mtl + + + + + + + + + + + + + + + + + + + + +#if 0 +// inconsistent with linear_algebra/identity.hpp + +namespace math { + +// temporary hack, must go to a proper place +template <typename Element, typename MonoidOp> +struct identity {}; + +#if 0 +template <typename Element, typename MonoidOp> +struct identity< Element, mtl::operations::update_adapter< Element, MonoidOp > > + : struct identity< Element, MonoidOp > +{}; +#endif + + +template < class T > +struct identity< T, mtl::operations::update_store<T> > +{ + static const T value = 0 ; + T operator()() const { return value ; } +} ; + +template < class T > +const T identity< T, mtl::operations::update_store< T > >::value ; + + + +template < class T > +struct identity< T, mtl::operations::update_plus<T> > +{ + static const T value = 0 ; + T operator()() const { return value ; } +} ; + +template < class T > +const T identity< T, mtl::operations::update_plus< T > >::value ; + + + +template < class T > +struct identity< T, mtl::operations::update_mult<T> > +{ + static const T value = 1 ; + T operator()() const { return value ; } +} ; + +template < class T > +const T identity< T, mtl::operations::update_mult< T > >::value ; + +} +#endif + +#endif // MTL_UPDATE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operation/upper_trisolve.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/upper_trisolve.hpp new file mode 100644 index 0000000000000000000000000000000000000000..6b82e692bb9761499cfc8e5a19590d565598fb6b --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operation/upper_trisolve.hpp @@ -0,0 +1,281 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_UPPER_TRISOLVE_INCLUDE +#define MTL_UPPER_TRISOLVE_INCLUDE + +#include <boost/mpl/int.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/property_map.hpp> +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/utility/static_assert.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/operation/resource.hpp> +#include <boost/numeric/linear_algebra/identity.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { namespace matrix { + + +namespace detail { + + /// Class that implements upper trisolver + /** DiaTag can be tag::regular_diagonal, tag::unit_diagonal, or tag::inverse_diagonal. + CompactStorage means that matrix contains only upper entries (strict upper when DiaTag == unit_diagonal). \sa \ref trisolve_object **/ + template <typename Matrix, typename DiaTag, bool CompactStorage= false> + struct upper_trisolve_t + { + MTL_STATIC_ASSERT((boost::is_same<DiaTag, tag::regular_diagonal>::value + || boost::is_same<DiaTag, tag::unit_diagonal>::value + || boost::is_same<DiaTag, tag::inverse_diagonal>::value), + "DiaTag must be either tag::regular_diagonal, tag::unit_diagonal, or tag::inverse_diagonal."); + + typedef typename Collection<Matrix>::value_type value_type; + typedef typename Collection<Matrix>::size_type size_type; + typedef typename OrientedCollection<Matrix>::orientation my_orientation; + typedef typename mtl::traits::category<Matrix>::type my_category; + typedef typename mtl::traits::range_generator<tag::major, Matrix>::type a_cur_type; // row or col accordingly + typedef typename mtl::traits::range_generator<tag::nz, a_cur_type>::type a_icur_type; + + /// Construction from matrix \p A + upper_trisolve_t(const Matrix& A) : A(A), value_a(A), col_a(A), row_a(A) + { MTL_THROW_IF(num_rows(A) != num_cols(A), matrix_not_square()); } + + template <typename M, typename D, bool C> + struct generic_version + : boost::mpl::int_<mtl::traits::is_row_major<M>::value ? 1 : 2> {}; + + template <typename M, typename D, bool C> + struct version + : generic_version<M, D, C> {}; + + template <typename Value, typename Para, typename D> + struct version<compressed2D<Value, Para>, D, true> + : boost::mpl::if_<mtl::traits::is_row_major<Para>, + boost::mpl::int_<3>, + generic_version<compressed2D<Value, Para>, D, true> + >::type {}; + + /// Solve \p w = A * \p v + template <typename VectorIn, typename VectorOut> + void operator()(const VectorIn& v, VectorOut& w) const + { + apply(v, w, version<Matrix, DiaTag, CompactStorage>()); + } + + /// Solves the upper triangular matrix A with the rhs v returns the solution + template <typename Vector> + Vector operator()(const Vector& v) const + { + Vector w(resource(v)); + (*this)(v, w); + return w; + } + + private: + // Initialization for regular and inverse diagonal is the same + template <typename Cursor, typename Value> + void row_init(size_type MTL_DEBUG_ARG(r), Cursor& aic, Cursor& MTL_DEBUG_ARG(aiend), Value& dia, tag::universe_diagonal) const + { + MTL_DEBUG_THROW_IF(aic == aiend || col_a(*aic) != r, missing_diagonal()); + dia= value_a(*aic); ++aic; + } + + template <typename Cursor, typename Value> + void row_init(size_type, Cursor&, Cursor&, Value&, tag::unit_diagonal) const {} + + template <typename Value> void row_update(Value& res, Value& rr, const Value& dia, tag::regular_diagonal) const { res= rr / dia; } + template <typename Value> void row_update(Value& res, Value& rr, const Value& dia, tag::inverse_diagonal) const { res= rr * dia; } + template <typename Value> void row_update(Value& res, Value& rr, const Value& , tag::unit_diagonal) const { res= rr; } + + template <typename Tag> int dia_inc(Tag) const { return 0; } + int dia_inc(tag::unit_diagonal) const { return 1; } + + // Generic row-major + template <typename VectorIn, typename VectorOut> + void inline apply(const VectorIn& v, VectorOut& w, boost::mpl::int_<1>) const + { + // vampir_trace<5042> tracer; + using namespace tag; + typedef typename mtl::Collection<VectorOut>::value_type out_value_type; + a_cur_type ac= begin<row>(A), aend= end<row>(A); + for (size_type r= num_rows(A) - 1; ac != aend--; --r) { + a_icur_type aic= CompactStorage ? begin<nz>(aend) : lower_bound<nz>(aend, r + dia_inc(DiaTag())), + aiend= end<nz>(aend); + out_value_type rr= v[r], dia; + row_init(r, aic, aiend, dia, DiaTag()); + for (; aic != aiend; ++aic) { + MTL_DEBUG_THROW_IF(col_a(*aic) <= r, logic_error("Matrix entries must be sorted for this.")); + rr-= value_a(*aic) * w[col_a(*aic)]; + } + row_update(w[r], rr, dia, DiaTag()); + } + } + + // Generic column-major + template <typename VectorIn, typename VectorOut> + void apply(const VectorIn& v, VectorOut& w, boost::mpl::int_<2>) const + { + // vampir_trace<5043> tracer; + using namespace tag; + typedef typename mtl::Collection<VectorOut>::value_type out_value_type; + w= v; + a_cur_type ac= begin<col>(A), aend= end<col>(A); + for (size_type r= num_rows(A) - 1; ac != aend--; --r) { + a_icur_type aic= begin<nz>(aend), + aiend= CompactStorage ? end<nz>(aend) : lower_bound<nz>(aend, r + 1 - dia_inc(DiaTag())); + out_value_type rr; + col_init(r, aic, aiend, rr, w[r], DiaTag()); + + for (; aic != aiend; ++aic) { + MTL_DEBUG_THROW_IF(row_a(*aic) >= r, logic_error("Matrix entries must be sorted for this.")); + w[row_a(*aic)]-= value_a(*aic) * rr; + } + } + } + + template <typename Value> + void crs_row_init(size_type MTL_DEBUG_ARG(r), size_type& j0, size_type MTL_DEBUG_ARG(cj1), Value& dia, tag::universe_diagonal) const + { + MTL_DEBUG_THROW_IF(j0 == cj1 || A.ref_minor()[j0] != r, missing_diagonal()); + dia= A.data[j0++]; + } + template <typename Value> void crs_row_init(size_type, size_type&, size_type, Value&, tag::unit_diagonal) const {} + + // Tuning for IC_0 and similar using compressed2D row-major compact + template <typename VectorIn, typename VectorOut> + void apply(const VectorIn& v, VectorOut& w, boost::mpl::int_<3>) const + { + // vampir_trace<5046> tracer; + typedef typename mtl::Collection<VectorOut>::value_type out_value_type; + for (size_type r= num_rows(A); r-- > 0; ) { + size_type j0= A.ref_major()[r]; + const size_type cj1= A.ref_major()[r+1]; + out_value_type rr= v[r], dia; + crs_row_init(r, j0, cj1, dia, DiaTag()); + for (; j0 != cj1; ++j0) { + MTL_DEBUG_THROW_IF(A.ref_minor()[j0] <= r, logic_error("Matrix entries must be sorted for this.")); + rr-= A.data[j0] * w[A.ref_minor()[j0]]; + } + row_update(w[r], rr, dia, DiaTag()); + } + } + + template <typename Cursor, typename Value> + void col_init(size_type MTL_DEBUG_ARG(r), Cursor& MTL_DEBUG_ARG(aic), Cursor& aiend, Value& rr, Value& res, tag::regular_diagonal) const + { + MTL_DEBUG_THROW_IF(aic == aiend, missing_diagonal()); + --aiend; + MTL_DEBUG_THROW_IF(row_a(*aiend) != r, missing_diagonal()); + rr= res/= value_a(*aiend); + } + + template <typename Cursor, typename Value> + void col_init(size_type MTL_DEBUG_ARG(r), Cursor& MTL_DEBUG_ARG(aic), Cursor& aiend, Value& rr, Value& res, tag::inverse_diagonal) const + { + MTL_DEBUG_THROW_IF(aic == aiend, missing_diagonal()); + --aiend; + MTL_DEBUG_THROW_IF(row_a(*aiend) != r, missing_diagonal()); + rr= res*= value_a(*aiend); + } + + template <typename Cursor, typename Value> + void col_init(size_type, Cursor&, Cursor&, Value& rr, Value& res, tag::unit_diagonal) const + { + rr= res; + } + + + const Matrix& A; + typename mtl::traits::const_value<Matrix>::type value_a; + typename mtl::traits::col<Matrix>::type col_a; + typename mtl::traits::row<Matrix>::type row_a; + }; + +} + +/// Solves the upper triangular matrix A with the rhs v and returns the solution vector +template <typename Matrix, typename Vector> +Vector inline upper_trisolve(const Matrix& A, const Vector& v) +{ + // vampir_trace<3043> tracer; + return detail::upper_trisolve_t<Matrix, tag::regular_diagonal>(A)(v); +} + +/// Solves the upper triangular matrix A with the rhs v while solution vector w is passed as reference +template <typename Matrix, typename VectorIn, typename VectorOut> +void inline upper_trisolve(const Matrix& A, const VectorIn& v, VectorOut& w) +{ + // vampir_trace<3043> tracer; + detail::upper_trisolve_t<Matrix, tag::regular_diagonal> solver(A); // use of anonymous variable causes weird error + solver(v, w); +} + +/// Solves the upper triangular matrix A (only one's in the diagonal) with the rhs v and returns the solution vector +template <typename Matrix, typename Vector> +Vector inline unit_upper_trisolve(const Matrix& A, const Vector& v) +{ + // vampir_trace<3044> tracer; + return detail::upper_trisolve_t<Matrix, tag::unit_diagonal>(A)(v); +} + +/// Solves the upper triangular matrix A (only one's in the diagonal) with the rhs v while solution vector w is passed as reference +template <typename Matrix, typename VectorIn, typename VectorOut> +void inline unit_upper_trisolve(const Matrix& A, const VectorIn& v, VectorOut& w) +{ + // vampir_trace<3044> tracer; + detail::upper_trisolve_t<Matrix, tag::unit_diagonal> solver(A); + solver(v, w); +} + +/// Solves the upper triangular matrix A (inverse the diagonal) with the rhs v and returns the solution vector +template <typename Matrix, typename Vector> +Vector inline inverse_upper_trisolve(const Matrix& A, const Vector& v) +{ + // vampir_trace<3045> tracer; + return detail::upper_trisolve_t<Matrix, tag::inverse_diagonal>(A)(v); +} + +/// Solves the upper triangular matrix A (inverse the diagonal) with the rhs v while solution vector w is passed as reference +template <typename Matrix, typename VectorIn, typename VectorOut> +void inline inverse_upper_trisolve(const Matrix& A, const VectorIn& v, VectorOut& w) +{ + // vampir_trace<3045> tracer; + detail::upper_trisolve_t<Matrix, tag::inverse_diagonal> solver(A); + solver(v, w); +} + +/// Solves the upper triangular matrix A with the rhs v and returns the solution vector +template <typename Matrix, typename Vector, typename DiaTag> +Vector inline upper_trisolve(const Matrix& A, const Vector& v, DiaTag) +{ + // vampir_trace<3046> tracer; + return detail::upper_trisolve_t<Matrix, DiaTag>(A)(v); +} + +/// Solves the upper triangular matrix A with the rhs v while solution vector w is passed as reference +template <typename Matrix, typename VectorIn, typename VectorOut, typename DiaTag> +void inline upper_trisolve(const Matrix& A, const VectorIn& v, VectorOut& w, DiaTag) +{ + // vampir_trace<3046> tracer; + detail::upper_trisolve_t<Matrix, DiaTag> solver(A); + solver(v, w); +} + +}} // namespace mtl::matrix + +#endif // MTL_UPPER_TRISOLVE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/operations.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/operations.hpp new file mode 100644 index 0000000000000000000000000000000000000000..57e1e447bab074564cb521e59137b4d98bfb160d --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/operations.hpp @@ -0,0 +1,113 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_OPERATIONS_INCLUDE +#define MTL_OPERATIONS_INCLUDE + +#include <boost/numeric/mtl/operation/adjoint.hpp> +#include <boost/numeric/mtl/operation/clone.hpp> +#include <boost/numeric/mtl/operation/cholesky.hpp> +#include <boost/numeric/mtl/operation/column_in_matrix.hpp> +#include <boost/numeric/mtl/operation/conj.hpp> +#include <boost/numeric/mtl/operation/copysign.hpp> +#include <boost/numeric/mtl/operation/crop.hpp> +#include <boost/numeric/mtl/operation/cross.hpp> +#include <boost/numeric/mtl/operation/cuppen.hpp> +#include <boost/numeric/mtl/operation/diagonal.hpp> +#include <boost/numeric/mtl/operation/dot.hpp> +#include <boost/numeric/mtl/operation/eigenvalue.hpp> +#include <boost/numeric/mtl/operation/eigenvalue_symmetric.hpp> +#include <boost/numeric/mtl/operation/entry1D.hpp> +#include <boost/numeric/mtl/operation/entry_similar.hpp> +#include <boost/numeric/mtl/operation/evaluate_lazy.hpp> +#include <boost/numeric/mtl/operation/extended_complex.hpp> +#include <boost/numeric/mtl/operation/fill.hpp> +#include <boost/numeric/mtl/operation/fuse.hpp> +#include <boost/numeric/mtl/operation/givens.hpp> +#include <boost/numeric/mtl/operation/hermitian.hpp> +#include <boost/numeric/mtl/operation/hessenberg.hpp> +#include <boost/numeric/mtl/operation/householder.hpp> +#include <boost/numeric/mtl/operation/imag.hpp> +#include <boost/numeric/mtl/operation/inv.hpp> +#include <boost/numeric/mtl/operation/invert_diagonal.hpp> +#include <boost/numeric/mtl/operation/is_negative.hpp> +#include <boost/numeric/mtl/operation/lazy.hpp> +#include <boost/numeric/mtl/operation/left_scale_inplace.hpp> +#include <boost/numeric/mtl/operation/lower_trisolve.hpp> +#include <boost/numeric/mtl/operation/lu.hpp> +#include <boost/numeric/mtl/operation/make_sparse.hpp> +#include <boost/numeric/mtl/operation/make_tag_vector.hpp> +#include <boost/numeric/mtl/operation/merge_complex_vector.hpp> +#include <boost/numeric/mtl/operation/minimal_increase.hpp> +#include <boost/numeric/mtl/operation/misc.hpp> +#include <boost/numeric/mtl/operation/mult.hpp> +#include <boost/numeric/mtl/operation/norms.hpp> +#include <boost/numeric/mtl/operation/ones.hpp> +#include <boost/numeric/mtl/operation/operators.hpp> +#include <boost/numeric/mtl/operation/orth.hpp> +#include <boost/numeric/mtl/operation/print.hpp> +#include <boost/numeric/mtl/operation/product.hpp> +#include <boost/numeric/mtl/operation/qr.hpp> +#include <boost/numeric/mtl/operation/random.hpp> +#include <boost/numeric/mtl/operation/rank_one_update.hpp> +#include <boost/numeric/mtl/operation/rank_two_update.hpp> +#include <boost/numeric/mtl/operation/real.hpp> +#include <boost/numeric/mtl/operation/resource.hpp> +#include <boost/numeric/mtl/operation/right_scale_inplace.hpp> +#include <boost/numeric/mtl/operation/scale.hpp> +#include <boost/numeric/mtl/operation/set_to_zero.hpp> +#include <boost/numeric/mtl/operation/secular.hpp> +#include <boost/numeric/mtl/operation/signum.hpp> +#include <boost/numeric/mtl/operation/split_complex_vector.hpp> +#include <boost/numeric/mtl/operation/sub_matrix.hpp> +#include <boost/numeric/mtl/operation/sum.hpp> +#include <boost/numeric/mtl/operation/min.hpp> +#include <boost/numeric/mtl/operation/min_pos.hpp> +#include <boost/numeric/mtl/operation/max.hpp> +#include <boost/numeric/mtl/operation/max_pos.hpp> +#include <boost/numeric/mtl/operation/max_abs_pos.hpp> +#include <boost/numeric/mtl/operation/num_cols.hpp> +#include <boost/numeric/mtl/operation/num_rows.hpp> +#include <boost/numeric/mtl/operation/row_in_matrix.hpp> +#include <boost/numeric/mtl/operation/size.hpp> +#include <boost/numeric/mtl/operation/size1D.hpp> +#include <boost/numeric/mtl/operation/static_num_cols.hpp> +#include <boost/numeric/mtl/operation/static_num_rows.hpp> +#include <boost/numeric/mtl/operation/static_size.hpp> +#include <boost/numeric/mtl/operation/svd.hpp> +#include <boost/numeric/mtl/operation/swap_row.hpp> +#include <boost/numeric/mtl/operation/trace.hpp> +#include <boost/numeric/mtl/operation/trans.hpp> +#include <boost/numeric/mtl/operation/unary_dot.hpp> +#include <boost/numeric/mtl/operation/unroll.hpp> +#include <boost/numeric/mtl/operation/upper_trisolve.hpp> + +#include <boost/numeric/mtl/matrix/bands.hpp> +#include <boost/numeric/mtl/matrix/identity.hpp> +#include <boost/numeric/mtl/matrix/lower.hpp> +#include <boost/numeric/mtl/matrix/permutation.hpp> +#include <boost/numeric/mtl/matrix/reorder.hpp> +#include <boost/numeric/mtl/matrix/reorder_ref.hpp> +#include <boost/numeric/mtl/matrix/reorder_matrix_rows.hpp> +#include <boost/numeric/mtl/matrix/strict_upper.hpp> +#include <boost/numeric/mtl/matrix/strict_lower.hpp> +#include <boost/numeric/mtl/matrix/upper.hpp> + +#include <boost/numeric/mtl/io/path.hpp> + +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/string_to_enum.hpp> +#include <boost/numeric/mtl/utility/make_copy_or_reference.hpp> + +#include <boost/numeric/mtl/interface/umfpack_solve.hpp> + +#endif // MTL_OPERATIONS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/recursion/base_case_cast.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/recursion/base_case_cast.hpp new file mode 100644 index 0000000000000000000000000000000000000000..198d56bed9acf0c0bf630006bbb51b6d5243bbf4 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/recursion/base_case_cast.hpp @@ -0,0 +1,40 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_BASE_CASE_CAST_INCLUDE +#define MTL_BASE_CASE_CAST_INCLUDE + +#include <boost/numeric/mtl/recursion/base_case_matrix.hpp> +#include <boost/numeric/mtl/recursion/simplify_base_case_matrix.hpp> + +namespace mtl { namespace recursion { + + +template <typename BaseCaseTest, typename Matrix> +typename base_case_matrix<Matrix, BaseCaseTest>::type inline +base_case_cast(Matrix const& matrix) +{ + return simplify_base_case_matrix(matrix, BaseCaseTest()); +} + + +template <typename BaseCaseTest, typename Matrix> +typename base_case_matrix<Matrix, BaseCaseTest>::type inline +base_case_cast(Matrix& matrix) +{ + return simplify_base_case_matrix(matrix, BaseCaseTest()); +} + + +}} // namespace mtl::recursion + +#endif // MTL_BASE_CASE_CAST_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/recursion/base_case_matrix.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/recursion/base_case_matrix.hpp new file mode 100644 index 0000000000000000000000000000000000000000..b07ae71c4a67039eeb6bf3a380fa749115ccf3e5 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/recursion/base_case_matrix.hpp @@ -0,0 +1,50 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_BASE_CASE_MATRIX_INCLUDE +#define MTL_BASE_CASE_MATRIX_INCLUDE + +#include <boost/numeric/mtl/utility/static_assert.hpp> +#include <boost/numeric/meta_math/is_power_of_2.hpp> +#include <boost/numeric/meta_math/log_2.hpp> +#include <boost/numeric/mtl/recursion/base_case_test.hpp> +#include <boost/numeric/mtl/recursion/bit_masking.hpp> + +namespace mtl { namespace recursion { + +template <typename Matrix, typename BaseCaseTest> +struct base_case_matrix +{ + typedef Matrix type; +}; + +template <typename Elt, unsigned long Mask, typename Parameters, typename BaseCaseTest> +struct base_case_matrix<mtl::matrix::morton_dense<Elt, Mask, Parameters>, BaseCaseTest> +{ + MTL_STATIC_ASSERT(meta_math::is_power_of_2<BaseCaseTest::base_case_size>::value, "Static base case size must be power of two"); + static const unsigned long base_case_bits= meta_math::log_2<BaseCaseTest::base_case_size>::value; + + typedef typename boost::mpl::if_< + is_k_power_base_case_row_major<base_case_bits, Mask> + , mtl::matrix::dense2D<Elt, matrix::parameters<row_major> > + , typename boost::mpl::if_< + is_k_power_base_case_col_major<base_case_bits, Mask> + , mtl::matrix::dense2D<Elt, matrix::parameters<col_major> > + , mtl::matrix::morton_dense<Elt, Mask, Parameters> + >::type + >::type type; +}; + + +}} // namespace mtl::recursion + +#endif // MTL_BASE_CASE_MATRIX_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/recursion/base_case_test.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/recursion/base_case_test.hpp new file mode 100644 index 0000000000000000000000000000000000000000..059239c9bdd4110aefdfd6c28abd30f9e5cd7f8c --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/recursion/base_case_test.hpp @@ -0,0 +1,125 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_BASE_CASE_TEST_INCLUDE +#define MTL_BASE_CASE_TEST_INCLUDE + +#include <algorithm> + +namespace mtl { namespace recursion { + +// Minimum of dimensions is less or equal to the reference value +struct min_dim_test +{ + min_dim_test(std::size_t comp) : comp(comp) {} + + template <typename Recursator> + bool operator() (Recursator const& recursator) const + { + return std::min(recursator.get_value().num_rows(), + recursator.get_value().num_cols()) + <= comp; + } + +private: + std::size_t comp; +}; + + +// Minimum of dimensions is less or equal to the reference value +// and it can't be split into 2 sub-matrices less or equal the ref value +struct undivisible_min_dim_test +{ + undivisible_min_dim_test(std::size_t comp) : comp(comp) {} + + template <typename Recursator> + bool operator() (Recursator const& recursator) const + { + std::size_t min_dim= std::min(recursator.get_value().num_rows(), + recursator.get_value().num_cols()), + max_dim= std::max(recursator.get_value().num_rows(), + recursator.get_value().num_cols()); + + return min_dim <= comp && 2 * min_dim > max_dim; + } + +private: + std::size_t comp; +}; + + +// Maximum of dimensions is less or equal to the reference value +struct max_dim_test +{ + max_dim_test(std::size_t comp) : comp(comp) {} + + template <typename Recursator> + bool operator() (Recursator const& recursator) const + { + return std::max(num_rows(*recursator), num_cols(*recursator)) <= comp; + } + +private: + std::size_t comp; +}; + + +// Same with compile-time reference value +template <unsigned long BaseCaseSize> +struct max_dim_test_static +{ + static const unsigned long base_case_size= BaseCaseSize; + + template <typename Recursator> + bool operator() (Recursator const& recursator) const + { + return std::max(recursator.get_value().num_rows(), + recursator.get_value().num_cols()) + <= BaseCaseSize; + } +}; + + +// Upper bound of dimensions in recursator is less or equal to the reference value +struct bound_test +{ + bound_test(std::size_t comp) : comp(comp) {} + + template <typename Recursator> + bool operator() (Recursator const& recursator) const + { + return recursator.bound() <= comp; + } + +private: + std::size_t comp; +}; + + +// Same with compile-time reference value +template <unsigned long BaseCaseSize> +struct bound_test_static +{ + static const unsigned long base_case_size= BaseCaseSize; + + template <typename Recursator> + bool operator() (Recursator const& recursator) const + { + return recursator.bound() <= base_case_size; + } +}; + + + +}} // namespace mtl::recursion + +#endif // MTL_BASE_CASE_TEST_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/recursion/bit_masking.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/recursion/bit_masking.hpp new file mode 100644 index 0000000000000000000000000000000000000000..6bb09ffb2906ba71be4fc140c0fd5d45c2dd5cf4 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/recursion/bit_masking.hpp @@ -0,0 +1,259 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_BIT_MASKING_INCLUDE +#define MTL_BIT_MASKING_INCLUDE + +#include <boost/type_traits/is_same.hpp> +#include <boost/mpl/if.hpp> + +#include <boost/numeric/mtl/utility/tag.hpp> + +namespace mtl { + +/* + The bit masks are row masks, that mean 1s represent rows and 0s columns. + + Bit masks: + + i-order (cyrillic i): + --------------------- + + binary: 01010101 ... 01 + 0x55555555 + + + z-order: + -------- + + binary: 10101010 ... 10 + 0xaaaaaaaa + + row major: + ---------- + + with 2^k columns + binary: 111111111...1000...0 + ------- k 0s at the end (LSB), all bits before 1s (MSB) + + column major: + ------------- + + with 2^k rows + binary: 000000000...0111...1 + ------- k 1s at the end (LSB), all bits before 0s (MSB) + + hybrid (Doppled): + ----------------- + + i-order + with 2^k by 2^k base case + row major + binary 0101....011...10...0 + ----- k 0s at the end (LSB); means columns + ----- k 1s before; means rows + ---------- i order + e.g. 32 by 32 base case 0101...01 11111 00000 = 0x555557e0 + + column major + binary 0101....010...01...1 + ----- k 1s at the end (LSB); means rows + ----- k 0s before; means columns + ---------- i order + e.g. 32 by 32 base case 0101...01 00000 11111 = 0x5555541f + + Shark-tooth base case: + ---------------------- + + 2^t tooth length + in 2^k by 2^k base case (of course t <= k) + row-major + binary 1..1 00..0 1..1 + ---- t 1s at the end (LSB); means 2^t tooth allong rows + ---- k 0s before; means columns + ---- k-t 1s before; means rows + + column-major + binary 0..0 11..1 0..0 + ---- t 0s at the end (LSB); means 2^t tooth allong columns + ---- k 1s before; means rows + ---- k-t 0s before; means columns + + +*/ + + +// Mask for the last N bits +template <unsigned long N> +struct lsb_mask +{ + static const unsigned long value= (lsb_mask<N-1>::value << 1) | 1; +}; + + +template <> +struct lsb_mask<0> +{ + static const unsigned long value= 0; +}; + + +/// Last N bits of Value +template <unsigned long N, unsigned long Value> +struct lsb_bits +{ + static const unsigned long value= lsb_mask<N>::value & Value; +}; + + +/// Compares two masks +template <unsigned long Mask1, unsigned long Mask2> +struct same_mask +{ + static const bool value= false; +}; + +template <unsigned long Mask> +struct same_mask<Mask, Mask> +{ + static const bool value= true; +}; + + +/// Row-major mask for 2^K by 2^K base case +template <unsigned long K> +struct row_major_mask +{ + static const unsigned long value= lsb_mask<K>::value << K; +}; + + +/// Column-major mask for 2^K by 2^K base case +template <unsigned long K> +struct col_major_mask + : public lsb_mask<K> +{}; + + +/// Checks whether 2^K by 2^K base case of hybric matrix, defined by Mask, is a row-major matrix +template <unsigned long K, unsigned long Mask> +struct is_k_power_base_case_row_major +{ + static const bool value= same_mask<lsb_bits<2*K, Mask>::value, row_major_mask<K>::value>::value; + // typedef +}; + + +/// Checks whether 2^K by 2^K base case of hybric matrix, defined by Mask, is a column-major matrix +template <unsigned long K, unsigned long Mask> +struct is_k_power_base_case_col_major +{ + static const bool value= same_mask<lsb_bits<2*K, Mask>::value, col_major_mask<K>::value>::value; +}; + + +/// Checks whether 32x32 base case of hybric matrix, defined by Mask, is a row-major matrix +template <unsigned long Mask> +struct is_32_base_case_row_major + : public is_k_power_base_case_row_major<5, Mask> +{}; + + +/// Checks whether 32x32 base case of hybric matrix, defined by Mask, is a col-major matrix +template <unsigned long Mask> +struct is_32_base_case_col_major + : public is_k_power_base_case_col_major<5, Mask> +{}; + + +/// Row-major mask for 2^K by 2^K base case with 2^T shark teeth +template <unsigned long K, unsigned long T> +struct row_major_shark_mask +{ + static const unsigned long value= (lsb_mask<K-T>::value << (K+T)) | lsb_mask<T>::value; +}; + + +/// Row-major mask for 2^K by 2^K base case with 2^T shark teeth +template <unsigned long K, unsigned long T> +struct col_major_shark_mask +{ + static const unsigned long value= lsb_mask<K>::value << T; +}; + + +/** Checks whether 2^K by 2^K base case of hybric matrix, defined by Mask, + is a row-major matrix shark-tooth with 2^T tooth length +**/ +template <unsigned long K, unsigned long T, unsigned long Mask> +struct is_k_power_base_case_row_major_t_shark +{ + static const bool value= same_mask<lsb_bits<2*K, Mask>::value, row_major_shark_mask<K, T>::value>::value; +}; + + +/** Checks whether 2^K by 2^K base case of hybric matrix, defined by Mask, + is a col-major matrix shark-tooth with 2^T tooth length +**/ +template <unsigned long K, unsigned long T, unsigned long Mask> +struct is_k_power_base_case_col_major_t_shark +{ + static const bool value= same_mask<lsb_bits<2*K, Mask>::value, col_major_shark_mask<K, T>::value>::value; +}; + + // e-order +/// N-order mask of N bits +template <unsigned long N> +struct i_order_mask +{ + // Check if N is even !!! + static const unsigned long value= (i_order_mask<N-2>::value << 2) | 1; +}; + +template<> struct i_order_mask<0> : public lsb_mask<0> {}; // set to 0 + + +/// Z-order mask of N bits +template <unsigned long N> +struct z_order_mask +{ + // Check if N is even !!! + static const unsigned long value= (z_order_mask<N-2>::value << 2) | 2; +}; + +template<> struct z_order_mask<0> : public lsb_mask<0> {}; // set to 0 + + +/** Generate arbitrary hybrid mask. + \param IOrder if true then i-order otherwise z-order + \param K 2^K by 2^K base case + \param Orientation mtl::row_major or mtl::col_major + \param T 2^T tooth length +**/ +template <bool IOrder, unsigned long K, typename Orientation, unsigned long T> +class generate_mask +{ + static const unsigned long rec_size= 8 * sizeof(unsigned long) - 2 * K, + rec_part= (IOrder ? i_order_mask<rec_size>::value : z_order_mask<rec_size>::value) << 2*K; + typedef typename boost::mpl::if_< + boost::is_same<Orientation, row_major> + , row_major_shark_mask<K, T> + , col_major_shark_mask<K, T> + >::type base_part_type; +public: + static const unsigned long value= rec_part | base_part_type::value; +}; + + +} // namespace mtl + +#endif // MTL_BIT_MASKING_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/recursion/dim_splitter.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/recursion/dim_splitter.hpp new file mode 100644 index 0000000000000000000000000000000000000000..d1569a4ffebf675b722dfbc7cf4301996e15cd1c --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/recursion/dim_splitter.hpp @@ -0,0 +1,154 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_DIM_SPLITTER_INCLUDE +#define MTL_DIM_SPLITTER_INCLUDE + +#include <algorithm> +#include <boost/numeric/mtl/recursion/utility.hpp> + +namespace mtl { namespace recursion { + +// Splits dimensions of a matrix separately into halfs (first value rounded up) +template <typename Matrix> +struct half_splitter +{ + typedef typename Matrix::size_type size_type; + + explicit half_splitter(Matrix const& matrix) + { + size_type nr= matrix.num_rows(), nc= matrix.num_cols(); + nr-= nr / 2; // keep the part (by removind the down-rounded half) + nc-= nc / 2; + my_row_split= matrix.begin_row() + nr; + my_col_split= matrix.begin_col() + nc; + } + + // End of northern half and beginning of southern + size_type row_split() const + { + return my_row_split; + } + + // End of western half and beginning of eastern + size_type col_split() const + { + return my_col_split; + } + +private: + size_type my_row_split, my_col_split; +}; + +// Splits dimensions of a matrix separately into a first part that +// is the largest power of 2 smaller than m or n, plus rest; +// doesn't yield empty submatrices if both dimension > 1 +template <typename Matrix> +struct separate_dim_splitter +{ + typedef typename Matrix::size_type size_type; + + explicit separate_dim_splitter(Matrix const& matrix) + : my_row_split(matrix.begin_row() + first_part(matrix.num_rows())), + my_col_split(matrix.begin_col() + first_part(matrix.num_cols())) + {} + + // End of northern half and beginning of southern + size_type row_split() const + { + return my_row_split; + } + + // End of western half and beginning of eastern + size_type col_split() const + { + return my_col_split; + } + +private: + size_type my_row_split, my_col_split; +}; + +// Splits dimensions of a matrix separately into a first part that +// is the largest power of 2 smaller than the maximum of m and n; +// can yield 1 or two empty submatrices if matrix is rather unproportional; +// helps creating square submatrices +template <typename Matrix> +struct max_dim_splitter +{ + typedef typename Matrix::size_type size_type; + + explicit max_dim_splitter(Matrix const& matrix) + : // matrix(matrix), + my_split(std::max(first_part(matrix.num_rows()), first_part(matrix.num_cols()))), + my_row_split(std::min(matrix.begin_row() + my_split, matrix.end_row())), + my_col_split(std::min(matrix.begin_col() + my_split, matrix.end_col())) + {} + + // End of northern half and beginning of southern (limited to end_row) + size_type row_split() const + { + return my_row_split; + } + + // End of western half and beginning of eastern (limited to end_col) + size_type col_split() const + { + return my_col_split; + } + +private: + // Matrix const& matrix; + size_type my_split, // minimal 2^(k-1) such that 2^k >= max(num_rows, num_cols) + my_row_split, my_col_split; +}; + + +// Splitting within bounding box of power of 2, using recursators +// For instance, the upper left part of a 530 x 17 matrix is +// 530 x 17 if the bound is 2048 or larger +// 512 x 17 if the bound is 1024 +// bound of 512 or smaller is a wrong bound +template <typename Recursator> +struct outer_bound_splitter +{ + typedef typename Recursator::size_type size_type; + + explicit outer_bound_splitter(Recursator const& recursator) + { + typename Recursator::matrix_type const& matrix= recursator.get_value(); + my_row_split= std::min(matrix.begin_row() + recursator.bound() / 2, matrix.end_row()); + my_col_split= std::min(matrix.begin_col() + recursator.bound() / 2, matrix.end_col()); + } + + + // End of northern half and beginning of southern (limited to end_row) + size_type row_split() const + { + return my_row_split; + } + + // End of western half and beginning of eastern (limited to end_col) + size_type col_split() const + { + return my_col_split; + } + +private: + size_type my_row_split, my_col_split; +}; + + + +}} // namespace mtl::recursion + +#endif // MTL_DIM_SPLITTER_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/recursion/for_each.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/recursion/for_each.hpp new file mode 100644 index 0000000000000000000000000000000000000000..ebc60b2e64dca06710520f2ac5da3e7a5a270db8 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/recursion/for_each.hpp @@ -0,0 +1,63 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_FOR_EACH_INCLUDE +#define MTL_FOR_EACH_INCLUDE + +namespace mtl { namespace recursion { + +// Go recursively down to base case and apply function on it +template <typename Matrix, typename Function, typename BaseCaseTest> +void for_each(matrix::recursator<Matrix> const& recursator, Function const& f, BaseCaseTest const& is_base) +{ + if (recursator.is_empty()) + return; + + if (is_base(recursator)) { + f(*recursator); + return; + } + + for_each(recursator.north_west(), f, is_base); + for_each(recursator.south_west(), f, is_base); + for_each(recursator.north_east(), f, is_base); + for_each(recursator.south_east(), f, is_base); +} + + +// Non-const version +template <typename Matrix, typename Function, typename BaseCaseTest> +void for_each(matrix::recursator<Matrix>& recursator, Function const& f, BaseCaseTest const& is_base) +{ + typedef matrix::recursator<Matrix> recursator_type; + + if (recursator.is_empty()) + return; + + if (is_base(recursator)) { + f(recursator.get_value()); + return; + } + + recursator_type tmp_nw(recursator.north_west()), tmp_sw(recursator.south_west()), + tmp_ne(recursator.north_east()), tmp_se(recursator.south_east()); + for_each(tmp_nw, f, is_base); + for_each(tmp_sw, f, is_base); + for_each(tmp_ne, f, is_base); + for_each(tmp_se, f, is_base); +} + + +}} // namespace mtl::recursion + + +#endif // MTL_FOR_EACH_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/recursion/matrix_recursator.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/recursion/matrix_recursator.hpp new file mode 100644 index 0000000000000000000000000000000000000000..8284279d5fd50464108a54462fddaf3a3649de25 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/recursion/matrix_recursator.hpp @@ -0,0 +1,543 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MATRIX_RECURATOR_INCLUDE +#define MTL_MATRIX_RECURATOR_INCLUDE + +#include <cmath> +#include <boost/shared_ptr.hpp> +#include <boost/type_traits/remove_const.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/operation/sub_matrix.hpp> +#include <boost/numeric/mtl/operation/print_matrix.hpp> +#include <boost/numeric/mtl/matrix/transposed_view.hpp> +#include <boost/numeric/mtl/recursion/dim_splitter.hpp> +#include <boost/numeric/mtl/recursion/utility.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> + +namespace mtl { namespace matrix { + + +template <typename Recursator1, typename Recursator2> +void inline equalize_depth(Recursator1& r1, Recursator2& r2); + +template <typename Recursator1, typename Recursator2, typename Recursator3> +void inline equalize_depth(Recursator1& r1, Recursator2& r2, Recursator3& r3); + + +/*! Class for matrix recursator + + How to use this class is described in the \ref rec_intro "recursion introduction". + + \sa \ref mtl::matrix::north_west, \ref mtl::matrix::north_east, + \ref mtl::matrix::south_west, \ref mtl::matrix::south_east, + \ref mtl::matrix::is_empty(const recursator<Matrix>&), + \ref mtl::matrix::is_full(const recursator<Matrix>&), + \ref mtl::matrix::num_rows(const recursator<Matrix>&), + \ref mtl::matrix::num_cols(const recursator<Matrix>&), + \ref mtl::matrix::size(const recursator<Matrix>&) +**/ +template <typename Matrix> +struct recursator +{ + typedef recursator self; + typedef Matrix matrix_type; + typedef typename sub_matrix_t<Matrix>::sub_matrix_type sub_matrix_type; + typedef typename sub_matrix_t<Matrix>::const_sub_matrix_type const_sub_matrix_type; + typedef typename Collection<Matrix>::size_type size_type; + typedef typename Collection<Matrix>::value_type matrix_value_type; + typedef recursion::outer_bound_splitter<self> splitter_type; + +private: + + template <typename MatrixType> // why was it templated ??? + sub_matrix_type constructor_helper(MatrixType const& matrix) + { + return sub_matrix(matrix, matrix.begin_row(), matrix.end_row(), + matrix.begin_col(), matrix.end_col()); + } + + // For views without own data, we need to generate a new sub_matrix as shared_ptr + template <typename MatrixType> + sub_matrix_type constructor_helper(transposed_view<MatrixType> const& view) + { + typedef typename boost::remove_const<MatrixType>::type tmp_type; + typedef typename sub_matrix_t<tmp_type>::sub_matrix_type ref_sub_type; + typedef boost::shared_ptr<ref_sub_type> pointer_type; + typedef typename transposed_view<MatrixType>::other ref_type; + + // Submatrix of referred matrix, colums and rows interchanged + // Create a submatrix, whos address will be kept by transposed_view + pointer_type p(new ref_sub_type(sub_matrix(const_cast<ref_type&>(view.ref), view.begin_col(), view.end_col(), + view.begin_row(), view.end_row()))); + return sub_matrix_type(p); + } + +public: + /*! Construct a recursator from a matrix. + \param matrix The matrix to which the recursator refers. + \param bound Explicit bound declaration; must not be smaller than the numbers of rows and the number of columns; + must also be a power of 2. + + Constructor takes the entire matrix as sub-matrix. + This allows to have different type for the matrix and the sub-matrix. + **/ + explicit recursator(Matrix const& matrix, + size_type bound= 0 + ) + : my_sub_matrix(constructor_helper(matrix)), my_bound(recursion::outer_bound(matrix)), + my_first_row(0), my_first_col(0) // splitter(*this) + { + if (bound == 0) + my_bound= recursion::outer_bound(matrix); + else { + MTL_DEBUG_THROW_IF(!recursion::is_power_of_2(bound), range_error("Bound must be a power of 2")); + MTL_DEBUG_THROW_IF(bound < num_rows(matrix) || bound < num_cols(matrix), + range_error("Bound must not be smaller than matrix dimensions")); + my_bound= bound; + } + } + + +private: + + template <typename SubMatrix> + sub_matrix_type get_value_dispatch(const SubMatrix& , + size_type br, size_type er, size_type bc, size_type ec) const + { + return sub_matrix(my_sub_matrix, br, er, bc, ec); + } + + template <typename SubMatrix> + sub_matrix_type get_value_dispatch(transposed_view<SubMatrix> view, + size_type br, size_type er, size_type bc, size_type ec) const + { + typedef typename sub_matrix_t<SubMatrix>::sub_matrix_type ref_sub_type; + typedef boost::shared_ptr<ref_sub_type> pointer_type; + typedef typename transposed_view<SubMatrix>::other ref_type; + + pointer_type p(new ref_sub_type(sub_matrix(const_cast<ref_type&>(view.ref), bc, ec, br, er))); + return sub_matrix_type(p); + } + + +public: + sub_matrix_type get_value() const + { + using std::min; + size_type begin_row= my_sub_matrix.begin_row() + my_first_row, + end_row= min(begin_row + my_bound, my_sub_matrix.end_row()), + begin_col= my_sub_matrix.begin_col() + my_first_col, + end_col= min(begin_col + my_bound, my_sub_matrix.end_col()); + +#if 0 + std::cout << "get_value [" << begin_row << "-" << end_row << "][" + << begin_col << "-" << end_col << "]\n"; +#endif + return get_value_dispatch(my_sub_matrix, begin_row, end_row, begin_col, end_col); + } + + /// Compute the sub-matrix corresponding to this recursator. + sub_matrix_type operator*() const + { + return get_value(); + } + + // Returning quadrants for non-const recursator + + self north_west() const + { + self tmp(*this); + tmp.my_bound >>= 1; // divide by 2 + return tmp; + } + + self south_west() const + { + self tmp(*this); + tmp.my_bound >>= 1; // divide by 2 + tmp.my_first_row += tmp.my_bound; + return tmp; + } + + self north_east() const + { + self tmp(*this); + tmp.my_bound >>= 1; // divide by 2 + tmp.my_first_col += tmp.my_bound; + return tmp; + } + + self south_east() const + { + self tmp(*this); + tmp.my_bound >>= 1; // divide by 20 + tmp.my_first_row += tmp.my_bound; + tmp.my_first_col += tmp.my_bound; + return tmp; + } + + bool is_empty() const + { + return my_first_row >= num_rows(my_sub_matrix) || my_first_col >= num_cols(my_sub_matrix); + } + + + /// Return the bound of the recursator + size_type bound() const + { + return my_bound; + } + + /*! Set the bound of the recursator. + \param b The new virtual bound; must be a power of 2. + + This function allows to declare a virtual bound smaller than the number of rows and/or columns. + It must be used with uttermost care. + **/ + void set_bound(size_type b) + { + my_bound= b; + } + + template <typename R1, typename R2> friend void equalize_depth (R1&, R2&); + template <typename R1, typename R2, typename R3> friend void equalize_depth (R1&, R2&, R3&); + + template <typename M> friend typename recursator<M>::size_type num_rows(const recursator<M>& rec); + template <typename M> friend typename recursator<M>::size_type num_cols(const recursator<M>& rec); + + // Dirty feature to be used with care + matrix_value_type* first_address() + { + return &my_sub_matrix[my_first_row][my_first_col]; + } + + const matrix_value_type* first_address() const + { + return &my_sub_matrix[my_first_row][my_first_col]; + } + + protected: + sub_matrix_type my_sub_matrix; /// Referred matrix (from which the sub-matrices are built) + size_type my_bound, /// Virtual matrix size, i.e. upper bound for size of sub-matrix. + my_first_row, /// Row of first entry in submatrix + my_first_col; /// Row of first entry in submatrix +}; + +#if 0 + +// Obsolete, only left in code because discussed in a paper +// To use recursator with const matrices Reference must be 'Matrix const&' +template <typename Matrix, typename Splitter = recursion::max_dim_splitter<Matrix> > +struct recursator_s +{ + typedef recursator_s self; + typedef Matrix matrix_type; + typedef Splitter splitter_type; + typedef typename sub_matrix_t<Matrix>::sub_matrix_type sub_matrix_type; + typedef typename sub_matrix_t<Matrix>::const_sub_matrix_type const_sub_matrix_type; + typedef typename Matrix::size_type size_type; + // typedef outer_bound_splitter<self> splitter_type; + +private: + + // template <typename Matrix> why was it templated ??? + sub_matrix_type constructor_helper(Matrix const& matrix) + { + return sub_matrix(matrix, matrix.begin_row(), matrix.end_row(), + matrix.begin_col(), matrix.end_col()); + } + + // For views without own data, we need to generate a new sub_matrix as shared_ptr + // template <typename Matrix> + sub_matrix_type constructor_helper(transposed_view<Matrix> const& matrix) + { + typedef typename sub_matrix_t<Matrix>::sub_matrix_type ref_sub_type; + typedef boost::shared_ptr<ref_sub_type> pointer_type; + + // Submatrix of referred matrix, colums and rows interchanged + // Create a submatrix, whos address will be kept by transposed_view + pointer_type p(new ref_sub_type(sub_matrix(matrix.ref, matrix.begin_col(), matrix.end_col(), + matrix.begin_row(), matrix.end_row()))); + return sub_matrix_type(p); + } + +public: + // Constructor takes the whole matrix as sub-matrix + // This allows to have different type for the matrix and the sub-matrix + // This also enables matrices to have references as sub-matrices + explicit recursator_s(Matrix const& matrix, size_type bound= 0) + : my_sub_matrix(constructor_helper(matrix)), my_bound(outer_bound(matrix)), + splitter(my_sub_matrix) + { + if (bound == 0) + my_bound= outer_bound(matrix); + else { + assert(is_power_of_2(bound)); + assert(bound >= matrix.num_rows() && bound >= matrix.num_cols()); + my_bound= bound; + } + } + + // Sub-matrices are copied directly + // explicit recursator(sub_matrix_type sub_matrix) : my_sub_matrix(sub_matrix) {} + + sub_matrix_type& get_value() + { + return my_sub_matrix; + } + + sub_matrix_type const& get_value() const + { + return my_sub_matrix; + } + + // Returning quadrants for non-const recursator + + self north_west() + { + sub_matrix_type sm(sub_matrix(my_sub_matrix, my_sub_matrix.begin_row(), splitter.row_split(), + my_sub_matrix.begin_col(), splitter.col_split())); + self tmp(sm, my_bound / 2); + return tmp; + } + + self south_west() + { + sub_matrix_type sm(sub_matrix(my_sub_matrix, splitter.row_split(), my_sub_matrix.end_row(), + my_sub_matrix.begin_col(), splitter.col_split())); + self tmp(sm, my_bound / 2); + return tmp; + } + + self north_east() + { + sub_matrix_type sm(sub_matrix(my_sub_matrix, my_sub_matrix.begin_row(), splitter.row_split(), + splitter.col_split(), my_sub_matrix.end_col())); + self tmp(sm, my_bound / 2); + return tmp; + } + + self south_east() + { + sub_matrix_type sm(sub_matrix(my_sub_matrix, splitter.row_split(), my_sub_matrix.end_row(), + splitter.col_split(), my_sub_matrix.end_col())); + self tmp(sm, my_bound / 2); + return tmp; + } + + // Returning quadrants for const recursator + + self const north_west() const + { + sub_matrix_type sm(sub_matrix(const_cast<self*>(this)->my_sub_matrix, my_sub_matrix.begin_row(), splitter.row_split(), + my_sub_matrix.begin_col(), splitter.col_split())); + self tmp(sm, my_bound / 2); + return tmp; + } + + self const south_west() const + { + sub_matrix_type sm(sub_matrix(const_cast<self*>(this)->my_sub_matrix, splitter.row_split(), my_sub_matrix.end_row(), + my_sub_matrix.begin_col(), splitter.col_split())); + self tmp(sm, my_bound / 2); + return tmp; + } + + self const north_east() const + { + sub_matrix_type sm(sub_matrix(const_cast<self*>(this)->my_sub_matrix, my_sub_matrix.begin_row(), splitter.row_split(), + splitter.col_split(), my_sub_matrix.end_col())); + self tmp(sm, my_bound / 2); + return tmp; + } + + self const south_east() const + { + sub_matrix_type sm(sub_matrix(const_cast<self*>(this)->my_sub_matrix, splitter.row_split(), my_sub_matrix.end_row(), + splitter.col_split(), my_sub_matrix.end_col())); + self tmp(sm, my_bound / 2); + return tmp; + } + + // Checking whether a quadrant is empty + + // For completeness + bool north_west_empty() const + { + return false; + } + + bool north_east_empty() const + { + return splitter.col_split() == my_sub_matrix.end_col(); + } + + bool south_west_empty() const + { + return splitter.row_split() == my_sub_matrix.end_row(); + } + + bool south_east_empty() const + { + return splitter.row_split() == my_sub_matrix.end_row() + || splitter.col_split() == my_sub_matrix.end_col(); + } + + bool is_empty() const + { + return my_sub_matrix.begin_row() == my_sub_matrix.end_row() + || my_sub_matrix.begin_col() == my_sub_matrix.end_col(); + } + +#if 0 + bool is_leaf() const + { + return my_sub_matrix.num_rows() < 2 || my_sub_matrix.num_cols() < 2; + } +#endif + + size_type bound() const + { + assert(my_bound >= my_sub_matrix.num_rows() && my_bound >= my_sub_matrix.num_cols()); + return my_bound; + } + + template <typename R1, typename R2> friend void equalize_depth (R1&, R2&); + template <typename R1, typename R2, typename R3> friend void equalize_depth (R1&, R2&, R3&); + + protected: + sub_matrix_type my_sub_matrix; + size_type my_bound; + splitter_type splitter; +}; + +#endif + +template <typename Recursator1, typename Recursator2> +void inline equalize_depth(Recursator1& r1, Recursator2& r2) +{ + typename Recursator1::size_type max_bound= std::max(r1.bound(), r2.bound()); + r1.my_bound= max_bound; + r2.my_bound= max_bound; +} + +template <typename Recursator1, typename Recursator2, typename Recursator3> +void inline equalize_depth(Recursator1& r1, Recursator2& r2, Recursator3& r3) +{ + typename Recursator1::size_type max_bound= std::max(std::max(r1.bound(), r2.bound()), r3.bound()); + r1.my_bound= max_bound; + r2.my_bound= max_bound; + r3.my_bound= max_bound; +} + + +// Define free functions (from member functions) + +/*! Compute the north-west quadrant of a recursator (i.e. its referred matrix). + The result is itself a recursator. + \sa \ref rec_intro "recursion intro" +**/ +template <typename Matrix> +recursator<Matrix> inline north_west(const recursator<Matrix>& rec) +{ + return rec.north_west(); +} + +/*! Compute the north-east quadrant of a recursator (i.e. its referred matrix). + The result is itself a recursator. + \sa \ref rec_intro "recursion intro" +**/ +template <typename Matrix> +recursator<Matrix> inline north_east(const recursator<Matrix>& rec) +{ + return rec.north_east(); +} + +/*! Compute the south-west quadrant of a recursator (i.e. its referred matrix). + The result is itself a recursator. + \sa \ref rec_intro "recursion intro" +**/ +template <typename Matrix> +recursator<Matrix> inline south_west(const recursator<Matrix>& rec) +{ + return rec.south_west(); +} + +/*! Compute the south-east quadrant of a recursator (i.e. its referred matrix). + The result is itself a recursator. + \sa \ref rec_intro "recursion intro" +**/ +template <typename Matrix> +recursator<Matrix> inline south_east(const recursator<Matrix>& rec) +{ + return rec.south_east(); +} + + +/*! Check if a recursator (i.e. its referred matrix) is empty. + \sa \ref rec_intro "recursion intro" +**/ +template <typename Matrix> +bool inline is_empty(const recursator<Matrix>& rec) +{ + return rec.is_empty(); +} + +/*! Check if a recursator (i.e. its referred matrix) fills the + entire block, i.e. if the number of rows and columns are both + equal to the virtual bound. + \sa \ref rec_intro "recursion intro" +**/ +template <typename Matrix> +bool inline is_full(const recursator<Matrix>& rec) +{ + return num_rows(rec) == rec.bound() && num_cols(rec) == rec.bound(); +} + +/*! The number of rows that a sub-matrix would have if it was constructed. + \sa \ref rec_intro "recursion intro" +**/ +template <typename Matrix> +typename recursator<Matrix>::size_type +inline num_rows(const recursator<Matrix>& rec) +{ + using std::min; + typename recursator<Matrix>::size_type tmp= num_rows(rec.my_sub_matrix); + return rec.my_first_row >= tmp ? 0 : min(rec.my_bound, tmp - rec.my_first_row); +} + +/*! The number of columns that a sub-matrix would have if it was constructed. + \sa \ref rec_intro "recursion intro" +**/ +template <typename Matrix> +typename recursator<Matrix>::size_type +inline num_cols(const recursator<Matrix>& rec) +{ + using std::min; + typename recursator<Matrix>::size_type tmp= num_cols(rec.my_sub_matrix); + return rec.my_first_col >= tmp ? 0 : min(rec.my_bound, tmp - rec.my_first_col); +} + +/*! The number of elements (rows times columns) that a sub-matrix would have if it was constructed. + \sa \ref rec_intro "recursion intro" +**/ +template <typename Matrix> +typename recursator<Matrix>::size_type +inline size(const recursator<Matrix>& rec) +{ + return num_rows(rec) * num_cols(rec); +} + +}} // namespace mtl::matrix + +#endif // MTL_MATRIX_RECURATOR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/recursion/predefined_masks.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/recursion/predefined_masks.hpp new file mode 100644 index 0000000000000000000000000000000000000000..884478c849c79b3b1114b345518abda8d76cd481 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/recursion/predefined_masks.hpp @@ -0,0 +1,90 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_PREDEFINED_MASKS_INCLUDE +#define MTL_PREDEFINED_MASKS_INCLUDE + +#include <boost/numeric/mtl/recursion/bit_masking.hpp> + +namespace mtl { namespace recursion { + + // Bitmasks: + const unsigned long morton_mask= generate_mask<true, 0, row_major, 0>::value, + morton_z_mask= generate_mask<false, 0, row_major, 0>::value, + doppled_2_row_mask= generate_mask<true, 1, row_major, 0>::value, + doppled_2_col_mask= generate_mask<true, 1, col_major, 0>::value, + doppled_4_row_mask= generate_mask<true, 2, row_major, 0>::value, + doppled_4_col_mask= generate_mask<true, 2, col_major, 0>::value, + doppled_16_row_mask= generate_mask<true, 4, row_major, 0>::value, + doppled_16_col_mask= generate_mask<true, 4, col_major, 0>::value, + doppled_z_16_row_mask= generate_mask<false, 4, row_major, 0>::value, + doppled_z_16_col_mask= generate_mask<false, 4, col_major, 0>::value, + doppled_32_row_mask= generate_mask<true, 5, row_major, 0>::value, + doppled_32_col_mask= generate_mask<true, 5, col_major, 0>::value, + doppled_z_32_row_mask= generate_mask<false, 5, row_major, 0>::value, + doppled_z_32_col_mask= generate_mask<false, 5, col_major, 0>::value, + doppled_64_row_mask= generate_mask<true, 6, row_major, 0>::value, + doppled_64_col_mask= generate_mask<true, 6, col_major, 0>::value, + doppled_z_64_row_mask= generate_mask<false, 6, row_major, 0>::value, + doppled_z_64_col_mask= generate_mask<false, 6, col_major, 0>::value, + doppled_128_row_mask= generate_mask<true, 7, row_major, 0>::value, + doppled_128_col_mask= generate_mask<true, 7, col_major, 0>::value, + doppled_z_128_row_mask= generate_mask<false, 7, row_major, 0>::value, + doppled_z_128_col_mask= generate_mask<false, 7, col_major, 0>::value, + shark_32_row_mask= generate_mask<true, 5, row_major, 1>::value, + shark_32_col_mask= generate_mask<true, 5, col_major, 1>::value, + shark_z_32_row_mask= generate_mask<false, 5, row_major, 1>::value, + shark_z_32_col_mask= generate_mask<false, 5, col_major, 1>::value, + shark_64_row_mask= generate_mask<true, 6, row_major, 1>::value, + shark_64_col_mask= generate_mask<true, 6, col_major, 1>::value, + shark_z_64_row_mask= generate_mask<false, 6, row_major, 1>::value, + shark_z_64_col_mask= generate_mask<false, 6, col_major, 1>::value; + + +} // namespace recursion + +// Export masks into MTL namespace + +using recursion::morton_mask; +using recursion::morton_z_mask; +using recursion::doppled_2_row_mask; +using recursion::doppled_2_col_mask; +using recursion::doppled_4_row_mask; +using recursion::doppled_4_col_mask; +using recursion::doppled_16_row_mask; +using recursion::doppled_16_col_mask; +using recursion::doppled_z_16_row_mask; +using recursion::doppled_z_16_col_mask; +using recursion::doppled_32_row_mask; +using recursion::doppled_32_col_mask; +using recursion::doppled_z_32_row_mask; +using recursion::doppled_z_32_col_mask; +using recursion::doppled_64_row_mask; +using recursion::doppled_64_col_mask; +using recursion::doppled_z_64_row_mask; +using recursion::doppled_z_64_col_mask; +using recursion::doppled_128_row_mask; +using recursion::doppled_128_col_mask; +using recursion::doppled_z_128_row_mask; +using recursion::doppled_z_128_col_mask; +using recursion::shark_32_row_mask; +using recursion::shark_32_col_mask; +using recursion::shark_z_32_row_mask; +using recursion::shark_z_32_col_mask; +using recursion::shark_64_row_mask; +using recursion::shark_64_col_mask; +using recursion::shark_z_64_row_mask; +using recursion::shark_z_64_col_mask; + +} // namespace mtl + +#endif // MTL_PREDEFINED_MASKS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/recursion/simplify_base_case_matrix.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/recursion/simplify_base_case_matrix.hpp new file mode 100644 index 0000000000000000000000000000000000000000..91d2781b2302e954a389b109e28dafb34f1f2196 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/recursion/simplify_base_case_matrix.hpp @@ -0,0 +1,98 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_SIMPLIFY_BASE_CASE_MATRIX_INCLUDE +#define MTL_SIMPLIFY_BASE_CASE_MATRIX_INCLUDE + +#include <boost/numeric/mtl/matrix/dimension.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/operation/sub_matrix.hpp> +#include <boost/numeric/mtl/recursion/base_case_matrix.hpp> + + +namespace mtl { namespace recursion { + + +namespace impl { + + // With conversion, i.e. when target and source type are different + template <typename Matrix, typename BaseCaseMatrix, typename BaseCaseTest> + struct simplify_base_case_matrix + { + BaseCaseMatrix operator()(Matrix const& matrix, BaseCaseTest const) + { + typename Matrix::size_type begin_row= matrix.begin_row(), begin_col= matrix.begin_col(); + + if (matrix.num_rows() == BaseCaseTest::base_case_size + && matrix.num_cols() == BaseCaseTest::base_case_size) + return BaseCaseMatrix(non_fixed::dimensions(matrix.num_rows(), matrix.num_cols()), + &const_cast<Matrix&>(matrix)[begin_row][begin_col]); + + BaseCaseMatrix square(non_fixed::dimensions(BaseCaseTest::base_case_size, BaseCaseTest::base_case_size), + &const_cast<Matrix&>(matrix)[begin_row][begin_col]); + return sub_matrix(square, begin_row, matrix.num_rows(), begin_col, matrix.num_cols()); + } + }; + + template <typename Matrix, typename BaseCaseTest> + struct simplify_base_case_matrix<Matrix, Matrix, BaseCaseTest> + { + Matrix operator()(Matrix const& matrix, BaseCaseTest const) + { + return matrix; + } + }; + + +#if 0 + inline BaseCaseMatrix + simplify_base_case_matrix(Matrix const& matrix, BaseCaseMatrix const&, BaseCaseTest const&) + { + typename Matrix::size_type begin_row= matrix.begin_row(), begin_col= matrix.begin_col(); + + if (matrix.num_rows() == BaseCaseTest::base_case_size + && matrix.num_cols() == BaseCaseTest::base_case_size) + return BaseCaseMatrix(non_fixed::dimensions(matrix.num_rows(), matrix.num_cols()), + &const_cast<Matrix&>(matrix)[begin_row][begin_col]); + + BaseCaseMatrix square(non_fixed::dimensions(BaseCaseTest::base_case_size, BaseCaseTest::base_case_size), + &const_cast<Matrix&>(matrix)[begin_row][begin_col]); + return sub_matrix(square, begin_row, matrix.num_rows(), begin_col, matrix.num_cols()); + } + + // Without conversion, i.e. when target and source type are identical + template <typename Matrix, typename BaseCaseTest> + inline Matrix + simplify_base_case_matrix(Matrix const& matrix, Matrix const&, BaseCaseTest const&) + { + return matrix; + } +#endif + +} // namespace impl + +template <typename Matrix, typename BaseCaseTest> +typename base_case_matrix<Matrix, BaseCaseTest>::type inline +simplify_base_case_matrix(Matrix const& matrix, BaseCaseTest test) +{ + // cout << "simplify dim " << matrix.num_rows() << ", " << matrix.num_cols() << "\n"; + MTL_DEBUG_THROW_IF(num_rows(matrix) > BaseCaseTest::base_case_size || num_cols(matrix) > BaseCaseTest::base_case_size, + logic_error("Matrix dimension is larger than base case")); + + return impl::simplify_base_case_matrix<Matrix, typename base_case_matrix<Matrix, BaseCaseTest>::type, BaseCaseTest>()(matrix, test); + +} + +}} // namespace mtl::recursion + + +#endif // MTL_SIMPLIFY_BASE_CASE_MATRIX_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/recursion/utility.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/recursion/utility.hpp new file mode 100644 index 0000000000000000000000000000000000000000..d20473ae0267c90bd10406e1539ba88feb72ff49 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/recursion/utility.hpp @@ -0,0 +1,66 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_RECURSION_UTILITIES_INCLUDE +#define MTL_RECURSION_UTILITIES_INCLUDE + +#include <limits> +#include <cmath> + +namespace mtl { namespace recursion { + + +// Splits a number into a next-smallest power of 2 and rest +std::size_t inline first_part(std::size_t n) +{ + if (n == 0) return 0; + + std::size_t i= std::numeric_limits<std::size_t>::max()/2 + 1; + + while(i >= n) i>>= 1; + return i; +} + + +// The remainder of first part +std::size_t inline second_part(std::size_t n) +{ + return n - first_part(n); +} + + +template <typename Matrix> +std::size_t inline outer_bound(Matrix const& matrix) +{ + std::size_t max_dim=std::max(num_rows(matrix), num_cols(matrix)), bound= 1; + for (; bound < max_dim;) bound<<= 1; + return bound; +} + + +template <typename Integral> +Integral inline least_significant_one_bit(Integral x) +{ + return x & -x; +} + + +template <typename Integral> +bool inline is_power_of_2(Integral x) +{ + return x == least_significant_one_bit(x); +} + + +}} // namespace mtl::recursion + +#endif // MTL_RECURSION_UTILITIES_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/types.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/types.hpp new file mode 100644 index 0000000000000000000000000000000000000000..c99938c2fb9cbb9b20fd22d75afa02771e8c9a25 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/types.hpp @@ -0,0 +1,34 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_TYPES_INCLUDE +#define MTL_TYPES_INCLUDE + +#include <boost/numeric/mtl/vectors.hpp> +#include <boost/numeric/mtl/matrices.hpp> + +#include <boost/numeric/mtl/utility/different_non_complex.hpp> +#include <boost/numeric/mtl/utility/irange.hpp> +#include <boost/numeric/mtl/utility/srange.hpp> +#include <boost/numeric/mtl/utility/iset.hpp> +#include <boost/numeric/mtl/utility/property_map.hpp> +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/utility/range_wrapper.hpp> + +#include <boost/numeric/mtl/io/matrix_market.hpp> +#include <boost/numeric/mtl/io/read_el_matrix.hpp> +#include <boost/numeric/mtl/io/test_ostream.hpp> + +#include <boost/numeric/mtl/interface/arprec.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +#endif // MTL_TYPES_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/add_const.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/add_const.hpp new file mode 100644 index 0000000000000000000000000000000000000000..002d7caafaef88eb2190f2f7611003a3f0791e11 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/add_const.hpp @@ -0,0 +1,72 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_ADD_CONST_INCLUDE +#define MTL_TRAITS_ADD_CONST_INCLUDE + +namespace mtl { namespace traits { + +/// Add const to data +/** In case of pointers, constify data of first level (even if it is a pointer itself) + instead of (outer) address. + Other types are constified like in boost::add_const. + \sa add_const_to_root, add_const_to_all **/ +template <typename T> +struct add_const_to_data +{ + typedef T const type; +}; + +template <typename T*> +struct add_const_to_data +{ + typedef T const * type; +}; + +/// Add const to data at the root +/** In case of pointers, constify data of innermost level and leave other levels as they are. + instead of (outer) address. + Other types are constified like in boost::add_const. + \sa add_const_to_data, add_const_to_all **/ +template <typename T> +struct add_const_to_root +{ + typedef T const type; +}; + +template <typename T*> +struct add_const_to_root +{ + typedef typename add_const_to_root<T>::type * type; +}; + +/// Add const on all levels +/** In case of pointers, constify the address and recursively the type it is pointing to. + Other types are constified like in boost::add_const. + \sa add_const_to_data, add_const_to_all **/ +template <typename T> +struct add_const_to_all +{ + typedef T const type; +}; + +template <typename T*> +struct add_const_to_all +{ + typedef typename add_const_to_all<T>::type * const type; +}; + +}} // namespace mtl::traits + +#endif // MTL_TRAITS_ADD_CONST_INCLUDE + + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/algebraic_category.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/algebraic_category.hpp new file mode 100644 index 0000000000000000000000000000000000000000..045f30f2be4e9937c73d9fdf89c759182722b54c --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/algebraic_category.hpp @@ -0,0 +1,39 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_ALGEBRAIC_CATEGORY_INCLUDE +#define MTL_TRAITS_ALGEBRAIC_CATEGORY_INCLUDE + +#include <boost/numeric/mtl/utility/is_what.hpp> + +namespace mtl { namespace traits { + +/// Meta-function for categorizing types into tag::scalar, tag::vector, and tag::matrix +/** Automatically derived from category + @ingroup Tags +*/ +template <typename T> +struct algebraic_category + : boost::mpl::if_< + is_matrix<T> + , tag::matrix + , typename boost::mpl::if_< + is_vector<T> + , tag::vector + , tag::scalar + >::type + > +{}; + +}} // namespace mtl::traits + +#endif // MTL_TRAITS_ALGEBRAIC_CATEGORY_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/ashape.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/ashape.hpp new file mode 100644 index 0000000000000000000000000000000000000000..e559fb30cf8aeda52faf0a9e7f01f98ad74b44af --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/ashape.hpp @@ -0,0 +1,724 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_ASHAPE_INCLUDE +#define MTL_ASHAPE_INCLUDE + +#include <vector> +#include <boost/type_traits/is_same.hpp> +#include <boost/mpl/if.hpp> + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/root.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/static_assert.hpp> + +// Not elegant but necessary to treat ITL types right +#include <boost/numeric/itl/itl_fwd.hpp> + +#ifdef MTL_WITH_INITLIST +# include <initializer_list> +#endif + +namespace mtl { + +/// Namespace for algebraic shapes; used for sophisticated dispatching between operations +namespace ashape { + +// forward declaration +template <typename T> struct ashape_aux; + +/// Tag for arbitrary algebraic shape +struct universe {}; + +// Types (tags) +/// Scalar algebraic shape +struct scal : universe {}; + +/// Non-scalar algebraic shape +struct nonscal : universe {}; +/// Row vector as algebraic shape +template <typename Value> struct rvec : nonscal {}; +/// Column vector as algebraic shape +template <typename Value> struct cvec : nonscal {}; +/// Matrix as algebraic shape +template <typename Value> struct mat : nonscal {}; +/// Undefined shape, e.g., for undefined results of operations +struct ndef {}; +/// Future shape, i.e. after appropriate evaluation it will have the shape \p Value +template <typename Value> struct future : nonscal {}; + +/// Meta-function for algebraic shape of T +/** Unknown types are treated like scalars. ashape of collections are template + parameterized with ashape of their elements, e.g., ashape< matrix < vector < double > > >::type is + mat< rvec < scal > > >. + Implemented with ashape_aux after type is cleaned up with mtl::traits::root. +**/ +template <typename T> +struct ashape + : ashape_aux<typename mtl::traits::root<T>::type> {}; + +template <typename T> +struct ashape_aux +{ + typedef scal type; +}; + +/// Vectors must be distinguished between row and column vectors +template <typename Value, typename Parameters> +struct ashape_aux<mtl::vector::dense_vector<Value, Parameters> > +{ + typedef typename boost::mpl::if_< + boost::is_same<typename Parameters::orientation, row_major> + , rvec<typename ashape<Value>::type> + , cvec<typename ashape<Value>::type> + >::type type; +}; + +/// Same as dense vector +template <typename Value, typename Parameters> +struct ashape_aux<vector::strided_vector_ref<Value, Parameters> > + : ashape<mtl::vector::dense_vector<Value, Parameters> > {}; + +/// Same as dense vector +template <typename Value, typename Parameters> +struct ashape_aux<vector::sparse_vector<Value, Parameters> > + : ashape<mtl::vector::dense_vector<Value, Parameters> > {}; + +/// One-dimensional arrays have rvec ashape; 2D arrays are matrices see below +template <typename Value, unsigned Rows> +struct ashape_aux<Value[Rows]> +{ + typedef rvec<typename ashape<Value>::type> type; +}; + +#ifdef MTL_WITH_INITLIST +/// Non-nested initializer_list have rvec ashape, nested lists are matrices see below +template <typename Value> +struct ashape_aux<std::initializer_list<Value> > +{ + typedef rvec<typename ashape<Value>::type> type; +}; +#endif + +/// std::vectors have rvec ashape +template <typename Value, typename Allocator> +struct ashape_aux<std::vector<Value, Allocator> > +{ + typedef rvec<typename ashape<Value>::type> type; +}; + +/// One-dimensional arrays have rvec ashape; 2D arrays are matrices see below +template <typename Value> +struct ashape_aux<Value*> +{ + typedef rvec<typename ashape<Value>::type> type; +}; + +template <typename E1, typename E2, typename SFunctor> +struct ashape_aux< vector::vec_vec_pmop_expr<E1, E2, SFunctor> > +{ + MTL_STATIC_ASSERT((boost::is_same<typename ashape<E1>::type, + typename ashape<E2>::type>::value), "Operands must have same algebraic shape."); + typedef typename ashape<E1>::type type; +}; + +template <typename E1, typename E2, typename SFunctor> +struct ashape_aux< vector::vec_vec_op_expr<E1, E2, SFunctor> > +{ +#if 0 // not sure if this is true in all operations + MTL_STATIC_ASSERT((boost::is_same<typename ashape<E1>::type, + typename ashape<E2>::type>::value), "Operands must have same algebraic shape."); +#endif + typedef typename ashape<E1>::type type; +}; + +template <typename E1, typename E2, typename SFunctor> +struct ashape_aux< vector::vec_vec_aop_expr<E1, E2, SFunctor> > +{ + typedef typename ashape<E1>::type type; +}; + +template <typename E1, typename E2, typename SFunctor> +struct ashape_aux< vector::vec_scal_aop_expr<E1, E2, SFunctor> > +{ + typedef typename ashape<E1>::type type; +}; + +template <typename Vector> +struct ashape_aux< vector::vec_const_ref_expr<Vector> > +{ + typedef typename ashape<Vector>::type type; +}; + + +// ======== +// Matrices +// ======== + +template <typename Value, typename Parameters> +struct ashape_aux<mtl::matrix::compressed2D<Value, Parameters> > +{ + typedef mat<typename ashape<Value>::type> type; +}; + +template <typename Value, typename Parameters> +struct ashape_aux<mtl::matrix::coordinate2D<Value, Parameters> > +{ + typedef mat<typename ashape<Value>::type> type; +}; + +template <typename Value, typename Parameters> +struct ashape_aux<mtl::matrix::sparse_banded<Value, Parameters> > +{ + typedef mat<typename ashape<Value>::type> type; +}; + +template <typename Value, typename Parameters> +struct ashape_aux<mtl::matrix::dense2D<Value, Parameters> > +{ + typedef mat<typename ashape<Value>::type> type; +}; + +template <typename Value, std::size_t Mask, typename Parameters> +struct ashape_aux<mtl::matrix::morton_dense<Value, Mask, Parameters> > +{ + typedef mat<typename ashape<Value>::type> type; +}; + +template <typename Functor> +struct ashape_aux<mtl::matrix::implicit_dense<Functor> > +{ + typedef mat<typename ashape<typename Functor::result_type>::type> type; +}; + +/// Two-dimensional arrays have mat ashape; 1D arrays are vectors see above +template <typename Value, unsigned Rows, unsigned Cols> +struct ashape_aux<Value[Rows][Cols]> +{ + typedef mat<typename ashape<Value>::type> type; +}; + +/// Two-dimensional arrays have mat ashape; 1D arrays are vectors see above +template <typename Value, unsigned Cols> +struct ashape_aux<Value (*)[Cols]> +{ + typedef mat<typename ashape<Value>::type> type; +}; + +#ifdef MTL_WITH_INITLIST +/// Nested initializer_list are matrices, non-nested are vectors see above +template <typename Value> +struct ashape_aux<std::initializer_list<std::initializer_list<Value> > > +{ + typedef mat<typename ashape<Value>::type> type; +}; +#endif + +template <typename Vector> +struct ashape_aux<mtl::matrix::multi_vector<Vector> > +{ + typedef mat<typename ashape<typename mtl::Collection<mtl::matrix::multi_vector<Vector> >::value_type>::type> type; +}; + +template <typename Value> +struct ashape_aux<matrix::element_structure<Value> > +{ + typedef mat<typename ashape<Value>::type> type; +}; + +template <typename Value, typename Parameters> +struct ashape_aux<mtl::matrix::ell_matrix<Value, Parameters> > +{ + typedef mat<typename ashape<Value>::type> type; +}; + + +template <typename Vector> +struct ashape_aux<matrix::multi_vector_range<Vector> > +{ + typedef mat<typename ashape<typename mtl::Collection<matrix::multi_vector_range<Vector> >::value_type>::type> type; +}; + +template <typename E1, typename E2, typename SFunctor> +struct ashape_aux< matrix::mat_mat_op_expr<E1, E2, SFunctor> > +{ + MTL_STATIC_ASSERT((boost::is_same<typename ashape<E1>::type, + typename ashape<E2>::type>::value), "Operands must have same algebraic shape."); + typedef typename ashape<E1>::type type; +}; + +template <typename Vector1, typename Vector2> +struct ashape< matrix::outer_product_matrix<Vector1, Vector2> > +{ + // BOOST_STATIC_ASSERT((boost::is_same<typename ashape<E1>::type, + // typename transposed_shape<typename ashape<E2>::type>::type>::value)); + typedef mat<typename ashape<typename mtl::Collection<Vector1>::value_type>::type> type; +}; + +template <typename Matrix, typename VectorIn> +struct ashape< vector::mat_cvec_multiplier<Matrix, VectorIn> > +{ + typedef cvec<scal> type; +}; + +// ===== +// Views +// ===== + +template <typename Functor, typename Coll> +struct ashape_aux<matrix::map_view<Functor, Coll> > +{ + typedef typename ashape<Coll>::type type; +}; + +template <typename Functor, typename Coll> +struct ashape_aux<vector::map_view<Functor, Coll> > +{ + typedef typename ashape<Coll>::type type; +}; + +template <typename Coll> +struct ashape_aux<vector::conj_view<Coll> > +{ + typedef typename ashape<Coll>::type type; +}; + +template <typename Coll> +struct ashape_aux<vector::real_view<Coll> > +{ + typedef typename ashape<Coll>::type type; +}; + +template <typename Coll> +struct ashape_aux<vector::imag_view<Coll> > +{ + typedef typename ashape<Coll>::type type; +}; + +#if 1 +// shouldn't be needed +template <typename Coll> +struct ashape_aux<mtl::matrix::transposed_view<const matrix::conj_view<Coll> > > +{ + typedef typename ashape<Coll>::type type; +}; +#endif + +template <typename Matrix> +struct ashape_aux<matrix::transposed_view<Matrix> > +{ + typedef typename ashape<Matrix>::type type; +}; + +template <typename Matrix> +struct ashape_aux<matrix::banded_view<Matrix> > +{ + typedef typename ashape<Matrix>::type type; +}; + +template <typename Matrix> +struct ashape_aux<matrix::indirect<Matrix> > +{ + typedef typename ashape<Matrix>::type type; +}; + +// Rule out other types as algebraic shape +template <typename IFStream, typename OFStream> +struct ashape_aux<io::matrix_file<IFStream, OFStream> > +{ + typedef ndef type; +}; + + +// ===================== +// Shapes of products: +// ===================== + +// a) The result's shape +// b) Classify operation in terms of shape + +// Operation types: + +struct scal_scal_mult {}; +struct cvec_rvec_mult {}; // outer product +struct rvec_cvec_mult {}; // inner product (without conj) +struct rvec_mat_mult {}; +struct mat_cvec_mult {}; +struct mat_mat_mult {}; +struct scal_rvec_mult {}; +struct scal_cvec_mult {}; +struct scal_mat_mult {}; +struct rvec_scal_mult {}; +struct cvec_scal_mult {}; +struct mat_scal_mult {}; + + + +// ===================== +// Results of operations +// ===================== + +/* + s cv rv m +------------------- + s | s cv* rv* m* +cv | cv* x m x +rv | rv* s x rv + m | m* cv x m + + * only on outer level, forbidden for elements of collections + +*/ + +// Results for elements of collections, i.e. scalar * matrix (vector) are excluded + + +/// Algebraic shape of multiplication's result when elements of collections are multiplied. +/** The types are the same as for multiplications of entire collections except that scalar * + matrix (or vector) is excluded to avoid ambiguities. + emult_shape <Shape1, Shape2> is only properly defined if emult_op <Shape1, Shape2>::type is not ndef! +**/ +template <typename Shape1, typename Shape2> +struct emult_shape +{ + typedef ndef type; +}; + +/// Type of operation when values of Shape1 and Shape2 are multiplied (so far only for elements of collections) +/** The types are the same as for multiplications of entire collections except that scalar * + matrix (or vector) is excluded to avoid ambiguities. **/ +template <typename Shape1, typename Shape2> +struct emult_op +{ + typedef ndef type; +}; + + +// Scalar * scalar -> scalar +template <> +struct emult_shape<scal, scal> +{ + typedef scal type; +}; + +template <> +struct emult_op<scal, scal> +{ + typedef scal_scal_mult type; +}; + +// Column times row vector, i.e. outer product +template <typename Value1, typename Value2> +struct emult_shape<cvec<Value1>, rvec<Value2> > +{ + typedef mat<typename emult_shape<Value1, Value2>::type> type; +}; + +template <typename Value1, typename Value2> +struct emult_op<cvec<Value1>, rvec<Value2> > +{ + // if product of elements is undefined then product is undefined too + typedef typename boost::mpl::if_< + boost::is_same<typename emult_op<Value1, Value2>::type, ndef> + , ndef + , cvec_rvec_mult + >::type type; +}; + + +// Row times column vector, i.e. inner product (without conj) +template <typename Value1, typename Value2> +struct emult_shape<rvec<Value1>, cvec<Value2> > +{ + typedef typename emult_shape<Value1, Value2>::type type; +}; + +template <typename Value1, typename Value2> +struct emult_op<rvec<Value1>, cvec<Value2> > +{ + // if product of elements is undefined then product is undefined too + typedef typename boost::mpl::if_< + boost::is_same<typename emult_op<Value1, Value2>::type, ndef> + , ndef + , rvec_cvec_mult + >::type type; +}; + +// Row vector times matrix +template <typename Value1, typename Value2> +struct emult_shape<rvec<Value1>, mat<Value2> > +{ + typedef rvec<typename emult_shape<Value1, Value2>::type> type; +}; + + +template <typename Value1, typename Value2> +struct emult_op<rvec<Value1>, mat<Value2> > +{ + // if product of elements is undefined then product is undefined too + typedef typename boost::mpl::if_< + boost::is_same<typename emult_op<Value1, Value2>::type, ndef> + , ndef + , rvec_mat_mult + >::type type; +}; + +// Matrix times column vector +template <typename Value1, typename Value2> +struct emult_shape<mat<Value1>, cvec<Value2> > +{ + typedef cvec<typename emult_shape<Value1, Value2>::type> type; +}; + +template <typename Value1, typename Value2> +struct emult_op<mat<Value1>, cvec<Value2> > +{ + // if product of elements is undefined then product is undefined too + typedef typename boost::mpl::if_< + boost::is_same<typename emult_op<Value1, Value2>::type, ndef> + , ndef + , mat_cvec_mult + >::type type; +}; + + +// Matrix product +template <typename Value1, typename Value2> +struct emult_shape<mat<Value1>, mat<Value2> > +{ + typedef mat<typename emult_shape<Value1, Value2>::type> type; +}; + +template <typename Value1, typename Value2> +struct emult_op<mat<Value1>, mat<Value2> > +{ + // if product of elements is undefined then product is undefined too + typedef typename boost::mpl::if_< + boost::is_same<typename emult_op<Value1, Value2>::type, ndef> + , ndef + , mat_mat_mult + >::type type; +}; + + +// Results for entire collections, i.e. scalar * matrix (vector) are allowed + +// Multiplying collections as emult + +template <typename Shape1, typename Shape2> +struct mult_shape + : public emult_shape<Shape1, Shape2> +{}; + +template <typename Shape1, typename Shape2> +struct mult_op + : public emult_op<Shape1, Shape2> +{}; + +// Scale collection from left + +template <typename Shape2> +struct mult_shape<scal, Shape2> +{ + typedef Shape2 type; +}; + +template <typename Value2> +struct mult_op<scal, rvec<Value2> > +{ + typedef scal_rvec_mult type; +}; + +template <typename Value2> +struct mult_op<scal, cvec<Value2> > +{ + typedef scal_cvec_mult type; +}; + +template <typename Value2> +struct mult_op<scal, mat<Value2> > +{ + typedef scal_mat_mult type; +}; + +// Scale collection from right + +template <typename Shape1> +struct mult_shape<Shape1, scal> +{ + typedef Shape1 type; +}; + +template <typename Value1> +struct mult_op<rvec<Value1>, scal> +{ + typedef rvec_scal_mult type; +}; + +template <typename Value1> +struct mult_op<cvec<Value1>, scal> +{ + typedef cvec_scal_mult type; +}; + +template <typename Value1> +struct mult_op<mat<Value1>, scal> +{ + typedef mat_scal_mult type; +}; + +// Arbitration +template <> +struct mult_shape<scal, scal> +{ + typedef scal type; +}; + + +// Needs to be verified for nested matrix types, cf. #140 +template <typename E1, typename E2> +struct ashape< matrix::mat_mat_times_expr<E1, E2> > +{ + // typedef typename ashape<E1>::type type; + typedef typename mult_shape<typename ashape<E1>::type, + typename ashape<E2>::type>::type type; +}; + + +template <typename E1, typename E2> +struct ashape< mat_cvec_times_expr<E1, E2> > +{ + // Resulting vector has the same shape as the multiplied + typedef typename ashape<E2>::type type; +}; + +template <typename E1, typename E2> +struct ashape< vector::rvec_mat_times_expr<E1, E2> > +{ + // Resulting vector has the same shape as the multiplied + typedef typename ashape<E1>::type type; +}; + + +// added by Hui Li (below) ----------------------------------------- + +// ===================== +// Shapes of divisions: +// ===================== + +// Operation types: + +struct scal_scal_div {}; +struct cvec_scal_div {}; +struct rvec_scal_div {}; +struct mat_scal_div {}; + +template < typename Shape1, typename Shape2 > +struct div_shape +{ + typedef ndef type; +}; + +template < typename Shape1, typename Shape2 > +struct div_op +{ + typedef ndef type; +}; + +template <> +struct div_shape<scal,scal> +{ + typedef scal type; +}; + +template<> +struct div_op<scal,scal> +{ + typedef scal type; +}; + +template < typename Value1 > +struct div_shape < rvec<Value1>, scal > +{ + typedef typename boost::mpl::if_< + typename boost::is_same<typename div_shape<Value1,scal>::type,ndef>::type, + ndef, + rvec<typename div_shape<Value1,scal>::type> + >::type type; +}; + +template < typename Value1 > +struct div_op< rvec<Value1>, scal > +{ + typedef typename boost::mpl::if_< + typename boost::is_same<typename div_shape<rvec<Value1>,scal>::type,ndef>::type, + ndef, + rvec_scal_div + >::type type; +}; + +template < typename Value1 > +struct div_shape < cvec<Value1>, scal > +{ + typedef typename boost::mpl::if_< + typename boost::is_same<typename div_shape<Value1,scal>::type,ndef>::type, + ndef, + cvec<typename div_shape<Value1,scal>::type> + >::type type; +}; + +template < typename Value1 > +struct div_op< cvec<Value1>, scal > +{ + typedef typename boost::mpl::if_< + typename boost::is_same<typename div_shape<cvec<Value1>,scal>::type,ndef>::type, + ndef, + cvec_scal_div + >::type type; +}; + +template < typename Value1 > +struct div_shape < mat<Value1>, scal > +{ + typedef typename boost::mpl::if_< + typename boost::is_same<typename div_shape<Value1,scal>::type,ndef>::type, + ndef, + mat<typename div_shape<Value1,scal>::type> + >::type type; +}; + +template < typename Value1 > +struct div_op < mat<Value1>, scal > +{ + typedef typename boost::mpl::if_< + typename boost::is_same<typename div_shape<mat<Value1>,scal>::type,ndef>::type, + ndef, + mat_scal_div + >::type type; +}; + +// added by Hui Li (above) ----------------------------------------- + +// ==================== ITL types ================================== + +template <typename PC, typename Vector, bool Adjoint> +struct ashape<itl::pc::solver<PC, Vector, Adjoint> > +{ + typedef future<cvec<scal> > type; // might be a problem with nested matrices and vectors +}; + + +}} // namespace mtl::ashape + +#endif // MTL_ASHAPE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/category.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/category.hpp new file mode 100644 index 0000000000000000000000000000000000000000..e0fd118de31570b76c418f8e711ac480e940141f --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/category.hpp @@ -0,0 +1,304 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_CATEGORY_INCLUDE +#define MTL_CATEGORY_INCLUDE + +#include <vector> + +#include <boost/type_traits/is_same.hpp> +#include <boost/mpl/if.hpp> +#include <boost/mpl/bool.hpp> + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> + +// Not elegant but necessary to treat ITL types right +#include <boost/numeric/itl/itl_fwd.hpp> + + +namespace mtl { namespace traits { + +/// Meta-function for categorizing MTL and external types +/** Has to be specialized for each %matrix, %vector, ... + Extensively used for dispatching + @ingroup Tags +*/ +template <typename Collection> struct category +{ + typedef tag::unknown type; +}; + +// Const types have the same category as their non-const counterpart +template <typename T> +struct category<const T> +{ + typedef typename category<T>::type type; +}; + +template <typename Value, typename Parameters> +struct category<mtl::matrix::dense2D<Value, Parameters> > +{ + typedef tag::dense2D type; +}; + + +template <typename Functor> +struct category<mtl::matrix::implicit_dense<Functor> > +{ + typedef tag::implicit_dense type; +}; + +template <typename Value> +struct category<mtl::matrix::ones_matrix<Value> > + : public category<mtl::matrix::implicit_dense<mtl::matrix::ones_functor<Value> > > +{}; + +template <typename Value> +struct category<mtl::matrix::hilbert_matrix<Value> > + : public category<mtl::matrix::implicit_dense<mtl::matrix::hilbert_functor<Value> > > +{}; + +template <typename Vector1, typename Vector2> +struct category<mtl::matrix::outer_product_matrix<Vector1, Vector2> > + : public category<mtl::matrix::implicit_dense<mtl::matrix::outer_product_functor<Vector1, Vector2> > > +{}; + + +template <typename Elt, std::size_t BitMask, typename Parameters> +struct category<mtl::matrix::morton_dense<Elt, BitMask, Parameters> > +{ + typedef mtl::tag::morton_dense type; +}; + +template <typename Elt, typename Parameters> +struct category<mtl::matrix::compressed2D<Elt, Parameters> > +{ + typedef tag::compressed2D type; +}; + +// should have the same tags as compressed2D +template <typename Elt, typename Parameters> +struct category<mtl::matrix::coordinate2D<Elt, Parameters> > +{ + typedef tag::compressed2D type; +}; + +template <typename Elt, typename Parameters> +struct category<mtl::matrix::sparse_banded<Elt, Parameters> > +{ + typedef tag::sparse_banded_matrix type; +}; + +template <typename Vector> +struct category<mtl::matrix::multi_vector<Vector> > +{ + typedef tag::multi_vector type; +}; + +template <typename Vector> +struct category<mtl::matrix::multi_vector_range<Vector> > +{ + typedef tag::multi_vector type; +}; + +template <typename Value> +struct category<mtl::matrix::element_structure<Value> > +{ + typedef tag::element_structure type; +}; + +template <typename Value, typename Parameters> +struct category<mtl::matrix::ell_matrix<Value, Parameters> > +{ + typedef tag::ell_matrix type; +}; + +template <typename T, typename Parameters> +struct category< mtl::vector::dense_vector<T, Parameters> > +{ + typedef typename boost::mpl::if_< + boost::is_same<typename Parameters::orientation, row_major> + , tag::dense_row_vector + , tag::dense_col_vector + >::type type; +} ; + +template <typename T, typename Parameters> +struct category< vector::strided_vector_ref<T, Parameters> > +{ + typedef typename boost::mpl::if_< + boost::is_same<typename Parameters::orientation, row_major> + , tag::strided_row_vector + , tag::strided_col_vector + >::type type; +} ; + +template <typename T, typename Parameters> +struct category< vector::sparse_vector<T, Parameters> > +{ + typedef typename boost::mpl::if_< + boost::is_same<typename Parameters::orientation, row_major> + , tag::sparse_row_vector + , tag::sparse_col_vector + >::type type; +} ; + + +template <class E1, class E2, class SFunctor> +struct category< vector::vec_vec_pmop_expr<E1,E2, SFunctor> > +{ + typedef category<E1> type; +}; + +template <typename Functor, typename Vector> +struct category<vector::map_view<Functor, Vector> > + : public category<Vector> +{}; + +template <typename Scaling, typename Vector> +struct category< vector::scaled_view<Scaling, Vector> > + : public category< vector::map_view<tfunctor::scale<Scaling, typename Vector::value_type>, + Vector> > +{}; + +// added by Hui Li +template <typename Vector,typename RScaling> +struct category< vector::rscaled_view<Vector,RScaling> > + : public category< vector::map_view<tfunctor::rscale<typename Vector::value_type,RScaling>, + Vector> > +{}; + +// added by Hui Li +template <typename Vector,typename Divisor> +struct category< vector::divide_by_view<Vector,Divisor> > + : public category< vector::map_view<tfunctor::divide_by<typename Vector::value_type,Divisor>, + Vector> > +{}; + +template <typename Vector> +struct category< vector::conj_view<Vector> > + : public category< vector::map_view<sfunctor::conj<typename Vector::value_type>, Vector> > +{}; + +template <typename Vector> +struct category< vector::negate_view<Vector> > + : public category< vector::map_view<sfunctor::negate<typename Vector::value_type>, Vector> > +{}; + +// To handle std::vector in algorithms +template <typename T> +struct category< std::vector<T> > +{ + typedef tag::std_vector type; +}; + +namespace detail { + + template <typename Cat> struct view_category { typedef Cat type; }; + + template <> struct view_category<tag::dense2D> { typedef tag::dense2D_view type; }; + template <> struct view_category<tag::morton_dense> { typedef tag::morton_view type; }; + template <> struct view_category<tag::compressed2D> { typedef tag::compressed2D_view type; }; + + template <typename Matrix> + struct simple_matrix_view_category + : view_category<typename category<Matrix>::type> + {}; + +} // detail + + +template <typename Functor, typename Matrix> +struct category<mtl::matrix::map_view<Functor, Matrix> > + : public detail::simple_matrix_view_category<Matrix> +{}; + +template <typename Scaling, typename Matrix> +struct category< mtl::matrix::scaled_view<Scaling, Matrix> > + : public category< matrix::map_view<tfunctor::scale<Scaling, typename Matrix::value_type>, + Matrix> > +{}; + +// added by Hui Li +template <typename Matrix, typename RScaling> +struct category< mtl::matrix::rscaled_view<Matrix,RScaling> > + : public category< matrix::map_view<tfunctor::rscale<typename Matrix::value_type,RScaling>, + Matrix> > +{}; + +// added by Hui Li +template <typename Matrix, typename Divisor> +struct category< mtl::matrix::divide_by_view<Matrix,Divisor> > + : public category< matrix::map_view<tfunctor::divide_by<typename Matrix::value_type,Divisor>, + Matrix> > +{}; + +// add dense to view_category +template <typename Matrix> +struct category<mtl::matrix::indirect<Matrix> > +{ + typedef mtl::tag::join<typename detail::simple_matrix_view_category<Matrix>::type, mtl::tag::dense> type; +}; + + +template <typename Matrix> +struct category<mtl::matrix::transposed_view<Matrix> > + : public category<Matrix> +{}; + +// Specialize on transposed multi-vectors +template <typename Vector> +struct category< mtl::matrix::transposed_view< mtl::matrix::multi_vector<Vector> > > +{ + typedef tag::transposed_multi_vector type; +}; + +template <typename Matrix> +struct category< matrix::conj_view<Matrix> > + : public category< matrix::map_view<sfunctor::conj<typename Matrix::value_type>, Matrix> > +{}; + +template <typename Matrix> +struct category< matrix::hermitian_view<Matrix> > + : public category< mtl::matrix::map_view<sfunctor::conj<typename Matrix::value_type>, + mtl::matrix::transposed_view<Matrix> > > +{}; + +// Specialize on Hermiatians of multi-vectors +template <typename Vector> +struct category< matrix::hermitian_view<mtl::matrix::multi_vector<Vector> > > +{ + typedef tag::hermitian_multi_vector type; +}; + + +template <typename Matrix> +struct category< mtl::matrix::banded_view<Matrix> > + : public detail::simple_matrix_view_category<Matrix> +{}; + +template <typename Matrix, typename VectorIn> +struct category< mtl::vector::mat_cvec_multiplier<Matrix, VectorIn> > +{ + typedef tag::mat_cvec_multiplier type; +}; + +template <typename PC, typename Vector, bool Adjoint> +struct category<itl::pc::solver<PC, Vector, Adjoint> > +{ + typedef tag::unevaluated type; // might be a problem with nested matrices and vectors +}; + +}} // namespace mtl::traits + +#endif // MTL_CATEGORY_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/common_include.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/common_include.hpp new file mode 100644 index 0000000000000000000000000000000000000000..adf0727d10605be4f00c066b566c08ace22a944a --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/common_include.hpp @@ -0,0 +1,37 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_COMMON_INCLUDES_INCLUDE +#define MTL_COMMON_INCLUDES_INCLUDE + +#include <boost/numeric/mtl/matrix/base_matrix.hpp> +#include <boost/numeric/mtl/matrix/crtp_base_matrix.hpp> +#include <boost/numeric/mtl/matrix/parameter.hpp> +#include <boost/numeric/mtl/utility/property_map.hpp> +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/detail/range_generator.hpp> +#include <boost/numeric/mtl/utility/complexity.hpp> +#include <boost/numeric/mtl/utility/glas_tag.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/matrix/inserter.hpp> +#include <boost/numeric/mtl/operation/matrix_bracket.hpp> +#include <boost/numeric/mtl/operation/sub_matrix.hpp> +#include <boost/numeric/mtl/operation/copy.hpp> +#include <boost/numeric/mtl/utility/maybe.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> + + +// Under construction +// #include <boost/numeric/mtl/utilities/iterator_adaptor_1D.hpp> + +#endif // MTL_COMMON_INCLUDES_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/complexity.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/complexity.hpp new file mode 100644 index 0000000000000000000000000000000000000000..eaa7a9bb401e60c3c86decb9f7ccd04921a0edc2 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/complexity.hpp @@ -0,0 +1,193 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_COMPLEXITY_INCLUDE +#define MTL_COMPLEXITY_INCLUDE + +#include <boost/mpl/int.hpp> +#include <boost/mpl/max.hpp> +#include <boost/mpl/if.hpp> +#include <boost/mpl/less.hpp> +#include <boost/mpl/less_equal.hpp> + +// This file contains types to characterize time complexities of operations or traversals +// Different traversals over given collections have different run time +// Algorithms implementable with different traversals can use these complexities to dispatch + +// Complexities in a order, which of course will not be changed +// The underlying MPL definitions might be modified to add finer grained distinctions + + + +namespace mtl { +/// Namespace to define complexity classes +namespace complexity_classes { + +/// Constant complexity where the value is expected to be in cache with high probability. +/** Special type for traversals to distinguish between strided or random memory access with 'constant' + (but slow) memory access and consecutive memory access with a good change that only one element + per cache line must be load from memory +**/ +struct cached : boost::mpl::int_<1> {}; + +/// Constant complexity +struct constant : boost::mpl::int_<2> {}; + +/// Logarithmic complexity +struct log_n : boost::mpl::int_<4> {}; + +/// Polynomial logarithm, i.e. log^k n +struct polylog_n : boost::mpl::int_<5> {}; + +/// Product of linear and cached +struct linear_cached : boost::mpl::int_<21> {}; + +/// Linear +struct linear : boost::mpl::int_<22> {}; + +/// Logarithm times linear, i.e. n * log n +struct n_log_n : boost::mpl::int_<24> {}; + +/// Polynomial logarithm times linear, i.e. n * log^k n +struct n_polylog_n : boost::mpl::int_<25> {}; + +struct quadratic : boost::mpl::int_<41> {}; + +/// All complexities larger than quadratic (< infinite) including n^2 log^k n +struct polynomial : boost::mpl::int_<200> {}; + +/// Infinite time complexity, which usually means that the operation or traversal is not available +struct infinite : boost::mpl::int_<1000> {}; + +/// Adding complexities of two operations is the maximal complexity of both operations +template <typename X, typename Y> +struct plus : boost::mpl::if_< boost::mpl::less<X, Y>, Y, X> {}; + +/// Minimal complexity class +template <typename X, typename Y> +struct min : boost::mpl::if_< boost::mpl::less<X, Y>, X, Y> {}; + + +namespace detail +{ + // specializations on first argument + + // polynomial is the most frequent result, otherwise explicit definition later + template <typename X, typename Y> struct times + { + typedef polynomial type; + }; + + template <typename Y> struct times<cached, Y> + { + typedef Y type; + }; + + template <typename Y> struct times<constant, Y> + { + typedef Y type; + }; + + template <> struct times<log_n, log_n> + { + typedef polylog_n type; + }; + + template <> struct times<log_n, polylog_n> : times<log_n, log_n> {}; + + template <> struct times<log_n, linear_cached> + { + typedef n_log_n type; + }; + + template <> struct times<log_n, linear> : times<log_n, linear_cached> {}; + + template <> struct times<log_n, n_log_n> + { + typedef n_polylog_n type; + }; + + template <> struct times<log_n, n_polylog_n> : times<log_n, n_log_n> {}; + + template <> struct times<polylog_n, polylog_n> + { + typedef polylog_n type; + }; + + template <> struct times<polylog_n, linear_cached> + { + typedef n_polylog_n type; + }; + + template <> struct times<polylog_n, linear> : times<polylog_n, linear_cached> {}; + + template <> struct times<polylog_n, n_log_n> : times<polylog_n, linear_cached> {}; + + template <> struct times<polylog_n, n_polylog_n> : times<polylog_n, linear_cached> {}; + + template <> struct times<linear_cached, linear_cached> + { + typedef quadratic type; + }; + + template <> struct times<linear_cached, linear> : times<linear_cached, linear_cached> {}; + + template <> struct times<linear, linear> : times<linear_cached, linear_cached> {}; + +} // namespace detail + +/// Product of complexities +// Multiplication needs to be defined explicitly +// At least is symmetric, so we only consider X <= Y +template <typename X, typename Y> +struct times + : boost::mpl::if_< + boost::mpl::less<X, Y> + , detail::times<X, Y> + , detail::times<Y, X> + >::type +{}; + +// Specializations on second argument (if were ordered) +// Done here to avoid ambiguities + +template <typename X> +struct times<X, infinite> +{ + typedef infinite type; +}; + +template <typename X> struct times<infinite, X> : times<X, infinite> {}; + +}} // namespace mtl::complexity + +#define MTL_PRINT_COMPLEXITY(TYPE, STRING) \ +inline std::ostream& operator<< (std::ostream& os, mtl::complexity_classes::TYPE) \ +{ \ + return os << STRING; \ +} + +MTL_PRINT_COMPLEXITY(cached, "cached constant complexity") +MTL_PRINT_COMPLEXITY(constant, "constant complexity") +MTL_PRINT_COMPLEXITY(log_n, "logarithmic complexity") +MTL_PRINT_COMPLEXITY(polylog_n, "poly-logarithmic complexity") +MTL_PRINT_COMPLEXITY(linear_cached, "cached linear complexity") +MTL_PRINT_COMPLEXITY(linear, "linear complexity") +MTL_PRINT_COMPLEXITY(n_log_n, "n log n complexity") +MTL_PRINT_COMPLEXITY(n_polylog_n, "n poly-log n complexity") +MTL_PRINT_COMPLEXITY(quadratic, "quadratic complexity") +MTL_PRINT_COMPLEXITY(polynomial, "polynomial complexity") +MTL_PRINT_COMPLEXITY(infinite, "infinite complexity") + + + +#endif // MTL_COMPLEXITY_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/compose_view.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/compose_view.hpp new file mode 100644 index 0000000000000000000000000000000000000000..50b68252e4cf934bbc02c3299b8d593ba4a85408 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/compose_view.hpp @@ -0,0 +1,64 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_COMPOSE_VIEW_INCLUDE +#define MTL_TRAITS_COMPOSE_VIEW_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/utility/static_assert.hpp> +#include <boost/numeric/mtl/utility/is_what.hpp> + +namespace mtl { namespace traits { + +/// Compose matrix view from code and matrix type +template <unsigned Code, typename Matrix> +struct matrix_compose_view +{ + MTL_STATIC_ASSERT(Code <= 7, "Illegal ViewCode!"); + typedef typename boost::remove_reference<typename matrix_compose_view<Code & 1, Matrix>::type>::type matrix_type; + + typedef typename boost::mpl::if_c< + (Code >= 6), + mtl::matrix::hermitian_view<matrix_type>, + typename boost::mpl::if_c< + (Code >= 4), + mtl::matrix::transposed_view<matrix_type>, + mtl::matrix::conj_view<matrix_type> + >::type + >::type type; +}; + +template <typename Matrix> +struct matrix_compose_view<0, Matrix> +{ + typedef Matrix& type; +}; + +template <typename Matrix> +struct matrix_compose_view<1, Matrix> +{ + typedef const Matrix& type; +}; + +// Add vector stuff + +/// Compose view from code and collection type (matrix or vector) +template <unsigned Code, typename Collection> +struct compose_view + : matrix_compose_view<Code, Collection> +{ + MTL_STATIC_ASSERT(is_matrix<Collection>::value, "Currently only matrices are supported."); +}; + +}} // namespace mtl::traits + +#endif // MTL_TRAITS_COMPOSE_VIEW_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/copy_expression_const_ref_container.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/copy_expression_const_ref_container.hpp new file mode 100644 index 0000000000000000000000000000000000000000..bbcaab66d3eecbb68b3c70d61670f3c83eb8b761 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/copy_expression_const_ref_container.hpp @@ -0,0 +1,78 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_COPY_EXPRESSION_CONST_REF_CONTAINER_INCLUDE +#define MTL_TRAITS_COPY_EXPRESSION_CONST_REF_CONTAINER_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> + +namespace mtl { namespace traits { + +/// Type trait that defines the type itself for expressions and a const reference otherwise +/** Needed for re-constructed expression templates because references to expression are + often invalid. **/ +template <typename Container> +struct copy_expression_const_ref_container +{ + typedef const Container& type; +}; + + +template <class E1, class E2, typename SFunctor> +struct copy_expression_const_ref_container< vector::vec_vec_pmop_expr<E1, E2, SFunctor> > +{ + typedef vector::vec_vec_pmop_expr<E1, E2, SFunctor> type; +}; + +template <class E1, class E2, typename SFunctor> +struct copy_expression_const_ref_container< vector::vec_vec_aop_expr<E1, E2, SFunctor> > +{ + typedef vector::vec_vec_aop_expr<E1, E2, SFunctor> type; +}; + +template <typename Functor, typename Vector> +struct copy_expression_const_ref_container< vector::map_view<Functor, Vector> > +{ + typedef vector::map_view<Functor, Vector> type; +}; + +template <typename Scaling, typename Vector> +struct copy_expression_const_ref_container< vector::scaled_view<Scaling, Vector> > +{ + typedef vector::scaled_view<Scaling, Vector> type; +}; + +template <typename Vector, typename RScaling> +struct copy_expression_const_ref_container< vector::rscaled_view<Vector, RScaling> > +{ + typedef vector::rscaled_view<Vector, RScaling> type; +}; + +template <typename Vector, typename Divisor> +struct copy_expression_const_ref_container< vector::divide_by_view<Vector, Divisor> > +{ + typedef vector::divide_by_view<Vector, Divisor> type; +}; + +template <typename Vector> +struct copy_expression_const_ref_container< vector::conj_view<Vector> > +{ + typedef vector::conj_view<Vector> type; +}; + + + + + +}} // namespace mtl::traits + +#endif // MTL_TRAITS_COPY_EXPRESSION_CONST_REF_CONTAINER_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/dense_el_cursor.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/dense_el_cursor.hpp new file mode 100644 index 0000000000000000000000000000000000000000..0799be58e470bcc0cf512320ac943e8cec2af27d --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/dense_el_cursor.hpp @@ -0,0 +1,53 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_DENSE_EL_CURSOR_INCLUDE +#define MTL_DENSE_EL_CURSOR_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/detail/base_cursor.hpp> + +namespace mtl { + +/// Cursor over every element of matrix, matrix row/column, or vector +template <typename Value> +struct dense_el_cursor : public detail::base_cursor<const Value*> +{ + typedef Value value_type; + typedef const value_type* const_pointer_type; // ? + typedef detail::base_cursor<const Value*> super; + + typedef dense_el_cursor self; + + dense_el_cursor () {} + dense_el_cursor (const_pointer_type me) : super(me) {} + dense_el_cursor (super s) : super(s) {} + + template <typename Parameters> + dense_el_cursor(mtl::matrix::dense2D<Value, Parameters> const& ma, size_t r, size_t c) + : super(ma.elements() + ma.indexer(ma, r, c)) + {} + + self operator+(int x) const + { + return self(super::operator+(x)); + } + + int operator-(self const& x) + { + return super::operator-(x); + } +}; + +} // namespace mtl + +#endif // MTL_DENSE_EL_CURSOR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/different_non_complex.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/different_non_complex.hpp new file mode 100644 index 0000000000000000000000000000000000000000..8558c671cc7ab65a17728bdf48920047043c9381 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/different_non_complex.hpp @@ -0,0 +1,34 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_DIFFERENT_NON_COMPLEX_INCLUDE +#define MTL_TRAITS_DIFFERENT_NON_COMPLEX_INCLUDE + +#include <boost/mpl/bool.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/type_traits/is_complex.hpp> +#include <boost/type_traits/is_scalar.hpp> + + +namespace mtl { namespace traits { + +/// Type trait for different non-complex scalars, i.e. pairs of scalars whose complex equivalents are not supported in binary operations +template <typename T, typename U> +struct different_non_complex + : boost::mpl::bool_< !boost::is_same<T, U>::value && !boost::is_complex<T>::value && !boost::is_complex<U>::value + && boost::is_scalar<T>::value && boost::is_scalar<U>::value> +{}; + + +}} // namespace mtl::traits + +#endif // MTL_TRAITS_DIFFERENT_NON_COMPLEX_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/domain.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/domain.hpp new file mode 100644 index 0000000000000000000000000000000000000000..9b4be551cee5085792356e83008064707d1c99ba --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/domain.hpp @@ -0,0 +1,40 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_DOMAIN_INCLUDE +#define MTL_TRAITS_DOMAIN_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/enable_if.hpp> + +namespace mtl { namespace traits { + +// Helper +template <typename Matrix, bool IsMatrix> +struct domain_aux {}; + +template <typename Matrix> +struct domain_aux<Matrix, true> +{ + typedef mtl::vector::dense_vector<typename Collection<Matrix>::value_type, vector::parameters<> > type; +}; + +/// Type trait returning domain type of linear operator (matrix) +template <typename Matrix> +struct domain + : domain_aux<Matrix, is_matrix<Matrix>::value> +{}; + +}} // namespace mtl::traits + +#endif // MTL_TRAITS_DOMAIN_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/enable_if.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/enable_if.hpp new file mode 100644 index 0000000000000000000000000000000000000000..3e070ef6febbadf8adcbb65beb7cdc7ee1cd8b53 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/enable_if.hpp @@ -0,0 +1,53 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_ENABLE_IF_INCLUDE +#define MTL_ENABLE_IF_INCLUDE + +#include <boost/utility/enable_if.hpp> +#include <boost/numeric/mtl/utility/is_what.hpp> + +namespace mtl { namespace traits { + +template <typename Value, typename Type = void> +struct enable_if_matrix + : boost::enable_if<is_matrix<Value>, Type> +{}; + +template <typename Value, typename Type = void> +struct enable_if_vector + : boost::enable_if<is_vector<Value>, Type> +{}; + +template <typename Value, typename Type = void> +struct enable_if_scalar + : boost::enable_if<is_scalar<Value>, Type> +{}; + +template <typename Value, typename Type> +struct lazy_enable_if_matrix + : boost::lazy_enable_if<is_matrix<Value>, Type> +{}; + +template <typename Value, typename Type> +struct lazy_enable_if_vector + : boost::lazy_enable_if<is_vector<Value>, Type> +{}; + +template <typename Value, typename Type> +struct lazy_enable_if_scalar + : boost::lazy_enable_if<is_scalar<Value>, Type> +{}; + +}} // namespace mtl + +#endif // MTL_ENABLE_IF_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/eval.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/eval.hpp new file mode 100644 index 0000000000000000000000000000000000000000..8c4668f75dae1e0ac90ff37fba8c31819e56b6bb --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/eval.hpp @@ -0,0 +1,173 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_EVAL_INCLUDE +#define MTL_TRAITS_EVAL_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/matrix/crtp_base_matrix.hpp> +#include <boost/numeric/mtl/matrix/mat_expr.hpp> + +namespace mtl { namespace traits { + + +template <typename T> +struct eval {}; + +#if 0 // To be done later +template <typename Value, typename Parameter> +struct eval< mtl::vector::dense_vector<Value, Parameter> > +{}; + + +template <typename Value1, typename Vector> +struct eval< mtl::vector::scaled_view<Value1, Vector> > +{}; + +template <typename Value1, typename Vector> +struct eval< mtl::vector::rscaled_view<Value1, Vector> > +{}; +#endif + + + namespace impl { + + template<typename T> + struct eval_self_ref + { + typedef const T& const_reference; + + explicit eval_self_ref(const T& ref) : ref(ref) {} + + const_reference value() const { return ref; } + + const T& ref; + }; + } + + +template <typename Value, typename Parameter> +struct eval< mtl::matrix::dense2D<Value, Parameter> > + : public impl::eval_self_ref< mtl::matrix::dense2D<Value, Parameter> > +{ + eval(const mtl::matrix::dense2D<Value, Parameter>& ref) + : impl::eval_self_ref< mtl::matrix::dense2D<Value, Parameter> >(ref) + {} +}; + +template <typename Value, std::size_t Mask, typename Parameter> +struct eval< mtl::matrix::morton_dense<Value, Mask, Parameter> > + : public impl::eval_self_ref< mtl::matrix::morton_dense<Value, Mask, Parameter> > +{ + eval(const mtl::matrix::morton_dense<Value, Mask, Parameter>& ref) + : impl::eval_self_ref< mtl::matrix::morton_dense<Value, Mask, Parameter> >(ref) + {} +}; + +template <typename Value, typename Parameter> +struct eval< mtl::matrix::compressed2D<Value, Parameter> > + : public impl::eval_self_ref< mtl::matrix::compressed2D<Value, Parameter> > +{ + eval(const mtl::matrix::compressed2D<Value, Parameter>& ref) + : impl::eval_self_ref< mtl::matrix::compressed2D<Value, Parameter> >(ref) + {} +}; + + + + +#if 0 // only dummy +template <typename E1, typename E2> +struct eval< mtl::matrix::mat_mat_asgn_expr<E1, E2> > +{}; +#endif + + +template <typename E1, typename E2> +struct eval< mtl::matrix::mat_mat_plus_expr<E1, E2> > + : public impl::eval_self_ref< mtl::matrix::mat_mat_plus_expr<E1, E2> > +{ + eval(const mtl::matrix::mat_mat_plus_expr<E1, E2>& ref) + : impl::eval_self_ref< mtl::matrix::mat_mat_plus_expr<E1, E2> >(ref) + {} +}; + +template <typename E1, typename E2> +struct eval< mtl::matrix::mat_mat_minus_expr<E1, E2> > + : public impl::eval_self_ref< mtl::matrix::mat_mat_minus_expr<E1, E2> > +{ + eval(const mtl::matrix::mat_mat_minus_expr<E1, E2>& ref) + : impl::eval_self_ref< mtl::matrix::mat_mat_minus_expr<E1, E2> >(ref) + {} +}; + +template <typename E1, typename E2> +struct eval< mtl::matrix::mat_mat_ele_times_expr<E1, E2> > + : public impl::eval_self_ref< mtl::matrix::mat_mat_ele_times_expr<E1, E2> > +{ + eval(const mtl::matrix::mat_mat_ele_times_expr<E1, E2>& ref) + : impl::eval_self_ref< mtl::matrix::mat_mat_ele_times_expr<E1, E2> >(ref) + {} +}; + + +template <typename E1, typename E2> +struct eval< mtl::matrix::mat_mat_times_expr<E1, E2> > +{ + // Needs dramatic improvement!!! Only for testing!!! + typedef matrix::dense2D<double> matrix_type; + typedef const matrix_type& const_reference; + + + explicit eval(const mtl::matrix::mat_mat_times_expr<E1, E2>& expr) + : prod(expr.first * expr.second) + {} + + const_reference value() { return prod; } + +private: + matrix_type prod; +}; + + + + +template <typename Value1, typename Matrix> +struct eval< mtl::matrix::scaled_view<Value1, Matrix> > +{}; + +template <typename Value1, typename Matrix> +struct eval< mtl::matrix::rscaled_view<Value1, Matrix> > +{}; + + +template <typename T> +eval<T> inline evaluate(const T& ref) +{ + return eval<T>(ref); +} + + +} // namespace traits + +namespace matrix { + using mtl::traits::evaluate; +} + +namespace vector { + using mtl::traits::evaluate; +} + + +} // namespace mtl + +#endif // MTL_TRAITS_EVAL_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/eval_dense.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/eval_dense.hpp new file mode 100644 index 0000000000000000000000000000000000000000..5e0176d0b1dfe31a085ec9eff06c66b90867411d --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/eval_dense.hpp @@ -0,0 +1,109 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_EVAL_DENSE_INCLUDE +#define MTL_TRAITS_EVAL_DENSE_INCLUDE + +#include <boost/mpl/bool.hpp> +#include <boost/numeric/mtl/mtl_fwd.hpp> + +namespace mtl { namespace traits { + + +template <typename T> +struct eval_dense + : boost::mpl::false_ +{}; + +template <typename Value, typename Parameter> +struct eval_dense< mtl::vector::dense_vector<Value, Parameter> > + : boost::mpl::true_ +{}; + +template <typename Value, typename Parameter> +struct eval_dense< mtl::matrix::dense2D<Value, Parameter> > + : boost::mpl::true_ +{}; + +template <typename Value, std::size_t Mask, typename Parameter> +struct eval_dense< mtl::matrix::morton_dense<Value, Mask, Parameter> > + : boost::mpl::true_ +{}; + + + +template <typename Value1, typename Vector> +struct eval_dense< mtl::vector::scaled_view<Value1, Vector> > + : eval_dense<Vector> +{}; + +template <typename Value1, typename Vector> +struct eval_dense< mtl::vector::rscaled_view<Value1, Vector> > + : eval_dense<Vector> +{}; + + + +template <typename E1, typename E2> +struct eval_dense< mtl::matrix::mat_mat_asgn_expr<E1, E2> > + : boost::mpl::bool_< eval_dense<E1>::value && eval_dense<E2>::value > +{}; + +template <typename E1, typename E2> +struct eval_dense< mtl::matrix::mat_mat_plus_expr<E1, E2> > + : boost::mpl::bool_< eval_dense<E1>::value && eval_dense<E2>::value > +{}; + +template <typename E1, typename E2> +struct eval_dense< mtl::matrix::mat_mat_minus_expr<E1, E2> > + : boost::mpl::bool_< eval_dense<E1>::value && eval_dense<E2>::value > +{}; + +template <typename E1, typename E2> +struct eval_dense< mtl::matrix::mat_mat_ele_times_expr<E1, E2> > + : boost::mpl::bool_< eval_dense<E1>::value && eval_dense<E2>::value > +{}; + +template <typename Value1, typename Matrix> +struct eval_dense< mtl::matrix::scaled_view<Value1, Matrix> > + : eval_dense<Matrix> +{}; + +template <typename Matrix> +struct eval_dense< mtl::matrix::negate_view<Matrix > > + : eval_dense<Matrix> +{}; + +template <typename Matrix> +struct eval_dense< mtl::matrix::real_view<Matrix > > + : eval_dense<Matrix> +{}; + +template <typename Matrix> +struct eval_dense< mtl::matrix::imag_view<Matrix > > + : eval_dense<Matrix> +{}; + +template <typename Functor, typename Matrix> +struct eval_dense< mtl::matrix::map_view<Functor, Matrix > > + : eval_dense<Matrix> +{}; + +template <typename Value1, typename Matrix> +struct eval_dense< mtl::matrix::rscaled_view<Value1, Matrix> > + : eval_dense<Matrix> +{}; + + +}} // namespace mtl::traits + +#endif // MTL_TRAITS_EVAL_DENSE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/exception.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/exception.hpp new file mode 100644 index 0000000000000000000000000000000000000000..95f3d07025e57c2836fd25bfdeb11913406f806f --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/exception.hpp @@ -0,0 +1,243 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MTL_EXCEPTION_INCLUDE +#define MTL_MTL_EXCEPTION_INCLUDE + +#include <cassert> +#include <stdexcept> + +namespace mtl { + +#ifndef NDEBUG +# define MTL_DEBUG_ARG(Arg) Arg +#else +# define MTL_DEBUG_ARG(Arg) +#endif + +#ifndef MTL_ASSERT_FOR_THROW +# define MTL_THROW_ARG(Arg) Arg +#else +# define MTL_THROW_ARG(Arg) +#endif + +// If MTL_ASSERT_FOR_THROW is defined all throws become assert +// MTL_DEBUG_THROW_IF completely disappears if NDEBUG is defined +#ifndef NDEBUG +# ifdef MTL_ASSERT_FOR_THROW +# define MTL_DEBUG_THROW_IF(Test, Exception) \ + { assert(!(Test)); } +# else +# define MTL_DEBUG_THROW_IF(Test, Exception) \ + { if (Test) throw Exception; } +# endif +#else +# define MTL_DEBUG_THROW_IF(Test,Exception) +#endif + + +#if defined(MTL_ASSERT_FOR_THROW) && !defined(NDEBUG) +# define MTL_THROW_IF(Test, Exception) \ + { \ + assert(!(Test)); \ + } +#else +# define MTL_THROW_IF(Test, Exception) \ + { \ + if (Test) throw Exception; \ + } +#endif + + +#if defined(MTL_ASSERT_FOR_THROW) && !defined(NDEBUG) +# define MTL_THROW(Exception) \ + { \ + assert(0); \ + } +#else +# define MTL_THROW(Exception) \ + { \ + throw Exception; \ + } +#endif + + +#if 0 +standard errors: + +exception + logic_error + domain_error + invalid_argument + length_error + out_of_range + runtime_error + range_error + overflow_error + underflow_error +bad_alloc +bad_cast +bad_exception +bad_typeid + +#endif + +/// Exception for indices out of range +struct index_out_of_range : public std::out_of_range +{ + /// Error can be specified more precisely in constructor if desired + explicit index_out_of_range(const char *s= "Index out of range") : std::out_of_range(s) {} +}; + +/// Exception for invalid range definitions, esp. in constructors +struct range_error : public std::range_error +{ + /// Error can be specified more precisely in constructor if desired + explicit range_error(const char *s= "Invalid range") : std::range_error(s) {} +}; + +/// Domain errors in MTL4 +struct domain_error : public std::domain_error +{ + /// Error can be specified more precisely in constructor if desired + explicit domain_error(const char *s= "MTL4 domain error.") : std::domain_error(s) {} +}; + +/// Exception for arguments with incompatible sizes +struct incompatible_size : public domain_error +{ + /// Error can be specified more precisely in constructor if desired + explicit incompatible_size(const char *s= "Arguments have incompatible size.") + : domain_error(s) {} +}; + +/// Exception for arguments that shall not be empty +struct need_nonempty : public domain_error +{ + /// Error can be specified more precisely in constructor if desired + explicit need_nonempty(const char *s= "Argument must be non-empty.") + : domain_error(s) {} +}; + +/// Exception for trying to change a fixed size (to another value) +struct change_static_size : public domain_error +{ + /// Error can be specified more precisely in constructor if desired + explicit change_static_size(const char *s= "You try to change a fixed size (to another value).") + : domain_error(s) {} +}; + +/// Exception for arguments with incompatible shapes, e.g. adding matrices and vectors +struct argument_result_conflict : public domain_error +{ + /// Error can be specified more precisely in constructor if desired + explicit argument_result_conflict(const char *s= "Used same object illegally as argument and result.") + : domain_error(s) {} +}; + +/// Exception for arguments with incompatible shapes, e.g. adding matrices and vectors +struct incompatible_shape : public domain_error +{ + /// Error can be specified more precisely in constructor if desired + explicit incompatible_shape(const char *s= "Arguments have incompatible shape.") + : domain_error(s) {} +}; + +/// Exception for arguments with incompatible sizes +struct matrix_not_square : public domain_error +{ + /// Error can be specified more precisely in constructor if desired + explicit matrix_not_square(const char *s= "Matrix must be square for this operation.") + : domain_error(s) {} +}; + +/// Exception for matrices too small for certain algorithms +struct matrix_too_small : public domain_error +{ + /// Error can be specified more precisely in constructor if desired + explicit matrix_too_small(const char *s= "Matrix is too small for certain algorithms.") + : domain_error(s) {} +}; + +/// Exception for singular matrices in solvers +struct matrix_singular : public domain_error +{ + /// Error can be specified more precisely in constructor if desired + explicit matrix_singular(const char *s= "Matrix singular in solver.") + : domain_error(s) {} +}; + +/// Exception for arguments with incompatible sizes +struct missing_diagonal : public domain_error +{ + /// Error can be specified more precisely in constructor if desired + explicit missing_diagonal(const char *s= "Diagonal entry missing or not where it belongs to.") + : domain_error(s) {} +}; + +/// Accessing (illegally) matrix or vector during insertion phase (dense non-distributed can be accessed always) +struct access_during_insertion : public domain_error +{ + /// Error can be specified more precisely in constructor if desired + explicit access_during_insertion(const char *s= "Diagonal entry missing.") + : domain_error(s) {} +}; + +/// Exception for a result that is not what it should be +struct unexpected_result : public domain_error +{ + /// Error can be specified more precisely in constructor if desired + explicit unexpected_result(const char *s= "The result of an operation is not the expected one.") + : domain_error(s) {} +}; + +/// Exception for run-time errors that doesn't fit into specific categories +struct runtime_error : public std::runtime_error +{ + /// Error can be specified more precisely in constructor if desired + explicit runtime_error(const char *s= "Run-time error") : std::runtime_error(s) {} +}; + +struct division_by_zero : mtl::runtime_error +{ + /// Error can be specified more precisely in constructor if desired + explicit division_by_zero(const char *s= "Division by zero") : runtime_error(s) {} +}; + + +/// Exception for logic errors that doesn't fit into specific categories +struct logic_error : public std::logic_error +{ + /// Error can be specified more precisely in constructor if desired + explicit logic_error(const char *s= "Logic error") : std::logic_error(s) {} +}; + +/// Exception for I/O errors in general +struct io_error : public std::runtime_error +{ + /// Error can be specified more precisely in constructor if desired + explicit io_error(const char *s= "I/O error") : std::runtime_error(s) {} +}; + +/// File not found +struct file_not_found : public io_error +{ + /// Error can be specified more precisely in constructor if desired + explicit file_not_found(const char *s= "File not found") : io_error(s) {} +}; + + + + +} // namespace mtl + +#endif // MTL_MTL_EXCEPTION_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/extended_complex.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/extended_complex.hpp new file mode 100644 index 0000000000000000000000000000000000000000..7a5ebc31b70b956070005206f18b0e522a4ede83 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/extended_complex.hpp @@ -0,0 +1,44 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_EXTENDED_COMPLEX_INCLUDE +#define MTL_TRAITS_EXTENDED_COMPLEX_INCLUDE + +#include <complex> +#include <boost/numeric/mtl/utility/different_non_complex.hpp> +#include <boost/numeric/mtl/concept/std_concept.hpp> + +namespace mtl { namespace traits { + + +template <typename T, typename U, bool enable> +struct extended_complex_aux +{}; + +template <typename T, typename U> +struct extended_complex_aux<T, U, true> +{ + typedef std::complex<typename mtl::Addable<T, U>::result_type> type; +}; + + +/// Result type of extended complex binary arithmetic +/** If operation already exist in standard or non-complex are incompatible \p type does not exist. + extended_complex<T,U>::type is an implicit enable_if and avoids ambiguities. **/ +template <typename T, typename U> +struct extended_complex + : extended_complex_aux<T, U, different_non_complex<T, U>::value > +{}; + +}} // namespace mtl::traits + +#endif // MTL_TRAITS_EXTENDED_COMPLEX_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/fast_multi_vector_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/fast_multi_vector_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..bfbb1cae5f162a7e581316b501c871b89655f063 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/fast_multi_vector_expr.hpp @@ -0,0 +1,90 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_FAST_MULTI_VECTOR_EXPR_INCLUDE +#define MTL_TRAITS_FAST_MULTI_VECTOR_EXPR_INCLUDE + +namespace mtl { namespace traits { + + +/// Type trait whether an expression can be evaluated by a single vector operation +template <typename T> +struct fast_multi_vector_expr +{}; + +template <typename Vector> +struct fast_multi_vector_expr< mtl::matrix::multi_vector<Vector> > +{ + typedef Vector type; +}; + +// template <typename Vector> +// struct fast_multi_vector_expr< const mtl::matrix::multi_vector<Vector> > +// { +// typedef const Vector type; +// }; + +// template <typename E1, typename E2> +// struct fast_multi_vector_expr< mtl::matrix::mat_mat_asgn_expr<E1, E2> > +// : boost::mpl::bool_< fast_multi_vector_expr<E1>::value && fast_multi_vector_expr<E2>::value > +// {}; + +template <typename E1, typename E2> +struct fast_multi_vector_expr< mtl::matrix::mv_mv_plus_expr<E1, E2> > +{ + typedef typename fast_multi_vector_expr<E1>::type V1; + typedef typename fast_multi_vector_expr<E2>::type V2; + typedef typename mtl::sfunctor::plus<typename V1::value_type, typename V2::value_type> Functor; + + typedef mtl::vector::vec_vec_pmop_expr<V1, V2, Functor> type; +}; + +template <typename E1, typename E2> +struct fast_multi_vector_expr< mtl::matrix::mat_mat_minus_expr<E1, E2> > +{ + typedef typename fast_multi_vector_expr<E1>::type V1; + typedef typename fast_multi_vector_expr<E2>::type V2; + typedef typename mtl::sfunctor::minus<typename V1::value_type, typename V2::value_type> Functor; + + typedef mtl::vector::vec_vec_pmop_expr<V1, V2, Functor> type; +}; + +// template <typename E1, typename E2> +// struct fast_multi_vector_expr< mtl::matrix::mat_mat_ele_times_expr<E1, E2> > +// { +// typedef mtl::matrix::mv_mv_ele_times_expr<typename fast_multi_vector_expr<E1>::type, +// typename fast_multi_vector_expr<E2>::type> type; +// }; + +template <typename Functor, typename Matrix> +struct fast_multi_vector_expr< mtl::matrix::map_view<Functor, Matrix> > +{ + typedef mtl::vector::map_view<Functor, typename fast_multi_vector_expr<Matrix>::type> type; +}; + + +template <typename Value1, typename Matrix> +struct fast_multi_vector_expr< mtl::matrix::scaled_view<Value1, Matrix> > +{ + typedef mtl::vector::scaled_view<Value1, typename fast_multi_vector_expr<Matrix>::type> type; +}; + +template <typename Value1, typename Matrix> +struct fast_multi_vector_expr< mtl::matrix::rscaled_view<Value1, Matrix> > +{ + typedef mtl::vector::rscaled_view<Value1, typename fast_multi_vector_expr<Matrix>::type> type; +}; + + +}} // namespace mtl::traits + +#endif // MTL_TRAITS_FAST_MULTI_VECTOR_EXPR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/flatcat.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/flatcat.hpp new file mode 100644 index 0000000000000000000000000000000000000000..390a3bbf7f57e1d23f508d0f03ec08da8e6e6ab9 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/flatcat.hpp @@ -0,0 +1,166 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_FLATCAT_INCLUDE +#define MTL_TRAITS_FLATCAT_INCLUDE + +#include <boost/mpl/if.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/type_traits/is_base_of.hpp> + +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> + +namespace mtl { namespace traits { + + +template <typename C, typename U1> +struct flatcat1_c + : boost::mpl::if_<boost::is_base_of<U1, C>, + tag::flat<U1>, + tag::universe + >::type +{}; + +template <typename T, typename U1> +struct flatcat1 + : flatcat1_c<typename category<T>::type, U1> {}; + +template <typename C, typename U1, typename U2> +struct flatcat2_c + : boost::mpl::if_<boost::is_base_of<U1, C>, + tag::flat<U1>, + flatcat1_c<C, U2> + >::type +{}; + +template <typename T, typename U1, typename U2> +struct flatcat2 + : flatcat2_c<typename category<T>::type, U1, U2> {}; + +template <typename C, typename U1, typename U2, typename U3> +struct flatcat3_c + : boost::mpl::if_<boost::is_base_of<U1, C>, + tag::flat<U1>, + flatcat2_c<C, U2, U3> + >::type +{}; + +template <typename T, typename U1, typename U2, typename U3> +struct flatcat3 + : flatcat3_c<typename category<T>::type, U1, U2, U3> {}; + + +template <typename C, typename U1, typename U2, typename U3, typename U4> +struct flatcat4_c + : boost::mpl::if_<boost::is_base_of<U1, C>, + tag::flat<U1>, + flatcat3_c<C, U2, U3, U4> + >::type +{}; + +template <typename T, typename U1, typename U2, typename U3, typename U4> +struct flatcat4 + : flatcat4_c<typename category<T>::type, U1, U2, U3, U4> {}; + + +template <typename C, typename U1, typename U2, typename U3, typename U4, typename U5> +struct flatcat5_c + : boost::mpl::if_<boost::is_base_of<U1, C>, + tag::flat<U1>, + flatcat4_c<C, U2, U3, U4, U5> + >::type +{}; + +template <typename T, typename U1, typename U2, typename U3, typename U4, typename U5> +struct flatcat5 + : flatcat5_c<typename category<T>::type, U1, U2, U3, U4, U5> {}; + +template <typename C, typename U1, typename U2, typename U3, typename U4, typename U5, typename U6> +struct flatcat6_c + : boost::mpl::if_<boost::is_base_of<U1, C>, + tag::flat<U1>, + flatcat5_c<C, U2, U3, U4, U5, U6> + >::type +{}; + +template <typename T, typename U1, typename U2, typename U3, typename U4, typename U5, typename U6> +struct flatcat6 + : flatcat6_c<typename category<T>::type, U1, U2, U3, U4, U5, U6> {}; + +template <typename C, typename U1, typename U2, typename U3, typename U4, typename U5, typename U6, typename U7> +struct flatcat7_c + : boost::mpl::if_<boost::is_base_of<U1, C>, + tag::flat<U1>, + flatcat6_c<C, U2, U3, U4, U5, U6, U7> + >::type +{}; + +template <typename T, typename U1, typename U2, typename U3, typename U4, typename U5, typename U6, typename U7> +struct flatcat7 + : flatcat7_c<typename category<T>::type, U1, U2, U3, U4, U5, U6, U7> {}; + + +// Some often reused flatcats: + +#if 0 +template <typename Matrix> +struct mat_cvec_flatcat + : flatcat7<Matrix, tag::element_structure, tag::sparse_banded_matrix, tag::transposed_multi_vector, tag::hermitian_multi_vector, tag::multi_vector, tag::dense, tag::sparse> +{}; +#endif + +template <typename Matrix> +struct mat_cvec_flatcat + : flatcat6<Matrix, tag::element_structure, tag::transposed_multi_vector, tag::hermitian_multi_vector, tag::multi_vector, tag::dense, tag::sparse> +{}; + +template <typename Collection> +struct shape_flatcat + : flatcat4<Collection, tag::matrix, tag::col_vector, tag::row_vector, tag::scalar> +{}; + +template <typename Collection> +struct sparsity_flatcat + : flatcat2<Collection, tag::dense, tag::sparse> +{}; + +template <typename Collection> +struct cursor_flatcat + : flatcat3<Collection, tag::has_fast_ra_cursor, tag::has_ra_cursor, tag::has_cursor> +{}; + +template <typename Collection> +struct iterator_flatcat + : flatcat3<Collection, tag::has_fast_ra_iterator, tag::has_ra_iterator, tag::has_iterator> +{}; + +template <typename Collection> +struct has_iterator_flatcat + : flatcat1<Collection, tag::has_iterator> +{}; + + +template <typename Collection> +struct layout_flatcat + : flatcat2<Collection, tag::has_2D_layout, tag::has_1D_layout> +{}; + + +template <typename Matrix> +struct sub_matrix_flatcat + : flatcat3<Matrix, tag::sub_divisible, tag::qsub_divisible, tag::has_sub_matrix> +{}; + +}} // namespace mtl::traits + +#endif // MTL_TRAITS_FLATCAT_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/glas_tag.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/glas_tag.hpp new file mode 100644 index 0000000000000000000000000000000000000000..2b6bed90e90ce81f8ea4e5e4cdecc0faf6a6bf10 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/glas_tag.hpp @@ -0,0 +1,42 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef GLAS_GLAS_TAG_INCLUDE +#define GLAS_GLAS_TAG_INCLUDE + +#undef major + +namespace glas { namespace tag { + +// To iterate only over non-zero elements +struct nz {}; + +// To iterate over all elements +struct all {}; + +// To iterate over rows +// Generated cursors must provide range generators +struct row {}; + +// To iterate over cols +// Generated cursors must provide range generators +struct col {}; + +// To iterate over the major dimension of matrices (like MTL 2) +struct major {}; + +// Same with minor +struct minor {}; + +}} // namespace glas::tag + +#endif // GLAS_GLAS_TAG_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/gradient.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/gradient.hpp new file mode 100644 index 0000000000000000000000000000000000000000..46430c5ad55a5f98ab1b86ade31938ae400e69bf --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/gradient.hpp @@ -0,0 +1,36 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_GRADIENT_INCLUDE +#define MTL_TRAITS_GRADIENT_INCLUDE + +#include <boost/mpl/if.hpp> +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/utility/linear_operator.hpp> + +namespace mtl { namespace traits { + +/// Type trait returning type for gradient of function with T as argument +template <typename T> +struct gradient + : boost::mpl::if_<is_scalar<T>, mtl::vector::dense_vector<T>, tag::unknown> +{}; + +template <typename Value, typename Para> +struct gradient<mtl::vector::dense_vector<Value, Para> > + : linear_operator<mtl::vector::dense_vector<Value, Para>, mtl::vector::dense_vector<Value, Para> > +{}; + +}} // namespace mtl::traits + +#endif // MTL_TRAITS_GRADIENT_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/index_evaluatable.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/index_evaluatable.hpp new file mode 100644 index 0000000000000000000000000000000000000000..078662c872624f3780317205b1d3f24cd18469b5 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/index_evaluatable.hpp @@ -0,0 +1,116 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_INDEX_EVALUATABLE_INCLUDE +#define MTL_TRAITS_INDEX_EVALUATABLE_INCLUDE + +#include <boost/mpl/bool.hpp> +#include <boost/mpl/and.hpp> +#include <boost/mpl/or.hpp> + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/utility/is_vector_reduction.hpp> +#include <boost/numeric/mtl/utility/is_row_major.hpp> +#include <boost/numeric/mtl/operation/sfunctor.hpp> + +// Not elegant but necessary to treat ITL types right +#include <boost/numeric/itl/itl_fwd.hpp> + +namespace mtl { namespace traits { + +/// Type trait to check whether \p T can be evaluated index-wise (usually in lazy evaluation) +template <typename T> +struct index_evaluatable : boost::mpl::false_ {}; + +#ifndef MTL_WITH_OPENMP + +template <typename T, typename U, typename Assign> +struct index_evaluatable<lazy_assign<T, U, Assign> > + : boost::mpl::or_< + boost::mpl::and_<is_vector<T>, is_scalar<U> >, + boost::mpl::and_<is_vector<T>, is_vector<U> >, + boost::mpl::and_<is_scalar<T>, is_vector_reduction<U> > + > +{}; + +template <typename V1, typename Matrix, typename V2, typename Assign> +struct index_evaluatable<lazy_assign<V1, mtl::mat_cvec_times_expr<Matrix, V2>, Assign> > + : is_row_major<Matrix> {}; + +template <typename V1, typename Matrix, typename V2, typename Assign> +struct index_evaluatable<lazy_assign<V1, mtl::vector::mat_cvec_multiplier<Matrix, V2>, Assign> > + : boost::mpl::false_ +{}; + +template <typename T, typename U> +struct index_evaluatable<fused_expr<T, U> > + : boost::mpl::and_<index_evaluatable<T>, index_evaluatable<U> > +{}; + +#endif // not MTL_WITH_OPENMP + +/// Type trait to control whether evaluation should be unrolled +template <typename T> +struct unrolled_index_evaluatable : boost::mpl::false_ {}; + +#ifndef MTL_WITH_OPENMP + +template <typename T, typename U, typename Assign> +struct unrolled_index_evaluatable<lazy_assign<T, U, Assign> > + : boost::mpl::or_< + boost::mpl::and_<is_vector<T>, is_scalar<U> >, + boost::mpl::and_<is_vector<T>, is_vector<U> >, + boost::mpl::and_<is_scalar<T>, is_vector_reduction<U> > + > +{}; + +template <typename T, typename U> +struct unrolled_index_evaluatable<fused_expr<T, U> > + : boost::mpl::and_<unrolled_index_evaluatable<T>, unrolled_index_evaluatable<U> > +{}; + +#endif // not MTL_WITH_OPENMP + +/// Typetrait for forward evaluation +/** All index_evaluatable types are implicitly forward-evaluatable **/ +template <typename T> +struct forward_index_evaluatable + : index_evaluatable<T> +{}; + +/// Typetrait for backward evaluation +/** All index_evaluatable types are implicitly backward-evaluatable **/ +template <typename T> +struct backward_index_evaluatable + : index_evaluatable<T> +{}; + +#ifndef MTL_WITH_OPENMP + +template <typename V1, typename Matrix, typename Value, typename V2> +struct backward_index_evaluatable<lazy_assign<V1, itl::pc::solver<itl::pc::ic_0<Matrix, Value>, V2, true>, assign::assign_sum> > + : boost::mpl::true_ {}; + +template <typename V1, typename Matrix, typename Factorizer, typename Value, typename V2> +struct backward_index_evaluatable<lazy_assign<V1, itl::pc::solver<itl::pc::ilu<Matrix, Factorizer, Value>, V2, true>, assign::assign_sum> > + : boost::mpl::true_ {}; + +#endif // not MTL_WITH_OPENMP + +}} // namespace mtl::traits + + + + + +#endif // MTL_TRAITS_INDEX_EVALUATABLE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/index_evaluator.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/index_evaluator.hpp new file mode 100644 index 0000000000000000000000000000000000000000..e6b88eacf127f3ec90616ba942733782f2b46af1 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/index_evaluator.hpp @@ -0,0 +1,50 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_INDEX_EVALUATOR_INCLUDE +#define MTL_TRAITS_INDEX_EVALUATOR_INCLUDE + +#include <boost/mpl/if.hpp> +#include <boost/utility/enable_if.hpp> + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/utility/is_what.hpp> + +namespace mtl { namespace traits { + +/// Result type of index evaluation +template <typename T> +struct index_evaluator {}; + +template <typename T, typename U, typename Assign> +struct index_evaluator<lazy_assign<T, U, Assign> > + : boost::lazy_enable_if<is_vector<T>, + boost::mpl::if_<is_vector<U>, + mtl::vector::vec_vec_aop_expr<T, U, Assign>, + mtl::vector::vec_scal_aop_expr<T, U, Assign> + > + > +{}; + +// ... more + +template <typename T, typename U> +struct index_evaluator<fused_expr<T, U> > +{ + typedef mtl::vector::fused_index_evaluator<T, U> type; +}; + + + +}} // namespace mtl::traits + +#endif // MTL_TRAITS_INDEX_EVALUATOR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/irange.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/irange.hpp new file mode 100644 index 0000000000000000000000000000000000000000..5edb4e3416f752292f8c4d50e952ff180ea727e3 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/irange.hpp @@ -0,0 +1,124 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_IRANGE_INCLUDE +#define MTL_IRANGE_INCLUDE + +#include <limits> +#include <iostream> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/operation/is_negative.hpp> +#include <boost/numeric/mtl/detail/base_cursor.hpp> + + +namespace mtl { + + /// Maximal index + const std::size_t imax= std::numeric_limits<std::size_t>::max(); + + /// Class to define a half open index ranges + class irange + { + public: + + typedef std::size_t size_type; + typedef detail::base_cursor<size_type> cursor_type; + + /// Create an index range of [start, finish) + explicit irange(size_type start, size_type finish) : my_start(start), my_finish(finish) {} + + /// Create an index range of [0, finish) + explicit irange(size_type finish) : my_start(0), my_finish(finish) {} + + /// Create an index range of [0, imax), i.e. all indices + irange() : my_start(0), my_finish(imax) {} + + /// Set the index range to [start, finish) + irange& set(size_type start, size_type finish) + { + my_start= start; my_finish= finish; return *this; + } + + /// Set the index range of [0, finish) + irange& set(size_type finish) + { + my_start= 0; my_finish= finish; return *this; + } + + /// Decrease finish, i.e. [start, finish) -> [start, finish-1) + irange& operator--() + { + --my_finish; return *this; + } + + /// First index in range + size_type start() const { return my_start; } + /// Past-end index in range + size_type finish() const { return my_finish; } + /// Number of indices + size_type size() const { return my_finish > my_start ? my_finish - my_start : 0; } + + /// Whether the range is empty + bool empty() const { return my_finish <= my_start; } + + /// First index in range + cursor_type begin() const { return my_start; } + /// Past-end index in range + cursor_type end() const { return my_finish; } + + /// Maps integers [0, size()) to [start(), finish()) + /** Checks index in debug mode. Inverse of from_range. **/ + size_type to_range(size_type i) const + { + MTL_DEBUG_THROW_IF(is_negative(i) || i >= size(), index_out_of_range()); + return my_start + i; + } + + /// Maps integers [start(), finish()) to [0, size()) + /** Checks index in debug mode. **/ + size_type from_range(size_type i) const + { + MTL_DEBUG_THROW_IF(i < my_start || i >= my_finish, index_out_of_range()); + return i - my_start; + } + + /// Wether index is in range + bool in_range(size_type i) const + { + return i >= my_start && i < my_finish; + } + + friend std::ostream& operator<<(std::ostream& os, const irange& ir) + { return os << "mtl::irange(" << ir.my_start << ", " << ir.my_finish << ")"; } + + private: + size_type my_start, my_finish; + }; + /// All index in range + namespace { + // problems with multiple cpp projects, which include mtl multiple times + static const irange iall(0, imax); + //inline irange iall() { return irange(); } + } + + /// Intersection of two ranges + irange inline intersection(irange const& r1, irange const& r2) + { + return irange(std::max(r1.start(), r2.start()), std::min(r1.finish(), r2.finish())); + } + + +} // namespace mtl + + + +#endif // MTL_IRANGE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/is_composable_vector.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/is_composable_vector.hpp new file mode 100644 index 0000000000000000000000000000000000000000..ffebbf584f8c670732cf911447d4b1b4f0dc1680 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/is_composable_vector.hpp @@ -0,0 +1,35 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_IS_COMPOSABLE_VECTOR_INCLUDE +#define MTL_TRAITS_IS_COMPOSABLE_VECTOR_INCLUDE + +#include <boost/mpl/bool.hpp> +#include <boost/numeric/mtl/mtl_fwd.hpp> + +namespace mtl { namespace traits { + +template <typename T> +struct is_composable_vector + : boost::mpl::false_ +{}; + +template <typename Value, typename Parameters> +struct is_composable_vector< mtl::vector::dense_vector<Value, Parameters> > + : boost::mpl::true_ +{}; + + + +}} // namespace mtl::traits + +#endif // MTL_TRAITS_IS_COMPOSABLE_VECTOR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/is_distributed.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/is_distributed.hpp new file mode 100644 index 0000000000000000000000000000000000000000..1db6856aba9b82ba8cc87cd4a3e7923d0e43eaf2 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/is_distributed.hpp @@ -0,0 +1,31 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_IS_DISTRIBUTED_INCLUDE +#define MTL_TRAITS_IS_DISTRIBUTED_INCLUDE + +namespace mtl { namespace traits { + +template <typename T> +struct is_distributed_aux + : boost::mpl::false_ // by default false +{}; + +/// Meta-function whether a certain type is distributed +template <typename T> +struct is_distributed + : is_distributed_aux<typename root<T>::type> +{}; + +}} // namespace mtl::traits + +#endif // MTL_TRAITS_IS_DISTRIBUTED_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/is_lazy.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/is_lazy.hpp new file mode 100644 index 0000000000000000000000000000000000000000..27432e3fd1f0e37fc6951af8d8f936da8bcea77d --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/is_lazy.hpp @@ -0,0 +1,35 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_IS_LAZY_INCLUDE +#define MTL_TRAITS_IS_LAZY_INCLUDE + +#include <boost/mpl/bool.hpp> +#include <boost/numeric/mtl/mtl_fwd.hpp> + +namespace mtl { namespace traits { + +/// Type trait for determining wether \p T is to be evaluated lazily +template <typename T> +struct is_lazy : boost::mpl::false_ {}; + +template <typename T, typename U, typename Assign> +struct is_lazy<lazy_assign<T, U, Assign> > : boost::mpl::true_ {}; + +template <typename T, typename U> +struct is_lazy<fused_expr<T, U> > + : boost::mpl::and_<is_lazy<T>, is_lazy<U> > +{}; + +}} // namespace mtl::traits + +#endif // MTL_TRAITS_IS_LAZY_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/is_multi_vector_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/is_multi_vector_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..03819c865c70a13857bbe50e7eee7bedfa4381e5 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/is_multi_vector_expr.hpp @@ -0,0 +1,111 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_IS_MULTI_VECTOR_EXPR_INCLUDE +#define MTL_TRAITS_IS_MULTI_VECTOR_EXPR_INCLUDE + +#include <boost/mpl/bool.hpp> +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/utility/is_composable_vector.hpp> + +namespace mtl { namespace traits { + +/// Type trait whether an expression can be evaluated by multiple vector operations +template <typename T> +struct is_multi_vector_expr + : boost::mpl::false_ +{}; + +template <typename Vector> +struct is_multi_vector_expr< mtl::matrix::multi_vector<Vector> > + : boost::mpl::true_ +{}; + +// template <typename E1, typename E2> +// struct is_multi_vector_expr< mtl::matrix::mat_mat_asgn_expr<E1, E2> > +// : boost::mpl::bool_< is_multi_vector_expr<E1>::value && is_multi_vector_expr<E2>::value > +// {}; + +template <typename E1, typename E2> +struct is_multi_vector_expr< mtl::matrix::mv_mv_plus_expr<E1, E2> > + : boost::mpl::bool_< is_multi_vector_expr<E1>::value && is_multi_vector_expr<E2>::value > +{}; + +template <typename E1, typename E2> +struct is_multi_vector_expr< mtl::matrix::mat_mat_minus_expr<E1, E2> > + : boost::mpl::bool_< is_multi_vector_expr<E1>::value && is_multi_vector_expr<E2>::value > +{}; + +// template <typename E1, typename E2> +// struct is_multi_vector_expr< mtl::matrix::mat_mat_ele_times_expr<E1, E2> > +// : boost::mpl::bool_< is_multi_vector_expr<E1>::value && is_multi_vector_expr<E2>::value > +// {}; + +template <typename Value1, typename Matrix> +struct is_multi_vector_expr< mtl::matrix::scaled_view<Value1, Matrix> > + : is_multi_vector_expr<Matrix> +{}; + +template <typename Value1, typename Matrix> +struct is_multi_vector_expr< mtl::matrix::rscaled_view<Value1, Matrix> > + : is_multi_vector_expr<Matrix> +{}; + +// ---------------------------------------------------- + + +/// Type trait whether an expression can be evaluated by a single vector operation +template <typename T> +struct is_fast_multi_vector_expr + : boost::mpl::false_ +{}; + +template <typename Vector> +struct is_fast_multi_vector_expr< mtl::matrix::multi_vector<Vector> > + : is_composable_vector<Vector> +{}; + +// template <typename E1, typename E2> +// struct is_fast_multi_vector_expr< mtl::matrix::mat_mat_asgn_expr<E1, E2> > +// : boost::mpl::bool_< is_fast_multi_vector_expr<E1>::value && is_fast_multi_vector_expr<E2>::value > +// {}; + +template <typename E1, typename E2> +struct is_fast_multi_vector_expr< mtl::matrix::mv_mv_plus_expr<E1, E2> > + : boost::mpl::bool_< is_fast_multi_vector_expr<E1>::value && is_fast_multi_vector_expr<E2>::value > +{}; + +template <typename E1, typename E2> +struct is_fast_multi_vector_expr< mtl::matrix::mat_mat_minus_expr<E1, E2> > + : boost::mpl::bool_< is_fast_multi_vector_expr<E1>::value && is_fast_multi_vector_expr<E2>::value > +{}; + +// template <typename E1, typename E2> +// struct is_fast_multi_vector_expr< mtl::matrix::mat_mat_ele_times_expr<E1, E2> > +// : boost::mpl::bool_< is_fast_multi_vector_expr<E1>::value && is_fast_multi_vector_expr<E2>::value > +// {}; + +template <typename Value1, typename Matrix> +struct is_fast_multi_vector_expr< mtl::matrix::scaled_view<Value1, Matrix> > + : is_fast_multi_vector_expr<Matrix> +{}; + +template <typename Value1, typename Matrix> +struct is_fast_multi_vector_expr< mtl::matrix::rscaled_view<Value1, Matrix> > + : is_fast_multi_vector_expr<Matrix> +{}; + + + +}} // namespace mtl::traits + +#endif // MTL_TRAITS_IS_MULTI_VECTOR_EXPR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/is_row_major.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/is_row_major.hpp new file mode 100644 index 0000000000000000000000000000000000000000..795623e32b0f3e1d0788948fec06d14778500f48 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/is_row_major.hpp @@ -0,0 +1,98 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_IS_ROW_MAJOR_INCLUDE +#define MTL_IS_ROW_MAJOR_INCLUDE + +#include <boost/mpl/bool.hpp> +#include <boost/mpl/not.hpp> +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/matrix/parameter.hpp> +#include <boost/numeric/mtl/vector/parameter.hpp> + +namespace mtl { namespace traits { + + /// Meta-function whether a tag is row_major or col_major + /** For convenience, directly applicable to matrix::parameter and vector::parameter. + Refined from boost::mpl::true_ or boost::mpl::false_ if defined. + **/ + template <typename Parameter> + struct is_row_major {}; + + template <> + struct is_row_major<row_major> + : boost::mpl::true_ {}; + + template <> + struct is_row_major<col_major> + : boost::mpl::false_ {}; + + template <typename Dimension, bool OnStack, typename SizeType> + struct is_row_major<vector::parameters<row_major, Dimension, OnStack, SizeType> > + : boost::mpl::true_ {}; + + template <typename T> + struct is_row_major<const T> + : is_row_major<T> {}; + + template <typename Dimension, bool OnStack, typename SizeType> + struct is_row_major<vector::parameters<col_major, Dimension, OnStack, SizeType> > + : boost::mpl::false_ {}; + + template <typename Index, typename Dimension, bool OnStack, typename SizeType> + struct is_row_major<matrix::parameters<row_major, Index, Dimension, OnStack, SizeType> > + : boost::mpl::true_ {}; + + template <typename Index, typename Dimension, bool OnStack, typename SizeType> + struct is_row_major<matrix::parameters<col_major, Index, Dimension, OnStack, SizeType> > + : boost::mpl::false_ {}; + + template <typename Value, typename Parameters> + struct is_row_major<vector::dense_vector<Value, Parameters> > + : is_row_major<Parameters> {}; + + template <typename Value, typename Parameters> + struct is_row_major<vector::strided_vector_ref<Value, Parameters> > + : is_row_major<Parameters> {}; + + template <typename Value, typename Parameters> + struct is_row_major<mtl::matrix::compressed2D<Value, Parameters> > + : is_row_major<Parameters> {}; + + template <typename Value, typename Parameters> + struct is_row_major<mtl::matrix::ell_matrix<Value, Parameters> > + : is_row_major<Parameters> {}; + + template <typename Value, typename Parameters> + struct is_row_major<mtl::matrix::dense2D<Value, Parameters> > + : is_row_major<Parameters> {}; + + template <typename Value, std::size_t Mask, typename Parameters> + struct is_row_major<mtl::matrix::morton_dense<Value, Mask, Parameters> > + : is_row_major<Parameters> {}; + + template <typename Matrix> + struct is_row_major<matrix::banded_view<Matrix> > + : is_row_major<Matrix> {}; + + template <typename Matrix> + struct is_row_major<matrix::transposed_view<Matrix> > + : boost::mpl::not_<is_row_major<Matrix> > {}; + + template <typename Matrix> + struct is_row_major<matrix::hermitian_view<Matrix> > + : boost::mpl::not_<is_row_major<Matrix> > {}; + +}} // namespace mtl::traits + +#endif // MTL_IS_ROW_MAJOR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/is_static.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/is_static.hpp new file mode 100644 index 0000000000000000000000000000000000000000..366d3a38e7f2031fab66d8592d9ca617627d039c --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/is_static.hpp @@ -0,0 +1,35 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_IS_STATIC_INCLUDE +#define MTL_TRAITS_IS_STATIC_INCLUDE + +#include <boost/mpl/bool.hpp> +#include <boost/numeric/mtl/mtl_fwd.hpp> + +namespace mtl { namespace traits { + + /// Meta-function whether a certain type has static size + template <typename T> struct is_static : boost::mpl::false_ {}; + + template <std::size_t Size> struct is_static<mtl::vector::fixed::dimension<Size> > : boost::mpl::true_ {}; + template <std::size_t Rows, std::size_t Cols> struct is_static<mtl::fixed::dimensions<Rows, Cols> > : boost::mpl::true_ {}; + + template <typename V, typename P> struct is_static<mtl::vector::dense_vector<V, P> > : is_static<typename P::dimension> {}; + + template <typename V, typename P> struct is_static<mtl::matrix::dense2D<V, P> > : is_static<typename P::dimensions> {}; + template <typename V, std::size_t M, typename P> struct is_static<mtl::matrix::morton_dense<V, M, P> > : is_static<typename P::dimensions> {}; + template <typename V, typename P> struct is_static<mtl::matrix::compressed2D<V, P> > : is_static<typename P::dimensions> {}; + +}} // namespace mtl::traits + +#endif // MTL_TRAITS_IS_STATIC_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/is_vector_reduction.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/is_vector_reduction.hpp new file mode 100644 index 0000000000000000000000000000000000000000..d7e8127bfe0138ab05e568fe0924d4f61b2808ce --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/is_vector_reduction.hpp @@ -0,0 +1,34 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_IS_VECTOR_REDUCTION_INCLUDE +#define MTL_TRAITS_IS_VECTOR_REDUCTION_INCLUDE + +namespace mtl { namespace traits { + +/// Type trait to check whether \p T is a vector reduction (i.e. an ET class for its lazy evaluation) +template <typename T> +struct is_vector_reduction : boost::mpl::false_ {}; + +template <unsigned long Unroll, typename Vector1, typename Vector2, typename ConjOpt> +struct is_vector_reduction<mtl::vector::dot_class<Unroll, Vector1, Vector2, ConjOpt> > + : boost::mpl::true_ {}; + +template<typename Vector, typename Functor> +struct is_vector_reduction<mtl::vector::lazy_reduction<Vector, Functor> > + : boost::mpl::true_ {}; + + + +}} // namespace mtl::traits + +#endif // MTL_TRAITS_IS_VECTOR_REDUCTION_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/is_what.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/is_what.hpp new file mode 100644 index 0000000000000000000000000000000000000000..205d5f043bfbc27016f2f7d61f49548b388b924a --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/is_what.hpp @@ -0,0 +1,93 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_IS_WHAT_INCLUDE +#define MTL_TRAITS_IS_WHAT_INCLUDE + +#include <boost/type_traits/is_base_of.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/mpl/if.hpp> +#include <boost/mpl/or.hpp> +#include <boost/mpl/bool.hpp> + +#include <boost/numeric/mtl/utility/ashape.hpp> +#include <boost/numeric/mtl/utility/category.hpp> + +namespace mtl { namespace traits { + +// Matrix, vector and scalar deduced from ashape not from category +template <typename T> +struct is_scalar + : boost::is_same<typename ashape::ashape<T>::type, ashape::scal> +{}; + +template <typename Shape> +struct is_matrix_aux + : boost::mpl::false_ +{}; + +template <typename Shape> +struct is_matrix_aux<ashape::mat<Shape> > + : boost::mpl::true_ +{}; + +template <typename T> +struct is_matrix + : is_matrix_aux<typename ashape::ashape<T>::type> +{}; + +template <typename Shape> +struct is_vector_aux + : boost::mpl::false_ +{}; + +template <typename Shape> +struct is_vector_aux<ashape::cvec<Shape> > + : boost::mpl::true_ +{}; + +template <typename Shape> +struct is_vector_aux<ashape::rvec<Shape> > + : boost::mpl::true_ +{}; + +template <typename T> +struct is_vector + : is_vector_aux<typename ashape::ashape<T>::type> +{}; + +template <typename T> +struct is_dense + : boost::is_base_of<tag::dense, typename category<T>::type> +{}; + + +template <typename T> +struct is_unevaluated + : boost::is_base_of<tag::unevaluated, typename category<T>::type> +{}; + +template <typename T> +struct is_sparse + : boost::is_base_of<tag::sparse, typename category<T>::type> +{}; + +// So far nothing is symmetric on the type level +template <typename T> +struct is_symmetric + : boost::mpl::false_ +{}; + + +}} // namespace mtl::traits + +#endif // MTL_TRAITS_IS_WHAT_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/iset.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/iset.hpp new file mode 100644 index 0000000000000000000000000000000000000000..6a2a55ec537140db79d302922314f3199eb904fc --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/iset.hpp @@ -0,0 +1,94 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_ISET_INCLUDE +#define MTL_ISET_INCLUDE + +#include <vector> +#include <boost/utility/enable_if.hpp> +#include <boost/type_traits/is_integral.hpp> +#include <boost/numeric/mtl/utility/push_back_comma_inserter.hpp> +#include <boost/numeric/mtl/operation/is_negative.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> + +namespace mtl { + + /// Class for arbitrary index sets + class iset + { + public: + /// Size type + typedef std::size_t size_type; + + void check(size_type MTL_DEBUG_ARG(i)) const + { MTL_DEBUG_THROW_IF(is_negative(i) || i >= indices.size(), index_out_of_range()); } + + iset() {} ///< Default constructor + + /// Construct from array + template <long Size> + iset(const size_type (&array)[Size]) : indices(&array[0], &array[Size]) {} + + /// Assign comma-separated list + template <typename Source> + typename boost::enable_if<boost::is_integral<Source>, push_back_comma_inserter<iset> >::type + operator=(const Source& src) + { + indices.clear(); + indices.push_back(src); + return push_back_comma_inserter<iset>(*this); + } + + /// Return i-th index + size_type operator[](size_type i) const { check(i); return indices[i]; } + + /// Insert a new index at the end + void push_back(size_type i) { indices.push_back(i); } + + /// Size of the set + size_type size() const { return indices.size(); } + + /// Equality + bool operator==(const iset& that) const + { + if (size() != that.size()) + return false; + for (size_type i= 0; i < size(); i++) + if (indices[i] != that.indices[i]) + return false; + return true; + } + + bool operator!=(const iset& that) const { return !(*this == that); } ///< Inequality + + /// Print iset + friend std::ostream& operator<<(std::ostream& os, const iset& is) + { os << "{"; + for (size_type i= 0; i < is.indices.size(); i++) { + os << is.indices[i]; + if (i+1 < is.indices.size()) + os << ", "; + } + return os << "}"; + } + + private: + std::vector<size_type> indices; + }; + + /// Size of an index set (as free function) + std::size_t inline size(const iset& i) + { return i.size(); } + +} // namespace mtl + +#endif // MTL_ISET_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/iterator_adaptor.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/iterator_adaptor.hpp new file mode 100644 index 0000000000000000000000000000000000000000..ed48ae725347cad430f20e0b81bd552ac326f8fe --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/iterator_adaptor.hpp @@ -0,0 +1,64 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_ITERATOR_ADAPTOR_INCLUDE +#define MTL_ITERATOR_ADAPTOR_INCLUDE + +#include <boost/numeric/mtl/utility/iterator_adaptor_detail.hpp> + +namespace mtl { namespace utilities { + + +// Should be distinguished between random access and forward iterator +// So far all (dense) cursors (within rows/columns) have random access + +template <typename PropertyMap, typename Cursor, typename ValueType> +struct const_iterator_adaptor + : public detail::ra_adaptor_operators< const_iterator_adaptor<PropertyMap, Cursor, ValueType> > +{ + typedef detail::const_iterator_proxy<PropertyMap, Cursor, ValueType> proxy; + + const_iterator_adaptor(PropertyMap map, Cursor cursor) + : map(map), cursor(cursor) {} + + proxy operator*() const + { + return proxy(map, cursor); + } + + PropertyMap map; + Cursor cursor; +}; + + +template <typename PropertyMap, typename Cursor, typename ValueType> +struct iterator_adaptor + : public detail::ra_adaptor_operators< iterator_adaptor<PropertyMap, Cursor, ValueType> > +{ + typedef detail::iterator_proxy<PropertyMap, Cursor, ValueType> proxy; + + iterator_adaptor(PropertyMap map, Cursor cursor) + : map(map), cursor(cursor) {} + + proxy operator*() + { + return proxy(map, cursor); + } + + PropertyMap map; + Cursor cursor; +}; + + +}} // namespace mtl::utilities + +#endif // MTL_ITERATOR_ADAPTOR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/iterator_adaptor_1D.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/iterator_adaptor_1D.hpp new file mode 100644 index 0000000000000000000000000000000000000000..4e7bf02a29601ea7de21a5e1a247df12e52d3e0a --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/iterator_adaptor_1D.hpp @@ -0,0 +1,161 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_ITERATOR_ADAPTOR_1D_INCLUDE +#define MTL_ITERATOR_ADAPTOR_1D_INCLUDE + +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/utility/glas_tag.hpp> +#include <boost/numeric/mtl/utility/iterator_adaptor.hpp> + +namespace mtl { namespace traits { + +// Range generator for one-dimensional iterators +// Implemented by means of cursors and value map + +template <typename Matrix> +struct range_generator<tag::const_iter::nz, Matrix> +{ + typedef typename traits::const_value<Matrix>::type map_type; + typedef typename glas::tag::nz cursor_tag; + typedef range_generator<cursor_tag, Matrix> cursor_range; + typedef typename cursor_range::type cursor_type; + typedef typename Matrix::value_type value_type; + typedef typename cursor_range::complexity complexity; + static int const level = cursor_range::level; + + // iterator is type of range generator + typedef utilities::const_iterator_adaptor<map_type, cursor_type, value_type> type; + + type begin(const Matrix& matrix) const + { + return type(map_type(matrix), cursor_range().begin(matrix)); + } + + type end(const Matrix& matrix) const + { + return type(map_type(matrix), cursor_range().end(matrix)); + } +}; + + +#if 0 +template <typename Matrix> +struct range_generator<tag::iter::nz, Matrix> +{ + typedef typename traits::value<Matrix>::type map_type; + typedef typename glas::tag::nz cursor_tag; + typedef typename range_generator<cursor_tag, Matrix>::type cursor_type; + typedef typename Matrix::value_type value_type; + typedef typename range_generator<cursor_tag, Matrix>::complexity complexity; + static int const level = range_generator<cursor_tag, Matrix>::level; + + // iterator is type of range generator + typedef utilities::const_iterator_adaptor<map_type, cursor_type, value_type> type; + + type begin(const Matrix& matrix) const + { + map_type map(matrix); + return type(map, begin<cursor_tag>(matrix)); + } + + type end(const Matrix& matrix) const + { + map_type map(matrix); + return type(map, end<cursor_tag>(matrix)); + } +}; + + +template <typename Matrix> +struct range_generator<tag::const_iter::all, Matrix> +{ + typedef typename traits::const_value<Matrix>::type map_type; + typedef typename glas::tag::all cursor_tag; + typedef typename range_generator<cursor_tag, Matrix>::type cursor_type; + typedef typename Matrix::value_type value_type; + typedef typename range_generator<cursor_tag, Matrix>::complexity complexity; + static int const level = range_generator<cursor_tag, Matrix>::level; + + // iterator is type of range generator + typedef utilities::const_iterator_adaptor<map_type, cursor_type, value_type> type; + + type begin(const Matrix& matrix) const + { + return type(map_type(matrix), begin<cursor_tag>(matrix)); + } + + type end(const Matrix& matrix) const + { + return type(map_type(matrix), end<cursor_tag>(matrix)); + } +}; + +template <typename Matrix> +struct range_generator<tag::iter::all, Matrix> +{ + typedef typename traits::value<Matrix>::type map_type; + typedef typename glas::tag::all cursor_tag; + typedef typename range_generator<cursor_tag, Matrix>::type cursor_type; + typedef typename Matrix::value_type value_type; + typedef typename range_generator<cursor_tag, Matrix>::complexity complexity; + static int const level = range_generator<cursor_tag, Matrix>::level; + + // iterator is type of range generator + typedef utilities::const_iterator_adaptor<map_type, cursor_type, value_type> type; + + type begin(const Matrix& matrix) const + { + map_type map(matrix); + return type(map, begin<cursor_tag>(matrix)); + } + + type end(const Matrix& matrix) const + { + map_type map(matrix); + return type(map, end<cursor_tag>(matrix)); + } +}; + + +#endif + + + + + + +#if 0 +template <typename Matrix> +struct morton_dense_row_const_iterator + : utilities::const_iterator_adaptor<typename traits::const_value<Matrix>::type, morton_dense_row_cursor<Matrix::mask>, + typename Matrix::value_type> +{ + static const unsigned long mask= Matrix::mask; + typedef morton_dense_row_cursor<mask> cursor_type; + typedef typename traits::const_value<Matrix>::type map_type; + typedef typename Matrix::value_type value_type; + typedef typename Matrix::size_type size_type; + typedef utilities::iterator_adaptor<map_type, cursor_type, value_type> base; + + morton_dense_row_const_iterator(const Matrix& matrix, size_type row, size_type col) + : base(map_type(matrix), cursor_type(row, col)) + {} +}; + +utilities::const_iterator_adaptor<typename traits::const_value<Matrix>::type, morton_dense_row_cursor<Matrix::mask>, + typename Matrix::value_type> +#endif + +}} // namespace mtl::traits + +#endif // MTL_ITERATOR_ADAPTOR_1D_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/iterator_adaptor_detail.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/iterator_adaptor_detail.hpp new file mode 100644 index 0000000000000000000000000000000000000000..e0e982f0ac16cd36e202a77491c062eabd9f0e8b --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/iterator_adaptor_detail.hpp @@ -0,0 +1,121 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_ITERATOR_ADAPTOR_DETAIL_INCLUDE +#define MTL_ITERATOR_ADAPTOR_DETAIL_INCLUDE + +namespace mtl { namespace utilities { namespace detail { + + +template <typename Adaptor> +struct adaptor_operators +{ + Adaptor& operator++() + { + Adaptor& me = static_cast<Adaptor&>(*this); + ++me.cursor; + return me; + } + + Adaptor& operator++(int) + { + Adaptor& me = static_cast<Adaptor&>(*this); + Adaptor tmp(me); + ++me.cursor; + return tmp; + } + + bool operator==(Adaptor const& x) const + { + Adaptor const& me = static_cast<Adaptor const&>(*this); + + // Sloppy, nothing tested about property map + return me.cursor == x.cursor; + + // Compare addresses of property maps + // Problem: different addresses doesn't imply that the maps are different + // return &me.map == &x.map && me.cursor == x.cursor; + + // Certainly better they provide comparison + // Problem: not guaranteed to exist or can be ridiculously expensive + // return me.map == x.map && me.cursor == x.cursor; + } + + bool operator!=(Adaptor const& x) const + { + return !operator==(x); + } +}; + +template <typename Adaptor> +struct ra_adaptor_operators + : public adaptor_operators<Adaptor> +{ + Adaptor operator+(int i) const + { + const Adaptor& me = static_cast<const Adaptor&>(*this); + return Adaptor(me.map, me.cursor + i); + } + + Adaptor& operator+=(int i) + { + Adaptor& me = static_cast<Adaptor&>(*this); + me.cursor+= i; + return me; + } +}; + + + + +template <typename PropertyMap, typename Cursor, typename ValueType> +struct const_iterator_proxy +{ + const_iterator_proxy(PropertyMap map, Cursor cursor) + : map(map), cursor(cursor) {} + + operator ValueType() const + { + return map(*cursor); + } + + PropertyMap map; + Cursor cursor; +}; + + +template <typename PropertyMap, typename Cursor, typename ValueType> +struct iterator_proxy +{ + typedef iterator_proxy self; + + iterator_proxy(PropertyMap map, Cursor cursor) + : map(map), cursor(cursor) {} + + operator ValueType() const + { + return map(*cursor); + } + + self& operator=(ValueType const& value) + { + map(*cursor, value); + return *this; + } + + PropertyMap map; + Cursor cursor; +}; + +}}} // namespace mtl::utilities::detail + +#endif // MTL_ITERATOR_ADAPTOR_DETAIL_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/linear_operator.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/linear_operator.hpp new file mode 100644 index 0000000000000000000000000000000000000000..5a281cbedb8de833733443903e837141fe4f18b1 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/linear_operator.hpp @@ -0,0 +1,34 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_LINEAR_OPERATOR_INCLUDE +#define MTL_TRAITS_LINEAR_OPERATOR_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> + +namespace mtl { namespace traits { + +/// Type trait returning type of linear operator projecting from vector space Vector1 to vector space Vector2 +/** The operator is dense. **/ +template <typename Vector1, typename Vector2> +struct linear_operator {}; + +template <typename Value1, typename Para1, typename Value2, typename Para2> +struct linear_operator<mtl::vector::dense_vector<Value1, Para1>, mtl::vector::dense_vector<Value2, Para2> > +{ + typedef mtl::matrix::dense2D<Value1> type; +}; + + +}} // namespace mtl::traits + +#endif // MTL_TRAITS_LINEAR_OPERATOR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/lu_matrix_type.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/lu_matrix_type.hpp new file mode 100644 index 0000000000000000000000000000000000000000..1208dc40dfb1244ee6b2ab5f53d7e68be7e4d65d --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/lu_matrix_type.hpp @@ -0,0 +1,35 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_LU_MATRIX_TYPE_INCLUDE +#define MTL_TRAITS_LU_MATRIX_TYPE_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> + +namespace mtl { namespace traits { + +template <typename Matrix> +struct lu_matrix_type +{ + typedef Matrix type; +}; + +template <typename Value, typename Parameters> +struct lu_matrix_type<matrix::compressed2D<Value, Parameters> > +{ + typedef matrix::dense2D<Value, Parameters> type; +}; + + +}} // namespace mtl::traits + +#endif // MTL_TRAITS_LU_MATRIX_TYPE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/make_copy_or_reference.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/make_copy_or_reference.hpp new file mode 100644 index 0000000000000000000000000000000000000000..53184101cce46c77f942e454fb9b899f11155216 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/make_copy_or_reference.hpp @@ -0,0 +1,94 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MAKE_COPY_OR_REFERENCE_INCLUDE +#define MTL_MAKE_COPY_OR_REFERENCE_INCLUDE + +namespace mtl { + + +/// Helper class to avoid avoidable copies for input parameters +/** Container is referred if it has already target type, otherwise copied. + Create an object of this type and pass the value member variable to the function, + e.g. make_in_copy_or_reference<Tgt, Src> copy_or_ref(v); f(copy_or_ref.value); + where Src is the type of v and Tgt the type of f's argument. +**/ +template <typename Target, typename Source> +struct make_in_copy_or_reference +{ + typedef Target type; + explicit make_in_copy_or_reference(const Source& src) : value(src) {} + Target value; +}; + +template <typename Target> +struct make_in_copy_or_reference<Target, Target> +{ + typedef const Target& type; + explicit make_in_copy_or_reference(const Target& src) : value(src) {} + const Target& value; +}; + + +/// Helper class to avoid avoidable copies for output parameters. +/** Container is referred if it has already target type, otherwise copied at destruction. + Create an object of this type and pass the value member variable to the function, + e.g. make_in_copy_or_reference<Tgt, Src> copy_or_ref(v); f(copy_or_ref.value); + where Src is the type of v and Tgt the type of f's argument. + Target must be DefaultConstructible. +**/ +template <typename Target, typename Source> +struct make_out_copy_or_reference +{ + explicit make_out_copy_or_reference(Source& src) : src(src) {} + ~make_out_copy_or_reference() { src= value; } + + Target value; +private: + Source& src; +}; + +template <typename Target> +struct make_out_copy_or_reference<Target, Target> +{ + explicit make_out_copy_or_reference(Target& src) : value(src) {} + Target& value; +}; + + +/// Helper class to avoid avoidable copies for input-output parameters. +/** Container is referred if it has already target type, otherwise copied construction and destruction. + Create an object of this type and pass the value member variable to the function, + e.g. make_in_copy_or_reference<Tgt, Src> copy_or_ref(v); f(copy_or_ref.value); + where Src is the type of v and Tgt the type of f's argument. +**/ +template <typename Target, typename Source> +struct make_in_out_copy_or_reference +{ + explicit make_in_out_copy_or_reference(Source& src) : value(src), src(src) {} + ~make_in_out_copy_or_reference() { src= value; } + + Target value; +private: + Source& src; +}; + +template <typename Target> +struct make_in_out_copy_or_reference<Target, Target> +{ + explicit make_in_out_copy_or_reference(Target& src) : value(src) {} + Target& value; +}; + +} // namespace mtl + +#endif // MTL_MAKE_COPY_OR_REFERENCE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/maybe.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/maybe.hpp new file mode 100644 index 0000000000000000000000000000000000000000..2811e3d3cf4734670d0fd43d798f4a9eaf1e109d --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/maybe.hpp @@ -0,0 +1,61 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MAYBE_INCLUDE +#define MTL_MAYBE_INCLUDE + +#include <iostream> + +namespace mtl { namespace utilities { + +template <class Value> +struct maybe : public std::pair<Value, bool> +{ + typedef std::pair<Value, bool> base; + typedef maybe<Value> self; + + maybe(bool b) : base(Value(), b) {} + maybe(Value v) : base(v, true) {} + maybe(Value v, bool b) : base(v, b) {} + maybe(base b) : base(b) {} + + operator bool() const + { + return this->second; + } + operator Value() const + { + return this->first; + } + bool has_value() const + { + return this->second; + } + Value value() const + { + return this->first; + } +}; + +template <class Value> +inline std::ostream& operator<< (std::ostream& os, maybe<Value> const& m) +{ + return os << '(' << m.value() << ", " << (m ? "true" : "false") << ')'; +} + +} // namespace utilities + +using utilities::maybe; + +} // namespace mtl + +#endif // MTL_MAYBE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/multi_tmp.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/multi_tmp.hpp new file mode 100644 index 0000000000000000000000000000000000000000..f06b836dc47953202cc3331f4d7e8f992d0ede29 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/multi_tmp.hpp @@ -0,0 +1,66 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_MULTI_TMP_INCLUDE +#define MTL_MULTI_TMP_INCLUDE + +namespace mtl { + +/// Helper class to define a set of temporaries +template <unsigned Size, typename Value> +struct multi_tmp +{ + typedef multi_tmp<Size-1, Value> sub_type; + + multi_tmp() {} + multi_tmp(const Value& v) : value(v), sub(v) {} + + Value sum() { return value + sub.sum(); } + + Value value; + sub_type sub; +}; + +template <typename Value> +struct multi_tmp<0, Value> +{ + multi_tmp() {} + multi_tmp(const Value&) {} + Value sum() { return 0; } +}; + +/// Helper class to define a set of constants and initialize it from an array +template <unsigned Index, unsigned Size, typename Value> +struct multi_constant_from_array +{ + typedef multi_constant_from_array<Index+1, Size, Value> sub_type; + + template <typename Array, typename IndexType> + multi_constant_from_array(const Array& x, IndexType i) : value(x[i+Index]), sub(x, i) {} + + const Value value; + sub_type sub; +}; + + +template <unsigned Size, typename Value> +struct multi_constant_from_array<Size, Size, Value> +{ + template <typename Array, typename IndexType> + multi_constant_from_array(const Array&, IndexType) {} +}; + + + +} // namespace mtl + +#endif // MTL_MULTI_TMP_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/omp_size_type.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/omp_size_type.hpp new file mode 100644 index 0000000000000000000000000000000000000000..273002166a97a95991b078f8c1074ba22a3034b0 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/omp_size_type.hpp @@ -0,0 +1,42 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_OMP_SIZE_TYPE_INCLUDE +#define MTL_TRAITS_OMP_SIZE_TYPE_INCLUDE + +#include <boost/mpl/if.hpp> + +namespace mtl { namespace traits { + +# ifdef MTL_WITH_OPENMP + + template <typename T> + struct omp_size_type + : boost::mpl::if_c<(sizeof(T) > sizeof(int)), long int, int> + {}; + +# else + + /// Type trait to provide size type w/wo OpenMP uniformely + /** OpenMP emits warnings for unsigned ints and we therefor use signed ints only. + Furthermore, we dispatch between int and long int. **/ + template <typename T> + struct omp_size_type + { + typedef T type; + }; + +# endif + +}} // namespace mtl::traits + +#endif // MTL_TRAITS_OMP_SIZE_TYPE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/papi.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/papi.hpp new file mode 100644 index 0000000000000000000000000000000000000000..ef7dcf219b653cec8a3b43afd82e567b885cef28 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/papi.hpp @@ -0,0 +1,200 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_PAPI_INCLUDE +#define MTL_PAPI_INCLUDE + +#ifdef MTL_HAS_PAPI + +#include <papi.h> +#include <boost/numeric/mtl/utility/exception.hpp> + +#endif // MTL_HAS_PAPI + +namespace mtl { namespace utility { + +/// Exception for errors with PAPI, is sub-divided further +struct papi_error : public runtime_error +{ + explicit papi_error(const char *s= "PAPI error") : runtime_error(s) {} +}; + +struct papi_version_mismatch : public papi_error +{ + explicit papi_version_mismatch(const char *s= "PAPI: version mismatch") : papi_error(s) {} +}; + +struct papi_no_counters : public papi_error +{ + explicit papi_no_counters(const char *s= "PAPI: no counters") : papi_error(s) {} +}; + +struct papi_create_eventset_error : public papi_error +{ + explicit papi_create_eventset_error(const char *s= "PAPI: create event set error") : papi_error(s) {} +}; + +struct papi_name_to_code_error : public papi_error +{ + explicit papi_name_to_code_error(const char *s= "PAPI: name to code error") : papi_error(s) {} +}; + +struct papi_query_event_error : public papi_error +{ + explicit papi_query_event_error(const char *s= "PAPI: query event error") : papi_error(s) {} +}; + +struct papi_start_event_error : public papi_error +{ + explicit papi_start_event_error(const char *s= "PAPI: start event error") : papi_error(s) {} +}; + +struct papi_add_event_error : public papi_error +{ + explicit papi_add_event_error(const char *s= "PAPI: add event error") : papi_error(s) {} +}; + +struct papi_reset_error : public papi_error +{ + explicit papi_reset_error(const char *s= "PAPI: reset error") : papi_error(s) {} +}; + +struct papi_read_error : public papi_error +{ + explicit papi_read_error(const char *s= "PAPI: read error") : papi_error(s) {} +}; + +struct papi_index_range_error : public papi_error +{ + explicit papi_index_range_error(const char *s= "PAPI: index range error") : papi_error(s) {} +}; + + +#ifdef MTL_HAS_PAPI + +class papi_t +{ + void init_papi() + { + static bool initialized= false; + if (!initialized) { + + MTL_THROW_IF(PAPI_library_init(PAPI_VER_CURRENT) != PAPI_VER_CURRENT, + papi_version_mismatch()); + + num_counters = PAPI_get_opt(PAPI_MAX_HWCTRS, NULL); + MTL_THROW_IF(num_counters <= 0, papi_no_counters()); + + counters= new long_long[num_counters]; + + MTL_THROW_IF(PAPI_create_eventset(&event_set) != PAPI_OK, papi_create_eventset_error()); + initialized= true; + } + } + +public: + const static bool true_papi = true; + + papi_t() : event_set(PAPI_NULL), active_events(0) + { + init_papi(); + } + + + ~papi_t() + { + delete[](counters); + } + + + // returns index of added event + int add_event(const char* name) + { + int code; + MTL_THROW_IF(PAPI_event_name_to_code(const_cast<char*>(name), &code) != PAPI_OK, + papi_name_to_code_error()); + // std::cout << "add event " << const_cast<char*>(name) << " " << code << "\n"; + MTL_THROW_IF (PAPI_query_event(code) != PAPI_OK, + papi_query_event_error()); + MTL_THROW_IF (PAPI_add_event(event_set, code) != PAPI_OK, + papi_add_event_error()); + list_events(); + return active_events++; + } + + void start() + { + MTL_THROW_IF (PAPI_start(event_set) != PAPI_OK, + papi_start_event_error()); + reset(); + } + + void list_events() + { +#if 0 + int evv[8], num= 8; + PAPI_list_events(event_set, evv, &num); + for (int i= 0; i < num; i++ ) std::cout << evv[i] << "\n"; +#endif + } + + bool is_event_supported(const char* name) const + { + int code; + return PAPI_event_name_to_code(const_cast<char*>(name), &code) == PAPI_OK + && PAPI_query_event(code) == PAPI_OK; + } + + void reset() + { + MTL_THROW_IF(PAPI_reset(event_set) != PAPI_OK, papi_reset_error()); + } + + void read() + { + list_events(); + MTL_THROW_IF (PAPI_read(event_set, counters) != PAPI_OK, papi_read_error()); + // std::cout << "counters read, first value: " << *counters << "\n"; + } + + long_long operator[](int index) const + { + if (index < 0 || index >= active_events) throw papi_index_range_error(); + return counters[index]; + } + + //private: + int num_counters, event_set, active_events; + long_long *counters; +}; + +#else // no papi + +// Faked papi type: + +struct papi_t +{ + const static bool true_papi = false; + int add_event(const char* name) { return 0;} + void start() {} + bool is_event_supported(const char* name) const { return false;} + void reset() {} + void read() {} + long long operator[](int index) const { return 0; } +}; + +#endif + +}} // namespace mtl::utility + + +#endif // MTL_PAPI_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/parameters.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/parameters.hpp new file mode 100644 index 0000000000000000000000000000000000000000..a9b75e8ea8460d91776ab4e8a7ddcb2c1445897d --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/parameters.hpp @@ -0,0 +1,57 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_PARAMETERS_INCLUDE +#define MTL_TRAITS_PARAMETERS_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/matrix/parameter.hpp> + +namespace mtl { namespace traits { + +template <typename T> +struct parameters +{ + typedef typename T::parameters type; +}; + +template <typename Vector> +struct parameters<mtl::matrix::multi_vector<Vector> > +{ + typedef mtl::matrix::parameters<> type; +}; + +template <typename Functor> +struct parameters<mtl::matrix::implicit_dense<Functor> > +{ + typedef mtl::matrix::parameters<> type; +}; + +template <typename Value> +struct parameters<mtl::matrix::ones_matrix<Value> > + : public parameters<mtl::matrix::implicit_dense<mtl::matrix::ones_functor<Value> > > +{}; + +template <typename Value> +struct parameters<mtl::matrix::hilbert_matrix<Value> > + : public parameters<mtl::matrix::implicit_dense<mtl::matrix::hilbert_functor<Value> > > +{}; + +template <typename Vector1, typename Vector2> +struct parameters<mtl::matrix::outer_product_matrix<Vector1, Vector2> > + : public parameters<mtl::matrix::implicit_dense<mtl::matrix::outer_product_functor<Vector1, Vector2> > > +{}; + + +}} // namespace mtl::traits + +#endif // MTL_TRAITS_PARAMETERS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/pos_type.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/pos_type.hpp new file mode 100644 index 0000000000000000000000000000000000000000..be847f3cfe42da0c757e8e7c690fbba464bf476d --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/pos_type.hpp @@ -0,0 +1,50 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_POS_TYPE_INCLUDE +#define MTL_TRAITS_POS_TYPE_INCLUDE + +#include <utility> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> + +namespace mtl { namespace traits { + +// Not a matrix -> should be a vector +template <typename T, bool IsMatrix> +struct pos_type_aux +{ + typedef typename Collection<T>::size_type type; +}; + +// Matrix specialization +template <typename T> +struct pos_type_aux<T, true> +{ + private: + typedef typename Collection<T>::size_type size_type; + public: + typedef std::pair<size_type, size_type> type; +}; + +/// Type trait for position type +/** This is size_type for a vector and for a matrix a pair of size_types. + N.B.: The implementation considers everything that is not a matrix as vector, to be improved one day. **/ +template <typename T> +struct pos_type + : pos_type_aux<T, is_matrix<T>::value> +{}; + + +}} // namespace mtl::traits + +#endif // MTL_TRAITS_POS_TYPE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/property_map.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/property_map.hpp new file mode 100644 index 0000000000000000000000000000000000000000..776f51ab823a462ae422a862bf186071108cd69f --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/property_map.hpp @@ -0,0 +1,410 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_PROPERTY_MAP_INCLUDE +#define MTL_PROPERTY_MAP_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/utility/property_map_impl.hpp> + +namespace mtl { namespace traits { + +template <class Matrix> struct row {}; +template <class Matrix> struct col {}; +template <class Matrix> struct const_value {}; +template <class Matrix> struct value {}; +template <class Matrix> struct offset {}; + +// For vectors +template <class Vector> struct index {}; + +// =========== +// For dense2D +// =========== + +template <typename Value, class Parameters> +struct row<mtl::matrix::dense2D<Value, Parameters> > +{ + typedef mtl::detail::indexer_row_ref<mtl::matrix::dense2D<Value, Parameters> > type; +}; + +template <typename Value, class Parameters> +struct col<mtl::matrix::dense2D<Value, Parameters> > +{ + typedef mtl::detail::indexer_col_ref<mtl::matrix::dense2D<Value, Parameters> > type; +}; + +template <typename Value, class Parameters> +struct const_value<mtl::matrix::dense2D<Value, Parameters> > +{ + typedef mtl::detail::direct_const_value<mtl::matrix::dense2D<Value, Parameters> > type; +}; + +template <typename Value, class Parameters> +struct value<mtl::matrix::dense2D<Value, Parameters> > +{ + typedef mtl::detail::direct_value<mtl::matrix::dense2D<Value, Parameters> > type; +}; + + +// ================ +// For morton_dense +// ================ + + +template <class Elt, std::size_t BitMask, class Parameters> +struct row<mtl::matrix::morton_dense<Elt, BitMask, Parameters> > +{ + typedef mtl::detail::row_in_key<mtl::matrix::morton_dense<Elt, BitMask, Parameters> > type; +}; + +template <class Elt, std::size_t BitMask, class Parameters> +struct col<mtl::matrix::morton_dense<Elt, BitMask, Parameters> > +{ + typedef mtl::detail::col_in_key<mtl::matrix::morton_dense<Elt, BitMask, Parameters> > type; +}; + +template <class Elt, std::size_t BitMask, class Parameters> +struct const_value<mtl::matrix::morton_dense<Elt, BitMask, Parameters> > +{ + typedef mtl::detail::matrix_const_value_ref<mtl::matrix::morton_dense<Elt, BitMask, Parameters> > type; +}; + +template <class Elt, std::size_t BitMask, class Parameters> +struct value<mtl::matrix::morton_dense<Elt, BitMask, Parameters> > +{ + typedef mtl::detail::matrix_value_ref<mtl::matrix::morton_dense<Elt, BitMask, Parameters> > type; +}; + + +// ================ +// For compressed2D +// ================ + +template <class Elt, class Parameters> +struct row<mtl::matrix::compressed2D<Elt, Parameters> > +{ + typedef typename boost::mpl::if_< + boost::is_same<typename Parameters::orientation, row_major> + , mtl::detail::major_in_key<mtl::matrix::compressed2D<Elt, Parameters> > + , mtl::detail::indexer_minor_ref<mtl::matrix::compressed2D<Elt, Parameters> > + >::type type; +}; + +template <class Elt, class Parameters> +struct col<mtl::matrix::compressed2D<Elt, Parameters> > +{ + typedef typename boost::mpl::if_< + boost::is_same<typename Parameters::orientation, row_major> + , mtl::detail::indexer_minor_ref<mtl::matrix::compressed2D<Elt, Parameters> > + , mtl::detail::major_in_key<mtl::matrix::compressed2D<Elt, Parameters> > + >::type type; +}; + +template <class Elt, class Parameters> +struct const_value<mtl::matrix::compressed2D<Elt, Parameters> > +{ + typedef mtl::detail::matrix_offset_const_value<mtl::matrix::compressed2D<Elt, Parameters> > type; +}; + +template <class Elt, class Parameters> +struct value<mtl::matrix::compressed2D<Elt, Parameters> > +{ + typedef mtl::detail::matrix_offset_value<mtl::matrix::compressed2D<Elt, Parameters> > type; +}; + +// Offset that corresponds to cursor, e.g. to set values in a matrix with same pattern +// needed in ILU_0, so far only for compressed2D, could be useful for algos on sparse and dense +template <class Elt, class Parameters> +struct offset<mtl::matrix::compressed2D<Elt, Parameters> > +{ + typedef mtl::detail::offset_from_key<mtl::matrix::compressed2D<Elt, Parameters> > type; +}; + + +// ================ +// For coordinate2D +// ================ + +template <class Value, class Parameters> +struct row<mtl::matrix::coordinate2D<Value, Parameters> > +{ + typedef mtl::detail::coordinate2D_row<Value, Parameters> type; +}; + +template <class Value, class Parameters> +struct col<mtl::matrix::coordinate2D<Value, Parameters> > +{ + typedef mtl::detail::coordinate2D_col<Value, Parameters> type; +}; + +template <class Value, class Parameters> +struct const_value<mtl::matrix::coordinate2D<Value, Parameters> > +{ + typedef mtl::detail::coordinate2D_const_value<Value, Parameters> type; +}; + +// ================= +// For sparse_banded +// ================= + +template <class Value, class Parameters> +struct row<mtl::matrix::sparse_banded<Value, Parameters> > +{ + typedef mtl::detail::sparse_banded_row<Value, Parameters> type; +}; + +template <class Value, class Parameters> +struct col<mtl::matrix::sparse_banded<Value, Parameters> > +{ + typedef mtl::detail::sparse_banded_col<Value, Parameters> type; +}; + +template <class Value, class Parameters> +struct const_value<mtl::matrix::sparse_banded<Value, Parameters> > +{ + typedef mtl::detail::sparse_banded_const_value<Value, Parameters> type; +}; + +// ================== +// For implicit_dense +// ================== + +template <typename Functor> +struct row<mtl::matrix::implicit_dense<Functor> > +{ + typedef mtl::detail::row_in_element_key<mtl::matrix::implicit_dense<Functor> > type; +}; + +template <typename Functor> +struct col<mtl::matrix::implicit_dense<Functor> > +{ + typedef mtl::detail::col_in_element_key<mtl::matrix::implicit_dense<Functor> > type; +}; + +template <typename Functor> +struct const_value<mtl::matrix::implicit_dense<Functor> > +{ + typedef mtl::detail::const_value_in_element_key<mtl::matrix::implicit_dense<Functor> > type; +}; + + +// =============== +// For ones_matrix +// =============== + +template <typename Value> +struct row<mtl::matrix::ones_matrix<Value> > + : public row<mtl::matrix::implicit_dense<mtl::matrix::ones_functor<Value> > > +{}; + +template <typename Value> +struct col<mtl::matrix::ones_matrix<Value> > + : public col<mtl::matrix::implicit_dense<mtl::matrix::ones_functor<Value> > > +{}; + +template <typename Value> +struct const_value<mtl::matrix::ones_matrix<Value> > + : public const_value<mtl::matrix::implicit_dense<mtl::matrix::ones_functor<Value> > > +{}; + + +// =============== +// For hilbert_matrix +// =============== + +template <typename Value> +struct row<mtl::matrix::hilbert_matrix<Value> > + : public row<mtl::matrix::implicit_dense<mtl::matrix::hilbert_functor<Value> > > +{}; + +template <typename Value> +struct col<mtl::matrix::hilbert_matrix<Value> > + : public col<mtl::matrix::implicit_dense<mtl::matrix::hilbert_functor<Value> > > +{}; + +template <typename Value> +struct const_value<mtl::matrix::hilbert_matrix<Value> > + : public const_value<mtl::matrix::implicit_dense<mtl::matrix::hilbert_functor<Value> > > +{}; + + +// ======================== +// For outer_product_matrix +// ======================== + +template <typename Vector1, typename Vector2> +struct row<mtl::matrix::outer_product_matrix<Vector1, Vector2> > + : public row<mtl::matrix::implicit_dense<mtl::matrix::outer_product_functor<Vector1, Vector2> > > +{}; + +template <typename Vector1, typename Vector2> +struct col<mtl::matrix::outer_product_matrix<Vector1, Vector2> > + : public col<mtl::matrix::implicit_dense<mtl::matrix::outer_product_functor<Vector1, Vector2> > > +{}; + +template <typename Vector1, typename Vector2> +struct const_value<mtl::matrix::outer_product_matrix<Vector1, Vector2> > + : public const_value<mtl::matrix::implicit_dense<mtl::matrix::outer_product_functor<Vector1, Vector2> > > +{}; + + +// ==================== +// For matrix::indirect +// ==================== + +template <typename Matrix> +struct row<mtl::matrix::indirect<Matrix> > +{ + typedef mtl::detail::row_in_element_key<mtl::matrix::indirect<Matrix> > type; +}; + +template <typename Matrix> +struct col<mtl::matrix::indirect<Matrix> > +{ + typedef mtl::detail::col_in_element_key<mtl::matrix::indirect<Matrix> > type; +}; + +template <typename Matrix> +struct const_value<mtl::matrix::indirect<Matrix> > +{ + typedef mtl::detail::const_value_in_element_key<mtl::matrix::indirect<Matrix> > type; +}; + + +// ================ +// For dense_vector +// ================ + +template <class Elt, class Parameters> +struct index<mtl::vector::dense_vector<Elt, Parameters> > +{ + typedef mtl::detail::index_from_offset< mtl::vector::dense_vector<Elt, Parameters> > type; +}; + +template <typename Value, class Parameters> +struct const_value<mtl::vector::dense_vector<Value, Parameters> > +{ + typedef mtl::detail::direct_const_value<mtl::vector::dense_vector<Value, Parameters> > type; +}; + +template <typename Value, class Parameters> +struct value<mtl::vector::dense_vector<Value, Parameters> > +{ + typedef mtl::detail::direct_value<mtl::vector::dense_vector<Value, Parameters> > type; +}; +// ================ +// For vector::strided_vector_ref +// ================ + +template <class Elt, class Parameters> +struct index<vector::strided_vector_ref<Elt, Parameters> > +{ + typedef mtl::detail::index_from_offset< vector::strided_vector_ref<Elt, Parameters> > type; +}; + +template <typename Value, class Parameters> +struct const_value<vector::strided_vector_ref<Value, Parameters> > +{ + typedef mtl::detail::direct_const_value<vector::strided_vector_ref<Value, Parameters> > type; +}; + +template <typename Value, class Parameters> +struct value<vector::strided_vector_ref<Value, Parameters> > +{ + typedef mtl::detail::direct_value<vector::strided_vector_ref<Value, Parameters> > type; +}; + + + + +}} // namespace mtl::traits + +namespace mtl { namespace matrix { + +// Helpers + +/// Row map of matrix A +template <typename Matrix> +typename mtl::traits::row<Matrix>::type +inline row_map(const Matrix& A) +{ + return typename mtl::traits::row<Matrix>::type(A); +} + +/// Column map of matrix A +template <typename Matrix> +typename mtl::traits::col<Matrix>::type +inline col_map(const Matrix& A) +{ + return typename mtl::traits::col<Matrix>::type(A); +} + +/// Constant value map of matrix A +template <typename Matrix> +typename mtl::traits::const_value<Matrix>::type +inline const_value_map(const Matrix& A) +{ + return typename mtl::traits::const_value<Matrix>::type(A); +} + +/// Value map of matrix A +template <typename Matrix> +typename mtl::traits::value<Matrix>::type +inline value_map(Matrix& A) +{ + return typename mtl::traits::value<Matrix>::type(A); +} + +/// Offset map of matrix A +template <typename Matrix> +typename mtl::traits::offset<Matrix>::type +inline offset_map(const Matrix& A) +{ + return typename mtl::traits::offset<Matrix>::type(A); +} + +}} // namespace typename mtl::matrix + +namespace mtl { namespace vector { + +/// Index map of vector A +template <typename Vector> +typename mtl::traits::index<Vector>::type +inline index_map(const Vector& A) +{ + return typename mtl::traits::index<Vector>::type(A); +} + +/// Constant value map of vector A +template <typename Vector> +typename mtl::traits::const_value<Vector>::type +inline const_value_map(const Vector& A) +{ + return typename mtl::traits::const_value<Vector>::type(A); +} + +/// Value map of vector A +template <typename Vector> +typename mtl::traits::value<Vector>::type +inline value_map(Vector& A) +{ + return typename mtl::traits::value<Vector>::type(A); +} + +}} // namespace typename mtl::vector + + + +#endif // MTL_PROPERTY_MAP_INCLUDE + + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/property_map_impl.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/property_map_impl.hpp new file mode 100644 index 0000000000000000000000000000000000000000..bba0870112657e0897fa9a1f5e6ead7d8dfba62c --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/property_map_impl.hpp @@ -0,0 +1,431 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_PROPERTY_MAP_IMPL_INCLUDE +#define MTL_PROPERTY_MAP_IMPL_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/utility/is_row_major.hpp> +#include <boost/numeric/mtl/utility/static_assert.hpp> + +namespace mtl { namespace detail { + +// functor with matrix reference to access rows +template <class Matrix> struct indexer_row_ref +{ + typedef Matrix matrix_type; + typedef typename Matrix::key_type key_type; + indexer_row_ref(const matrix_type& ma) : ma(ma) {} + + typename Matrix::size_type operator() (key_type const& key) const + { + return ma.indexer.row(ma, key); + } + const matrix_type& ma; +}; + + +// functor to access rows using the key itself +template <class Matrix> struct row_in_key +{ + typedef Matrix matrix_type; + typedef typename Matrix::key_type key_type; + row_in_key(const matrix_type&) {} + + typename Matrix::size_type operator() (key_type const& key) const + { + return key.row(); + } +}; + +// functor to access rows using the key itself +template <class Matrix> struct row_in_element_key +{ + typedef Matrix matrix_type; + row_in_element_key(const matrix_type&) {} + + template <typename Key> + typename Matrix::size_type operator() (Key const& key) const + { + return key.indices[0]; + } +}; + + +// functor access the major dimension in key itself +template <class Matrix> struct major_in_key +{ + typedef Matrix matrix_type; + typedef typename Matrix::key_type key_type; + major_in_key(const matrix_type&) {} + + typename Matrix::size_type operator() (key_type const& key) const + { + return key.major; + } +}; + +// functor to access rows using the key itself +template <class Matrix> struct major_in_element_key +{ + typedef Matrix matrix_type; + major_in_element_key(const matrix_type&) {} + + template <typename Key> + typename Matrix::size_type operator() (Key const& key) const + { + return key.indices[0]; + } +}; + +template <class Matrix> struct indexer_minor_ref +{ + typedef Matrix matrix_type; + typedef typename Matrix::key_type key_type; + indexer_minor_ref(const matrix_type& ma) : ma(ma) {} + + typename Matrix::size_type operator() (key_type const& key) const + { + return ma.indexer.minor_from_offset(ma, key.offset); + } + const matrix_type& ma; +}; + + +template <class Matrix> struct indexer_col_ref +{ + typedef Matrix matrix_type; + typedef typename Matrix::key_type key_type; + indexer_col_ref(const matrix_type& ma) : ma(ma) {} + + typename Matrix::size_type operator() (key_type const& key) const + { + return ma.indexer.col(ma, key); + } + const matrix_type& ma; +}; + + +template <class Matrix> struct col_in_key +{ + typedef Matrix matrix_type; + typedef typename Matrix::key_type key_type; + col_in_key(const matrix_type&) {} + + typename Matrix::size_type operator() (key_type const& key) const + { + return key.col(); + } +}; + +// functor to access columns using the key itself +template <class Matrix> struct col_in_element_key +{ + typedef Matrix matrix_type; + col_in_element_key(const matrix_type&) {} + + template <typename Key> + typename Matrix::size_type operator() (Key const& key) const + { + return key.indices[1]; + } +}; + +// Collection must be derived from contiguous_memory_block +// key must contain pointer +template <class Collection> struct index_from_offset +{ + typedef Collection collection_type; + + index_from_offset(const collection_type& coll) : coll(coll) {} + + template <typename Key> + typename Collection::size_type operator() (Key const& key) const + { + return coll.offset(&*key); + } +private: + const collection_type& coll; +}; + +template <typename Matrix> +struct const_value_from_other +{ + typedef typename Matrix::other other; + typedef typename other::key_type key_type; + typedef typename other::value_type value_type; + + explicit const_value_from_other(Matrix const& matrix) + : its_const_value(matrix.ref) {} + + const value_type operator() (key_type const& key) const + { + return its_const_value(key); + } + + protected: + typename traits::const_value<typename boost::remove_const<other>::type>::type its_const_value; +}; + + + + +template <typename Matrix> +struct value_from_other +{ + typedef typename Matrix::other other; + typedef typename other::key_type key_type; + typedef typename other::value_type value_type; + + explicit value_from_other(Matrix const& matrix) + : its_value(matrix.ref) {} + + const value_type operator() (key_type const& key) const + { + return its_value(key); + } + + void operator() (key_type const& key, value_type value) const + { + its_value(key, value); + } + + protected: + typename traits::value<other>::type its_value; +}; + + +// property map to read value if key is referring to value, e.g. pointer +template <class Matrix> struct direct_const_value +{ + direct_const_value(const Matrix&) {} // for compatibility + typename Matrix::value_type const operator() (const typename Matrix::key_type key) const + { + return *key; + } +}; + + +// same with writing +template <class Matrix> struct direct_value + : public direct_const_value<Matrix> +{ + typedef typename Matrix::value_type value_type; + + direct_value(const Matrix& ma) + : direct_const_value<Matrix>(ma) + {} // for compatibility + + // May be to be replaced by inserter + void operator() (typename Matrix::key_type const& key, value_type value) + { + * const_cast<value_type *>(key) = value; + } + + // should be inherited + typename Matrix::value_type operator() (typename Matrix::key_type const& key) const + { + return *key; + } +}; + + +template <class Matrix> struct matrix_const_value_ref +{ + typedef Matrix matrix_type; + typedef typename Matrix::key_type key_type; + matrix_const_value_ref(const matrix_type& ma) : ma(ma) {} + + typename Matrix::value_type operator() (key_type const& key) const + { + return ma(key); + } + const matrix_type& ma; +}; + + +template <class Matrix> struct matrix_value_ref +{ + typedef Matrix matrix_type; + typedef typename Matrix::key_type key_type; + typedef typename Matrix::value_type value_type; + matrix_value_ref(matrix_type& ma) : ma(ma) {} + + typename Matrix::value_type operator() (key_type const& key) const + { + return ma(key); + } + + // Much better with inserters + void operator() (typename Matrix::key_type const& key, value_type const& value) + { + ma(key, value); + } + + matrix_type& ma; +}; + + +template <class Matrix> struct matrix_offset_const_value +{ + typedef Matrix matrix_type; + typedef typename Matrix::key_type key_type; + matrix_offset_const_value(const matrix_type& ma) : ma(ma) {} + + typename Matrix::value_type operator() (key_type const& key) const + { + return ma.value_from_offset(key.offset); + } + const matrix_type& ma; +}; + + +template <class Matrix> struct matrix_offset_value +{ + typedef Matrix matrix_type; + typedef typename Matrix::key_type key_type; + typedef typename Matrix::value_type value_type; + matrix_offset_value(matrix_type& ma) : ma(ma) {} + + typename Matrix::value_type operator() (key_type const& key) const + { + return ma.value_from_offset(key.offset); + } + + // Much better with inserters + void operator() (typename Matrix::key_type const& key, value_type const& value) + { + ma.value_from_offset(key.offset) = value; + } + + matrix_type& ma; +}; + +template <class Matrix> struct offset_from_key +{ + typedef Matrix matrix_type; + typedef typename Matrix::key_type key_type; + typedef typename Matrix::size_type size_type; + offset_from_key(const matrix_type& ) {} + + size_type operator() (key_type const& key) const + { + return key.offset; + } +}; + +// functor to access columns using the key itself +template <class Matrix> struct const_value_in_element_key +{ + typedef Matrix matrix_type; + const_value_in_element_key(const matrix_type&) {} + + template <typename Key> + typename Matrix::value_type operator() (Key const& key) const + { + return key.ref[key.indices[0]][key.indices[1]]; + } +}; + +template <class Value, class Parameters> +struct coordinate2D_row +{ + typedef const mtl::matrix::coordinate2D<Value, Parameters>& matrix_ref_type; + explicit coordinate2D_row(matrix_ref_type A) : A(A) {} + + template <typename Key> + typename Parameters::size_type operator() (Key key) const + { return A.row_index_array()[key.offset]; } + + matrix_ref_type A; +}; + +template <class Value, class Parameters> +struct coordinate2D_col +{ + typedef const mtl::matrix::coordinate2D<Value, Parameters>& matrix_ref_type; + explicit coordinate2D_col(matrix_ref_type A) : A(A) {} + + template <typename Key> + typename Parameters::size_type operator() (Key key) const + { return A.column_index_array()[key.offset]; } + + matrix_ref_type A; +}; + +template <class Value, class Parameters> +struct coordinate2D_const_value +{ + typedef const mtl::matrix::coordinate2D<Value, Parameters>& matrix_ref_type; + explicit coordinate2D_const_value(matrix_ref_type A) : A(A) {} + + template <typename Key> + Value operator() (Key key) const + { return A.value_array()[key.offset]; } + + matrix_ref_type A; +}; + +template <class Value, class Parameters> +struct sparse_banded_row // maybe refactor into sparse_banded_major +{ + MTL_STATIC_ASSERT((mtl::traits::is_row_major<Parameters>::value), "Only row-major sparse banded matrices supported so far."); + typedef const mtl::matrix::sparse_banded<Value, Parameters>& matrix_ref_type; + typedef typename Parameters::size_type size_type; + explicit sparse_banded_row(matrix_ref_type A) : A(A) {} + + template <typename Key> + size_type operator() (Key key) const + { return key.offset / A.ref_bands().size(); } + + matrix_ref_type A; +}; + +template <class Value, class Parameters> +struct sparse_banded_col // maybe refactor into sparse_banded_minor +{ + MTL_STATIC_ASSERT((mtl::traits::is_row_major<Parameters>::value), "Only row-major sparse banded matrices supported so far."); + typedef const mtl::matrix::sparse_banded<Value, Parameters>& matrix_ref_type; + typedef typename Parameters::size_type size_type; + + explicit sparse_banded_col(matrix_ref_type A) : A(A) {} + + template <typename Key> + size_type operator() (Key key) const + { + size_type bs= A.ref_bands().size(), major= key.offset / bs, b= key.offset % bs; + return major + A.ref_bands()[b]; + } + + matrix_ref_type A; +}; + +template <class Value, class Parameters> +struct sparse_banded_const_value +{ + typedef const mtl::matrix::sparse_banded<Value, Parameters>& matrix_ref_type; + explicit sparse_banded_const_value(matrix_ref_type A) : A(A) {} + + template <typename Key> + Value operator() (Key key) const + { return A.ref_data()[key.offset]; } + + matrix_ref_type A; +}; + + +}} // namespace mtl::detail + + +#endif // MTL_PROPERTY_MAP_IMPL_INCLUDE + + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/push_back_comma_inserter.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/push_back_comma_inserter.hpp new file mode 100644 index 0000000000000000000000000000000000000000..76f1cccac7e33bf3adede00816baa65079eaaf0b --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/push_back_comma_inserter.hpp @@ -0,0 +1,38 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_PUSH_BACK_COMMA_INSERTER_INCLUDE +#define MTL_PUSH_BACK_COMMA_INSERTER_INCLUDE + +namespace mtl { + + /// Helper class to inserter with push_back using comma separation + template <typename T> + class push_back_comma_inserter + { + typedef push_back_comma_inserter self; + public: + /// Constructor takes a mutable reference of the object inserted into + push_back_comma_inserter(T& ref) : ref(ref) {} + + /// Overloaded comma operator performs push_back + template <typename Source> + self& operator, (Source val) + { ref.push_back(val); return *this; } + + private: + T& ref; + }; + +} // namespace mtl + +#endif // MTL_PUSH_BACK_COMMA_INSERTER_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/range_generator.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/range_generator.hpp new file mode 100644 index 0000000000000000000000000000000000000000..2db4ca7576e38fa1c0b426ca64bdfbff035e89f8 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/range_generator.hpp @@ -0,0 +1,224 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_RANGE_GENERATOR_INCLUDE +#define MTL_RANGE_GENERATOR_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/detail/range_generator.hpp> +#include <boost/numeric/mtl/utility/complexity.hpp> +#include <boost/numeric/mtl/utility/static_assert.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/mpl/if.hpp> + +namespace mtl { + +namespace traits +{ + /// Functor for generating begin and end cursors over a collection + /** Thus functor must contain begin and end member functions which are used by free functions + The cursor type must be defined as 'typedef xxx type;' + complexity characterizes the run time of a traveral, cf. utility/complexity.hpp + complexity can be used to dispatch between different traversals depending on algorithm + and on collection (corr. subset represented by cursor) + level indicates the maximal level of nesting + - level 0: there is no traversal of this Tag for this collection + - level 1: cursor refers directly to elements + - level 2: cursor iterates over sets of elements or is only an intermediate cursor + cursor e.g. over rows, + its generated ranges are level 1 and iterate over elements + - level 3: cursor over sets of sets of elements, + its generated ranges are level 2 or 1 depending on the tag used on the cursor + - level 4: for instance blocked matrix -> level 4: block rows -> level 3: block elements + -> level 2: regular rows -> level 1: matrix elements + if an element cursor range was generated from the block element then the nesting + would be only 3 (since the last two levels collapse) + Cursors of level > 1 represent subsets of a collection and thus, it is only logical that + there must be range generators for these subset, which are applied on the cursor. + **/ + template <typename Tag, typename Collection> + struct range_generator + { + typedef complexity_classes::infinite complexity; + static int const level = 0; + typedef Tag tag; + + // MTL_STATIC_ASSERT(false, "range generator not implemented for these arguments (e.g. wrong combination)."); + + // specializations must contain the following members + // typedef xxx type; + // type begin() { ... } + // type end() { ... } + }; +} // namespace traits + + + +/// Returns begin cursor over the Collection or a subset of the Collection +/** Form of traversal depends on Tag, cf utility/glas_tag.hpp + On nested traversals, cursors of level > 1 must provide at least one range generator + \sa end() **/ +template <class Tag, class Collection> +typename traits::range_generator<Tag, Collection>::type +inline begin(Collection const& c) +{ + typedef traits::range_generator<Tag, Collection> gen_type; + MTL_STATIC_ASSERT(gen_type::level != 0, + "Template arguments not supported, probably traversal with unsupported tag combination."); + return gen_type().begin(c); +} + +template <class Tag, class Collection> +typename traits::range_generator<Tag, Collection>::type +inline begin(Collection& c) +{ + typedef traits::range_generator<Tag, Collection> gen_type; + MTL_STATIC_ASSERT(gen_type::level != 0, + "Template arguments not supported, probably traversal with unsupported tag combination."); + return gen_type().begin(c); +} + +/// Corresponding end cursor +/** \sa begin() **/ +template <class Tag, class Collection> +typename traits::range_generator<Tag, Collection>::type +inline end(Collection const& c) +{ + return traits::range_generator<Tag, Collection>().end(c); +} + +template <class Tag, class Collection> +typename traits::range_generator<Tag, Collection>::type +inline end(Collection& c) +{ + return traits::range_generator<Tag, Collection>().end(c); +} + +/// Cursor to an element with index equal or larger than \p position in a one-dimensional traversion. +/** This function is only defined where Tag represents an obvious one-dimensional traversion + of Collection allowing for an interpretation of position. + Examples are tag::row for a dense matrix or row-major compressed matrix. + tag::all regarding an entire matrix (i.e. going over all entries of a matrix) + does not characterize a one-dimensional traversion + so that \p position has no unique meaning. + Traversing all entries of a matrix row is one-dimensional and \p position is understood as looking for + a column index, i.e. lower_bound<tag::all>(row_cursor, 7) returns a cursor to a matrix element whose row + is the one of row_cursor and whose column is 7. + Likewise traversing all non-zeros of a row will return a cursor that points to an entry with according + row index and column index at least 7. + If the searched index could not be found in the one-dimensional collection the returned cursor will be + identical to the one returned by the end function. +**/ +template <class Tag, class Coll> +typename traits::range_generator<Tag, Coll>::type +inline lower_bound(Coll const& c, typename Collection<Coll>::size_type position) +{ + return traits::range_generator<Tag, Coll>().lower_bound(c, position); +} + +template <class Tag, class Coll> +typename traits::range_generator<Tag, Coll>::type +inline lower_bound(Coll& c, typename Collection<Coll>::size_type position) +{ + return traits::range_generator<Tag, Coll>().lower_bound(c, position); +} + + +namespace traits { + + // Dispatch between row and column-major traversal + template <typename Matrix> + struct range_generator<tag::major, Matrix> + : public range_generator< + typename boost::mpl::if_< + boost::is_same<typename OrientedCollection<Matrix>::orientation, row_major> + , ::mtl::tag::row + , ::mtl::tag::col + >::type, + Matrix> + {}; + + // Dispatch between row and column-major traversal + template <typename Matrix> + struct range_generator<tag::minor, Matrix> + : public range_generator< + typename boost::mpl::if_< + boost::is_same<typename OrientedCollection<Matrix>::orientation, row_major> + , ::mtl::tag::col + , ::mtl::tag::row + >::type, + Matrix> + {}; + + //=== Range generators for matrix::indirect ==================== + + // Range generator over all rows + template <typename Matrix> + struct range_generator<glas::tag::row, mtl::matrix::indirect<Matrix> > + : detail::all_rows_range_generator<mtl::matrix::indirect<Matrix>, complexity_classes::linear, 2> + {}; + + // Range generator over all entries within a row + template <typename Matrix> + struct range_generator<glas::tag::all, + mtl::traits::detail::sub_matrix_cursor<mtl::matrix::indirect<Matrix>, glas::tag::row, 2> > + : detail::all_cols_in_row_range_generator< + mtl::traits::detail::sub_matrix_cursor<mtl::matrix::indirect<Matrix>, glas::tag::row, 2> > + {}; + + // Range generator over all non-zero entries within a row, same as all entries + template <typename Matrix> + struct range_generator<glas::tag::nz, + mtl::traits::detail::sub_matrix_cursor<mtl::matrix::indirect<Matrix>, glas::tag::row, 2> > + : detail::all_cols_in_row_range_generator< + mtl::traits::detail::sub_matrix_cursor<mtl::matrix::indirect<Matrix>, glas::tag::row, 2> > + {}; + + // - same for columns first + + // Range generator over all colums + template <typename Matrix> + struct range_generator<glas::tag::col, mtl::matrix::indirect<Matrix> > + : detail::all_cols_range_generator<mtl::matrix::indirect<Matrix>, complexity_classes::linear, 2> + {}; + + // Range generator over all entries within a column + template <typename Matrix> + struct range_generator<glas::tag::all, + mtl::traits::detail::sub_matrix_cursor<mtl::matrix::indirect<Matrix>, glas::tag::col, 2> > + : detail::all_rows_in_col_range_generator< + mtl::traits::detail::sub_matrix_cursor<mtl::matrix::indirect<Matrix>, glas::tag::col, 2> > + {}; + + // Range generator over all non-zero entries within a column, same as all entries + template <typename Matrix> + struct range_generator<glas::tag::nz, + mtl::traits::detail::sub_matrix_cursor<mtl::matrix::indirect<Matrix>, glas::tag::col, 2> > + : detail::all_rows_in_col_range_generator< + mtl::traits::detail::sub_matrix_cursor<mtl::matrix::indirect<Matrix>, glas::tag::col, 2> > + {}; + + // Take major same as row + // Not necessarily best choice but shouldn't matter here + template <typename Matrix> + struct range_generator<glas::tag::major, mtl::matrix::indirect<Matrix> > + : detail::all_rows_range_generator<mtl::matrix::indirect<Matrix>, complexity_classes::linear, 2> + {}; + +} + + +} // namespace mtl + +#endif // MTL_RANGE_GENERATOR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/range_wrapper.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/range_wrapper.hpp new file mode 100644 index 0000000000000000000000000000000000000000..81ce21f8b1f0f805cf3b1847896c848c440df70d --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/range_wrapper.hpp @@ -0,0 +1,120 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_RANGE_WRAPPER_INCLUDE +#define MTL_TRAITS_RANGE_WRAPPER_INCLUDE + +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/utility/static_assert.hpp> + +namespace mtl { namespace traits { + +/// Wrapper for range_generator +/** Instead of passing the collection or cursor to the begin() and end() function, + it is passed to the constructor. + As a consequence, it can be used with ranged for from C++11. **/ +template <typename Tag, typename Collection> +struct range_wrapper + : range_generator<Tag, Collection> +{ + typedef range_generator<Tag, Collection> gen_type; + MTL_STATIC_ASSERT(gen_type::level != 0, "Template arguments not supported, probably traversal with unsupported tag combination."); + typedef typename gen_type::type type; + + explicit range_wrapper(const Collection& c) : c(c) {} //< Initialize with collection + + type begin() const { return gen_type::begin(c); } //< nullary begin + type end() const { return gen_type::end(c); } //< nullary end + + private: + const Collection& c; +}; + +}} // namespace mtl::traits + +namespace mtl { + +/// Cursor over rows of a collection +template <typename T> +mtl::traits::range_wrapper<tag::row, T> +inline rows_of(const T& x) +{ + return mtl::traits::range_wrapper<tag::row, T>(x); +} + +/// Cursor over cols of a collection +template <typename T> +mtl::traits::range_wrapper<tag::col, T> +inline cols_of(const T& x) +{ + return mtl::traits::range_wrapper<tag::col, T>(x); +} + +/// Cursor over major index of a collection +template <typename T> +mtl::traits::range_wrapper<tag::major, T> +inline major_of(const T& x) +{ + return mtl::traits::range_wrapper<tag::major, T>(x); +} + +/// Cursor over minor index of a collection +template <typename T> +mtl::traits::range_wrapper<tag::minor, T> +inline minor_of(const T& x) +{ + return mtl::traits::range_wrapper<tag::minor, T>(x); +} + +/// Cursor over non-zero elements of a collection +template <typename T> +mtl::traits::range_wrapper<tag::nz, T> +inline nz_of(const T& x) +{ + return mtl::traits::range_wrapper<tag::nz, T>(x); +} + +/// Cursor over all elements of a collection +template <typename T> +mtl::traits::range_wrapper<tag::all, T> +inline all_of(const T& x) +{ + return mtl::traits::range_wrapper<tag::all, T>(x); +} + +/// Cursor over tagged range of a collection +template <typename Tag, typename T> +mtl::traits::range_wrapper<Tag, T> +inline range_of(const T& x) +{ + return mtl::traits::range_wrapper<Tag, T>(x); +} + + +namespace matrix { + using mtl::rows_of; + using mtl::cols_of; + using mtl::major_of; + using mtl::minor_of; + using mtl::nz_of; + using mtl::all_of; + using mtl::range_of; +} // matrix + + + + +} // mtl + + +#endif // MTL_TRAITS_RANGE_WRAPPER_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/root.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/root.hpp new file mode 100644 index 0000000000000000000000000000000000000000..19058dbb8a40368d4003e8f7b2b329972fcc7911 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/root.hpp @@ -0,0 +1,249 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_ROOT_INCLUDE +#define MTL_TRAITS_ROOT_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> + +namespace mtl { namespace traits { + + +/// Type trait to reduce types to their essentials by removing const, reference, ... and gearing derived types to their bases +template <typename T> +struct root +{ + typedef T type; +}; + +// ========================== +// Remove language attributes +// ========================== + +template <typename T> +struct root<T&> + : public root<T> {}; + +template <typename T> +struct root<const T> + : public root<T> {}; + +// Redundant specialization to make xlc++ happy +template <typename T, int R, int C> +struct root<const T[R][C]> + : public root<T[R][C]> {}; + + +// ============ +// Base classes +// ============ + +// Implicit dense matrices + +template <typename Value> +struct root<mtl::matrix::ones_matrix<Value> > +{ + typedef mtl::matrix::implicit_dense<mtl::matrix::ones_functor<Value> > type; +}; + +template <typename Value> +struct root<mtl::matrix::hilbert_matrix<Value> > +{ + typedef mtl::matrix::implicit_dense<mtl::matrix::hilbert_functor<Value> > type; +}; + +template <typename Vector1, typename Vector2> +struct root<mtl::matrix::outer_product_matrix<Vector1, Vector2> > +{ + typedef mtl::matrix::implicit_dense<mtl::matrix::outer_product_functor<Vector1, Vector2> > type; +}; + +// Matrix map views + +template <typename Scaling, typename Matrix> +struct root< mtl::matrix::scaled_view<Scaling, Matrix> > +{ + typedef mtl::matrix::map_view<tfunctor::scale<Scaling, typename Matrix::value_type>, Matrix> type; +}; + +template <typename Matrix> +struct root< mtl::matrix::conj_view<Matrix> > +{ + typedef mtl::matrix::map_view<sfunctor::conj<typename Matrix::value_type>, Matrix> type; +}; + +template <typename Matrix> +struct root< mtl::matrix::negate_view<Matrix> > +{ + typedef mtl::matrix::map_view<sfunctor::negate<typename Matrix::value_type>, Matrix> type; +}; + +template <typename Matrix> +struct root< mtl::matrix::imag_view<Matrix> > +{ + typedef mtl::matrix::map_view<sfunctor::imag<typename Matrix::value_type>, Matrix> type; +}; + +template <typename Matrix> +struct root< mtl::matrix::real_view<Matrix> > +{ + typedef mtl::matrix::map_view<sfunctor::real<typename Matrix::value_type>, Matrix> type; +}; + +template <typename Matrix> +struct root< mtl::matrix::hermitian_view<Matrix> > +{ + typedef mtl::matrix::map_view<sfunctor::conj<typename Matrix::value_type>, mtl::matrix::transposed_view<Matrix> > type; +}; + +template <typename Matrix, typename RScaling> +struct root< mtl::matrix::rscaled_view<Matrix, RScaling> > +{ + typedef mtl::matrix::map_view<tfunctor::rscale<typename Matrix::value_type, RScaling>, Matrix> type; +}; + +template <typename Matrix, typename Divisor> +struct root< mtl::matrix::divide_by_view<Matrix, Divisor> > +{ + typedef mtl::matrix::map_view<tfunctor::divide_by<typename Matrix::value_type, Divisor>, Matrix> type; +}; + +// Matrix operations +template <typename M1, typename M2> +struct root< mtl::matrix::mat_mat_plus_expr<M1, M2> > +{ + typedef mtl::sfunctor::plus<typename Collection<M1>::value_type, typename Collection<M2>::value_type> f_type; + typedef mtl::matrix::mat_mat_op_expr<M1, M2, f_type> type; +}; + +template <typename M1, typename M2> +struct root< mtl::matrix::mv_mv_plus_expr<M1, M2> > +{ + typedef typename root< mtl::matrix::mat_mat_plus_expr<M1, M2> >::type type; +}; + +template <typename M1, typename M2> +struct root< mtl::matrix::mat_mat_minus_expr<M1, M2> > +{ + typedef mtl::sfunctor::minus<typename Collection<M1>::value_type, typename Collection<M2>::value_type> f_type; + typedef mtl::matrix::mat_mat_op_expr<M1, M2, f_type> type; +}; + +template <typename M1, typename M2> +struct root< mtl::matrix::mv_mv_minus_expr<M1, M2> > +{ + typedef typename root< mtl::matrix::mat_mat_minus_expr<M1, M2> >::type type; +}; + +template <typename M1, typename M2> +struct root< mtl::matrix::mat_mat_times_expr<M1, M2> > +{ + typedef mtl::sfunctor::times<typename Collection<M1>::value_type, typename Collection<M2>::value_type> f_type; + typedef mtl::matrix::mat_mat_op_expr<M1, M2, f_type> type; +}; + +template <typename M1, typename M2> +struct root< mtl::matrix::mat_mat_ele_times_expr<M1, M2> > +{ + typedef mtl::sfunctor::times<typename Collection<M1>::value_type, typename Collection<M2>::value_type> f_type; + typedef mtl::matrix::mat_mat_op_expr<M1, M2, f_type> type; +}; + + +// Vector assignment expressions + +template <typename E1, typename E2> +struct root< vector::vec_vec_asgn_expr<E1, E2> > +{ + typedef vector::vec_vec_aop_expr< E1, E2, mtl::sfunctor::assign<typename E1::value_type, typename E2::value_type> > type; +}; + +template <typename E1, typename E2> +struct root< vector::vec_vec_plus_asgn_expr<E1, E2> > +{ + typedef vector::vec_vec_aop_expr< E1, E2, mtl::sfunctor::plus_assign<typename E1::value_type, typename E2::value_type> > type; +}; + +template <typename E1, typename E2> +struct root< vector::vec_vec_minus_asgn_expr<E1, E2> > +{ + typedef vector::vec_vec_aop_expr< E1, E2, mtl::sfunctor::minus_assign<typename E1::value_type, typename E2::value_type> > type; +}; + +template <typename E1, typename E2> +struct root< vector::vec_scal_asgn_expr<E1, E2> > +{ + typedef vector::vec_scal_aop_expr< E1, E2, mtl::sfunctor::assign<typename E1::value_type, E2> > type; +}; + +template <typename E1, typename E2> +struct root< vector::vec_scal_times_asgn_expr<E1, E2> > +{ + typedef vector::vec_scal_aop_expr< E1, E2, mtl::sfunctor::times_assign<typename E1::value_type, E2> > type; +}; + +template <typename E1, typename E2> +struct root< vector::vec_scal_div_asgn_expr<E1, E2> > +{ + typedef vector::vec_scal_aop_expr< E1, E2, mtl::sfunctor::divide_assign<typename E1::value_type, E2> > type; +}; + +template <typename Scaling, typename Vector> +struct root< vector::scaled_view<Scaling, Vector> > +{ + typedef vector::map_view<tfunctor::scale<Scaling, typename Vector::value_type>, Vector> type; +}; + +template <typename Vector, typename RScaling> +struct root< vector::rscaled_view<Vector, RScaling> > +{ + typedef vector::map_view<tfunctor::rscale<typename Vector::value_type, RScaling>, Vector> type; +}; + +template <typename Vector, typename Divisor> +struct root< vector::divide_by_view<Vector, Divisor> > +{ + typedef vector::map_view<tfunctor::divide_by<typename Vector::value_type, Divisor>, Vector> type; +}; + +template <typename Vector> +struct root< vector::conj_view<Vector> > +{ + typedef vector::map_view<mtl::sfunctor::conj<typename Vector::value_type>, Vector> type; +}; + +template <typename Vector> +struct root< vector::negate_view<Vector> > +{ + typedef vector::map_view<mtl::sfunctor::negate<typename Vector::value_type>, Vector> type; +}; + +template <unsigned BSize, typename Vector> +struct root< vector::unrolled1<BSize, Vector> > +{ + typedef Vector type; +}; + + + +#if 0 // template +struct root +{ + typedef type; +}; +#endif + + +}} // namespace mtl::traits + +#endif // MTL_TRAITS_ROOT_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/shrink_stl_vector.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/shrink_stl_vector.hpp new file mode 100644 index 0000000000000000000000000000000000000000..a12d148f4ad9afe9d9e82ddb83f6afe6280a8ad0 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/shrink_stl_vector.hpp @@ -0,0 +1,31 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_SHRINK_STL_VECTOR_INCLUDE +#define MTL_SHRINK_STL_VECTOR_INCLUDE + +namespace mtl { + +/// Shrink memory consumption of an STL vector to its size +template <typename Value, typename Allocator> +void inline shrink_stl_vector(std::vector<Value, Allocator>& v) +{ + if (v.capacity() > v.size()) { + std::vector<Value, Allocator> tmp(v.begin(), v.end()); + swap(tmp, v); + } +} + + +} // namespace mtl + +#endif // MTL_SHRINK_STL_VECTOR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/sometimes_data.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/sometimes_data.hpp new file mode 100644 index 0000000000000000000000000000000000000000..6a6024868c0e89ed9e67be830c56001ed70f4b84 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/sometimes_data.hpp @@ -0,0 +1,37 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_UTILITY_SOMETIMES_DATA_INCLUDE +#define MTL_UTILITY_SOMETIMES_DATA_INCLUDE + +namespace mtl { namespace utility { + +template <bool C, typename T> +struct sometimes_data +{ + sometimes_data(const T& data) : data(data) {} + T data; +}; + +template <typename T> +struct sometimes_data<false, T> +{ + sometimes_data(const T&) {} +}; + +} // namespace utility + +using utility::sometimes_data; + +} // namespace mtl + +#endif // MTL_UTILITY_SOMETIMES_DATA_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/srange.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/srange.hpp new file mode 100644 index 0000000000000000000000000000000000000000..98176ca789b610e3109339283e8b2de430059507 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/srange.hpp @@ -0,0 +1,69 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_SRANGE_INCLUDE +#define MTL_SRANGE_INCLUDE + +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/irange.hpp> + +namespace mtl { + +class srange +{ + public: + typedef std::size_t size_type; + + /// Create a strided index range of [start, finish) + explicit srange(size_type start, size_type finish, size_type stride) + : my_start(start), my_finish(finish), my_stride(stride) {} + + /// First index in range + size_type start() const { return my_start; } + /// Past-end index in range + size_type finish() const { return my_finish; } + /// Stride + size_type stride() const { return my_stride; } + + /// Number of indices + size_type size() const { return my_finish > my_start ? my_finish - my_start / my_stride : 0; } + + /// Maps integers [0, size()) to [start(), start()+stride(), ..., finish()) + /** Checks index in debug mode. Inverse of from_range. **/ + size_type to_range(size_type i) const + { + MTL_DEBUG_THROW_IF(is_negative(i) || i >= size(), index_out_of_range()); + return my_start + i * my_stride; + } + + /// Maps integers [start(), finish()) to [0, size()) + /** Checks index in debug mode. **/ + size_type from_range(size_type i) const + { + MTL_DEBUG_THROW_IF(i < my_start || i >= my_finish, index_out_of_range()); + MTL_DEBUG_THROW_IF((i - my_start) % my_stride != 0, runtime_error("Index not on stride.")); + return i - my_start; + } + + /// Wether index is in range + bool in_range(size_type i) const + { + return i >= my_start && i < my_finish && (i - my_start) % my_stride == 0; + } + + private: + size_type my_start, my_finish, my_stride; +}; + +} // namespace mtl + +#endif // MTL_SRANGE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/static_assert.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/static_assert.hpp new file mode 100644 index 0000000000000000000000000000000000000000..1e5a59786ba865c9544afba171e274fb427fe191 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/static_assert.hpp @@ -0,0 +1,28 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_STATIC_ASSERT_INCLUDE +#define MTL_STATIC_ASSERT_INCLUDE + +#include <boost/static_assert.hpp> + +namespace mtl { + +#ifdef MTL_WITH_STATICASSERT +# define MTL_STATIC_ASSERT(Condition, Message) static_assert(Condition, Message) +#else +# define MTL_STATIC_ASSERT(Condition, Message) BOOST_STATIC_ASSERT(Condition) +#endif + +} // namespace mtl + +#endif // MTL_STATIC_ASSERT_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/strided_dense_el_cursor.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/strided_dense_el_cursor.hpp new file mode 100644 index 0000000000000000000000000000000000000000..f582a54b137342d39997f3b482108fd8a66a9575 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/strided_dense_el_cursor.hpp @@ -0,0 +1,49 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_STRIDED_DENSE_EL_CURSOR_INCLUDE +#define MTL_STRIDED_DENSE_EL_CURSOR_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/detail/strided_base_cursor.hpp> + +namespace mtl { + +/// Cursor going in strides over element of matrix, matrix row/column, or vector +template <typename Value> +struct strided_dense_el_cursor : public detail::strided_base_cursor<const Value*> +{ + typedef Value value_type; + typedef const value_type* const_pointer_type; + typedef detail::strided_base_cursor<const Value*> super; + typedef strided_dense_el_cursor self; + + // strided_dense_el_cursor () {} + strided_dense_el_cursor (const_pointer_type me, size_t stride) : super(me, stride) {} + + template <typename Parameters> + strided_dense_el_cursor(mtl::matrix::dense2D<Value, Parameters> const& ma, size_t r, size_t c, size_t stride) + : super(ma.elements() + ma.indexer(ma, r, c), stride) + {} + + // Why do we need this? + strided_dense_el_cursor(super const& x) : super(x) {} + + self operator+(int x) const + { + return super::operator+(x); + } +}; + +} // namespace mtl + +#endif // MTL_STRIDED_DENSE_EL_CURSOR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/strided_dense_el_iterator.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/strided_dense_el_iterator.hpp new file mode 100644 index 0000000000000000000000000000000000000000..8edce1df03ebd08a537c930dc24e8929b1bea92d --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/strided_dense_el_iterator.hpp @@ -0,0 +1,87 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_STRIDED_DENSE_EL_ITERATOR_INCLUDE +#define MTL_STRIDED_DENSE_EL_ITERATOR_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/detail/strided_base_cursor.hpp> + +namespace mtl { + + +/// Iterator going in strides over element of matrix, matrix row/column, or vector +/** - Strided iterator *operator returns (const) reference to Value instead of key + - row(i) and col(i) don't work +**/ +template <typename Value> +struct strided_dense_el_const_iterator + : public detail::strided_base_cursor<const Value*> +{ + typedef const Value* key_type; + typedef detail::strided_base_cursor<key_type> super; + typedef strided_dense_el_const_iterator self; + + strided_dense_el_const_iterator(key_type me, size_t stride) : super(me, stride) {} + + template <typename Parameters> + strided_dense_el_const_iterator(mtl::matrix::dense2D<Value, Parameters> const& ma, size_t r, size_t c, size_t stride) + : super(ma.elements() + ma.indexer(ma, r, c), stride) + {} + + self operator+(int x) const + { + return super::operator+(x); + } + + const Value& operator*() const + { + return *(this->key); + } +}; + +/// Iterator going in strides over element of matrix, matrix row/column, or vector +/** - Strided iterator *operator returns (const) reference to Value instead of key + - row(i) and col(i) don't work +**/ +template <typename Value> +struct strided_dense_el_iterator + : public detail::strided_base_cursor<Value*> +{ + typedef Value* key_type; + typedef detail::strided_base_cursor<key_type> super; + typedef strided_dense_el_iterator self; + + strided_dense_el_iterator(key_type me, size_t stride) : super(me, stride) {} + + template <typename Parameters> + strided_dense_el_iterator(mtl::matrix::dense2D<Value, Parameters>& ma, size_t r, size_t c, size_t stride) + : super(ma.elements() + ma.indexer(ma, r, c), stride) + {} + + self operator+(int x) const + { + self tmp(*this); + tmp+= x; + return tmp; + } + + Value& operator*() const + { + return *(this->key); + } +}; + + +} // namespace mtl + +#endif // MTL_STRIDED_DENSE_EL_ITERATOR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/string_to_enum.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/string_to_enum.hpp new file mode 100644 index 0000000000000000000000000000000000000000..6043e135d018c5686d83c86261e0e45ae73a415a --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/string_to_enum.hpp @@ -0,0 +1,39 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_STRING_TO_ENUM_INCLUDE +#define MTL_STRING_TO_ENUM_INCLUDE + +#include <string> +#include <boost/numeric/mtl/operation/size.hpp> + +namespace mtl { + +/** Searches string \p s in list \p l of strings and returns enum + + List \p l is given as array of const char*, which is the easiest to + initialize. The search is case sensitive, thus (de)-capitalize + your string upfront, e.g., with boost::to_lower(). + If the string is not found then a runtime_error is thrown. +**/ +template <typename EnumType, typename Array> +EnumType inline string_to_enum(const std::string& s, const Array& l, EnumType) +{ + std::size_t i; + for (i= 0; i < size(l) && std::string(l[i]) != s; i++) {} + MTL_THROW_IF(i == size(l), runtime_error("Search string not found")); + return EnumType(i); +} + +} // namespace mtl + +#endif // MTL_STRING_TO_ENUM_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/tag.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/tag.hpp new file mode 100644 index 0000000000000000000000000000000000000000..0b3da34e5f252e67f7d00bae03a0eca22dfb80ff --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/tag.hpp @@ -0,0 +1,378 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_TAG_INCLUDE +#define MTL_TAG_INCLUDE + +#include <boost/numeric/mtl/utility/glas_tag.hpp> + + +namespace mtl { namespace tag { + +/** @defgroup Tags Tags for concept-free dispatching + * @{ + */ + +// For internal use (e.g., to invalidate range generators) +// Is this the same as bottom? +struct unsupported {}; + +// Name says it +struct dummy3 {}; +struct dummy4 {}; + +/// Tag for all types +struct universe {}; + +/// Tag used to flatten categories +/** The virtual derivation causes perceivable run-time overhead that can be avoided with this struct using traits::flatcat1 and such. **/ +template <typename T> struct flat : universe {}; + +// Tag for any scalar value +/** At the moment default for unknown types (will be precised later) */ +struct scalar : virtual universe {}; + +/// For non-MTL types with category not explicitly defined +/** At the moment all treated as scalars (will be precised later) */ +struct unknown : virtual scalar {}; + +/// Tag for intermediate objects that require explicit evaluation +struct unevaluated : virtual universe {}; + +/// Any collection, i.e. vectors, matrices or higher-dimensional tensor +struct collection : virtual universe {}; + +/// Tag for any MTL vector (and user-declared MTL vectors) +struct vector : virtual collection {}; + +/// Tag for references to vector +/** For instance to not access memory directly but use functions, e.g. in set_to_zero. **/ +struct vector_ref : virtual vector {}; + +/// Tag for any MTL column vector (and user-declared MTL vectors) +struct col_vector : virtual vector {}; + +/// Tag for any MTL row vector (and user-declared MTL vectors) +struct row_vector : virtual vector {}; + +/// Tag for any MTL matrix (and user-declared MTL matrices) +struct matrix : virtual collection {}; + +/// Tag for any dense collection +struct dense : virtual universe {}; + +/// Tag for vectors with one-dimensional memory addressing +/** offet v_i is x*i for some x */ +struct has_1D_layout : virtual dense {}; + +/// Tag for matrices with two-dimensional memory addressing +/** offet a_ij is x*i + y*j for some x and y */ +struct has_2D_layout : virtual dense {}; + +/// Tag for any sparse collection +struct sparse : virtual universe {}; + +// for distinction between dense and sparse matrices +struct dense_matrix : virtual dense, virtual matrix {}; +struct sparse_matrix : virtual sparse, virtual matrix {}; + +/// Tag for collections where values are stored contigously in memory +struct contiguous_memory : virtual universe {}; + +/// Tag for dense and contiguous collections +/** Only short cut */ +struct contiguous_dense : virtual dense, virtual contiguous_memory {}; + +/// Collection with iterator +struct has_iterator : virtual universe {}; + +/// Collection with random-access iterator +struct has_ra_iterator : virtual has_iterator {}; + +/// Collection with fast random-access iterator +/** Meaning: unrolling is probably beneficial. Counter-example: Morton-ordered matrices have + random access but this is so slow that regular traversal is favorable */ +struct has_fast_ra_iterator : virtual has_ra_iterator {}; + +/// Collection with cursor +struct has_cursor : virtual universe {}; + +/// Collection with random-access cursor +struct has_ra_cursor : virtual has_cursor {}; + +/// Collection with fast random-access cursor +/** Meaning: unrolling is probably beneficial. Counter-example: Morton-ordered matrices have + random access but this is so slow that regular traversal is favorable */ +struct has_fast_ra_cursor : virtual has_ra_cursor {}; + +/// Tag for matrices with sub_matrix function exist and doesn't say for which ranges it is defined +struct has_sub_matrix : virtual universe {}; + +/// Sub-divisible into quadrants, i.e. arbitrary sub-matrices not necessarily supported but recursion works +// more explanation needed +struct qsub_divisible : virtual has_sub_matrix {}; + +/// Tag for sub-divisible matrix, i.e. sub_matrix works +struct sub_divisible : virtual qsub_divisible {}; + +/// Tag for dense row vector in the category lattice +struct dense_row_vector + : virtual row_vector, virtual contiguous_dense, + virtual has_fast_ra_iterator, virtual has_fast_ra_cursor, virtual has_1D_layout +{}; + +/// Tag for dense column vector in the category lattice +struct dense_col_vector + : virtual col_vector, virtual contiguous_dense, + virtual has_fast_ra_iterator, virtual has_fast_ra_cursor, virtual has_1D_layout +{}; + +/// Tag for strided row vector in the category lattice +struct strided_row_vector + : virtual row_vector, virtual vector_ref, + virtual has_fast_ra_iterator, virtual has_fast_ra_cursor, virtual has_1D_layout +{}; + +/// Tag for strided column vector in the category lattice +struct strided_col_vector + : virtual col_vector, virtual vector_ref, + virtual has_fast_ra_iterator, virtual has_fast_ra_cursor, virtual has_1D_layout +{}; + +/// Tag for sparse row vector in the category lattice +struct sparse_row_vector + : virtual row_vector, virtual sparse +{}; + +/// Tag for sparse column vector in the category lattice +struct sparse_col_vector + : virtual col_vector, virtual sparse +{}; + +/// Tag to handle std::vector in the category lattice +struct std_vector + : virtual vector, virtual contiguous_dense, virtual has_1D_layout +{}; + +/// Tag for a view on a (regular) dense matrix in the category lattice +/** The map perform address computation and has therefore no 2D-layout. + It is also not (yet) assumed that the view provides iterators. */ +struct dense2D_view + : virtual matrix, virtual contiguous_dense, virtual has_fast_ra_cursor + // , virtual sub_divisible // is currently not sub-divisible +{}; + +/// Tag for (regular) dense matrix in the category lattice +struct dense2D + : virtual dense2D_view, virtual has_fast_ra_iterator, virtual has_2D_layout, virtual sub_divisible +{}; + +struct implicit_dense + : virtual matrix, virtual dense, virtual has_fast_ra_cursor +{}; + +/// Tag for a view on a Morton-order matrix in the category lattice +/** It is not (yet) assumed that the view provides iterators. */ +struct morton_view + : virtual matrix, virtual contiguous_dense, + virtual has_ra_cursor // , virtual qsub_divisible // is currently not sub-divisible +{}; + + +/// Tag for Morton-order matrix in the category lattice +struct morton_dense + : virtual morton_view, virtual has_ra_iterator, virtual qsub_divisible +{}; + +/// Tag for a view on a compressed matrix in the category lattice +/** It is not (yet) assumed that the view provides iterators. */ +struct compressed2D_view + : virtual matrix, virtual sparse, virtual has_cursor +{}; + +/// Tag for compressed matrix in the category lattice +struct compressed2D + : virtual compressed2D_view, virtual has_iterator +{}; + +/// Tag for multi_vector +// Maybe splitting later into sparse and dense form +struct multi_vector + : virtual matrix, virtual dense +{}; + +/// Tag for transposed multi_vector +// Maybe splitting later into sparse and dense form +struct transposed_multi_vector + : virtual matrix, virtual dense +{}; + +/// Tag for transposed multi_vector +// Maybe splitting later into sparse and dense form +struct hermitian_multi_vector + : virtual matrix, virtual dense +{}; + +/// Tag for ell_matrix (preliminary) +struct ell_matrix + : sparse_matrix +{}; + +/// Tag for element structure matrix +struct element_structure + : sparse_matrix +{}; + +/// Tag for element structure matrix +struct sparse_banded_matrix + : sparse_matrix +{}; + +/// Tag for mat_cvec_multiplier +struct mat_cvec_multiplier + : col_vector +{}; + +/// Tag for implicit dense matrices + + +/// Tag for bottom of the category lattice +/** Only for completeness; probably not needed in practice. */ +struct bottom + : virtual compressed2D, virtual morton_dense, virtual dense2D, + virtual dense_col_vector, virtual dense_row_vector, virtual unknown, + virtual multi_vector +{}; + +template <typename Tag1, typename Tag2, typename Tag3= dummy3, typename Tag4= dummy4> +struct join + : virtual Tag1, virtual Tag2, virtual Tag3, virtual Tag4 +{}; + + +// ===================== +// Types for orientation +// ===================== + + +/// Characterizes row-major orientation in matrices and row vector in 1D +struct row_major {}; + +/// Characterizes column-major orientation in matrices and column vector in 1D +struct col_major {}; + +/// Common base for diagonal tags +struct universe_diagonal {}; + +/// Tag indicating that diagonal is stored regularly +struct regular_diagonal : universe_diagonal {}; + +/// Tag indicating that diagonal contains unit elements +struct unit_diagonal : universe_diagonal {}; + +/// Tag indicating that diagonal entries are stored as inverses +/** Storing value in different ways can be faster in several algorithms. + By the time of this writing it is experimental and only used + in upper_trisolve and lower_trisolve. **/ +struct inverse_diagonal : universe_diagonal {}; + + + + +/*@}*/ // end of group Tags + +} // namespace mtl::tag + +/** @addtogroup Tags + * @{ + */ + +/// Characterizes row-major orientation in matrices and row vector in 1D +using tag::row_major; + +/// Characterizes column-major orientation in matrices and column vector in 1D +using tag::col_major; + + + +/*@}*/ // end of group Tags + +// ===================== +// Tags for traversals +// Import some from GLAS +// ===================== + +namespace tag { + +/** @addtogroup Tags + * @{ + */ + + /// Tag for cursor traversal of non-zero elements of a collection + /** Also used for elements within rows and columns */ + using glas::tag::nz; + + /// Tag for cursor traversal of all elements of a collection + /** Also used for elements within rows and columns */ + using glas::tag::all; + + /// Tag for traversal of all rows in a matrix + using glas::tag::row; + /// Tag for traversal of all columns in a matrix + using glas::tag::col; + + /// Tag for traversal of a matrix's major dimension + /** Is equivalent to glas::tag::row for row-major matrices and + glas::tag::col for column-major matrices */ + using glas::tag::major; + + /// Tag for traversal of a matrix's minor dimension + /** Is equivalent to glas::tag::row for row-major matrices and + glas::tag::col for column-major matrices */ + using glas::tag::minor; + + // To define iterators over matrices or rows/cols of it, vectors + + namespace iter { + + /// Tag for iterator traversal of non-zero elements of a collection + /** Also used for elements within rows and columns */ + struct nz {}; + + /// Tag for iterator traversal of all elements of a collection + /** Also used for elements within rows and columns */ + struct all {}; + + } // namespace mtl::tag::iter + + // Same with const iterators + + namespace const_iter { + + /// Tag for const-iterator traversal of non-zero elements of a collection + /** Also used for elements within rows and columns */ + struct nz {}; + + /// Tag for const-iterator traversal of all elements of a collection + /** Also used for elements within rows and columns */ + struct all {}; + + } // namespace mtl::tag::const_iter + +/*@}*/ // end of group Tags + +} // namespace mtl::tag + + +} // namespace mtl + +#endif // MTL_TAG_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/transposed_matrix_type.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/transposed_matrix_type.hpp new file mode 100644 index 0000000000000000000000000000000000000000..e05db52b4a1532509aaa3600a8fea1ccf150974c --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/transposed_matrix_type.hpp @@ -0,0 +1,81 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_TRANSPOSED_MATRIX_TYPE_INCLUDE +#define MTL_TRAITS_TRANSPOSED_MATRIX_TYPE_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/utility/transposed_orientation.hpp> + +namespace mtl { namespace traits { + +template <class T> struct transposed_matrix_parameter {}; + +template <typename O, typename I, typename D, bool S, typename ST> +struct transposed_matrix_parameter<matrix::parameters<O, I, D, S, ST> > +{ + typedef matrix::parameters<typename transposed_orientation<O>::type, I, D, S, ST> type; +}; + +template <class T> struct transposed_matrix_type {}; + +template <typename Value, typename Parameters> +struct transposed_matrix_type<matrix::dense2D<Value, Parameters> > +{ + typedef matrix::dense2D<Value, typename transposed_matrix_parameter<Parameters>::type> type; +}; + +template <typename Value, typename Parameters> +struct transposed_matrix_type<matrix::compressed2D<Value, Parameters> > +{ + typedef matrix::compressed2D<Value, typename transposed_matrix_parameter<Parameters>::type> type; +}; + +template <typename Value, std::size_t Mask, typename Parameters> +struct transposed_matrix_type<matrix::morton_dense<Value, Mask, Parameters> > +{ + typedef matrix::morton_dense<Value, Mask, typename transposed_matrix_parameter<Parameters>::type> type; +}; + + + + +template <class T> struct transposed_sparse_matrix_type {}; + +template <typename Value, typename Parameters> +struct transposed_sparse_matrix_type<matrix::compressed2D<Value, Parameters> > +{ + typedef matrix::compressed2D<Value, typename transposed_matrix_parameter<Parameters>::type> type; +}; + +template <typename Matrix> +struct transposed_sparse_matrix_type<matrix::banded_view<Matrix> > +{ + typedef typename transposed_sparse_matrix_type<Matrix>::type type; +}; + + +template <typename Value, typename Parameters> +struct transposed_sparse_matrix_type<matrix::transposed_view<matrix::compressed2D<Value, Parameters> > > +{ + typedef matrix::compressed2D<Value, Parameters> type; +}; + +template <typename Value, typename Parameters> +struct transposed_sparse_matrix_type<matrix::transposed_view<const matrix::compressed2D<Value, Parameters> > > +{ + typedef matrix::compressed2D<Value, Parameters> type; +}; + +}} // namespace mtl::traits + +#endif // MTL_TRAITS_TRANSPOSED_MATRIX_TYPE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/transposed_orientation.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/transposed_orientation.hpp new file mode 100644 index 0000000000000000000000000000000000000000..96d0f068c3db163396f4a8324c6ec55f9acabae2 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/transposed_orientation.hpp @@ -0,0 +1,36 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_TRANSPOSED_ORIENTATION_INCLUDE +#define MTL_TRAITS_TRANSPOSED_ORIENTATION_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> + +namespace mtl { namespace traits { + +/// Orientation type for transposed matrices and vectors +template <class T> struct transposed_orientation {}; + +template<> struct transposed_orientation<tag::row_major> +{ + typedef tag::col_major type; +}; + +template<> struct transposed_orientation<tag::col_major> +{ + typedef tag::row_major type; +}; + + +}} // namespace mtl::traits + +#endif // MTL_TRAITS_TRANSPOSED_ORIENTATION_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/true_copy.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/true_copy.hpp new file mode 100644 index 0000000000000000000000000000000000000000..20332d97ce4d9c6c106fec12fbe9c7f75b1abeb3 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/true_copy.hpp @@ -0,0 +1,33 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_TRUE_COPY_INCLUDE +#define MTL_TRAITS_TRUE_COPY_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> + +namespace mtl { namespace traits { + +/// Type trait to force copy +/** Some libs define types to force shallow copy. This causes stale references in expression templates. + To counter-act we substitute the types, e.g. mp_real_tmp with mp_real, to force a copy. **/ +template <typename T> +struct true_copy +{ + typedef T type; +}; + + + +}} // namespace mtl::traits + +#endif // MTL_TRAITS_TRUE_COPY_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/unroll_size1.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/unroll_size1.hpp new file mode 100644 index 0000000000000000000000000000000000000000..e74cd4a349944decebf9869d4844e7cb6d7c9063 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/unroll_size1.hpp @@ -0,0 +1,36 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_UNROLL_SIZE1_INCLUDE +#define MTL_TRAITS_UNROLL_SIZE1_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> + +namespace mtl { namespace traits { + +/// Type trait for one-dimensional unrolling, default is 4. +template <typename Collection> +struct unroll_size1 +{ + static const unsigned value0= 4; +}; + +template <unsigned BSize, typename Vector> +struct unroll_size1<vector::unrolled1<BSize, Vector> > +{ + static const unsigned value0= BSize; +}; + + +}} // namespace mtl::traits + +#endif // MTL_TRAITS_UNROLL_SIZE1_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/updater_to_assigner.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/updater_to_assigner.hpp new file mode 100644 index 0000000000000000000000000000000000000000..8300761e4d76f74bd092573607b9d45a10bd53cf --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/updater_to_assigner.hpp @@ -0,0 +1,45 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_UPDATER_TO_ASSIGNER_INCLUDE +#define MTL_TRAITS_UPDATER_TO_ASSIGNER_INCLUDE + +#include <boost/numeric/mtl/operation/assign_mode.hpp> +#include <boost/numeric/mtl/operation/update.hpp> + +namespace mtl { namespace traits { + +template <typename Updater> +struct updater_to_assigner +{}; + +template <typename Element> +struct updater_to_assigner<mtl::operations::update_store<Element> > +{ + typedef mtl::assign::assign_sum type; +}; + +template <typename Element> +struct updater_to_assigner<mtl::operations::update_plus<Element> > +{ + typedef mtl::assign::plus_sum type; +}; + +template <typename Element> +struct updater_to_assigner<mtl::operations::update_minus<Element> > +{ + typedef mtl::assign::minus_sum type; +}; + +}} // namespace mtl::traits + +#endif // MTL_TRAITS_UPDATER_TO_ASSIGNER_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/view_code.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/view_code.hpp new file mode 100644 index 0000000000000000000000000000000000000000..39517cc36ab4bfa984ecc438da345d8ff41bf9a8 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/view_code.hpp @@ -0,0 +1,98 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_VIEW_CODE_INCLUDE +#define MTL_TRAITS_VIEW_CODE_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/utility/is_what.hpp> + +namespace mtl { namespace traits { + +/// Represent views by code (quite advanced feature for internal use) +/** 1-bit: constant + 2-bit: conjugated + 4-bit: transposed + -> hermitian_view of constant matrix is 7. **/ +template <typename T> +struct view_code +{ + MTL_STATIC_ASSERT(is_matrix<T>::value, "Currently only matrices are supported."); + static const unsigned value= 0; ///< Default is zero +}; + +template <typename T> +struct view_code<const T> +{ + static const unsigned value= view_code<T>::value | 1; ///< Toggle constancy bit +}; + +template <typename Matrix> +struct view_code< matrix::conj_view<Matrix> > +{ + static const unsigned value= view_code<Matrix>::value ^ 2; ///< Toggle conjugation bit +}; + +template <typename Matrix> +struct view_code<mtl::matrix::transposed_view<Matrix> > +{ + static const unsigned value= view_code<Matrix>::value ^ 4; ///< Toggle transposition bit +}; + +template <typename Matrix> +struct view_code<mtl::matrix::hermitian_view<Matrix> > +{ + static const unsigned value= view_code<Matrix>::value ^ 6; ///< Toggle transposition and conjugation bit +}; + +// add vector stuff + +template <unsigned Value> +struct view_normalize_const +{ + static const unsigned tmp2= Value == 0 || Value == 4 ? Value | 1 : Value, // if matrix ref or transposed, make it const + value= (tmp2 & 3) == 3 ? tmp2 ^ 1 : tmp2; // for conj turn off const +}; + +template <typename ViewCode> +struct view_add_const +{ + static const unsigned value= ViewCode::value | 1; +}; + +template <typename ViewCode> +struct view_remove_const +{ + static const unsigned value= ViewCode::value & ~1; +}; + +template <typename ViewCode> +struct view_toggle_conj +{ + static const unsigned value= view_normalize_const<ViewCode::value ^ 2>::value; +}; + +template <typename ViewCode> +struct view_toggle_trans +{ + static const unsigned value= ViewCode::value ^ 4; +}; + +template <typename ViewCode> +struct view_toggle_hermitian +{ + static const unsigned value= view_normalize_const<ViewCode::value ^ 6>::value; +}; + +}} // namespace mtl::traits + +#endif // MTL_TRAITS_VIEW_CODE_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/viewed_collection.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/viewed_collection.hpp new file mode 100644 index 0000000000000000000000000000000000000000..f83497c22579192700f0df87b8501bbde29247a8 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/viewed_collection.hpp @@ -0,0 +1,49 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_VIEWED_COLLECTION_INCLUDE +#define MTL_TRAITS_VIEWED_COLLECTION_INCLUDE + +#include <boost/type_traits/remove_const.hpp> +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/utility/is_what.hpp> + +namespace mtl { namespace traits { + +/// Type of the viewed matrix or vector, by default itself +template <typename T> +struct viewed_collection +{ + MTL_STATIC_ASSERT(is_matrix<T>::value, "Currently only matrices are supported."); + typedef typename boost::remove_const<T>::type type; +}; + +template <typename Matrix> +struct viewed_collection< matrix::conj_view<Matrix> > + : viewed_collection<Matrix> +{}; + +template <typename Matrix> +struct viewed_collection< matrix::transposed_view<Matrix> > + : viewed_collection<Matrix> +{}; + +template <typename Matrix> +struct viewed_collection< matrix::hermitian_view<Matrix> > + : viewed_collection<Matrix> +{}; + +// add vector stuff + +}} // namespace mtl::traits + +#endif // MTL_TRAITS_VIEWED_COLLECTION_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/with_unroll1.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/with_unroll1.hpp new file mode 100644 index 0000000000000000000000000000000000000000..8359693fd84b11715bffd9a834c14789c663d396 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/with_unroll1.hpp @@ -0,0 +1,33 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_TRAITS_WITH_UNROLL1_INCLUDE +#define MTL_TRAITS_WITH_UNROLL1_INCLUDE + +#include <boost/mpl/bool.hpp> +#include <boost/numeric/mtl/mtl_fwd.hpp> + +namespace mtl { namespace traits { + +/// Type trait for enabling one-dimensional unrolling, default is false. +template <typename Collection> +struct with_unroll1 + : boost::mpl::false_ {}; + +template <unsigned BSize, typename Vector> +struct with_unroll1<vector::unrolled1<BSize, Vector> > + : boost::mpl::true_ {}; + + +}} // namespace mtl::traits + +#endif // MTL_TRAITS_WITH_UNROLL1_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/wrapped_object.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/wrapped_object.hpp new file mode 100644 index 0000000000000000000000000000000000000000..aa4493cf0fceca26ad66ae2106a578ec53169fef --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/wrapped_object.hpp @@ -0,0 +1,37 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_WRAPPED_OBJECT_INCLUDE +#define MTL_WRAPPED_OBJECT_INCLUDE + +namespace mtl { + +/// Wrapper for objects +/** Can be referred in base classes to preserve initialization order + and avoid ambiguities. Using the object as base class can cause + name clashes and as member it cannot be initialized after all + base classes with pedantic warnings. **/ +template <typename View> +struct wrapped_object +{ + template <typename T> + wrapped_object(T& x) : wrapped_object_member(x) {} + + template <typename T, typename U> + wrapped_object(const T& x, const U& y) : wrapped_object_member(x, y) {} + + View wrapped_object_member; // ugly name avoid ambiguities in derived classes +}; + +} // namespace mtl + +#endif // MTL_WRAPPED_OBJECT_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/utility/zipped_sort.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/zipped_sort.hpp new file mode 100644 index 0000000000000000000000000000000000000000..b4bb093441067cf7748244f9abf57fc3204c67dc --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/utility/zipped_sort.hpp @@ -0,0 +1,212 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_ZIPPED_SORT_INCLUDE +#define MTL_ZIPPED_SORT_INCLUDE + +// Designed for pointers so far and not tested for general iterators +// For internal use only + +#include <cmath> +#include <utility> +#include <iterator> +#include <boost/numeric/mtl/utility/exception.hpp> + +namespace mtl { namespace utility { + +template <typename T, typename U> struct zip_ref; +template <typename T, typename U> struct zip_it; +template <typename T, typename U> struct zip_value; + +struct less_0 +{ + template <typename T, typename U> + bool operator()(const zip_ref<T, U>& x, const zip_ref<T, U>& y) const + { + return x.a[x.p] < y.a[y.p]; + } + + template <typename T, typename U> + bool operator()(const zip_ref<T, U>& x, const zip_value<T, U>& y) const + { + return x.a[x.p] < y.x; + } + + template <typename T, typename U> + bool operator()(const zip_value<T, U>& x, const zip_ref<T, U>& y) const + { + return x.x < y.a[y.p]; + } +}; + +struct greater_0 +{ + template <typename T, typename U> + bool operator()(const zip_ref<T, U>& x, const zip_ref<T, U>& y) const + { + return x.a[x.p] > y.a[y.p]; + } + + template <typename T, typename U> + bool operator()(const zip_ref<T, U>& x, const zip_value<T, U>& y) const + { + return x.a[x.p] > y.x; + } + + template <typename T, typename U> + bool operator()(const zip_value<T, U>& x, const zip_ref<T, U>& y) const + { + return x.x > y.a[y.p]; + } +}; + +struct abs_greater_0 +{ + template <typename T, typename U> + bool operator()(const zip_ref<T, U>& x, const zip_ref<T, U>& y) const + { + using std::abs; + return abs(x.a[x.p]) > abs(y.a[y.p]); + } + + template <typename T, typename U> + bool operator()(const zip_ref<T, U>& x, const zip_value<T, U>& y) const + { + using std::abs; + return abs(x.a[x.p]) > abs(y.x); + } + + template <typename T, typename U> + bool operator()(const zip_value<T, U>& x, const zip_ref<T, U>& y) const + { + using std::abs; + return abs(x.x) > abs(y.a[y.p]); + } +}; + + +template <typename T, typename U> +struct zip_it +{ + typedef zip_ref<T, U> ref_type; + typedef long diff_type; + // typedef std::difference_type diff_type; + + explicit zip_it(T* a, U* v, diff_type p) : a(a), v(v), p(p) {} + + ref_type operator*() { return ref_type(a, v, p); } + zip_it& operator++() { p++; return *this;} + zip_it operator++(int) { zip_it tmp(a, v, p); p++; return tmp;} + zip_it& operator--() { p--; return *this;} + zip_it operator--(int) { zip_it tmp(a, v, p); p--; return tmp;} + + void check(const zip_it& MTL_DEBUG_ARG(other)) const { assert(a == other.a); assert(v == other.v); } + + bool operator==(const zip_it& other) const { check(other); return p == other.p; } + bool operator!=(const zip_it& other) const { check(other); return p != other.p; } + bool operator<=(const zip_it& other) const { check(other); return p <= other.p; } + bool operator<(const zip_it& other) const { check(other); return p < other.p; } + bool operator>=(const zip_it& other) const { check(other); return p >= other.p; } + bool operator>(const zip_it& other) const { check(other); return p > other.p; } + diff_type operator-(const zip_it& other) const { check(other); return p - other.p; } + zip_it operator+(diff_type i) const { return zip_it(a, v, p+i); } + zip_it& operator+=(diff_type i) { p+= i; return *this; } + zip_it operator-(diff_type i) const { return zip_it(a, v, p-i); } + zip_it& operator=(const zip_it& other) { check(other); p= other.p; return *this; } + + T* a; + U* v; + diff_type p; +}; + + +template <typename T, typename U> +struct zip_ref +{ + typedef zip_ref self; + + zip_ref(T* a, U* v, int p) : a(a), v(v), p(p) {} + + void check(const zip_ref& MTL_DEBUG_ARG(other)) const { assert(a == other.a); assert(v == other.v); } + + bool operator<(const zip_ref& r) const { check(r); return a[p] < r.a[r.p]; } + zip_ref& operator=(const zip_ref& r) + { + check(r); + if (p == r.p) + return *this; + a[p]= r.a[r.p]; v[p]= r.v[r.p]; + p= r.p; + return *this; + } +#ifdef MTL_WITH_MOVE + zip_ref& operator=(zip_value<T, U>&& zv) + { + a[p]= zv.x; + v[p]= zv.y; + return *this; + } +#endif + + zip_ref& operator=(const zip_value<T, U>& zv) + { + a[p]= zv.x; + v[p]= zv.y; + return *this; + } + + T *a; + U *v; + int p; + +}; + +// const ref is ugly but mutable ref doesn't work with temporaries and copy is not as good as overload +template <typename T, typename U> +inline void swap(const zip_ref<T, U>& x, const zip_ref<T, U>& y) +{ + using std::swap; + + swap(x.a[x.p], y.a[y.p]); + swap(x.v[x.p], y.v[y.p]); +} + +template <typename T, typename U> +struct zip_value +{ + zip_value(const zip_ref<T, U>& r) : x(r.a[r.p]), y(r.v[r.p]) {} + + T x; + U y; +}; + + +}} // namespace mtl::utility + +namespace std { + template <typename T, typename U> + struct iterator_traits<mtl::utility::zip_it<T, U> > + { + typedef mtl::utility::zip_ref<T, U> ref_type; + typedef mtl::utility::zip_value<T, U> value_type; + typedef ref_type& reference; + typedef ref_type* pointer; + typedef int difference_type; + typedef random_access_iterator_tag iterator_category; + }; +} + +// usage: +// sort(zip_it<T, U>(a, v, 0), zip_it<T, U>(a, v, S), less_0()); +// where a and v are pointers or arrays and S the size of both arrays + +#endif // MTL_ZIPPED_SORT_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/all_vec_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/all_vec_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..839e7ceeece8483b1a02c05ee162e8cde96a0702 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/all_vec_expr.hpp @@ -0,0 +1,34 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_ALL_VEC_EXPR_INCLUDE +#define MTL_ALL_VEC_EXPR_INCLUDE + +#include <boost/numeric/mtl/vector/vec_expr.hpp> +#include <boost/numeric/mtl/vector/vec_negate_expr.hpp> +#include <boost/numeric/mtl/vector/vec_vec_ele_prod_expr.hpp> +#include <boost/numeric/mtl/vector/vec_vec_ele_quot_expr.hpp> +#include <boost/numeric/mtl/vector/vec_vec_plus_expr.hpp> +#include <boost/numeric/mtl/vector/vec_vec_minus_expr.hpp> +#include <boost/numeric/mtl/vector/vec_vec_asgn_expr.hpp> +#include <boost/numeric/mtl/vector/vec_vec_plus_asgn_expr.hpp> +#include <boost/numeric/mtl/vector/vec_vec_minus_asgn_expr.hpp> +#include <boost/numeric/mtl/vector/vec_vec_times_asgn_expr.hpp> +#include <boost/numeric/mtl/vector/vec_vec_div_asgn_expr.hpp> +#include <boost/numeric/mtl/vector/vec_scal_plus_asgn_expr.hpp> +#include <boost/numeric/mtl/vector/vec_scal_minus_asgn_expr.hpp> +#include <boost/numeric/mtl/vector/vec_scal_times_asgn_expr.hpp> +#include <boost/numeric/mtl/vector/vec_scal_div_asgn_expr.hpp> // added by Hui Li +#include <boost/numeric/mtl/vector/vec_scal_asgn_expr.hpp> +#include <boost/numeric/mtl/vector/vec_scal_mixed_expr.hpp> + +#endif // MTL_ALL_VEC_EXPR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/assign_expression.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/assign_expression.hpp new file mode 100644 index 0000000000000000000000000000000000000000..d4bfecc1770361ddb0d6906e3464df6e9643b9be --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/assign_expression.hpp @@ -0,0 +1,89 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +// Adapted from GLAS implementation by Karl Meerbergen and Toon Knappen + + +#ifndef MTL_VEC_VEC_ASGN_EXPR_INCLUDE +#define MTL_VEC_VEC_ASGN_EXPR_INCLUDE + + +namespace mtl { namespace vector { + +// Model of VectorExpression +template <class E1, class E2> +class vec_vec_asgn_expr +{ +public: + // temporary solution + typedef typename E1::value_type value_type; + // typedef typename glas::value< glas::scalar::vec_vec_asgn_expr<typename E1::value_type, typename E2::value_type > >::type value_type ; + + // temporary solution + typedef typename E1::size_type size_type; + //typedef typename utilities::smallest< typename E1::size_type, typename E2::size_type >::type size_type ; + + typedef value_type const_dereference_type ; + + typedef E1 first_argument_type ; + typedef E2 second_argument_type ; + + + vec_vec_asgn_expr( first_argument_type& v1, second_argument_type const& v2 ) + : first( v1 ), second( v2 ), delayed_assign( false ) + {} + + ~vec_vec_asgn_expr() + { + if (!delayed_assign) + for (size_type i= 0; i < size(first); ++i) + first( i )= second( i ); + } + + void delay_assign() { delayed_assign= true; } + + size_type size() const { + assert( size(first) == second_.size() ) ; + return size(first) ; + } + + const_dereference_type operator() ( size_type i ) const { + assert( delayed_assign ); + return first( i )= second( i ) ; + } + + const_dereference_type operator[] ( size_type i ) const { + assert( delayed_assign ); + return first( i )= second( i ) ; + } + + private: + first_argument_type& first ; + second_argument_type const& second ; + bool delayed_assign; + } ; // vec_vec_asgn_expr + +} } // Namespace mtl::vector + + +namespace mtl { namespace traits { + + template <class E1, class E2> + struct category< vector::vec_vec_asgn_expr<E1,E2> > + { + typedef vector type ; + } ; + +}} // Namespace mtl::traits + +#endif + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/assigner.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/assigner.hpp new file mode 100644 index 0000000000000000000000000000000000000000..13d752c318f18c5d38bd9add3322f0212b55432a --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/assigner.hpp @@ -0,0 +1,35 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_VECTOR_ASSIGNER_INCLUDE +#define MTL_VECTOR_ASSIGNER_INCLUDE + +namespace mtl { namespace vector { + +struct assigner_base {}; + +/// CRTP class to assign the result of the derived class to a vector +template <typename Derived> +struct assigner : assigner_base +{ + /// Function that must be defined in \p Derived where it is called by static down-cast + template <typename Vector> + void assign_to(Vector& tgt) const + { + static_cast<const Derived&>(*this).assign_to(tgt); + } + +}; + +}} // namespace mtl::vector + +#endif // MTL_VECTOR_ASSIGNER_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/crtp_base_vector.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/crtp_base_vector.hpp new file mode 100644 index 0000000000000000000000000000000000000000..2d6a6a050b29957523173f3f3c12d8d071b4b401 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/crtp_base_vector.hpp @@ -0,0 +1,554 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_CRTP_BASE_VECTOR_INCLUDE +#define MTL_CRTP_BASE_VECTOR_INCLUDE + +#include <boost/mpl/if.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/type_traits/is_base_of.hpp> + +#include <boost/utility/enable_if.hpp> +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/vector/all_vec_expr.hpp> +#include <boost/numeric/mtl/vector/assigner.hpp> +#include <boost/numeric/mtl/vector/decrementer.hpp> +#include <boost/numeric/mtl/vector/incrementer.hpp> +#include <boost/numeric/mtl/operation/mat_cvec_times_expr.hpp> +#include <boost/numeric/mtl/operation/mult.hpp> +#include <boost/numeric/mtl/operation/mat_vec_mult.hpp> +#include <boost/numeric/mtl/operation/mult_assign_mode.hpp> +#include <boost/numeric/mtl/operation/right_scale_inplace.hpp> +#include <boost/numeric/mtl/utility/ashape.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/utility/flatcat.hpp> +#include <boost/numeric/mtl/utility/is_distributed.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> + +#include <boost/numeric/itl/itl_fwd.hpp> + +namespace mtl { namespace vector { + + +namespace detail { + + template <typename Vector, typename Source, typename SCat, typename VCat> + struct crtp_assign {}; + + /// Assign scalar to a vector by setting all values to the scalar + template <typename Vector, typename Source, typename VCat> + struct crtp_assign<Vector, Source, VCat, ashape::scal> + { + typedef vec_scal_asgn_expr<Vector, Source> type; + type operator()(Vector& vector, const Source& src) + { + return type(vector, src); + } + }; + + /// Assign vector to a vector + template <typename Vector, typename Source, typename Cat> + struct crtp_assign<Vector, Source, Cat, Cat> + { + typedef vec_vec_asgn_expr<Vector, Source> type; + type operator()(Vector& vector, const Source& src) + { + return type(vector, src); + } + }; + + template <typename Vector, typename Source> + struct assign_assigner + { + typedef const Vector& type; + type operator()(Vector& vector, const Source& src) + { + src.assign_to(vector); + return vector; + } + }; + +} // namespace detail + +template <typename Vector, typename Source> +struct crtp_assign + : boost::mpl::if_ + <boost::is_base_of<assigner_base, Source>, + detail::assign_assigner <Vector, Source>, + detail::crtp_assign<Vector, Source, typename ashape::ashape<Vector>::type, typename ashape::ashape<Source>::type> + >::type +{}; + +/// Assign matrix vector product by calling mult +/** Note that this does not work for arbitrary expressions. **/ +template <typename Vector, typename E1, typename E2> +struct crtp_assign<Vector, mat_cvec_times_expr<E1, E2> > +{ + typedef Vector& type; + type operator()(Vector& vector, const mat_cvec_times_expr<E1, E2>& src) + { + vector.checked_change_resource(src); + set_to_zero(vector); + mat_cvec_mult(src.first, src.second, vector, assign::assign_sum(), traits::mat_cvec_flatcat<E1>()); + return vector; + } +}; + + +/// Assign vector matrix product by calling mult +/** Note that this does not work for arbitrary expressions. **/ +template <typename Vector, typename E1, typename E2> +struct crtp_assign<Vector, rvec_mat_times_expr<E1, E2> > +{ + typedef Vector& type; + type operator()(Vector& vector, const rvec_mat_times_expr<E1, E2>& src) + { + vector.checked_change_resource(src); + rvec_mat_mult(src.first, src.second, vector, assign::assign_sum(), traits::mat_cvec_flatcat<E2>()); + return vector; + } +}; + +/// Assign c-style 1D-array, because it's easier to initialize. +template <typename Vector, typename Value, unsigned Rows> +struct crtp_assign<Vector, Value[Rows]> +{ + typedef Vector& type; + type operator()(Vector& vector, const Value src[Rows]) + { + typedef typename Collection<Vector>::size_type size_type; + + vector.checked_change_dim(Rows); + + for (size_type r= 0; r < Rows; ++r) + vector[r]= src[r]; + return vector; + } +}; + + +namespace detail { + + template <typename Vector, typename Source, typename SCat, typename VCat> + struct crtp_plus_assign {}; + + /// Assign-add vector to a vector + template <typename Vector, typename Source, typename Cat> + struct crtp_plus_assign<Vector, Source, Cat, Cat> + { + typedef vec_vec_plus_asgn_expr<Vector, Source> type; + type operator()(Vector& vector, const Source& src) + { + return type( vector, src ); + } + }; + + /// Increment a vector by a scalar + template <typename Vector, typename Source, typename VCat> + struct crtp_plus_assign<Vector, Source, VCat, ashape::scal> + { + typedef vec_scal_plus_asgn_expr<Vector, Source> type; + type operator()(Vector& vector, const Source& src) + { + return type(vector, src); + } + }; + + template <typename Vector, typename Source> + struct assign_incrementer + { + typedef const Vector& type; + type operator()(Vector& vector, const Source& src) + { + src.increment_it(vector); + return vector; + } + }; + +} // namespace detail + +template <typename Vector, typename Source> +struct crtp_plus_assign + : boost::mpl::if_ + <boost::is_base_of<incrementer_base, Source>, + detail::assign_incrementer<Vector, Source>, + detail::crtp_plus_assign<Vector, Source, typename ashape::ashape<Vector>::type, + typename ashape::ashape<Source>::type> + >::type +{}; + +/// Assign-add matrix vector product by calling mult +/** Note that this does not work for arbitrary expressions. **/ +template <typename Vector, typename E1, typename E2> +struct crtp_plus_assign<Vector, mat_cvec_times_expr<E1, E2> > +{ + typedef Vector& type; + type operator()(Vector& vector, const mat_cvec_times_expr<E1, E2>& src) + { + mat_cvec_mult(src.first, src.second, vector, assign::plus_sum(), traits::mat_cvec_flatcat<E1>()); + return vector; + } +}; + +/// Assign-add vector matrix product by calling mult +/** Note that this does not work for arbitrary expressions. **/ +template <typename Vector, typename E1, typename E2> +struct crtp_plus_assign<Vector, rvec_mat_times_expr<E1, E2> > +{ + typedef Vector& type; + type operator()(Vector& vector, const rvec_mat_times_expr<E1, E2>& src) + { + rvec_mat_mult(src.first, src.second, vector, assign::plus_sum(), traits::mat_cvec_flatcat<E2>()); + return vector; + } +}; + + +namespace detail { + + template <typename Vector, typename Source, typename VCat, typename SCat> + struct crtp_minus_assign {}; + + /// Assign-add vector to a vector + template <typename Vector, typename Source, typename Cat> + struct crtp_minus_assign<Vector, Source, Cat, Cat> + { + typedef vec_vec_minus_asgn_expr<Vector, Source> type; + type operator()(Vector& vector, const Source& src) + { + return type(vector, src); + } + }; + + /// Decrement a vector by a scalar + template <typename Vector, typename Source, typename VCat> + struct crtp_minus_assign<Vector, Source, VCat, ashape::scal> + { + typedef vec_scal_minus_asgn_expr<Vector, Source> type; + type operator()(Vector& vector, const Source& src) + { + return type(vector, src); + } + }; + + template <typename Vector, typename Source> + struct assign_decrementer + { + typedef const Vector& type; + type operator()(Vector& vector, const Source& src) + { + src.decrement_it(vector); + return vector; + } + }; + +} // namespace detail + +template <typename Vector, typename Source> +struct crtp_minus_assign + : boost::mpl::if_ + <boost::is_base_of<decrementer_base, Source>, + detail::assign_decrementer<Vector, Source>, + detail::crtp_minus_assign<Vector, Source, typename ashape::ashape<Vector>::type, + typename ashape::ashape<Source>::type> + >::type +{}; + +/// Assign-subtract matrix vector product by calling mult +/** Note that this does not work for arbitrary expressions. **/ +template <typename Vector, typename E1, typename E2> +struct crtp_minus_assign<Vector, mat_cvec_times_expr<E1, E2> > +{ + typedef Vector& type; + type operator()(Vector& vector, const mat_cvec_times_expr<E1, E2>& src) + { + mat_cvec_mult(src.first, src.second, vector, assign::minus_sum(), traits::mat_cvec_flatcat<E1>()); + return vector; + } +}; + +/// Assign-subtract vector matrix product by calling mult +/** Note that this does not work for arbitrary expressions. **/ +template <typename Vector, typename E1, typename E2> +struct crtp_minus_assign<Vector, rvec_mat_times_expr<E1, E2> > +{ + typedef Vector& type; + type operator()(Vector& vector, const rvec_mat_times_expr<E1, E2>& src) + { + rvec_mat_mult(src.first, src.second, vector, assign::minus_sum(), traits::mat_cvec_flatcat<E2>()); + return vector; + } +}; + +#if 1 +namespace detail { + + template <typename Vector, typename Source, typename SCat, typename VCat> + struct crtp_times_assign {}; + + /// Assign-add vector to a vector + template <typename Vector, typename Source, typename Cat> + struct crtp_times_assign<Vector, Source, Cat, Cat> + { + typedef vec_vec_times_asgn_expr<Vector, Source> type; + type operator()(Vector& vector, const Source& src) + { + return type( vector, src ); + } + }; + + /// Increment a vector by a scalar + template <typename Vector, typename Source, typename VCat> + struct crtp_times_assign<Vector, Source, VCat, ashape::scal> + { + typedef vec_scal_times_asgn_expr<Vector, Source> type; + type operator()(Vector& vector, const Source& src) + { + return type(vector, src); + } + }; + + template <typename Vector, typename Source> + struct assign_multiplyer + { + typedef const Vector& type; + type operator()(Vector& vector, const Source& src) + { + src.multiply_it(vector); + return vector; + } + }; + +} // namespace detail + +template <typename Vector, typename Source> +struct crtp_times_assign + : boost::mpl::if_ + <boost::is_base_of<incrementer_base, Source>, + detail::assign_multiplyer<Vector, Source>, + detail::crtp_times_assign<Vector, Source, typename ashape::ashape<Vector>::type, + typename ashape::ashape<Source>::type> + >::type +{}; + +/// Assign-add matrix vector product by calling mult +/** Note that this does not work for arbitrary expressions. **/ +template <typename Vector, typename E1, typename E2> +struct crtp_times_assign<Vector, mat_cvec_times_expr<E1, E2> > +{ + typedef Vector& type; + type operator()(Vector& vector, const mat_cvec_times_expr<E1, E2>& src) + { + mat_cvec_mult(src.first, src.second, vector, assign::times_sum(), traits::mat_cvec_flatcat<E1>()); + return vector; + } +}; + +/// Assign-add vector matrix product by calling mult +/** Note that this does not work for arbitrary expressions. **/ +template <typename Vector, typename E1, typename E2> +struct crtp_times_assign<Vector, rvec_mat_times_expr<E1, E2> > +{ + typedef Vector& type; + type operator()(Vector& vector, const rvec_mat_times_expr<E1, E2>& src) + { + rvec_mat_mult(src.first, src.second, vector, assign::times_sum(), traits::mat_cvec_flatcat<E2>()); + return vector; + } +}; + + +namespace detail { + + template <typename Vector, typename Source, typename SCat, typename VCat> + struct crtp_div_assign {}; + + /// Assign-divide vector to a vector + template <typename Vector, typename Source, typename Cat> + struct crtp_div_assign<Vector, Source, Cat, Cat> + { + typedef vec_vec_div_asgn_expr<Vector, Source> type; + type operator()(Vector& vector, const Source& src) + { + return type( vector, src ); + } + }; + + /// Divide a vector by a scalar + template <typename Vector, typename Source, typename VCat> + struct crtp_div_assign<Vector, Source, VCat, ashape::scal> + { + typedef vec_scal_div_asgn_expr<Vector, Source> type; + type operator()(Vector& vector, const Source& src) + { + return type(vector, src); + } + }; + + template <typename Vector, typename Source> + struct assign_divider + { + typedef const Vector& type; + type operator()(Vector& vector, const Source& src) + { + src.divide_it(vector); + return vector; + } + }; + +} // namespace detail + +template <typename Vector, typename Source> +struct crtp_div_assign + : boost::mpl::if_ + <boost::is_base_of<incrementer_base, Source>, + detail::assign_divider<Vector, Source>, + detail::crtp_div_assign<Vector, Source, typename ashape::ashape<Vector>::type, + typename ashape::ashape<Source>::type> + >::type +{}; + +/// Assign-divide matrix vector product by calling mult +/** Note that this does not work for arbitrary expressions. **/ +template <typename Vector, typename E1, typename E2> +struct crtp_div_assign<Vector, mat_cvec_times_expr<E1, E2> > +{ + typedef Vector& type; + type operator()(Vector& vector, const mat_cvec_times_expr<E1, E2>& src) + { + mat_cvec_mult(src.first, src.second, vector, assign::divide_sum(), traits::mat_cvec_flatcat<E1>()); + return vector; + } +}; + +/// Assign-divide vector matrix product by calling mult +/** Note that this does not work for arbitrary expressions. **/ +template <typename Vector, typename E1, typename E2> +struct crtp_div_assign<Vector, rvec_mat_times_expr<E1, E2> > +{ + typedef Vector& type; + type operator()(Vector& vector, const rvec_mat_times_expr<E1, E2>& src) + { + rvec_mat_mult(src.first, src.second, vector, assign::divide_sum(), traits::mat_cvec_flatcat<E2>()); + return vector; + } +}; + +#endif + + + +/// Base class to provide vector assignment operators generically +template <typename Vector, typename ValueType, typename SizeType> +struct crtp_vector_assign +{ + /// Templated assignment implemented by functor to allow for partial specialization + template <typename E> + typename boost::disable_if<boost::is_same<Vector, E>, + typename crtp_assign<Vector, E>::type>::type + operator=(const E& e) + { + return crtp_assign<Vector, E>()(static_cast<Vector&>(*this), e); + } + + /// Assign-add vector expression + template <class E> + typename crtp_plus_assign<Vector, E>::type operator+=(const E& e) + { + return crtp_plus_assign<Vector, E>()(static_cast<Vector&>(*this), e); + } + + /// Assign-subtract vector expression + template <class E> + typename crtp_minus_assign<Vector, E>::type operator-=(const E& e) + { + return crtp_minus_assign<Vector, E>()(static_cast<Vector&>(*this), e); + } + + +#if 1 + /// Assign-times vector expression + template <class E> + typename crtp_times_assign<Vector, E>::type operator*=(const E& e) + { + return crtp_times_assign<Vector, E>()(static_cast<Vector&>(*this), e); + } + + /// Assign-div vector expression + template <class E> + typename crtp_div_assign<Vector, E>::type operator/=(const E& e) + { + return crtp_div_assign<Vector, E>()(static_cast<Vector&>(*this), e); + } +#endif + +#if 0 + /// Scale vector (in place) with scalar value + /** In the future, row vectors be possibly scaled by a matrix **/ + template <typename Factor> + vec_scal_times_asgn_expr<Vector, Factor> operator*=(const Factor& alpha) + { + return vec_scal_times_asgn_expr<Vector, Factor>( static_cast<Vector&>(*this), alpha ); + } + + /// Devide vector (in place) by a scalar value + // added by Hui Li 12/11/2007 + template <typename Factor> + vec_scal_div_asgn_expr<Vector, Factor> operator/=(const Factor& alpha) + { + return vec_scal_div_asgn_expr<Vector, Factor>( static_cast<Vector&>(*this), alpha ); + } +#endif + /// Check whether source and target have compatible resources and adapt empty target + /** For expressions like u= v + w, u can be set to the size of v and w if still is 0. **/ + template <typename Src> + void checked_change_resource(const Src& src) + { checked_change_resource_aux(src, typename mtl::traits::is_distributed<Vector>::type()); } + + template <typename Src> + void checked_change_resource_aux(const Src& src, boost::mpl::false_) + { checked_change_dim(mtl::vector::size(src)); } + + + /// Check whether vector size is compatible or if vector is 0 change it s. + void checked_change_dim(SizeType s) + { + Vector& vector= static_cast<Vector&>(*this); + vector.check_dim(s); + vector.change_dim(s); + } +}; + + +template <typename Vector, typename ValueType, typename SizeType> +struct const_crtp_base_vector +{}; + +template <typename Vector, typename ValueType, typename SizeType> +struct mutable_crtp_base_vector + : public crtp_vector_assign<Vector, ValueType, SizeType> +{}; + + + +template <typename Vector, typename ValueType, typename SizeType> +struct crtp_base_vector + : boost::mpl::if_<boost::is_const<Vector>, + const_crtp_base_vector<Vector, ValueType, SizeType>, + mutable_crtp_base_vector<Vector, ValueType, SizeType> + >::type +{}; + + +}} // namespace mtl::vector + +#endif // MTL_CRTP_BASE_VECTOR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/decrementer.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/decrementer.hpp new file mode 100644 index 0000000000000000000000000000000000000000..efcde8d3aa1201c03b4e6e41999333b97dcbaa2a --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/decrementer.hpp @@ -0,0 +1,35 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_VECTOR_DECREMENTER_INCLUDE +#define MTL_VECTOR_DECREMENTER_INCLUDE + +namespace mtl { namespace vector { + +struct decrementer_base {}; + +/// CRTP class to decrement a vector with the result of the derived class +template <typename Derived> +struct decrementer : decrementer_base +{ + /// Function that must be defined in \p Derived where it is called by static down-cast + template <typename Vector> + void decrement_it(Vector& tgt) const + { + static_cast<const Derived&>(*this).decrement_it(tgt); + } + +}; + +}} // namespace mtl::vector + +#endif // MTL_VECTOR_DECREMENTER_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/dense_vector.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/dense_vector.hpp new file mode 100644 index 0000000000000000000000000000000000000000..77813ee21682248be4fb979b31e0c400521b0329 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/dense_vector.hpp @@ -0,0 +1,432 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +// Adapted from GLAS implementation by Karl Meerbergen and Toon Knappen + + +#ifndef MTL_DENSE_VECTOR_INCLUDE +#define MTL_DENSE_VECTOR_INCLUDE + + +#include <iostream> +#include <cassert> +#include <vector> +#include <algorithm> +#include <boost/static_assert.hpp> +#include <boost/utility/enable_if.hpp> +#include <boost/type_traits/is_integral.hpp> + +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/ashape.hpp> +#include <boost/numeric/mtl/vector/all_vec_expr.hpp> +#include <boost/numeric/mtl/vector/parameter.hpp> +#include <boost/numeric/mtl/detail/contiguous_memory_block.hpp> +#include <boost/numeric/mtl/vector/crtp_base_vector.hpp> +#include <boost/numeric/mtl/utility/dense_el_cursor.hpp> +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/utility/irange.hpp> +#include <boost/numeric/mtl/utility/is_static.hpp> +#include <boost/numeric/mtl/utility/is_row_major.hpp> +#include <boost/numeric/mtl/utility/transposed_orientation.hpp> +#include <boost/numeric/mtl/operation/is_negative.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +#ifdef MTL_WITH_INITLIST +# include <initializer_list> +#endif + +namespace mtl { namespace vector { + +/// Dense vector +template <class Value, typename Parameters = parameters<> > +class dense_vector + : public vec_expr<dense_vector<Value, Parameters> >, + public ::mtl::detail::contiguous_memory_block< Value, Parameters::on_stack, Parameters::dimension::value >, + public crtp_base_vector< dense_vector<Value, Parameters>, Value, std::size_t > +{ + public: + typedef dense_vector<Value, Parameters> self; + typedef ::mtl::detail::contiguous_memory_block< Value, Parameters::on_stack, + Parameters::dimension::value > memory_base; + typedef crtp_base_vector< self, Value, std::size_t > crtp_base; + typedef crtp_vector_assign< self, Value, std::size_t > assign_base; + typedef vec_expr<dense_vector<Value, Parameters> > expr_base; + typedef Value value_type ; + typedef std::size_t size_type ; + typedef value_type& reference ; + typedef value_type const& const_reference ; + typedef Value* pointer ; + typedef Value const* const_pointer ; + typedef typename Parameters::orientation orientation; + + typedef const_pointer key_type; + + /// Check whether index is non-negative and less than size + void check_index( size_type MTL_DEBUG_ARG(i) ) const + { + MTL_DEBUG_THROW_IF( is_negative(i) || i >= this->used_memory(), index_out_of_range()); + } + + /// Check for a given vector if the sizes are equal or this has size 0 (and can take the size of source) + void check_dim( size_type MTL_DEBUG_ARG(s) ) const + { + MTL_DEBUG_THROW_IF( this->used_memory() != 0 && this->used_memory() != s, incompatible_size()); + } + + /// Check at compile time for a given vector if the sizes are equal + void static_check( size_type MTL_DEBUG_ARG(s) ) const + { + assert(!traits::is_static<self>::value || s == size(typename Parameters::dimension())); + } + + /// Check if a given vector expression whether it has the same shape as the object + /** Both must be row vectors or column vectors. The elements must have the same + algebraic shape, e.g. a row vector of scalars is not compatible with a row + vector of matrices. **/ + template <class E> + void check_consistent_shape( vec_expr<E> const& ) const + { + MTL_DEBUG_THROW_IF((!boost::is_same< + typename ashape::ashape<self>::type + , typename ashape::ashape<E>::type + >::value), + incompatible_shape()); + } + + /// Default constructor + dense_vector( ) : memory_base( Parameters::dimension::value ) {} + + /// Constructor for size \p n + explicit dense_vector( size_type n ) : memory_base( n ) { static_check( n ); } + + /// Constructor for size \p n and value \p value that is set in all entries + explicit dense_vector( size_type n, value_type value ) + : memory_base( n ) + { + static_check( n ); + std::fill(begin(), end(), value); + } + + /// Constructor for size \p n and \p address + /** Can be used to handle vectors from other libraries, even in other languages like Fortran **/ + explicit dense_vector( size_type n, value_type *address ) + : memory_base( address, n, true ) + { static_check( n ); } + + /// Copy constructor + dense_vector( const self& src ) + : memory_base( src ) + { + vampir_trace<2042> tracer; + using std::copy; + copy(src.begin(), src.end(), this->begin()); + } + + /// Clone constructor + /** Copies every vector, even those that refer to external data, sub-vectors, or rows and columns in a matrix **/ + dense_vector( const self& src, clone_ctor ) + : memory_base( src, clone_ctor()) {} + + struct dummy_type {}; + + /// Constructor from vector expressions + template <typename VectorSrc> + explicit dense_vector(const VectorSrc& src, + typename boost::disable_if<boost::is_integral<VectorSrc>, dummy_type>::type= dummy_type()) + { vampir_trace<2043> tracer; *this= src; } + +#ifdef MTL_WITH_INITLIST + /// Constructor for initializer list \p values + template <typename Value2> + dense_vector(std::initializer_list<Value2> values) + : memory_base(values.size()) + { + static_check(values.size()); + std::copy(values.begin(), values.end(), begin()); + } + + /// Assignment from initializer list \p values + template <typename Value2> + self& operator=(std::initializer_list<Value2> values) + { + checked_change_dim(values.size()); + std::copy(values.begin(), values.end(), begin()); + return *this; + } +#endif + + /// Constructor from std::vector; value_type must be identic + explicit dense_vector(const std::vector<value_type>& src) + : memory_base(src.size()) + { std::copy(src.begin(), src.end(), this->begin()); } + + /// Stride is always 1 + size_type stride() const { return 1 ; } + + /// i-th entry + reference operator()( size_type i ) + { + check_index(i); + return this->value_n( i ) ; + } + + /// i-th entry (constant) + const_reference operator()( size_type i ) const + { + check_index(i); + return this->value_n( i ) ; + } + + reference operator[]( size_type i ) { return (*this)( i ) ; } ///< i-th entry + const_reference operator[]( size_type i ) const { return (*this)( i ) ; } ///< i-th entry (constant) + + self operator[]( irange r ) { return sub_vector(*this, r.start(), r.finish()); } ///< sub-vector + const self operator[]( irange r ) const { return sub_vector(*this, r.start(), r.finish()); } ///< sub-vector + + void delay_assign() const {} + + // Compatibility with STL + const_pointer begin() const { return this->elements() ; } + const_pointer end() const { return this->elements() + this->used_memory(); } + pointer begin() { return this->elements() ; } + pointer end() { return this->elements() + this->used_memory(); } + bool empty() const { return this->used_memory() == 0; } ///< Whether it is empty + + + /// Address of first data entry; to be used with care. + value_type* address_data() { return begin(); } + const value_type* address_data() const { return begin(); } + + +#ifdef MTL_VECTOR_MOVE_EMULATION + /// Move assignment + self& operator=(self src) + { + // Self-copy would be an indication of an error + assert(this != &src); + + checked_change_dim(src.used_memory()); + memory_base::move_assignment(src); + return *this; + } +#else +// #if defined(_MSC_VER) && !defined(MTL_VECTOR_MOVE_EMULATION) + /// Copy assignment + self& operator=(const self& src) + { + if (this == &src) + return *this; + + checked_change_dim(src.used_memory()); + memory_base::operator=(src); + return *this; + } +#endif + +#ifdef MTL_WITH_MOVE + self& operator=(self&& src) + { + checked_change_dim(src.used_memory()); + memory_base::move_assignment(src); + return *this; + } +#endif + +#if 0 // def __PGI + using crtp_base::operator=; +#else + using assign_base::operator=; +#endif + + template <typename Value2> friend void fill(self&, const Value2&); + + /// swap two vectors + friend void swap(self& vector1, self& vector2) + { + swap(static_cast<memory_base&>(vector1), static_cast<memory_base&>(vector2)); + } + + void change_resource(size_type n) { this->realloc(n); } ///< Change resource, like \ref change_dim + void change_dim(size_type n) { this->realloc(n); } ///< Change dimension of vector + void checked_change_dim(size_type n) { check_dim(n); change_dim(n); } ///< Only change dim if it was empty before + + void crop() {} ///< Delete structural zeros, only dummy here for completeness + +} ; // dense_vector + + +/// Size of v +template <typename Value, typename Parameters> +inline typename dense_vector<Value, Parameters>::size_type +size(const dense_vector<Value, Parameters>& v) +{ return v.used_memory() ; } + + + +// ================ +// Free functions +// ================ + +/// Fill \p vector with \p value +template <typename Value, typename Parameters, typename Value2> +inline void fill(dense_vector<Value, Parameters>& vector, const Value2& value) +{ + std::fill(vector.begin(), vector.end(), value); +} + + +template <typename Value, typename Parameters> +typename dense_vector<Value, Parameters>::size_type +inline num_rows_aux(const dense_vector<Value, Parameters>& , tag::row_major) +{ + return 1; +} + +template <typename Value, typename Parameters> +typename dense_vector<Value, Parameters>::size_type +inline num_rows_aux(const dense_vector<Value, Parameters>& vector, tag::col_major) +{ + return vector.used_memory(); +} + +/// Number of rows: is size for column vectors and 1 for row vectors +template <typename Value, typename Parameters> +typename dense_vector<Value, Parameters>::size_type +inline num_rows(const dense_vector<Value, Parameters>& vector) +{ + return num_rows_aux(vector, typename Parameters::orientation()); +} + + +/// Number of columns: is size for row vectors and 1 for column vectors +template <typename Value, typename Parameters> +typename dense_vector<Value, Parameters>::size_type +inline num_cols(const dense_vector<Value, Parameters>& vector) +{ + return num_rows_aux(vector, typename mtl::traits::transposed_orientation<typename Parameters::orientation>::type()); +} + +/// Sub-vector function, more convenient with irange +template <typename Value, typename Parameters> +dense_vector<Value, Parameters> +inline sub_vector(dense_vector<Value, Parameters>& v, + typename dense_vector<Value, Parameters>::size_type start, + typename dense_vector<Value, Parameters>::size_type finish) +{ + typedef dense_vector<Value, Parameters> Vector; + + MTL_DEBUG_THROW_IF( is_negative(start) || is_negative(finish), index_out_of_range()); + irange r= intersection(irange(start, finish), irange(0, mtl::vector::size(v))); + return r.empty() ? Vector() : Vector(r.size(), &v[r.start()]); + +#if 0 + finish= min(finish, size(v)); + start= min(start, finish); // implies min(start, size(v)) + return start < finish ? Vector(finish - start, &v[start]) : Vector(); +#endif +} + +template <typename Value, typename Parameters> +const dense_vector<Value, Parameters> +inline sub_vector(const dense_vector<Value, Parameters>& v, + typename dense_vector<Value, Parameters>::size_type start, + typename dense_vector<Value, Parameters>::size_type finish) +{ + typedef dense_vector<Value, Parameters> Vector; + return sub_vector(const_cast<Vector&>(v), start, finish); +} + + +}} // namespace mtl::vector + +namespace mtl { + + // Enable cloning of dense vectors + template <typename Value, typename Parameters> + struct is_clonable< vector::dense_vector<Value, Parameters> > : boost::mpl::true_ {}; + +} // namespace mtl + +namespace mtl { namespace traits { + + +// ================ +// Range generators +// For cursors +// ================ + + template <typename Value, class Parameters> + struct range_generator<tag::all, mtl::vector::dense_vector<Value, Parameters> > + : public detail::dense_element_range_generator<mtl::vector::dense_vector<Value, Parameters>, + dense_el_cursor<Value>, complexity_classes::linear_cached> + {}; + + template <typename Value, class Parameters> + struct range_generator<tag::nz, mtl::vector::dense_vector<Value, Parameters> > + : public range_generator<tag::all, mtl::vector::dense_vector<Value, Parameters> > + {}; + + template <typename Value, class Parameters> + struct range_generator<tag::iter::all, mtl::vector::dense_vector<Value, Parameters> > + { + typedef mtl::vector::dense_vector<Value, Parameters> collection_t; + typedef complexity_classes::linear_cached complexity; + static int const level = 1; + typedef typename collection_t::pointer type; + + type begin(collection_t& collection) + { + return collection.begin(); + } + type end(collection_t& collection) + { + return collection.end(); + } + }; + + template <typename Value, class Parameters> + struct range_generator<tag::iter::nz, mtl::vector::dense_vector<Value, Parameters> > + : public range_generator<tag::iter::all, mtl::vector::dense_vector<Value, Parameters> > + {}; + + template <typename Value, class Parameters> + struct range_generator<tag::const_iter::all, mtl::vector::dense_vector<Value, Parameters> > + { + typedef mtl::vector::dense_vector<Value, Parameters> collection_t; + typedef complexity_classes::linear_cached complexity; + static int const level = 1; + typedef typename collection_t::const_pointer type; + + type begin(const collection_t& collection) const + { + return collection.begin(); + } + type end(const collection_t& collection) const + { + return collection.end(); + } + }; + + template <typename Value, class Parameters> + struct range_generator<tag::const_iter::nz, mtl::vector::dense_vector<Value, Parameters> > + : public range_generator<tag::const_iter::all, mtl::vector::dense_vector<Value, Parameters> > + {}; + + +}} // namespace mtl::traits + +namespace mtl { + using vector::dense_vector; +} + +#endif // MTL_DENSE_VECTOR_INCLUDE + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/dimension.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/dimension.hpp new file mode 100644 index 0000000000000000000000000000000000000000..e0674858eb9e516e33fbecc59da7671aa7ece8a1 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/dimension.hpp @@ -0,0 +1,54 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_DIMENSION_INCLUDE +#define MTL_DIMENSION_INCLUDE + +namespace mtl { namespace vector { + +// Compile time version +namespace fixed { + + /// Compile-time dimension + template <std::size_t Size> + struct dimension + { + typedef std::size_t size_type; + static size_type const value= Size; + friend inline size_type size(const dimension&) { return dimension::value; } ///< Size + + /// To check whether it is static + static bool const is_static= true; + }; +} + +namespace non_fixed { + + /// Run-time dimension + struct dimension + { + typedef std::size_t size_type; + + static size_type const value= 0; // for compatibility + dimension(size_type v= 0) : my_size(v) {} /// Constructor with default zero + friend inline size_type size(const dimension& d) { return d.my_size; } ///< Size + + /// To check whether it is static + static bool const is_static= false; + protected: + size_type my_size; + }; +} + +}} // namespace mtl::vector + +#endif // MTL_DIMENSION_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/dot_index_evaluator.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/dot_index_evaluator.hpp new file mode 100644 index 0000000000000000000000000000000000000000..010045d75c63c8ff95bff5f08ebafc2e172f791e --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/dot_index_evaluator.hpp @@ -0,0 +1,56 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_VECTOR_DOT_INDEX_EVALUATOR_INCLUDE +#define MTL_VECTOR_DOT_INDEX_EVALUATOR_INCLUDE + +namespace mtl { namespace vector { + +/// Class for index-wise computation of dot product +template <typename Scalar, typename Vector1, typename Vector2, typename ConjOpt, typename Assign> +struct dot_index_evaluator +{ + dot_index_evaluator(Scalar& scalar, const Vector1& v1, const Vector2& v2) + : scalar(scalar), v1(v1), v2(v2) + { + tmp[0]= tmp[1]= tmp[2]= tmp[3]= Scalar(0); + } + + ~dot_index_evaluator() + { + Scalar s(tmp[0] + tmp[1] + tmp[2] + tmp[3]); + Assign::apply(scalar, s); + } + + void operator() (std::size_t i) { tmp[0]+= ConjOpt()(v1[i]) * v2[i]; } + void operator[] (std::size_t i) { (*this)(i); } + + template <unsigned Offset> + void at(std::size_t i) + { tmp[Offset]+= ConjOpt()(v1[i+Offset]) * v2[i+Offset]; } + + Scalar& scalar; + Scalar tmp[4]; + const Vector1& v1; + const Vector2& v2; +}; + +template <typename Scalar, typename Vector1, typename Vector2, typename ConjOpt, typename Assign> +inline std::size_t size(const dot_index_evaluator<Scalar, Vector1, Vector2, ConjOpt, Assign>& eval) +{ + return size(eval.v1); +} + + +}} // namespace mtl::vector + +#endif // MTL_VECTOR_DOT_INDEX_EVALUATOR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/extracter.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/extracter.hpp new file mode 100644 index 0000000000000000000000000000000000000000..6b89160c784439a45599b712f2fa2d1b1874809d --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/extracter.hpp @@ -0,0 +1,78 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.short.txt in the distribution. + +#ifndef MTL_VECTOR_EXTRACTER_INCLUDE +#define MTL_VECTOR_EXTRACTER_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> + +namespace mtl { namespace vector { + +template< typename Vector > +struct indexbuffer +{ + typedef typename Collection<Vector>::value_type value_type; + typedef typename Collection<Vector>::size_type size_type; + typedef indexbuffer self; + + indexbuffer(const Vector& v) : vec(v) {} + + inline self& operator()(const size_type p, value_type& dest) + { + dest = vec[p]; + return *this; + } + + inline void update() {} + private: + const Vector& vec; +}; + + +template< typename Vector > +class extracter +{ + public: + typedef typename Collection<Vector>::value_type value_type; + typedef typename Collection<Vector>::size_type size_type; + typedef indexbuffer< Vector > buffer_type; + + extracter(const Vector& vec): + destroyBuffer(true), buffer(new buffer_type(vec)) + {} + extracter(buffer_type& buf): + destroyBuffer(false), buffer(&buf) + {} + + struct bracket_proxy + { + const size_type p; + buffer_type& buffer; + bracket_proxy(const size_type p, buffer_type& b) : p(p), buffer(b) {} + + inline buffer_type& operator>>(value_type& dest) { return buffer(p, dest); } + }; + + inline bracket_proxy operator[](const size_type p) { return bracket_proxy(p, *buffer); } + + ~extracter() { + buffer->update(); + if(destroyBuffer) + delete buffer; + } + private: + const bool destroyBuffer; + buffer_type* buffer; +}; + +}} //namespace mtl::vector +#endif diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/incrementer.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/incrementer.hpp new file mode 100644 index 0000000000000000000000000000000000000000..ec807cca32668fc5d3edd6a59395e3a8050e3b06 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/incrementer.hpp @@ -0,0 +1,34 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_VECTOR_INCREMENTER_INCLUDE +#define MTL_VECTOR_INCREMENTER_INCLUDE + +namespace mtl { namespace vector { + +struct incrementer_base {}; + +/// CRTP class to increment a vector with the result of the derived class +template <typename Derived> +struct incrementer : incrementer_base +{ + /// Function that must be defined in \p Derived where it is called by static down-cast + template <typename Vector> + void increment_it(Vector& tgt) const + { + static_cast<const Derived&>(*this).increment_it(tgt); + } +}; + +}} // namespace mtl::vector + +#endif // MTL_VECTOR_INCREMENTER_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/inserter.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/inserter.hpp new file mode 100644 index 0000000000000000000000000000000000000000..a060ad8e35bacd52621df63ca9263112b1ec3222 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/inserter.hpp @@ -0,0 +1,91 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_VECTOR_INSERTER_INCLUDE +#define MTL_VECTOR_INSERTER_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/operation/update.hpp> + +namespace mtl { namespace vector { + +/// Class for generic insertion into vectors +/** \param Vector is the type of the vector in which will be inserted + \param Updater is a functor that determine how existed entries are updated + \b Remark: For regular vectors, one can set the entries directly without inserter. + An inserter is needed when vectors are distributed. + Reversely, setting vectors with an inserter works for both distributed and non-distributed + vector types and is therefore more generic. + To understand how to use inserters it is best to read the page \ref matrix_insertion. + This applies all to vector insertion except that only one index is used. +**/ +template <typename Vector, typename Updater> +struct inserter +{ + typedef inserter self; + typedef typename Collection<Vector>::size_type size_type; + typedef typename Collection<Vector>::value_type value_type; + typedef update_proxy<self, size_type> proxy_type; + + explicit inserter(Vector& vector) : vector(vector) {} + + proxy_type operator() (size_type n) { return proxy_type(*this, n); } + proxy_type operator[] (size_type n) { return proxy_type(*this, n); } + + template <typename Modifier> + void modify(size_type n, value_type value) { Modifier()(vector[n], value); } + + void update(size_type n, value_type value) { modify<Updater>(n, value); } + +protected: + Vector& vector; +}; + + +// Not to confuse with the equally-named class in operations (which should be in matrix anyway) +template <typename Inserter, typename Size> +struct update_proxy +{ + typedef update_proxy self; + typedef typename Inserter::value_type value_type; + + explicit update_proxy(Inserter& ins, Size n) : ins(ins), n(n) {} + + template <typename Value> + self& operator<< (Value const& val) + { + ins.update(n, val); + return *this; + } + + template <typename Value> + self& operator= (Value const& val) + { + ins.template modify<update_store<value_type> > (n, val); + return *this; + } + + template <typename Value> + self& operator+= (Value const& val) + { + ins.template modify<update_plus<value_type> > (n, val); + return *this; + } + + private: + Inserter& ins; + Size n; +}; + +}} // namespace mtl::vector + +#endif // MTL_VECTOR_INSERTER_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/lazy_reduction.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/lazy_reduction.hpp new file mode 100644 index 0000000000000000000000000000000000000000..f258b74500fdf282832dae53bd4b5e5ae15891cf --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/lazy_reduction.hpp @@ -0,0 +1,34 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_VECTOR_LAZY_REDUCTION_INCLUDE +#define MTL_VECTOR_LAZY_REDUCTION_INCLUDE + +namespace mtl { namespace vector { + +/// Helper class for lazy evaluation +template <typename Vector, typename Functor> +struct lazy_reduction +{ + lazy_reduction(const Vector& v) : v(v) {} + const Vector& v; +}; + +template <typename Vector, typename Functor> +inline std::size_t size(const lazy_reduction<Vector, Functor>& lazy) +{ + return size(lazy.v); +} + +}} // namespace mtl::vector + +#endif // MTL_VECTOR_LAZY_REDUCTION_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/map_view.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/map_view.hpp new file mode 100644 index 0000000000000000000000000000000000000000..31269c410ec9e10b7ccbcd12bacf42555e8cce50 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/map_view.hpp @@ -0,0 +1,340 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_VECTOR_MAP_VIEW_INCLUDE +#define MTL_VECTOR_MAP_VIEW_INCLUDE + +#include <utility> +#include <boost/shared_ptr.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/utility/property_map.hpp> +#include <boost/numeric/mtl/utility/copy_expression_const_ref_container.hpp> +#include <boost/numeric/mtl/operation/sfunctor.hpp> +#include <boost/numeric/mtl/operation/tfunctor.hpp> +#include <boost/numeric/mtl/operation/conj.hpp> +#include <boost/numeric/mtl/operation/real.hpp> +#include <boost/numeric/mtl/operation/imag.hpp> +#include <boost/numeric/mtl/vector/vec_expr.hpp> + + +namespace mtl { namespace vector { namespace detail { + // Forward declaration for friend declaration + template <typename, typename> struct map_value; +}}} + +namespace mtl { namespace vector { + +template <typename Functor, typename Vector> +struct map_view + : public vec_expr< map_view<Functor, Vector> > +{ + typedef map_view self; + typedef vec_expr< self > expr_base; + typedef Vector other; + + typedef typename Functor::result_type value_type; + typedef typename Functor::result_type const_reference; + typedef typename Collection<Vector>::size_type size_type; + + map_view (const Functor& functor, const other& ref) + : expr_base(*this), functor(functor), ref(ref) + { + ref.delay_assign(); + } + + map_view (const Functor& functor, boost::shared_ptr<Vector> p) + : expr_base(*this), functor(functor), my_copy(p), ref(*p) + { + ref.delay_assign(); + } + +#ifdef MTL_WITH_CPP11_MOVE + map_view (self&& that) : functor(that.functor), my_copy(std::move(that.my_copy)), ref(that.ref) {} + map_view (const self& that) : functor(that.functor), ref(that.ref) { assert(that.my_copy.use_count() == 0); } +#endif + + friend size_type inline num_rows(const self& v) { return num_rows(v.ref); } + friend size_type inline num_cols(const self& v) { return num_cols(v.ref); } + + size_type stride() const { return ref.stride(); } + const_reference operator() (size_type i) const { return functor(ref(i)); } + const_reference operator[] (size_type i) const { return functor(ref[i]); } + void delay_assign() const {} + + template <typename, typename> friend struct detail::map_value; + + protected: + boost::shared_ptr<Vector> my_copy; + public: + Functor functor; + // ref is a const& if Vector is a true vector and a copy if it is an expression + typename mtl::traits::copy_expression_const_ref_container<Vector>::type ref; +}; + + +template <typename Functor, typename Vector> +inline std::size_t size(const map_view<Functor, Vector>& v) +{ return mtl::vector::size(v.ref); } + +// ================ +// Free functions +// ================ + + + namespace detail { + + template <typename Functor, typename Vector> + struct map_value + { + typedef typename Vector::key_type key_type; + typedef typename vector::map_view<Functor, Vector>::value_type value_type; + + map_value(vector::map_view<Functor, Vector> const& map_vector) + : map_vector(map_vector), its_value(map_vector.ref) + {} + + value_type operator() (key_type const& key) const + { + return map_vector.functor(its_value(key)); + } + + protected: + vector::map_view<Functor, Vector> const& map_vector; + typename ::mtl::traits::const_value<Vector>::type its_value; + }; + + } // detail + +}} // namespace mtl::vector + + + +namespace mtl { namespace traits { + + // ================ + // Property maps + // ================ + + template <typename Functor, typename Vector> + struct index<vector::map_view<Functor, Vector> > + : public index<Vector> + {}; + + template <typename Functor, typename Vector> + struct const_value<vector::map_view<Functor, Vector> > + { + typedef vector::detail::map_value<Functor, Vector> type; + }; + + + // ================ + // Range generators + // ================ + + // Use range_generator of original vector + template <typename Tag, typename Functor, typename Vector> + struct range_generator<Tag, vector::map_view<Functor, Vector> > + : public range_generator<Tag, Vector> + {}; + +}} // mtl::traits + +namespace mtl { namespace vector { + +template <typename Scaling, typename Vector> +struct scaled_view + : public map_view<tfunctor::scale<Scaling, typename Vector::value_type>, Vector> +{ + typedef tfunctor::scale<Scaling, typename Vector::value_type> functor_type; + typedef map_view<functor_type, Vector> base; + typedef scaled_view self; + + explicit scaled_view(const Scaling& scaling, const Vector& vector) + : base(functor_type(scaling), vector) + {} + + explicit scaled_view(const Scaling& scaling, boost::shared_ptr<Vector> p) + : base(functor_type(scaling), p) + {} + +#ifdef MTL_WITH_CPP11_MOVE + scaled_view (self&& that) : base(that) {} + scaled_view (const self& that) : base(that) {} +#endif +}; + +// added by Hui Li +template <typename Vector, typename RScaling> +struct rscaled_view + : public map_view<tfunctor::rscale<typename Vector::value_type, RScaling>, Vector> +{ + typedef tfunctor::rscale<typename Vector::value_type, RScaling> functor_type; + typedef map_view<functor_type, Vector> base; + typedef rscaled_view self; + + explicit rscaled_view(const Vector& vector, const RScaling& rscaling) + : base(functor_type(rscaling), vector) + {} + + explicit rscaled_view(boost::shared_ptr<Vector> p, const RScaling& rscaling) + : base(functor_type(rscaling), p) + {} + +#ifdef MTL_WITH_CPP11_MOVE + rscaled_view (self&& that) : base(that) {} + rscaled_view (const self& that) : base(that) {} +#endif +}; + + +// added by Hui Li +template <typename Vector, typename Divisor> +struct divide_by_view + : public map_view<tfunctor::divide_by<typename Vector::value_type, Divisor>, Vector> +{ + typedef tfunctor::divide_by<typename Vector::value_type, Divisor> functor_type; + typedef map_view<functor_type, Vector> base; + typedef divide_by_view self; + + explicit divide_by_view(const Vector& vector, const Divisor& div) + : base(functor_type(div), vector) + {} + + explicit divide_by_view(boost::shared_ptr<Vector> p, const Divisor& div) + : base(functor_type(div), p) + {} + +#ifdef MTL_WITH_CPP11_MOVE + divide_by_view (self&& that) : base(that) {} + divide_by_view (const self& that) : base(that) {} +#endif +}; + + +template <typename Vector> +struct conj_view + : public map_view<mtl::sfunctor::conj<typename Vector::value_type>, Vector> +{ + typedef mtl::sfunctor::conj<typename Vector::value_type> functor_type; + typedef map_view<functor_type, Vector> base; + typedef conj_view self; + + explicit conj_view(const Vector& vector) + : base(functor_type(), vector) + {} + + explicit conj_view(boost::shared_ptr<Vector> p) + : base(functor_type(), p) + {} + +#ifdef MTL_WITH_CPP11_MOVE + conj_view (self&& that) : base(that) {} + conj_view (const self& that) : base(that) {} +#endif +}; + +template <typename Vector> +struct real_view + : public map_view<mtl::sfunctor::real<typename Vector::value_type>, Vector> +{ + typedef mtl::sfunctor::real<typename Vector::value_type> functor_type; + typedef map_view<functor_type, Vector> base; + typedef real_view self; + + explicit real_view(const Vector& vector) + : base(functor_type(), vector) + {} + + explicit real_view(boost::shared_ptr<Vector> p) + : base(functor_type(), p) + {} + +#ifdef MTL_WITH_CPP11_MOVE + real_view (self&& that) : base(that) {} + real_view (const self& that) : base(that) {} +#endif +}; + +template <typename Vector> +struct imag_view + : public map_view<mtl::sfunctor::imag<typename Vector::value_type>, Vector> +{ + typedef mtl::sfunctor::imag<typename Vector::value_type> functor_type; + typedef map_view<functor_type, Vector> base; + typedef imag_view self; + + explicit imag_view(const Vector& vector) + : base(functor_type(), vector) + {} + + explicit imag_view(boost::shared_ptr<Vector> p) + : base(functor_type(), p) + {} + +#ifdef MTL_WITH_CPP11_MOVE + imag_view (self&& that) : base(that) {} + imag_view (const self& that) : base(that) {} +#endif +}; + +template <typename Vector> +struct negate_view + : public map_view<mtl::sfunctor::negate<typename Vector::value_type>, Vector> +{ + typedef mtl::sfunctor::negate<typename Vector::value_type> functor_type; + typedef map_view<functor_type, Vector> base; + typedef negate_view self; + + explicit negate_view(const Vector& vector) + : base(functor_type(), vector) + {} + + explicit negate_view(boost::shared_ptr<Vector> p) + : base(functor_type(), p) + {} + +#ifdef MTL_WITH_CPP11_MOVE + negate_view (self&& that) : base(that) {} + negate_view (const self& that) : base(that) {} +#endif +}; + + +}} // namespace mtl::vector + +namespace mtl { namespace sfunctor { + + + template <typename Vector> + struct conj_aux<Vector, tag::vector> + { + typedef mtl::vector::conj_view<Vector> result_type; + + static inline result_type apply(const Vector& vector) + { + return result_type(vector); + } + + result_type operator() (const Vector& vector) const + { + return apply(vector); + } + }; + +}} + + + + +#endif // MTL_VECTOR_MAP_VIEW_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/mapped_inserter.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/mapped_inserter.hpp new file mode 100644 index 0000000000000000000000000000000000000000..b399d681aaa64e171d5bb3258feab1e2996871db --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/mapped_inserter.hpp @@ -0,0 +1,55 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_VECTOR_MAPPED_INSERTER_INCLUDE +#define MTL_VECTOR_MAPPED_INSERTER_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/operation/update.hpp> + +namespace mtl { +namespace vector { + +/// Inserter with shifted indices +/** The main work is performed by the underlying base inserter whose type is given as template + argument. **/ +template <typename BaseInserter, typename Mapper > +class mapped_inserter +{ + public: + typedef mapped_inserter self; + typedef typename BaseInserter::size_type size_type; + typedef update_proxy<BaseInserter, size_type> proxy_type; + + /// Constructor with matrix \p A, the mapping, and the slot size + mapped_inserter(BaseInserter& A, Mapper& map) + : ins(A), map(map) {} + + public: + /// To be used in ins(r, c) << value; + proxy_type operator[] (size_type row) + { return proxy_type(ins, map.row(row)); } + + /// To be used in ins(r, c) << value; + proxy_type operator() (size_type row) + { return proxy_type(ins, map.row(row)); } + + // update, modify and operator<< are used from BaseInserter + +private: + BaseInserter ins; + Mapper& map; +}; + +} // namespace vector +} // namespace mtl +#endif //MTL_VECTOR_MAPPED_INSERTER_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/mat_cvec_multiplier.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/mat_cvec_multiplier.hpp new file mode 100644 index 0000000000000000000000000000000000000000..6f27724782b8d1c3507f222ddda686bc5596f313 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/mat_cvec_multiplier.hpp @@ -0,0 +1,102 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_VECTOR_MAT_CVEC_MULTIPLIER_INCLUDE +#define MTL_VECTOR_MAT_CVEC_MULTIPLIER_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/concept/std_concept.hpp> + +#include <boost/numeric/mtl/vector/vec_expr.hpp> +#include <boost/numeric/mtl/vector/assigner.hpp> +#include <boost/numeric/mtl/vector/decrementer.hpp> +#include <boost/numeric/mtl/vector/incrementer.hpp> +#include <boost/numeric/mtl/operation/assign_mode.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace mtl { namespace vector { + +/// Helper class for delaying matrix vector multiplication, e.g. for matrix-free operators +template <typename Matrix, typename VectorIn> +struct mat_cvec_multiplier + : assigner<mat_cvec_multiplier<Matrix, VectorIn> >, + incrementer<mat_cvec_multiplier<Matrix, VectorIn> >, + decrementer<mat_cvec_multiplier<Matrix, VectorIn> >, + vec_expr<mat_cvec_multiplier<Matrix, VectorIn> > +{ + typedef typename Multiplicable<typename Collection<Matrix>::value_type, + typename Collection<VectorIn>::value_type>::result_type value_type; + + + /// Construct with matrix \p A and vector \p v + mat_cvec_multiplier(const Matrix& A, const VectorIn& v) : A(A), v(v) {} + + /// Assing the product to vector \p w, if possible directly within w's memory without copying + template <typename VectorOut> + void assign_to(VectorOut& w) const + { + vampir_trace<3068> tracer; + A.mult(v, w, mtl::assign::assign_sum()); + } + + /// Increment vector \p w with the product, if possible directly within w's memory without copying + template <typename VectorOut> + void increment_it(VectorOut& w) const + { + vampir_trace<3068> tracer; + A.mult(v, w, mtl::assign::plus_sum()); + } + + /// Decrement vector \p w with the product, if possible directly within w's memory without copying + template <typename VectorOut> + void decrement_it(VectorOut& w) const + { + vampir_trace<3068> tracer; + A.mult(v, w, mtl::assign::minus_sum()); + } + +#if 1 + /// Multiply vector \p w with the product, if possible directly within w's memory without copying + template <typename VectorOut> + void multiply_it(VectorOut& w) const + { + vampir_trace<3068> tracer; + A.mult(v, w, mtl::assign::times_sum()); + } + + /// Divide vector \p w with the product, if possible directly within w's memory without copying + template <typename VectorOut> + void divide_it(VectorOut& w) const + { + vampir_trace<3068> tracer; + A.mult(v, w, mtl::assign::divide_sum()); + } +#endif + void delay_assign() const { } + + const Matrix& A; + const VectorIn& v; +}; + +template <typename Matrix, typename VectorIn> +inline std::size_t size(const mat_cvec_multiplier<Matrix, VectorIn>& m) +{ return num_rows(m.A); } + +template <typename Matrix, typename VectorIn> +inline std::size_t num_rows(const mat_cvec_multiplier<Matrix, VectorIn>& m) { return num_rows(m.A); } + +template <typename Matrix, typename VectorIn> +inline std::size_t num_cols(const mat_cvec_multiplier<Matrix, VectorIn>&) { return 1; } + +}} // namespace mtl::vector + +#endif // MTL_VECTOR_MAT_CVEC_MULTIPLIER_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/parameter.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/parameter.hpp new file mode 100644 index 0000000000000000000000000000000000000000..3f20d87e0c69e9b4df6f8d7bc54ecd703566bd34 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/parameter.hpp @@ -0,0 +1,46 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_VECTOR_PARAMETERS_INCLUDE +#define MTL_VECTOR_PARAMETERS_INCLUDE + +#include <boost/mpl/bool.hpp> +#include <boost/numeric/mtl/utility/static_assert.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/vector/dimension.hpp> +#include <boost/numeric/mtl/utility/is_static.hpp> + +namespace mtl { namespace vector { + +/// This type exist only for bundling template parameters (to reduce typing) +/** OnStack = true can only be used with fixed::dimension. + \sa \ref tuning_fsize + \sa \ref tuning_sizetype **/ +template <typename Orientation= col_major, + typename Dimension= non_fixed::dimension, + bool OnStack= mtl::traits::is_static<Dimension>::value, + typename SizeType= std::size_t> +struct parameters +{ + typedef Orientation orientation; + typedef Dimension dimension; + static const bool on_stack= OnStack; + typedef SizeType size_type; + + // Vector dimension must be known at compile time to be on the stack + MTL_STATIC_ASSERT(( !on_stack || dimension::is_static ), "Types to be stored on stack must provide static size."); +}; + + +}} // namespace mtl::vector + +#endif // MTL_VECTOR_PARAMETERS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/reduction.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/reduction.hpp new file mode 100644 index 0000000000000000000000000000000000000000..4393d742e671a524e205986ed960321217a04dc7 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/reduction.hpp @@ -0,0 +1,182 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_REDUCTION_INCLUDE +#define MTL_REDUCTION_INCLUDE + +#include <boost/mpl/bool.hpp> +#include <boost/numeric/meta_math/loop1.hpp> +#include <boost/numeric/mtl/utility/omp_size_type.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> +#include <boost/numeric/mtl/utility/static_assert.hpp> + +namespace mtl { namespace vector { + + + namespace impl { + + template <unsigned long Index0, unsigned long Max0, typename Functor> + struct reduction + { + typedef reduction<Index0+1, Max0, Functor> next; + + template <typename Value> + static inline void init(Value& tmp00, Value& tmp01, Value& tmp02, Value& tmp03, Value& tmp04, + Value& tmp05, Value& tmp06, Value& tmp07) + { + Functor::init(tmp00); + next::init(tmp01, tmp02, tmp03, tmp04, tmp05, tmp06, tmp07, tmp00); + } + + template <typename Value, typename Vector, typename Size> + static inline void update(Value& tmp00, Value& tmp01, Value& tmp02, Value& tmp03, Value& tmp04, + Value& tmp05, Value& tmp06, Value& tmp07, const Vector& v, Size i) + { + Functor::update(tmp00, v[ i + Index0-1 ]); + next::update(tmp01, tmp02, tmp03, tmp04, tmp05, tmp06, tmp07, tmp00, v, i); + } + + template <typename Value> + static inline void finish(Value& tmp00, Value& tmp01, Value& tmp02, Value& tmp03, Value& tmp04, + Value& tmp05, Value& tmp06, Value& tmp07) + { + next::finish(tmp01, tmp02, tmp03, tmp04, tmp05, tmp06, tmp07, tmp00); + Functor::finish(tmp00, tmp01); + } + }; + + template <unsigned long Max0, typename Functor> + struct reduction<Max0, Max0, Functor> + { + template <typename Value> + static inline void init(Value& tmp00, Value&, Value&, Value&, Value&, Value&, Value&, Value&) + { + Functor::init(tmp00); + } + + template <typename Value, typename Vector, typename Size> + static inline void update(Value& tmp00, Value&, Value&, Value&, Value&, Value&, Value&, Value&, + const Vector& v, Size i) + { + Functor::update(tmp00, v[ i + Max0-1 ]); + } + + template <typename Value> + static inline void finish(Value&, Value&, Value&, Value&, Value&, Value&, Value&, Value&) {} + }; + + } // namespace impl + + +// Will need distinction between dense and sparse in the future +template <unsigned long Unroll, typename Functor, typename Result> +struct reduction +{ + template <typename Vector> + Result static inline apply(const Vector& v) + { + vampir_trace<2009> tracer; + return apply(v, typename mtl::traits::is_sparse<Vector>()); + } + + private: + template <typename Vector> + Result static inline apply(const Vector& v, boost::mpl::true_) + { + Result tmp00; + Functor::init(tmp00); + + for (std::size_t i= 0, n= v.nnz(); i < n; i++) + Functor::update(tmp00, v.value(i)); + // std::cout << "i == " << i << " + +#if 0 + typename mtl::traits::const_value<Vector>::type value(v); + typedef typename mtl::traits::range_generator<tag::nz, Vector>::type cursor_type; + + for (cursor_type cursor = begin<tag::nz>(v), cend = end<tag::nz>(v); cursor != cend; ++cursor) + Functor::update(tmp00, value(*cursor)); +#endif + return tmp00; + } + +# ifdef MTL_WITH_OPENMP + + template <typename Vector> + Result static inline apply(const Vector& v, boost::mpl::false_) + { + MTL_STATIC_ASSERT((Unroll >= 1), "Unroll size must be at least 1."); + MTL_STATIC_ASSERT((Unroll <= 8), "Maximal unrolling is 8."); // Might be relaxed in future versions + + Result result; + Functor::init(result); + + typedef typename mtl::traits::omp_size_type<typename Collection<Vector>::size_type>::type size_type; + const size_type i_max= mtl::vector::size(v), i_block= Unroll * (i_max / Unroll); + + #pragma omp parallel + { + vampir_trace<8002> tracer; + Result tmp00, tmp01, tmp02, tmp03, tmp04, tmp05, tmp06, tmp07; + impl::reduction<1, Unroll, Functor>::init(tmp00, tmp01, tmp02, tmp03, tmp04, tmp05, tmp06, tmp07); + + #pragma omp for + for (size_type i= 0; i < i_block; i+= Unroll) + impl::reduction<1, Unroll, Functor>::update(tmp00, tmp01, tmp02, tmp03, + tmp04, tmp05, tmp06, tmp07, v, i); + + impl::reduction<1, Unroll, Functor>::finish(tmp00, tmp01, tmp02, tmp03, tmp04, tmp05, tmp06, tmp07); + + #pragma omp critical + Functor::finish(result, tmp00); + } + + for (size_type i= i_block; i < i_max; i++) + Functor::update(result, v[i]); + + return result; + } + +# else + + template <typename Vector> + Result static inline apply(const Vector& v, boost::mpl::false_) + { + MTL_STATIC_ASSERT((Unroll >= 1), "Unroll size must be at least 1."); + MTL_STATIC_ASSERT((Unroll <= 8), "Maximal unrolling is 8."); // Might be relaxed in future versions + + Result tmp00, tmp01, tmp02, tmp03, tmp04, tmp05, tmp06, tmp07; + impl::reduction<1, Unroll, Functor>::init(tmp00, tmp01, tmp02, tmp03, tmp04, tmp05, tmp06, tmp07); + + typedef typename Collection<Vector>::size_type size_type; + const size_type i_max= mtl::vector::size(v), i_block= Unroll * (i_max / Unroll); + for (size_type i= 0; i < i_block; i+= Unroll) + impl::reduction<1, Unroll, Functor>::update(tmp00, tmp01, tmp02, tmp03, + tmp04, tmp05, tmp06, tmp07, v, i); + for (size_type i= i_block; i < i_max; i++) + Functor::update(tmp00, v[i]); + + impl::reduction<1, Unroll, Functor>::finish(tmp00, tmp01, tmp02, tmp03, tmp04, tmp05, tmp06, tmp07); + return tmp00; + } + +# endif + + +}; + +}} // namespace mtl + +#endif // MTL_REDUCTION_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/reduction_functors.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/reduction_functors.hpp new file mode 100644 index 0000000000000000000000000000000000000000..c4f3d09502d2fedd820a6e260edaf7893ceb2b6c --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/reduction_functors.hpp @@ -0,0 +1,244 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_REDUCTION_FUNCTORS_INCLUDE +#define MTL_REDUCTION_FUNCTORS_INCLUDE + +#include <cmath> +#include <boost/numeric/linear_algebra/identity.hpp> +#include <boost/numeric/mtl/operation/squared_abs.hpp> + +namespace mtl { namespace vector { + +struct one_norm_functor +{ + template <typename Value> + static inline void init(Value& value) + { + using math::zero; + value= zero(value); + } + + template <typename Value, typename Element> + static inline void update(Value& value, const Element& x) + { + using std::abs; + value+= abs(x); + } + + template <typename Value> + static inline void finish(Value& value, const Value& value2) + { + value+= value2; + } + + template <typename Value> + static inline Value post_reduction(const Value& value) + { + return value; + } +}; + + +// sub-optimal if abs is not needed +struct two_norm_functor +{ + template <typename Value> + static inline void init(Value& value) + { + using math::zero; + value= zero(value); + } + + template <typename Value, typename Element> + static inline void update(Value& value, const Element& x) + { + using mtl::squared_abs; + value+= squared_abs(x); + } + + template <typename Value> + static inline void finish(Value& value, const Value& value2) + { + value+= value2; + } + + // After reduction compute square root + template <typename Value> + static inline Value post_reduction(const Value& value) + { + using std::sqrt; + return sqrt(value); + } +}; + +// same as two-norm without the root at the end +struct unary_dot_functor + : two_norm_functor +{ + template <typename Value> + static inline Value post_reduction(const Value& value) + { + return value; + } +}; + +struct infinity_norm_functor +{ + template <typename Value> + static inline void init(Value& value) + { + using math::zero; + value= zero(value); + } + + template <typename Value, typename Element> + static inline void update(Value& value, const Element& x) + { + using std::abs; using std::max; + value= max(value, Value(abs(x))); + } + + template <typename Value> + static inline void finish(Value& value, const Value& value2) + { + using std::abs; using std::max; + value= max(value, Value(abs(value2))); + } + + template <typename Value> + static inline Value post_reduction(const Value& value) + { + return value; + } +}; + + +struct sum_functor +{ + template <typename Value> + static inline void init(Value& value) + { + using math::zero; + value= zero(value); + } + + template <typename Value, typename Element> + static inline void update(Value& value, const Element& x) + { + value+= x; + } + + template <typename Value> + static inline void finish(Value& value, const Value& value2) + { + value+= value2; + } + + template <typename Value> + static inline Value post_reduction(const Value& value) + { + return value; + } +}; + + +struct product_functor +{ + template <typename Value> + static inline void init(Value& value) + { + using math::one; + value= one(value); + } + + template <typename Value, typename Element> + static inline void update(Value& value, const Element& x) + { + value*= x; + } + + template <typename Value> + static inline void finish(Value& value, const Value& value2) + { + value*= value2; + } + + template <typename Value> + static inline Value post_reduction(const Value& value) + { + return value; + } +}; + + +struct max_functor +{ + template <typename Value> + static inline void init(Value& value) + { + using math::identity; + value= math::identity(math::max<Value>(), value); // ADL doesn't work here in g++ 4.4 + } + + template <typename Value, typename Element> + static inline void update(Value& value, const Element& x) + { + value= math::max<Value>()(value, x); + } + + template <typename Value> + static inline void finish(Value& value, const Value& value2) + { + value= math::max<Value>()(value, value2); + } + + template <typename Value> + static inline Value post_reduction(const Value& value) + { + return value; + } +}; + + +struct min_functor +{ + template <typename Value> + static inline void init(Value& value) + { + using math::identity; + value= math::identity(math::min<Value>(), value); // ADL doesn't work here in g++ 4.4 + } + + template <typename Value, typename Element> + static inline void update(Value& value, const Element& x) + { + value= math::min<Value>()(value, x); + } + + template <typename Value> + static inline void finish(Value& value, const Value& value2) + { + value= math::min<Value>()(value, value2); + } + + template <typename Value> + static inline Value post_reduction(const Value& value) + { + return value; + } +}; + + +}} // namespace mtl::vector + +#endif // MTL_REDUCTION_FUNCTORS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/reduction_index_evaluator.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/reduction_index_evaluator.hpp new file mode 100644 index 0000000000000000000000000000000000000000..52508fe9b1392b4c0d70fa13e475c1dcf9af5f4c --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/reduction_index_evaluator.hpp @@ -0,0 +1,58 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_VECTOR_REDUCTION_INDEX_EVALUATOR_INCLUDE +#define MTL_VECTOR_REDUCTION_INDEX_EVALUATOR_INCLUDE + +namespace mtl { namespace vector { + +/// Class for index-wise vector reductions +template <typename Scalar, typename Vector, typename Functor, typename Assign> +struct reduction_index_evaluator +{ + reduction_index_evaluator(Scalar& scalar, const Vector& v) + : scalar(scalar), v(v) + { + Functor::init(tmp[0]); + tmp[1]= tmp[2]= tmp[3]= tmp[0]; + } + + ~reduction_index_evaluator() + { + Functor::finish(tmp[0], tmp[1]); + Functor::finish(tmp[2], tmp[3]); + Functor::finish(tmp[0], tmp[2]); + Assign::apply(scalar, Functor::post_reduction(tmp[0])); // compute sqrt or such if necessary + } + + template <unsigned Offset> + void at(std::size_t i) + { + Functor::update(tmp[Offset], v[i+Offset]); + } + + void operator[] (std::size_t i) { at<0>(i); } + void operator() (std::size_t i) { at<0>(i); } + + Scalar& scalar; + Scalar tmp[4]; + const Vector& v; +}; + +template <typename Scalar, typename Vector, typename Functor, typename Assign> +inline std::size_t size(const reduction_index_evaluator<Scalar, Vector, Functor, Assign>& eval) +{ return size(eval.v); } + + +}} // namespace mtl::vector + +#endif // MTL_VECTOR_REDUCTION_INDEX_EVALUATOR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/row_mat_cvec_index_evaluator.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/row_mat_cvec_index_evaluator.hpp new file mode 100644 index 0000000000000000000000000000000000000000..4ba018f1ff630aa8fd490da2ec5ea5b7fc09644c --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/row_mat_cvec_index_evaluator.hpp @@ -0,0 +1,78 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_ROW_MAT_CVEC_INDEX_EVALUATOR_INCLUDE +#define MTL_ROW_MAT_CVEC_INDEX_EVALUATOR_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/is_row_major.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/utility/static_assert.hpp> + +namespace mtl { namespace vector { + +/// ET class to evaluate the product of a row-major matrix and a column vector row by row +template <typename VectorOut, typename Matrix, typename VectorIn, typename Assign> +struct row_mat_cvec_index_evaluator +{ + MTL_STATIC_ASSERT((mtl::traits::is_row_major<Matrix>::value), "Only row-major matrices supported here."); + typedef typename mtl::Collection<VectorOut>::value_type value_type; + typedef typename mtl::Collection<Matrix>::size_type size_type; + + row_mat_cvec_index_evaluator(VectorOut& w, const Matrix& A, const VectorIn& v) : w(w), A(A), v(v) {} + + template <unsigned Offset> + void at(size_type i, boost::mpl::true_) + { + // value_type tmp(math::zero(w[i+Offset])); + value_type tmp(0); + const size_type cj0= A.ref_major()[i+Offset], cj1= A.ref_major()[i+Offset+1]; + for (size_type j= cj0; j != cj1; ++j) + tmp+= A.data[j] * v[A.ref_minor()[j]]; + Assign::first_update(w[i+Offset], tmp); + } + + template <unsigned Offset> + void at(size_type i, boost::mpl::false_) + { + value_type tmp(math::zero(w[i+Offset])); + for (size_type j= 0; j < num_cols(A); j++) + tmp+= A[i][j] * v[j]; + Assign::first_update(w[i+Offset], tmp); + } + + template <unsigned Offset> + void at(size_type i) + { + at<Offset>(i, typename mtl::traits::is_sparse<Matrix>::type()); + } + + void operator()(size_type i) { at<0>(i); } + void operator[](size_type i) { at<0>(i); } + + VectorOut& w; + const Matrix& A; + const VectorIn& v; +}; + +template <typename VectorOut, typename Matrix, typename VectorIn, typename Assign> +inline std::size_t size(const row_mat_cvec_index_evaluator<VectorOut, Matrix, VectorIn, Assign>& eval) +{ + return size(eval.w); +} + + +}} // namespace mtl::vector + +#endif // MTL_ROW_MAT_CVEC_INDEX_EVALUATOR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/rvec_mat_times_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/rvec_mat_times_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..f0d7db3c58b41b8bbac21a9b8cbf66227debb971 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/rvec_mat_times_expr.hpp @@ -0,0 +1,42 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_RVEC_MAT_TIMES_EXPR_INCLUDE +#define MTL_RVEC_MAT_TIMES_EXPR_INCLUDE + +#include <boost/numeric/mtl/operation/bin_op_expr.hpp> +#include <boost/numeric/mtl/mtl_fwd.hpp> + +namespace mtl { namespace vector { + +template <typename E1, typename E2> +struct rvec_mat_times_expr + : public bin_op_expr< E1, E2 >, + public mtl::vector::vec_expr< rvec_mat_times_expr<E1, E2> > +{ + typedef bin_op_expr< E1, E2 > base; + typedef rvec_mat_times_expr<E1, E2> self; + + typedef typename Multiplicable<typename Collection<E1>::value_type, + typename Collection<E2>::value_type>::result_type value_type; + typedef typename Collection<E2>::size_type size_type; + + rvec_mat_times_expr( E1 const& v, E2 const& A ) : base(v, A) {} +}; + +template <typename E1, typename E2> +std::size_t inline size(const rvec_mat_times_expr<E1, E2>& x) +{ return num_cols(x.first); } + +}} // namespace mtl::vector + +#endif // MTL_RVEC_MAT_TIMES_EXPR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/sparse_vector.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/sparse_vector.hpp new file mode 100644 index 0000000000000000000000000000000000000000..e181b947aee24f82df962a120fddb49d413aacbf --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/sparse_vector.hpp @@ -0,0 +1,169 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_VECTOR_SPARSE_VECTOR_INCLUDE +#define MTL_VECTOR_SPARSE_VECTOR_INCLUDE + +#include <iostream> +#include <vector> +#include <algorithm> + +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/is_row_major.hpp> +#include <boost/numeric/mtl/utility/zipped_sort.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace mtl { namespace vector { + +/// This is not (yet) a full numeric class!!! It is only a helper for factorization with very limited functionality. DO NOT USE in numeric code (yet)!!! +template <typename Value, typename Parameter= parameters<> > +class sparse_vector +{ + typedef Value value_type; + typedef std::vector<value_type> vv_type; + typedef typename Parameter::size_type size_type; + typedef std::vector<size_type> sv_type; + typedef typename Parameter::orientation orientation; + typedef sparse_vector self; + + void check(size_type MTL_DEBUG_ARG(j)) const + { MTL_DEBUG_THROW_IF(is_negative(j) || j > size_type(indices.size()), mtl::index_out_of_range()); } + + public: + sparse_vector(size_type n= 0) : n(n), on_indices(true) /*, longest(0) */ {} + + // ~sparse_vector() { std::cout << "longest vector was " << longest << '\n'; } + + std::size_t nnz() const { assert(indices.size() == data.size()); return indices.size(); } + + bool exists(size_type i) const + { return find(indices.begin(), indices.end(), i) != indices.end(); } + + value_type operator[](size_type i) const + { + typename sv_type::iterator it= find(indices.begin(), indices.end(), i); + // size_type j= distance(indices.begin(), it); + return it != indices.end() ? data[distance(indices.begin(), it)] : value_type(0); + } + + void insert(size_type i, const value_type& v) + { + // vampir_trace<9901> tracer; + typename sv_type::iterator it= std::lower_bound(indices.begin(), indices.end(), i); + if (it == indices.end()) { + // std::cout << "Insert entry " << i << " at the end\n"; + indices.push_back(i); + data.push_back(v); + return; + } + + // std::cout << "Insert entry " << i << " at position " << distance(indices.begin(), it) << '\n'; + typename vv_type::iterator dit= data.begin(); + // std::cout << "*dit == " << *dit << '\n'; + advance(dit, distance(indices.begin(), it)); + // std::cout << "*dit == " << *dit << ", distance(data.begin(), dit) == " << distance(data.begin(), dit) << '\n'; + data.insert(dit, v); // insert v at same position + indices.insert(it, i); + } + + size_type pos(size_type i) const + { + typename sv_type::const_iterator it= std::lower_bound(indices.begin(), indices.end(), i); + MTL_DEBUG_THROW_IF(it == indices.end(), logic_error("Position doesn't exists")); + return distance(indices.begin(), it); + } + + value_type& operator[](size_type i) + { + if (!exists(i)) + insert(i, value_type(0)); + return data[pos(i)]; + } + + void make_empty() { data.resize(0); indices.resize(0); } + + void crop(value_type threshold= value_type(0)) + { + using std::abs; + std::size_t j= 0; + for (std::size_t i= 0, end= data.size(); i < end; i++) + if (abs(data[i]) > threshold) { + if (i > j) { + data[j]= data[i]; + indices[j]= indices[i]; + } + ++j; + } + data.resize(j); + indices.resize(j); + } + + void sort_on_data() // largest magnitude first + { + // vampir_trace<9903> tracer; + if (n > 0) + std::sort(utility::zip_it<value_type, size_type>(&data[0], &indices[0], 0), + utility::zip_it<value_type, size_type>(&data[0], &indices[0], indices.size()), + utility::abs_greater_0()); + on_indices= false; + + // if (indices.size() > longest) longest= indices.size(); + } + + void sort_on_indices() + { + if (n > 0) + std::sort(utility::zip_it<size_type, value_type>(&indices[0], &data[0], 0), + utility::zip_it<size_type, value_type>(&indices[0], &data[0], indices.size()), + utility::less_0()); + on_indices= true; + } + + size_type index(size_type j) const { check(j); return indices[j]; } + value_type const& value(size_type j) const { check(j); return data[j]; } + value_type& value(size_type j) { check(j); return data[j]; } + + std::pair<size_type, value_type> entry(size_type j) const + { return std::make_pair(indices[j], data[j]); } + + std::pair<size_type, value_type> largest(size_type j) const + { + MTL_DEBUG_THROW_IF(on_indices, logic_error("Vector must be sorted on values to use this function")); + MTL_DEBUG_THROW_IF(j > size_type(data.size()), logic_error("There are less than j entries.")); + return std::make_pair(indices[j], data[j]); + } + + friend std::ostream& operator<<(std::ostream& out, const self& v) + { + out << '{' << v.n << (traits::is_row_major<orientation>::value ? "R" : "C") << "}["; + for (std::size_t i= 0, end= v.data.size(); i < end; i++) + out << v.indices[i] << ':' << v.data[i] << (i+1 < end ? ", " : ""); + return out << ']'; + } + + private: + size_type n; + sv_type indices; + vv_type data; + bool on_indices; // if true sorted on indices, otherwise on values + + // std::size_t longest; +}; + +template <typename Value, typename Parameter> +std::size_t inline size(const sparse_vector<Value, Parameter>& v) +{ return v.n; } + + +}} // namespace mtl::vector + +#endif // MTL_VECTOR_SPARSE_VECTOR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/strided_vector_ref.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/strided_vector_ref.hpp new file mode 100644 index 0000000000000000000000000000000000000000..dd76ddd2e676e0d8e28b818e0252161decc8059b --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/strided_vector_ref.hpp @@ -0,0 +1,274 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_STRIDED_VECTOR_REF_INCLUDE +#define MTL_STRIDED_VECTOR_REF_INCLUDE + + +#include <iostream> +#include <cassert> +#include <vector> +#include <algorithm> +#include <boost/static_assert.hpp> +#include <boost/utility/enable_if.hpp> + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/ashape.hpp> +#include <boost/numeric/mtl/utility/common_include.hpp> +#include <boost/numeric/mtl/vector/all_vec_expr.hpp> +#include <boost/numeric/mtl/vector/parameter.hpp> +#include <boost/numeric/mtl/vector/crtp_base_vector.hpp> +#include <boost/numeric/mtl/utility/dense_el_cursor.hpp> +#include <boost/numeric/mtl/utility/range_generator.hpp> +#include <boost/numeric/mtl/utility/property_map.hpp> +#include <boost/numeric/mtl/utility/irange.hpp> +#include <boost/numeric/mtl/utility/is_row_major.hpp> +#include <boost/numeric/mtl/utility/strided_dense_el_iterator.hpp> +#include <boost/numeric/mtl/utility/strided_dense_el_cursor.hpp> +#include <boost/numeric/mtl/operation/is_negative.hpp> + + +namespace mtl { namespace vector { + + +/// Class for referring vectors stored in strides, e.g. columns in a row-major matrix +template <class Value, typename Parameters = parameters<> > +class strided_vector_ref + : public vec_expr<strided_vector_ref<Value, Parameters> >, + public crtp_base_vector< strided_vector_ref<Value, Parameters>, Value, std::size_t > +{ + typedef strided_vector_ref self; + typedef crtp_base_vector< self, Value, std::size_t > crtp_base; + typedef crtp_vector_assign< self, Value, std::size_t > assign_base; + typedef vec_expr<strided_vector_ref<Value, Parameters> > expr_base; + public: + typedef typename boost::remove_const<Value>::type value_type ; + typedef std::size_t size_type ; + typedef Value& reference ; + typedef Value const& const_reference ; + typedef Value* pointer ; + typedef Value const* const_pointer ; + typedef const_pointer key_type; + typedef mtl::strided_dense_el_cursor<Value> cursor_type; + typedef mtl::strided_dense_el_const_iterator<Value> const_iterator; + typedef mtl::strided_dense_el_iterator<Value> iterator; + typedef typename Parameters::orientation orientation; + + void check_index( size_type MTL_DEBUG_ARG(i) ) const + { + MTL_DEBUG_THROW_IF( is_negative(i) || i >= size(*this), index_out_of_range()); + } + + void check_dim( size_type MTL_DEBUG_ARG(s) ) const + { + MTL_DEBUG_THROW_IF( size(*this) != 0 && size(*this) != s, incompatible_size()); + } + + template <class E> + void check_consistent_shape( vec_expr<E> const& ) const + { + MTL_DEBUG_THROW_IF((!boost::is_same< + typename ashape::ashape<self>::type + , typename ashape::ashape<E>::type + >::value), + incompatible_shape()); + } + + private: + /// Make default constructor invisible + strided_vector_ref(); + + public: + + /// Constructor take address, length and stride + strided_vector_ref( size_type length, pointer start_address, size_type stride= 1) + : data(start_address), my_size(length), my_stride(stride), cloned(false) {} + + /// Clone constructor + strided_vector_ref(const strided_vector_ref& other, clone_ctor) + : data(new Value[other.my_size]), my_size(other.my_size), my_stride(1), cloned(true) + { + *this= other; + } + + // Default copy constructor refers to same vector which is okay + + ~strided_vector_ref() { if (cloned && data) delete[] data; } + + // friend size_type inline size(const self& v) { return v.my_size; } // impedes explicit namespace qualification + + template <typename V2, typename P2> + friend std::size_t size(const strided_vector_ref<V2, P2>& v); + + size_type stride() const { return my_stride ; } + + reference operator()( size_type i ) { check_index(i); return data[i * my_stride]; } + const_reference operator()( size_type i ) const { check_index(i); return data[i * my_stride]; } + + reference operator[]( size_type i ) { return (*this)( i ) ; } + const_reference operator[]( size_type i ) const { return (*this)( i ) ; } + + self operator[]( irange r ) { return sub_vector(*this, r.start(), r.finish()); } + const self operator[]( irange r ) const { return sub_vector(*this, r.start(), r.finish()); } + + void delay_assign() const {} + + const_iterator begin() const { return const_iterator(data, my_stride); } + const_iterator end() const { return const_iterator(data + my_size * my_stride, my_stride); } + + iterator begin() { return iterator(data, my_stride); } + iterator end() { return iterator(data + my_size * my_stride, my_stride); } + + /// Address of first data entry; to be used with care. + pointer address_data() { return data; } + const_pointer address_data() const { return data; } + + // from pointer to index + size_type offset(const_pointer p) const + { + size_type o= p - data, i= o / my_stride; + MTL_DEBUG_THROW_IF(o % my_stride, logic_error("Address not consistent with stride.")); + check_index(i); + return i; + } + + friend size_type inline num_rows(const self& v) { return mtl::traits::is_row_major<self>::value ? 1 : size(v); } + friend size_type inline num_cols(const self& v) { return mtl::traits::is_row_major<self>::value ? size(v) : 1; } + + vec_vec_asgn_expr<self, self> operator=( self const& e ) + { + return vec_vec_asgn_expr<self, self>( *this, e ); + } + + // self& operator=(self src) Cannot move! + + using assign_base::operator=; + + template <typename Value2> friend void fill(self& vector, const Value2& value) + { + std::fill(vector.begin(), vector.end(), value); + } + + /// Swapping not efficient since elements have to be swapped for not owning the data + friend void swap(self& vector1, self& vector2) + { + vector1.check_dim(vector2.size()); // size(vector2) doesn't compiled with ICC 10.1 + for (size_type i= 0; i < vector1.size(); ++i) + swap(vector1[i], vector2[i]); + } + + void change_dim(size_type MTL_DEBUG_ARG(n)) { MTL_DEBUG_THROW_IF(my_size != n, incompatible_size()); } + void crop() {} // Only dummy here + + private: + pointer data; + size_type my_size, my_stride; + bool cloned; +} ; // strided_vector_ref + + +template <typename Value, typename Parameters> +inline std::size_t size(const strided_vector_ref<Value, Parameters>& v) +{ + return v.my_size; +} + + +template <typename Value, typename Parameters> +strided_vector_ref<Value, Parameters> +inline sub_vector(strided_vector_ref<Value, Parameters>& v, + typename strided_vector_ref<Value, Parameters>::size_type start, + typename strided_vector_ref<Value, Parameters>::size_type finish) +{ + using std::min; + typedef strided_vector_ref<Value, Parameters> Vector; + typedef typename Vector::size_type size_type; + + MTL_DEBUG_THROW_IF( is_negative(start) || is_negative(finish), index_out_of_range()); + finish= min(finish, size(v)); + start= min(start, finish); // implies min(start, size(v)) + return Vector(start <= finish ? finish - start : size_type(0), &v[start], v.stride()); +} + +template <typename Value, typename Parameters> +const strided_vector_ref<Value, Parameters> +inline sub_vector(const strided_vector_ref<Value, Parameters>& v, + typename strided_vector_ref<Value, Parameters>::size_type start, + typename strided_vector_ref<Value, Parameters>::size_type finish) +{ + typedef strided_vector_ref<Value, Parameters> Vector; + return sub_vector(const_cast<Vector&>(v), start, finish); +} + + +}} // namespace mtl::vector + +namespace mtl { + + // Enable cloning of strided_vector_ref + template <typename Value, typename Parameters> + struct is_clonable< vector::strided_vector_ref<Value, Parameters> > : boost::mpl::true_ {}; + +} // namespace mtl + +namespace mtl { namespace traits { + + +// ================ +// Range generators +// For cursors +// ================ + + template <typename Value, class Parameters> + struct range_generator<tag::all, vector::strided_vector_ref<Value, Parameters> > + : public detail::strided_element_range_generator< + vector::strided_vector_ref<Value, Parameters>, + const vector::strided_vector_ref<Value, Parameters>, + mtl::strided_dense_el_cursor<Value> + > {}; + + template <typename Value, class Parameters> + struct range_generator<tag::nz, vector::strided_vector_ref<Value, Parameters> > + : public range_generator<tag::all, vector::strided_vector_ref<Value, Parameters> > {}; + + template <typename Value, class Parameters> + struct range_generator<tag::iter::all, vector::strided_vector_ref<Value, Parameters> > + : public detail::strided_element_range_generator< + vector::strided_vector_ref<Value, Parameters>, + vector::strided_vector_ref<Value, Parameters>, + mtl::strided_dense_el_iterator<Value> + > {}; + + template <typename Value, class Parameters> + struct range_generator<tag::iter::nz, vector::strided_vector_ref<Value, Parameters> > + : public range_generator<tag::iter::all, vector::strided_vector_ref<Value, Parameters> > {}; + + template <typename Value, class Parameters> + struct range_generator<tag::const_iter::all, vector::strided_vector_ref<Value, Parameters> > + : public detail::strided_element_range_generator< + vector::strided_vector_ref<Value, Parameters>, + const vector::strided_vector_ref<Value, Parameters>, + mtl::strided_dense_el_const_iterator<Value> + > {}; + + template <typename Value, class Parameters> + struct range_generator<tag::const_iter::nz, vector::strided_vector_ref<Value, Parameters> > + : public range_generator<tag::const_iter::all, vector::strided_vector_ref<Value, Parameters> > + {}; + + +}} // namespace mtl::traits + + +#endif // MTL_STRIDED_VECTOR_REF_INCLUDE + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/unit_vector.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/unit_vector.hpp new file mode 100644 index 0000000000000000000000000000000000000000..15a886be6c6d02cb4f200f3f95407740a2c1830a --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/unit_vector.hpp @@ -0,0 +1,64 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_VECTOR_UNIT_VECTOR_INCLUDE +#define MTL_VECTOR_UNIT_VECTOR_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/vector/parameter.hpp> + +namespace mtl { + +namespace traits { + + /// Type of unit_vector; will be changed later to a proxy for the sake of efficiency + template <typename Value= double> + struct unit_vector + { + typedef mtl::vector::dense_vector<Value, mtl::vector::parameters<> > type; + }; +} + +namespace vector { + + /// Return k-th unit vector of size n + /** The result is a dense column vector. In the future this will + be replaced by a proxy for the sake of efficiency. + If you use unit_vector in an expression you will not encounter + this change. If you define a variable you should use + traits::unit_vector, e.g.: + \code + typename mtl::traits::unit_vector<float>::type e_k(mtl::vector::unit_vector(k, n)); + \endcode + **/ + template <typename Value> + typename traits::unit_vector<Value>::type + inline unit_vector(std::size_t k, std::size_t n) + { + using math::zero; using math::one; + dense_vector<Value> v(n, zero(Value())); + v[k]= one(Value()); + return v; + } + + /// Unit vector of type double + traits::unit_vector<double>::type + inline unit_vector(std::size_t k, std::size_t n) + { + return unit_vector<double>(k, n); + } + +} // namespace mtl::vector + +} // namespace mtl + +#endif // MTL_VECTOR_UNIT_VECTOR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/unrolled1.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/unrolled1.hpp new file mode 100644 index 0000000000000000000000000000000000000000..920a86cc08005109b9ed801c6b8c60515164bf96 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/unrolled1.hpp @@ -0,0 +1,61 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_VECTOR_UNROLLED1_INCLUDE +#define MTL_VECTOR_UNROLLED1_INCLUDE + +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/vector/crtp_base_vector.hpp> + +namespace mtl { namespace vector { + +/// Helper class for unrolling loops \sa \ref mtl::unroll +template <unsigned BSize, typename Vector> +class unrolled1 + : public crtp_base_vector< unrolled1<BSize, Vector>, typename Collection<Vector>::value_type, std::size_t > +{ + typedef unrolled1 self; + public: + typedef typename Collection<Vector>::value_type value_type; + typedef typename Collection<Vector>::size_type size_type; + typedef value_type& reference ; + typedef crtp_vector_assign< self, value_type, std::size_t > assign_base; // base of crtp_base_vector + + unrolled1(Vector& ref) : ref(ref) {} + + reference operator()(size_type i) { return ref(i); } + reference operator[](size_type i) { return (*this)(i); } + // const versions shouldn't be needed because it is supposed to be a lvalue + + //friend inline size_type size(const self& v) { return size(v.ref); } + friend inline size_type num_rows(const self& v) { return num_rows(v.ref); } + friend inline size_type num_cols(const self& v) { return num_cols(v.ref); } + + void change_dim(size_type d) { ref.change_dim(d); } + + using assign_base::operator=; + +#if !defined(_MSC_VER) || _MSC_VER != 1400 // Bug in MSVC 2005 + template <unsigned BBSize, typename VVector> + friend inline std::size_t size(const unrolled1<BBSize, VVector>& v); + private: +#endif + Vector& ref; +}; + +template <unsigned BSize, typename Vector> +inline std::size_t size(const unrolled1<BSize, Vector>& v) +{ return size(v.ref); } + +}} // namespace mtl::vector + +#endif // MTL_VECTOR_UNROLLED1_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_const_ref_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_const_ref_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..0a9c1f81d483f9bc26ce292b15e0a2c3e3c9912a --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_const_ref_expr.hpp @@ -0,0 +1,42 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_VECTOR_VEC_CONST_REF_EXPR_INCLUDE +#define MTL_VECTOR_VEC_CONST_REF_EXPR_INCLUDE + +namespace mtl { namespace vector { + + +/// Class for providing interface for a vector given as reference +template <typename Vector> +struct vec_const_ref_expr + : vec_expr< vec_const_ref_expr<Vector> > +{ + typedef vec_const_ref_expr self; + typedef typename Vector::size_type size_type; + typedef typename Vector::value_type value_type; + typedef value_type const_dereference_type ; + + vec_const_ref_expr(const Vector& ref) : ref(ref) {} + void delay_assign() const {} + const_dereference_type operator() ( size_type i ) const { return ref(i); } + const_dereference_type operator[] ( size_type i ) const { return ref[i]; } + + friend inline size_type size(const self& v) { return size(v.ref); } + private: + const Vector& ref; +}; + + +}} // namespace mtl::vector + +#endif // MTL_VECTOR_VEC_CONST_REF_EXPR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..64ff130542d139605943847e4bd87cc59e776c0f --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_expr.hpp @@ -0,0 +1,25 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_VEC_EXPR_INCLUDE +#define MTL_VEC_EXPR_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> + +namespace mtl { namespace vector { + +template <typename Vector> +struct vec_expr {}; + +}} // namespace mtl::vector + +#endif // MTL_VEC_EXPR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_negate_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_negate_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..b6b444fa702b800181469731afae4f325fe3f8c9 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_negate_expr.hpp @@ -0,0 +1,30 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_VEC_NEGATE_EXPR_INCLUDE +#define MTL_VEC_NEGATE_EXPR_INCLUDE + +#include <boost/numeric/mtl/vector/map_view.hpp> + +namespace mtl { namespace vector { + +template <typename E1> +inline negate_view< E1 > +operator- (const vec_expr<E1>& e1) +{ + return negate_view< E1 >(static_cast<const E1&>(e1)); +} + +} } // Namespace mtl::vector + +#endif + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_scal_aop_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_scal_aop_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..8c8be2aa0a8180dea62885fed05499e1e49c6f37 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_scal_aop_expr.hpp @@ -0,0 +1,124 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_VEC_SCAL_AOP_EXPR_INCLUDE +#define MTL_VEC_SCAL_AOP_EXPR_INCLUDE + +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/vector/vec_expr.hpp> +#include <boost/numeric/mtl/operation/sfunctor.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + + +namespace mtl { namespace vector { + +// Generic assign operation expression template for vectors +// Model of VectorExpression +template <class E1, class E2, typename SFunctor> +struct vec_scal_aop_expr + : public vec_expr< vec_scal_aop_expr<E1, E2, SFunctor> > +{ + typedef vec_expr< vec_scal_aop_expr<E1, E2, SFunctor> > expr_base; + typedef vec_scal_aop_expr self; + typedef typename E1::value_type value_type; + + // temporary solution + typedef typename E1::size_type size_type; + //typedef typename utilities::smallest< typename E1::size_type, typename E2::size_type >::type size_type ; + + typedef value_type reference_type ; + + typedef E1 first_argument_type ; + typedef E2 second_argument_type ; + + vec_scal_aop_expr( first_argument_type& v1, second_argument_type const& v2, bool delay= false ) + : first( v1 ), second( v2 ), delayed_assign( delay ), with_comma( false ), index(0) + {} + + ~vec_scal_aop_expr() + { + if (!delayed_assign) { + vampir_trace<2018> tracer; + if (with_comma) { + MTL_DEBUG_THROW_IF(index != mtl::vector::size(first), incompatible_size("Not all vector entries initialized!")); + } else + for (size_type i= 0; i < mtl::vector::size(first); ++i) + SFunctor::apply( first(i), second ); + } + } + + void delay_assign() const + { + MTL_DEBUG_THROW_IF(with_comma, logic_error("Comma notation conflicts with rich expression templates.")); + delayed_assign= true; + } + + //friend size_type inline size(const self& v) { return size(v.first); } + template <typename EE1, typename EE2, typename SSFunctor> + friend std::size_t size(const vec_scal_aop_expr<EE1, EE2, SSFunctor>& v); + + value_type& operator() ( size_type i ) const + { + assert( delayed_assign && !with_comma); + return SFunctor::apply( first(i), second ); + } + + value_type& operator[] ( size_type i ) const + { + assert( delayed_assign ); + return SFunctor::apply( first(i), second ); + } + + template <unsigned Offset> + value_type& at(size_type i) const { + assert(delayed_assign); + return SFunctor::apply(first(i+Offset), second); + } + + template <typename Source> + self& operator, (Source val) + { + //std::cout << "vec_scal_aop_expr::operator,\n"; + if (!with_comma) { + with_comma= true; + assert(index == 0); + SFunctor::apply( first(index++), second); // We haven't set v[0] yet + } + MTL_DEBUG_THROW_IF(index >= mtl::vector::size(first), range_error()); + SFunctor::apply( first(index++), val); + return *this; + } + + private: + first_argument_type& first ; + second_argument_type const& second ; + mutable bool delayed_assign, with_comma; + size_type index; +} ; // vec_scal_aop_expr + + +template <typename E1, typename E2, typename SFunctor> +inline std::size_t size(const vec_scal_aop_expr<E1, E2, SFunctor>& v) +{ + return size(v.first); +} + + + +} } // Namespace mtl::vector + + + + + +#endif + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_scal_asgn_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_scal_asgn_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..7d6d7013c2895699a6c8f6e6fd39326b0cb45a44 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_scal_asgn_expr.hpp @@ -0,0 +1,39 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + + +#ifndef MTL_VEC_SCAL_ASGN_EXPR_INCLUDE +#define MTL_VEC_SCAL_ASGN_EXPR_INCLUDE + +#include <boost/static_assert.hpp> + +#include <boost/numeric/mtl/vector/vec_scal_aop_expr.hpp> +#include <boost/numeric/mtl/utility/ashape.hpp> +#include <boost/numeric/mtl/operation/sfunctor.hpp> + +namespace mtl { namespace vector { + +// Model of VectorExpression +template <class E1, class E2> +struct vec_scal_asgn_expr + : public vec_scal_aop_expr< E1, E2, mtl::sfunctor::assign<typename E1::value_type, E2> > +{ + typedef vec_scal_aop_expr< E1, E2, mtl::sfunctor::assign<typename E1::value_type, E2> > base; + vec_scal_asgn_expr( E1& v1, E2 const& v2 ) + : base( v1, v2 ) + {} +}; + +} } // Namespace mtl::vector + +#endif + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_scal_div_asgn_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_scal_div_asgn_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..0455ad7032ea88ebc8a5ef1a577f0ca95b5b7969 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_scal_div_asgn_expr.hpp @@ -0,0 +1,34 @@ +/* + * vec_scal_div_asgn_expr.h + * MTL4 + * + * Created by Hui Li (huil@Princeton.EDU) + * + */ + +#ifndef MTL_VEC_SCAL_DIV_ASGN_EXPR_INCLUDE +#define MTL_VEC_SCAL_DIV_ASGN_EXPR_INCLUDE + +#include <boost/static_assert.hpp> + +#include <boost/numeric/mtl/vector/vec_scal_aop_expr.hpp> +#include <boost/numeric/mtl/utility/ashape.hpp> +#include <boost/numeric/mtl/operation/sfunctor.hpp> + +namespace mtl { namespace vector { + + // Model of VectorExpression + template <class E1, class E2> + struct vec_scal_div_asgn_expr + : public vec_scal_aop_expr< E1, E2, mtl::sfunctor::divide_assign<typename E1::value_type, E2> > + { + typedef vec_scal_aop_expr< E1, E2, mtl::sfunctor::divide_assign<typename E1::value_type, E2> > base; + vec_scal_div_asgn_expr( E1& v1, E2 const& v2 ) + : base( v1, v2 ) + {} + }; + +} } // Namespace mtl::vector + +#endif + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_scal_minus_asgn_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_scal_minus_asgn_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..c669c00025a7a14a60aba1e8f91e9cfaf6a2c2a5 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_scal_minus_asgn_expr.hpp @@ -0,0 +1,35 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_VECTOR_VEC_SCAL_MINUS_ASGN_EXPR_INCLUDE +#define MTL_VECTOR_VEC_SCAL_MINUS_ASGN_EXPR_INCLUDE + +#include <boost/numeric/mtl/vector/vec_scal_aop_expr.hpp> +#include <boost/numeric/mtl/utility/ashape.hpp> +#include <boost/numeric/mtl/operation/sfunctor.hpp> + +namespace mtl { namespace vector { + +// Model of VectorExpression +template <class E1, class E2> +struct vec_scal_minus_asgn_expr + : public vec_scal_aop_expr< E1, E2, mtl::sfunctor::minus_assign<typename E1::value_type, E2> > +{ + typedef vec_scal_aop_expr< E1, E2, mtl::sfunctor::minus_assign<typename E1::value_type, E2> > base; + vec_scal_minus_asgn_expr( E1& v1, E2 const& v2 ) + : base( v1, v2 ) + {} +}; + +}} // namespace mtl::vector + +#endif // MTL_VECTOR_VEC_SCAL_MINUS_ASGN_EXPR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_scal_mixed_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_scal_mixed_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..3b6207d113bbcc1251a819615013402f65a95351 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_scal_mixed_expr.hpp @@ -0,0 +1,104 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_VECTOR_VEC_SCAL_MIXED_EXPR_INCLUDE +#define MTL_VECTOR_VEC_SCAL_MIXED_EXPR_INCLUDE + +#include <boost/numeric/mtl/utility/enable_if.hpp> +#include <boost/numeric/mtl/vector/map_view.hpp> +#include <boost/numeric/mtl/operation/tfunctor_mixed.hpp> + +namespace mtl { namespace vector { + +template <typename E1, typename E2> +typename mtl::traits::enable_if_scalar<E1, map_view<tfunctor::left_plus<E1, typename E2::value_type>, E2> >::type +inline operator+(const E1& e1, const vec_expr<E2>& e2) +{ + typedef tfunctor::left_plus<E1, typename E2::value_type> ftype; + typedef map_view<ftype, E2> type; + + return type(ftype(e1), static_cast<const E2&>(e2)); +} + +template <typename E1, typename E2> +typename mtl::traits::enable_if_scalar<E2, map_view<tfunctor::right_plus<typename E1::value_type, E2>, E1> >::type +inline operator+(const vec_expr<E1>& e1, const E2& e2) +{ + typedef tfunctor::right_plus<typename E1::value_type, E2>ftype; + typedef map_view<ftype, E1> type; + + return type(ftype(e2), static_cast<const E1&>(e1)); +} + +template <typename E1, typename E2> +typename mtl::traits::enable_if_scalar<E1, map_view<tfunctor::left_minus<E1, typename E2::value_type>, E2> >::type +inline operator-(const E1& e1, const vec_expr<E2>& e2) +{ + typedef tfunctor::left_minus<E1, typename E2::value_type> ftype; + typedef map_view<ftype, E2> type; + + return type(ftype(e1), static_cast<const E2&>(e2)); +} + +template <typename E1, typename E2> +typename mtl::traits::enable_if_scalar<E2, map_view<tfunctor::right_minus<typename E1::value_type, E2>, E1> >::type +inline operator-(const vec_expr<E1>& e1, const E2& e2) +{ + typedef tfunctor::right_minus<typename E1::value_type, E2>ftype; + typedef map_view<ftype, E1> type; + + return type(ftype(e2), static_cast<const E1&>(e1)); +} + +template <typename E1, typename E2> +typename mtl::traits::enable_if_scalar<E1, map_view<tfunctor::left_min<E1, typename E2::value_type>, E2> >::type +inline min(const E1& e1, const vec_expr<E2>& e2) +{ + typedef tfunctor::left_min<E1, typename E2::value_type> ftype; + typedef map_view<ftype, E2> type; + + return type(ftype(e1), static_cast<const E2&>(e2)); +} + +template <typename E1, typename E2> +typename mtl::traits::enable_if_scalar<E2, map_view<tfunctor::right_min<typename E1::value_type, E2>, E1> >::type +inline min(const vec_expr<E1>& e1, const E2& e2) +{ + typedef tfunctor::right_min<typename E1::value_type, E2>ftype; + typedef map_view<ftype, E1> type; + + return type(ftype(e2), static_cast<const E1&>(e1)); +} + +template <typename E1, typename E2> +typename mtl::traits::enable_if_scalar<E1, map_view<tfunctor::left_max<E1, typename E2::value_type>, E2> >::type +inline max(const E1& e1, const vec_expr<E2>& e2) +{ + typedef tfunctor::left_max<E1, typename E2::value_type> ftype; + typedef map_view<ftype, E2> type; + + return type(ftype(e1), static_cast<const E2&>(e2)); +} + +template <typename E1, typename E2> +typename mtl::traits::enable_if_scalar<E2, map_view<tfunctor::right_max<typename E1::value_type, E2>, E1> >::type +inline max(const vec_expr<E1>& e1, const E2& e2) +{ + typedef tfunctor::right_max<typename E1::value_type, E2>ftype; + typedef map_view<ftype, E1> type; + + return type(ftype(e2), static_cast<const E1&>(e1)); +} + +}} // namespace mtl::vector + +#endif // MTL_VECTOR_VEC_SCAL_MIXED_EXPR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_scal_plus_asgn_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_scal_plus_asgn_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..2c65fe3a3c4c50a7ae51078740aee22a63963802 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_scal_plus_asgn_expr.hpp @@ -0,0 +1,35 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG, www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also tools/license/license.mtl.txt in the distribution. + +#ifndef MTL_VECTOR_VEC_SCAL_PLUS_ASGN_EXPR_INCLUDE +#define MTL_VECTOR_VEC_SCAL_PLUS_ASGN_EXPR_INCLUDE + +#include <boost/numeric/mtl/vector/vec_scal_aop_expr.hpp> +#include <boost/numeric/mtl/utility/ashape.hpp> +#include <boost/numeric/mtl/operation/sfunctor.hpp> + +namespace mtl { namespace vector { + +// Model of VectorExpression +template <class E1, class E2> +struct vec_scal_plus_asgn_expr + : public vec_scal_aop_expr< E1, E2, mtl::sfunctor::plus_assign<typename E1::value_type, E2> > +{ + typedef vec_scal_aop_expr< E1, E2, mtl::sfunctor::plus_assign<typename E1::value_type, E2> > base; + vec_scal_plus_asgn_expr( E1& v1, E2 const& v2 ) + : base( v1, v2 ) + {} +}; + +}} // namespace mtl::vector + +#endif // MTL_VECTOR_VEC_SCAL_PLUS_ASGN_EXPR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_scal_times_asgn_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_scal_times_asgn_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..b974cbf10c3b0988d083e57761c0f70d64c3b30e --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_scal_times_asgn_expr.hpp @@ -0,0 +1,37 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + + +#ifndef MTL_VEC_SCAL_TIMES_ASGN_EXPR_INCLUDE +#define MTL_VEC_SCAL_TIMES_ASGN_EXPR_INCLUDE + +#include <boost/numeric/mtl/vector/vec_scal_aop_expr.hpp> +#include <boost/numeric/mtl/utility/ashape.hpp> +#include <boost/numeric/mtl/operation/sfunctor.hpp> + +namespace mtl { namespace vector { + +// Model of VectorExpression +template <class E1, class E2> +struct vec_scal_times_asgn_expr + : public vec_scal_aop_expr< E1, E2, mtl::sfunctor::times_assign<typename E1::value_type, E2> > +{ + typedef vec_scal_aop_expr< E1, E2, mtl::sfunctor::times_assign<typename E1::value_type, E2> > base; + vec_scal_times_asgn_expr( E1& v1, E2 const& v2 ) + : base( v1, v2 ) + {} +}; + +} } // Namespace mtl::vector + +#endif + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_aop_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_aop_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..d3aa6e1c803a3f5a4dbaa239017c38f0a4b14bf6 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_aop_expr.hpp @@ -0,0 +1,196 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_VEC_VEC_AOP_EXPR_INCLUDE +#define MTL_VEC_VEC_AOP_EXPR_INCLUDE + +#include <boost/mpl/bool.hpp> +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/vector/vec_expr.hpp> +#include <boost/numeric/mtl/operation/static_size.hpp> +#include <boost/numeric/mtl/operation/sfunctor.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> +#include <boost/numeric/mtl/utility/is_static.hpp> +#include <boost/numeric/mtl/utility/tag.hpp> +#include <boost/numeric/mtl/utility/category.hpp> +#include <boost/numeric/mtl/utility/omp_size_type.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/utility/unroll_size1.hpp> +#include <boost/numeric/mtl/utility/with_unroll1.hpp> +#include <boost/numeric/mtl/interface/vpt.hpp> + +namespace mtl { namespace vector { + + namespace impl { + + template <unsigned long Index, unsigned long Max, typename SFunctor> + struct assign + { + typedef assign<Index+1, Max, SFunctor> next; + + template <typename E1, typename E2, typename Size> + static inline void apply(E1& first, const E2& second, Size i) + { + SFunctor::apply( first(i+Index), second(i+Index) ); + next::apply( first, second, i ); + } + }; + + template <unsigned long Max, typename SFunctor> + struct assign<Max, Max, SFunctor> + { + template <typename E1, typename E2, typename Size> + static inline void apply(E1& first, const E2& second, Size i) + { + SFunctor::apply( first(i+Max), second(i+Max) ); + } + }; + } + +// Generic assign operation expression template for vectors +// Model of VectorExpression +template <typename E1, typename E2, typename SFunctor> +struct vec_vec_aop_expr + : public vec_expr< vec_vec_aop_expr<E1, E2, SFunctor> > +{ + typedef vec_expr< vec_vec_aop_expr<E1, E2, SFunctor> > expr_base; + typedef vec_vec_aop_expr<E1, E2, SFunctor> self; + typedef typename Collection<E1>::value_type value_type; + + typedef typename Collection<E1>::size_type size_type; + typedef value_type reference_type ; + + typedef E1 first_argument_type ; + typedef E2 second_argument_type ; + + vec_vec_aop_expr( first_argument_type& v1, second_argument_type const& v2, bool delay= false ) + : first(v1), second(v2), delayed_assign(delay) + { + second.delay_assign(); + } + + private: + void dynamic_assign(boost::mpl::false_) // Without unrolling + { + typedef typename traits::omp_size_type<size_type>::type size_type; + size_type s= size_type(mtl::vector::size(first)); + + #ifdef MTL_WITH_OPENMP + # pragma omp parallel + { + vampir_trace<8003> tracer; + #pragma omp for + for (size_type i= 0; i < s; ++i) + SFunctor::apply( first(i), second(i) ); + } + #else + for (size_type i= 0; i < s; ++i) + SFunctor::apply( first(i), second(i) ); + #endif + } + + void dynamic_assign(boost::mpl::true_) // With unrolling + { + typedef typename traits::omp_size_type<size_type>::type size_type; + const size_type BSize= traits::unroll_size1<E1>::value0; + size_type s= mtl::vector::size(first), sb= s / BSize * BSize; + + #ifdef MTL_WITH_OPENMP + # pragma omp parallel + { + vampir_trace<8003> tracer; + #pragma omp for + for (size_type i= 0; i < sb; i+= BSize) + impl::assign<0, BSize-1, SFunctor>::apply(first, second, i); + } + #else + for (size_type i= 0; i < sb; i+= BSize) + impl::assign<0, BSize-1, SFunctor>::apply(first, second, i); + #endif + + for (size_type i= sb; i < s; i++) + SFunctor::apply( first(i), second(i) ); + } + + + void assign(boost::mpl::false_) + { + vampir_trace<2017> tracer; + // If target is constructed by default it takes size of source + //int a= size(second); + //int b= second; + if (mtl::vector::size(first) == 0) first.change_dim(mtl::vector::size(second)); + MTL_DEBUG_THROW_IF(mtl::vector::size(first) != mtl::vector::size(second), incompatible_size()); // otherwise error + + // need to do more benchmarking before making unrolling default + dynamic_assign(traits::with_unroll1<E1>()); + } + + void assign(boost::mpl::true_) + { + vampir_trace<1001> tracer; + MTL_DEBUG_THROW_IF(mtl::vector::size(first) != mtl::vector::size(second), incompatible_size()); // We cannot resize, only check + + // impl::assign<0, static_size<E1>::value-1, SFunctor>::apply(first, second); // Slower, at least on gcc + for (size_type i= 0; i < mtl::vector::size(first); ++i) // Do an ordinary loop instead + SFunctor::apply(first(i), second(i)); + } + + public: + ~vec_vec_aop_expr() + { + if (!delayed_assign) + assign(traits::is_static<E1>()); + } + + void delay_assign() const { delayed_assign= true; } + + template <typename EE1, typename EE2, typename SSFunctor> + friend std::size_t size(const vec_vec_aop_expr<EE1, EE2, SSFunctor>& v); + + value_type& operator() (size_type i) const { + assert( delayed_assign ); + return SFunctor::apply(first(i), second(i)); + } + + value_type& operator[] (size_type i) const { return (*this)(i); } + + template <unsigned Offset> + value_type& at(size_type i) const { + assert(delayed_assign); + return SFunctor::apply(first(i+Offset), second(i+Offset)); + } + + first_argument_type const& first_argument() const { return first; } + second_argument_type const& second_argument() const { return second; } + + private: + first_argument_type& first ; + second_argument_type const& second ; + mutable bool delayed_assign; +} ; // vec_vec_aop_expr + +template <typename E1, typename E2, typename SFunctor> +inline std::size_t size(const vec_vec_aop_expr<E1, E2, SFunctor>& v) +{ + MTL_DEBUG_THROW_IF( size(v.first) != 0 && size(v.first) != size(v.second), incompatible_size()); + return size(v.second); +} + +} } // Namespace mtl::vector + + + + +#endif + + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_asgn_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_asgn_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..8da805f1f80e6636bbf675a483be4546057801fd --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_asgn_expr.hpp @@ -0,0 +1,44 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +// Adapted from GLAS implementation by Karl Meerbergen and Toon Knappen + + +#ifndef MTL_VEC_VEC_ASGN_EXPR_INCLUDE +#define MTL_VEC_VEC_ASGN_EXPR_INCLUDE + +#include <boost/static_assert.hpp> + +#include <boost/numeric/mtl/vector/vec_vec_aop_expr.hpp> +#include <boost/numeric/mtl/utility/ashape.hpp> +#include <boost/numeric/mtl/operation/sfunctor.hpp> + +namespace mtl { namespace vector { + +// Model of VectorExpression +template <class E1, class E2> +struct vec_vec_asgn_expr + : public vec_vec_aop_expr< E1, E2, mtl::sfunctor::assign<typename E1::value_type, typename E2::value_type> > +{ + typedef vec_vec_aop_expr< E1, E2, mtl::sfunctor::assign<typename E1::value_type, typename E2::value_type> > base; + vec_vec_asgn_expr( E1& v1, E2 const& v2 ) + : base( v1, v2 ) + {} +}; + +} } // Namespace mtl::vector + + + + +#endif + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_div_asgn_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_div_asgn_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..57b378d86d045e21b686671607c80271c4d077fd --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_div_asgn_expr.hpp @@ -0,0 +1,41 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +// Adapted from GLAS implementation by Karl Meerbergen and Toon Knappen + + +#ifndef MTL_VEC_VEC_DIV_ASGN_EXPR_INCLUDE +#define MTL_VEC_VEC_DIV_ASGN_EXPR_INCLUDE + +#include <boost/static_assert.hpp> + +#include <boost/numeric/mtl/vector/vec_vec_aop_expr.hpp> +#include <boost/numeric/mtl/utility/ashape.hpp> +#include <boost/numeric/mtl/operation/sfunctor.hpp> + +namespace mtl { namespace vector { + +// Model of VectorExpression +template <class E1, class E2> +struct vec_vec_div_asgn_expr + : public vec_vec_aop_expr< E1, E2, mtl::sfunctor::divide_assign<typename E1::value_type, typename E2::value_type> > +{ + typedef vec_vec_aop_expr< E1, E2, mtl::sfunctor::divide_assign<typename E1::value_type, typename E2::value_type> > base; + vec_vec_div_asgn_expr( E1& v1, E2 const& v2 ) + : base( v1, v2 ) + {} +}; + +} } // Namespace mtl::vector + +#endif + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_ele_prod_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_ele_prod_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..88070a08bf500f6042271bce32af8ce4510e03d9 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_ele_prod_expr.hpp @@ -0,0 +1,41 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_VECTOR_VEC_VEC_ELE_PROD_EXPR_INCLUDE +#define MTL_VECTOR_VEC_VEC_ELE_PROD_EXPR_INCLUDE + +#include <boost/static_assert.hpp> + +#include <boost/numeric/mtl/vector/vec_vec_op_expr.hpp> +#include <boost/numeric/mtl/utility/ashape.hpp> +#include <boost/numeric/mtl/utility/static_assert.hpp> +#include <boost/numeric/mtl/operation/sfunctor.hpp> + +namespace mtl { namespace vector { + +template <typename E1, typename E2> +inline vec_vec_op_expr< E1, E2, mtl::sfunctor::times<typename E1::value_type, typename E2::value_type> > +ele_prod(const vec_expr<E1>& e1, const vec_expr<E2>& e2) +{ + // do not add row and column vectors (or inconsistent value types) + MTL_STATIC_ASSERT((boost::is_same<typename ashape::ashape<E1>::type, + typename ashape::ashape<E2>::type>::value), + "Vectors do not have consistent algebraic shape (i.e. nested types)."); + typedef vec_vec_op_expr< E1, E2, mtl::sfunctor::times<typename E1::value_type, typename E2::value_type> > type; + return type(static_cast<const E1&>(e1), static_cast<const E2&>(e2)); +} + + + +}} // namespace mtl::vector + +#endif // MTL_VECTOR_VEC_VEC_ELE_PROD_EXPR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_ele_quot_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_ele_quot_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..168cab2f95015e3919545b314a1f3b517104d2a4 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_ele_quot_expr.hpp @@ -0,0 +1,39 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_VECTOR_VEC_VEC_ELE_QUOT_EXPR_INCLUDE +#define MTL_VECTOR_VEC_VEC_ELE_QUOT_EXPR_INCLUDE + +#include <boost/numeric/mtl/vector/vec_vec_op_expr.hpp> +#include <boost/numeric/mtl/utility/ashape.hpp> +#include <boost/numeric/mtl/utility/static_assert.hpp> +#include <boost/numeric/mtl/operation/sfunctor.hpp> + +namespace mtl { namespace vector { + +template <typename E1, typename E2> +inline vec_vec_op_expr< E1, E2, mtl::sfunctor::divide<typename E1::value_type, typename E2::value_type> > +ele_quot(const vec_expr<E1>& e1, const vec_expr<E2>& e2) +{ + // do not add row and column vectors (or inconsistent value types) + MTL_STATIC_ASSERT((boost::is_same<typename ashape::ashape<E1>::type, + typename ashape::ashape<E2>::type>::value), + "Vectors do not have consistent algebraic shape (i.e. nested types)."); + typedef vec_vec_op_expr< E1, E2, mtl::sfunctor::divide<typename E1::value_type, typename E2::value_type> > type; + return type(static_cast<const E1&>(e1), static_cast<const E2&>(e2)); +} + + + +}} // namespace mtl::vector + +#endif // MTL_VECTOR_VEC_VEC_ELE_QUOT_EXPR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_minus_asgn_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_minus_asgn_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..480de5ac8bb546100b8af8beba5c0e7d2cdeed99 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_minus_asgn_expr.hpp @@ -0,0 +1,41 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +// Adapted from GLAS implementation by Karl Meerbergen and Toon Knappen + + +#ifndef MTL_VEC_VEC_MINUS_ASGN_EXPR_INCLUDE +#define MTL_VEC_VEC_MINUS_ASGN_EXPR_INCLUDE + +#include <boost/static_assert.hpp> + +#include <boost/numeric/mtl/vector/vec_vec_aop_expr.hpp> +#include <boost/numeric/mtl/utility/ashape.hpp> +#include <boost/numeric/mtl/operation/sfunctor.hpp> + +namespace mtl { namespace vector { + +// Model of VectorExpression +template <class E1, class E2> +struct vec_vec_minus_asgn_expr + : public vec_vec_aop_expr< E1, E2, mtl::sfunctor::minus_assign<typename E1::value_type, typename E2::value_type> > +{ + typedef vec_vec_aop_expr< E1, E2, mtl::sfunctor::minus_assign<typename E1::value_type, typename E2::value_type> > base; + vec_vec_minus_asgn_expr( E1& v1, E2 const& v2 ) + : base( v1, v2 ) + {} +}; + +} } // Namespace mtl::vector + +#endif + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_minus_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_minus_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..11f6bc59b9e94b8b7e86fb26a6533f8b3281346e --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_minus_expr.hpp @@ -0,0 +1,43 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +// Adapted from GLAS implementation by Karl Meerbergen and Toon Knappen + + +#ifndef MTL_VEC_VEC_MINUS_EXPR_INCLUDE +#define MTL_VEC_VEC_MINUS_EXPR_INCLUDE + +#include <boost/static_assert.hpp> + +#include <boost/numeric/mtl/vector/vec_vec_pmop_expr.hpp> +#include <boost/numeric/mtl/utility/ashape.hpp> +#include <boost/numeric/mtl/utility/static_assert.hpp> +#include <boost/numeric/mtl/operation/sfunctor.hpp> + +namespace mtl { namespace vector { + +template <typename E1, typename E2> +inline vec_vec_pmop_expr< E1, E2, mtl::sfunctor::minus<typename E1::value_type, typename E2::value_type> > +operator- (const vec_expr<E1>& e1, const vec_expr<E2>& e2) +{ + // do not subtract row and column vectors (or inconsistent value types) + MTL_STATIC_ASSERT((boost::is_same<typename ashape::ashape<E1>::type, + typename ashape::ashape<E1>::type>::value), + "Vectors do not have consistent algebraic shape (i.e. nested types)."); + typedef vec_vec_pmop_expr< E1, E2, mtl::sfunctor::minus<typename E1::value_type, typename E2::value_type> > type; + return type(static_cast<const E1&>(e1), static_cast<const E2&>(e2)); +} + +} } // Namespace mtl::vector + +#endif + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_op_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_op_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..1317fa44de8799745a0eaf7f48dc0afa958f5dae --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_op_expr.hpp @@ -0,0 +1,89 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +// Adapted from GLAS implementation by Karl Meerbergen and Toon Knappen + + +#ifndef MTL_VEC_VEC_OP_EXPR_INCLUDE +#define MTL_VEC_VEC_OP_EXPR_INCLUDE + +#include <boost/numeric/mtl/vector/vec_expr.hpp> + +namespace mtl { namespace vector { + +// Model of VectorExpression +template <typename E1, typename E2, typename SFunctor> +struct vec_vec_op_expr + : public vec_expr< vec_vec_op_expr<E1, E2, SFunctor> > +{ + typedef vec_expr< vec_vec_op_expr<E1, E2, SFunctor> > expr_base; + typedef vec_vec_op_expr self; + + // temporary solution + // typedef typename E1::value_type value_type; + // typedef typename glas::value< glas::scalar::vec_vec_op_expr<typename E1::value_type, typename E2::value_type > >::type value_type ; + typedef typename SFunctor::result_type value_type; + + // temporary solution + typedef typename E1::size_type size_type; + //typedef typename utilities::smallest< typename E1::size_type, typename E2::size_type >::type size_type ; + + typedef value_type const_dereference_type ; + + typedef E1 first_argument_type ; + typedef E2 second_argument_type ; + +public: + vec_vec_op_expr( first_argument_type const& v1, second_argument_type const& v2 ) + : first( v1 ), second( v2 ) + { + // std::cerr << "vec_vec_op_expr.vec_vec_op_expr() " << size(first) << " " << size(second) << "\n"; + first.delay_assign(); + second.delay_assign(); + } + + void delay_assign() const {} + + template <typename EE1, typename EE2, typename SSFunctor> + friend std::size_t size(const vec_vec_op_expr<EE1, EE2, SSFunctor>& v); + + const_dereference_type operator() ( size_type i ) const + { + return SFunctor::apply( first( i ), second( i ) ) ; + } + + const_dereference_type operator[] ( size_type i ) const + { + return SFunctor::apply( first( i ), second( i ) ) ; + } + + private: + first_argument_type const& first ; + second_argument_type const& second ; +} ; // vec_vec_op_expr + + +template <typename E1, typename E2, typename SFunctor> +inline std::size_t size(const vec_vec_op_expr<E1, E2, SFunctor>& v) +{ + // std::cerr << "vec_vec_op_expr.size() " << first.size() << " " << second.size() << "\n"; + assert( size(v.first) == size(v.second) ) ; + return size(v.first) ; +} + + + +} } // Namespace mtl::vector + + +#endif + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_plus_asgn_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_plus_asgn_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..f149c7c2ef82d89fbba2f7d2d339fd8a343896f6 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_plus_asgn_expr.hpp @@ -0,0 +1,41 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +// Adapted from GLAS implementation by Karl Meerbergen and Toon Knappen + + +#ifndef MTL_VEC_VEC_PLUS_ASGN_EXPR_INCLUDE +#define MTL_VEC_VEC_PLUS_ASGN_EXPR_INCLUDE + +#include <boost/static_assert.hpp> + +#include <boost/numeric/mtl/vector/vec_vec_aop_expr.hpp> +#include <boost/numeric/mtl/utility/ashape.hpp> +#include <boost/numeric/mtl/operation/sfunctor.hpp> + +namespace mtl { namespace vector { + +// Model of VectorExpression +template <class E1, class E2> +struct vec_vec_plus_asgn_expr + : public vec_vec_aop_expr< E1, E2, mtl::sfunctor::plus_assign<typename E1::value_type, typename E2::value_type> > +{ + typedef vec_vec_aop_expr< E1, E2, mtl::sfunctor::plus_assign<typename E1::value_type, typename E2::value_type> > base; + vec_vec_plus_asgn_expr( E1& v1, E2 const& v2 ) + : base( v1, v2 ) + {} +}; + +} } // Namespace mtl::vector + +#endif + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_plus_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_plus_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..c5a8f01d5bf79e1ea33f7a35969fd80e8dc2fd49 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_plus_expr.hpp @@ -0,0 +1,41 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +// Adapted from GLAS implementation by Karl Meerbergen and Toon Knappen + + +#ifndef MTL_VEC_VEC_PLUS_EXPR_INCLUDE +#define MTL_VEC_VEC_PLUS_EXPR_INCLUDE + +#include <boost/numeric/mtl/vector/vec_vec_pmop_expr.hpp> +#include <boost/numeric/mtl/utility/ashape.hpp> +#include <boost/numeric/mtl/utility/static_assert.hpp> +#include <boost/numeric/mtl/operation/sfunctor.hpp> + +namespace mtl { namespace vector { + +template <typename E1, typename E2> +inline vec_vec_pmop_expr< E1, E2, mtl::sfunctor::plus<typename E1::value_type, typename E2::value_type> > +operator+ (const vec_expr<E1>& e1, const vec_expr<E2>& e2) +{ + // do not add row and column vectors (or inconsistent value types) + MTL_STATIC_ASSERT((boost::is_same<typename ashape::ashape<E1>::type, + typename ashape::ashape<E2>::type>::value), + "Vectors do not have consistent algebraic shape (i.e. nested types)."); + typedef vec_vec_pmop_expr< E1, E2, mtl::sfunctor::plus<typename E1::value_type, typename E2::value_type> > type; + return type(static_cast<const E1&>(e1), static_cast<const E2&>(e2)); +} + +} } // Namespace mtl::vector + +#endif + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_pmop_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_pmop_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..19dd992816212ceb84893cbc1abbde1395963802 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_pmop_expr.hpp @@ -0,0 +1,88 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_VECTOR_VEC_VEC_PMOP_EXPR_INCLUDE +#define MTL_VECTOR_VEC_VEC_PMOP_EXPR_INCLUDE + +#include <boost/numeric/mtl/mtl_fwd.hpp> +#include <boost/numeric/mtl/concept/collection.hpp> +#include <boost/numeric/mtl/vector/vec_expr.hpp> +#include <boost/numeric/mtl/operation/compute_summand.hpp> +#include <boost/numeric/mtl/utility/exception.hpp> + +namespace mtl { namespace vector { + +// Model of VectorExpression +template <class E1, class E2, typename SFunctor> +struct vec_vec_pmop_expr + : vec_expr< vec_vec_pmop_expr<E1, E2, SFunctor> > +{ + typedef vec_vec_pmop_expr<E1, E2, SFunctor> self; + typedef typename mtl::operation::compute_summand<E1>::type first_argument_type; + typedef typename mtl::operation::compute_summand<E2>::type second_argument_type; + typedef SFunctor functor_type; + + typedef typename SFunctor::result_type const_dereference_type; + + typedef const_dereference_type value_type; + typedef typename Collection<first_argument_type>::size_type size_type; + + vec_vec_pmop_expr( E1 const& v1, E2 const& v2 ) + : first(v1), second(v2) + { + first.value.delay_assign(); second.value.delay_assign(); + } + + void delay_assign() const {} + +#if 0 + friend size_type inline size(const self& x) + { + assert( size(x.first.value) == 0 || size(x.first.value) == size(x.second.value) ); + return size(x.first.value); + } +#endif + + template <typename EE1, typename EE2, typename SSFunctor> + friend std::size_t size(const vec_vec_pmop_expr<EE1, EE2, SSFunctor>&); + + const_dereference_type operator() (size_type i) const + { + return SFunctor::apply(first.value(i), second.value(i)); + } + + const_dereference_type operator[] (size_type i) const + { + return SFunctor::apply(first.value(i), second.value(i)); + } + + operation::compute_summand<E1> const& first_argument() const { return first; } + operation::compute_summand<E2> const& second_argument() const { return second; } + + private: + operation::compute_summand<E1> first; + operation::compute_summand<E2> second; +}; + +template <typename E1, typename E2, typename SFunctor> +inline std::size_t size(const vec_vec_pmop_expr<E1, E2, SFunctor>& v) +{ + MTL_DEBUG_THROW_IF(mtl::vector::size(v.first.value) != 0 + && mtl::vector::size(v.first.value) != mtl::vector::size(v.second.value), incompatible_size()); + return mtl::vector::size(v.first.value); +} + + + +}} // namespace mtl::vector + +#endif // MTL_VECTOR_VEC_VEC_PMOP_EXPR_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_times_asgn_expr.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_times_asgn_expr.hpp new file mode 100644 index 0000000000000000000000000000000000000000..cb9651f7e840518923b19151e870785b979df063 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vector/vec_vec_times_asgn_expr.hpp @@ -0,0 +1,41 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +// Adapted from GLAS implementation by Karl Meerbergen and Toon Knappen + + +#ifndef MTL_VEC_VEC_TIMES_ASGN_EXPR_INCLUDE +#define MTL_VEC_VEC_TIMES_ASGN_EXPR_INCLUDE + +#include <boost/static_assert.hpp> + +#include <boost/numeric/mtl/vector/vec_vec_aop_expr.hpp> +#include <boost/numeric/mtl/utility/ashape.hpp> +#include <boost/numeric/mtl/operation/sfunctor.hpp> + +namespace mtl { namespace vector { + +// Model of VectorExpression +template <class E1, class E2> +struct vec_vec_times_asgn_expr + : public vec_vec_aop_expr< E1, E2, mtl::sfunctor::times_assign<typename E1::value_type, typename E2::value_type> > +{ + typedef vec_vec_aop_expr< E1, E2, mtl::sfunctor::times_assign<typename E1::value_type, typename E2::value_type> > base; + vec_vec_times_asgn_expr( E1& v1, E2 const& v2 ) + : base( v1, v2 ) + {} +}; + +} } // Namespace mtl::vector + +#endif + diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/vectors.hpp b/AMDiS/lib/mtl4/boost/numeric/mtl/vectors.hpp new file mode 100644 index 0000000000000000000000000000000000000000..b203cdd6a93f39ed5f96733e84a1a8030aa45073 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/vectors.hpp @@ -0,0 +1,32 @@ +// Software License for MTL +// +// Copyright (c) 2007 The Trustees of Indiana University. +// 2008 Dresden University of Technology and the Trustees of Indiana University. +// 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +// All rights reserved. +// Authors: Peter Gottschling and Andrew Lumsdaine +// +// This file is part of the Matrix Template Library +// +// See also license.mtl.txt in the distribution. + +#ifndef MTL_VECTORS_INCLUDE +#define MTL_VECTORS_INCLUDE + +#include <boost/numeric/mtl/vector/dense_vector.hpp> +#include <boost/numeric/mtl/vector/unit_vector.hpp> +#include <boost/numeric/mtl/vector/strided_vector_ref.hpp> +#include <boost/numeric/mtl/vector/parameter.hpp> +#include <boost/numeric/mtl/vector/inserter.hpp> +#include <boost/numeric/mtl/vector/mapped_inserter.hpp> +#include <boost/numeric/mtl/vector/extracter.hpp> + +#include <boost/numeric/mtl/vector/assigner.hpp> +#include <boost/numeric/mtl/vector/decrementer.hpp> +#include <boost/numeric/mtl/vector/incrementer.hpp> + +// To find operators +#include <boost/numeric/mtl/vector/vec_vec_minus_expr.hpp> +#include <boost/numeric/mtl/vector/vec_vec_plus_expr.hpp> + +#endif // MTL_VECTORS_INCLUDE diff --git a/AMDiS/lib/mtl4/boost/numeric/mtl/version.hpp.in b/AMDiS/lib/mtl4/boost/numeric/mtl/version.hpp.in new file mode 100644 index 0000000000000000000000000000000000000000..124862a9588f5bbfd02660ac9ddb4b5b94d5a456 --- /dev/null +++ b/AMDiS/lib/mtl4/boost/numeric/mtl/version.hpp.in @@ -0,0 +1,6 @@ +#ifndef MTL_VERSION_HPP +#define MTL_VERSION_HPP + +#define MTL_VERSION @CurrentRevision@ + +#endif diff --git a/AMDiS/lib/mtl4/tools/cmake/ARPREC.cmake b/AMDiS/lib/mtl4/tools/cmake/ARPREC.cmake new file mode 100644 index 0000000000000000000000000000000000000000..d18442272a1670c946b2adb115fa0ab3354751eb --- /dev/null +++ b/AMDiS/lib/mtl4/tools/cmake/ARPREC.cmake @@ -0,0 +1,9 @@ +find_file(MP_REAL_H "arprec/mp_real.h" PATHS $ENV{ARPREC_HEADER_HINT} DOC "The arprec header mp_real.h; you can provide the path of it in the environment variable ARPREC_HEADER_HINT.") +find_library(ARPREC_LIBRARY arprec PATHS $ENV{ARPREC_LIBRARY_HINT} DOC "the arprec library arprec; you can provide the path of it in the environment variable ARPREC_LIBRARY_HINT.") +set(HAVE_ARPREC false) +if(MP_REAL_H AND ARPREC_LIBRARY) + get_filename_component(ARPREC_INCLUDE_DIRS ${MP_REAL_H} PATH) + set(ARPREC_INCLUDE_DIRS "${ARPREC_INCLUDE_DIRS}/../") + set(HAVE_ARPREC true) + set(ARPREC_LIBRARIES ${ARPREC_LIBRARY}) +endif() diff --git a/AMDiS/lib/mtl4/tools/cmake/AUTO_CHECK.cpp b/AMDiS/lib/mtl4/tools/cmake/AUTO_CHECK.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fbc281df6a7250770bca75b551083946a8e2c427 --- /dev/null +++ b/AMDiS/lib/mtl4/tools/cmake/AUTO_CHECK.cpp @@ -0,0 +1,7 @@ + +int main() +{ + auto x= 8.3 - 7u; + + return 0; +} diff --git a/AMDiS/lib/mtl4/tools/cmake/C++11Features.cmake b/AMDiS/lib/mtl4/tools/cmake/C++11Features.cmake new file mode 100644 index 0000000000000000000000000000000000000000..5886aae836656477a153174b0a5fd26349462cd3 --- /dev/null +++ b/AMDiS/lib/mtl4/tools/cmake/C++11Features.cmake @@ -0,0 +1,49 @@ +include(CheckCXXCompilerFlag) + +# Compiler flag for C++11: special case for VC only, everything else should be equal +# Might need later adaption, once compilers don't support this flag any longer +if(MSVC) + set(CXX_ELEVEN_FLAG "/Qstd=c++0x") +else() + set(CXX_ELEVEN_FLAG "-std=c++0x") +endif() + +# only performed once (to reevaluated delete CMakeCache.txt) +check_cxx_compiler_flag("${CXX_ELEVEN_FLAG}" CXX_ELEVEN_FLAG_SUPPORTED) + +if (NOT CXX_ELEVEN_FLAG_SUPPORTED) + if (ENABLE_CXX_ELEVEN) + message("C++11 flag not supported by your compiler (probably too old).") + endif() + return() +endif() + +if (NOT ENABLE_CXX_ELEVEN) + return() +endif() + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set(CXX_ELEVEN_FLAG "${CXX_ELEVEN_FLAG} -stdlib=libc++") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lc++") +endif() + +message(STATUS "Add ${CXX_ELEVEN_FLAG}") +list(APPEND MTL_CXX_DEFINITIONS ${CXX_ELEVEN_FLAG}) +#add_definitions("${CXX_ELEVEN_FLAG}") + +set (CXX_ELEVEN_FEATURE_LIST "MOVE" "AUTO" "RANGEDFOR" "INITLIST" "STATICASSERT" "DEFAULTIMPL") + +foreach (feature ${CXX_ELEVEN_FEATURE_LIST}) + set(CURFILE "${MTL_DIR}/tools/cmake/${feature}_CHECK.cpp") + if(EXISTS "${CURFILE}") + try_compile(${feature}_RESULT ${CMAKE_BINARY_DIR} "${CURFILE}" COMPILE_DEFINITIONS "${CXX_ELEVEN_FLAG}") + else() + message(ERROR "could not find ${CURFILE}") + endif() + # try_compile(${feature}_RESULT . "./${feature}_CHECK.cpp") + message(STATUS "Support C++11's ${feature} - ${${feature}_RESULT}") + if (${feature}_RESULT) + list(APPEND MTL_CXX_DEFINITIONS "-DMTL_WITH_${feature}") + #add_definitions("-DMTL_WITH_${feature}") + endif() +endforeach() diff --git a/AMDiS/lib/mtl4/tools/cmake/DEFAULTIMPL_CHECK.cpp b/AMDiS/lib/mtl4/tools/cmake/DEFAULTIMPL_CHECK.cpp new file mode 100644 index 0000000000000000000000000000000000000000..587c6b6cadb6542c0ca1d2c40ed37d2d22bf13f9 --- /dev/null +++ b/AMDiS/lib/mtl4/tools/cmake/DEFAULTIMPL_CHECK.cpp @@ -0,0 +1,9 @@ +struct dings +{ + dings(const dings&) = default; +}; + +int main() +{ + return 0; +} diff --git a/AMDiS/lib/mtl4/tools/cmake/INITLIST_CHECK.cpp b/AMDiS/lib/mtl4/tools/cmake/INITLIST_CHECK.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4cbf89f1830dab7997f2029d96ce63f8a06a906c --- /dev/null +++ b/AMDiS/lib/mtl4/tools/cmake/INITLIST_CHECK.cpp @@ -0,0 +1,31 @@ +#include <initializer_list> + +struct ctor {}; + +template <typename V> +struct my_vector +{ + typedef my_vector<V> self; + + template <typename T> + my_vector(std::initializer_list<T> ls) + { + for (auto l : ls); + } + + my_vector(self&&) {} + my_vector(const self&) {} + my_vector(const self&, ctor) {} + + self& operator=(self&&) {} +}; + +int main() +{ + my_vector<double> v= {3, 4, 5}; + v= {4, 5, 6}; + + const my_vector<double> w= {3, 4, 5}; + + return 0; +} diff --git a/AMDiS/lib/mtl4/tools/cmake/MOVE_CHECK.cpp b/AMDiS/lib/mtl4/tools/cmake/MOVE_CHECK.cpp new file mode 100644 index 0000000000000000000000000000000000000000..73ea06d66d5d5b326d1d2f9faf83dc86e6c30a7c --- /dev/null +++ b/AMDiS/lib/mtl4/tools/cmake/MOVE_CHECK.cpp @@ -0,0 +1,9 @@ +struct dings +{ + dings(dings&&) {} +}; + +int main() +{ + return 0; +} diff --git a/AMDiS/lib/mtl4/tools/cmake/MTLCommon.cmake b/AMDiS/lib/mtl4/tools/cmake/MTLCommon.cmake new file mode 100644 index 0000000000000000000000000000000000000000..a02451f7ba7fb16681a2841a7ad14f01bbb5699b --- /dev/null +++ b/AMDiS/lib/mtl4/tools/cmake/MTLCommon.cmake @@ -0,0 +1,120 @@ +############################ +#This configuration file defines some cmake variables: +#MTL_INCLUDE_DIRS: list of include directories for the mtl +#MTL_LIBRARIES: libraries needed for interfaces like umfpack and arprec, see below +#MTL_COMPILE_DEFINITIONS: definitions to enable the requested interfaces +# +#supported components: +#Umfpack, Arprec + +option(ENABLE_OPENMP "switch on to enable OpenMP flags for mtl" OFF) +option(ENABLE_SHORT_ELE_PROD "enable short notation for element-wise product" OFF) +option(ENABLE_CXX_ELEVEN "enable C++11 features as far as compiler permits" ON) +option(USE_ASSERTS "Use assert instead of throwing exceptions" ON) + + +find_package(Boost 1.40 REQUIRED) +if(Boost_FOUND) + LIST(APPEND MTL_INCLUDE_DIRS ${Boost_INCLUDE_DIRS}) +endif(Boost_FOUND) + +include(${MTL_DIR}/tools/cmake/Vampir.cmake) +include(${MTL_DIR}/tools/cmake/UMFPACK.cmake) +include(${MTL_DIR}/tools/cmake/ARPREC.cmake) + +unset(MTL_LIBRARIES ) +unset(MTL_CXX_DEFINITIONS ) +unset(MTL_INCLUDE_DIRS ) + +if(NOT NO_CXX11_FEATURE_CHECK AND EXISTS ${MTL_DIR}/tools/cmake/C++11Features.cmake) + include(${MTL_DIR}/tools/cmake/C++11Features.cmake) +endif() + +if (USE_ASSERTS) + list(APPEND MTL_CXX_DEFINITIONS "-DMTL_ASSERT_FOR_THROW") +endif() + +if(HAVE_UMFPACK) + list(APPEND MTL_CXX_DEFINITIONS "-DMTL_HAS_UMFPACK") + include_directories(${UMFPACK_INCLUDE_DIRS}) + list(APPEND MTL_LIBRARIES ${UMFPACK_LIBRARIES}) +endif() +if(HAVE_ARPREC) + list(APPEND MTL_CXX_DEFINITIONS "-DMTL_HAS_ARPREC") + include_directories(${ARPREC_INCLUDE_DIRS}) + list(APPEND MTL_LIBRARIES ${ARPREC_LIBRARIES}) +endif() +if(EXISTS ${MTL_DIR}/boost/numeric/mtl/mtl.hpp) + list(APPEND MTL_INCLUDE_DIRS "${MTL_DIR}") +else() + list(APPEND MTL_INCLUDE_DIRS "${MTL_DIR}/../../include") +endif(EXISTS ${MTL_DIR}/boost/numeric/mtl/mtl.hpp) + +if(ENABLE_VAMPIR AND VAMPIR_FOUND) +#add_definitions("-DMTL_HAS_VPT -DVTRACE -vt:inst manual") + list(APPEND MTL_CXX_DEFINITIONS "-DMTL_HAS_VPT" "-DVTRACE") + list(APPEND MTL_CXX_DEFINITIONS ${VT_COMPILE_FLAGS}) + set(MTL_LINK_FLAGS "${MTL_LINK_FLAGS} ${VT_LINK_FLAGS}") + if(EXISTS ${MTL_DIR}/boost/numeric/mtl/interface/vpt.cpp) + set(VAMPIR_SRC ${MTL_DIR}/boost/numeric/mtl/interface/vpt.cpp) + else() + set(VAMPIR_SRC ${MTL_DIR}/vpt.cpp) + endif() + get_target_property(MTL_VAMPIR_ADDED mtl_vampir TYPE) + if(NOT MTL_VAMPIR_ADDED) + add_library(mtl_vampir ${VAMPIR_SRC}) + endif() + list(APPEND MTL_LIBRARIES ${VT_LIBRARIES} mtl_vampir) + set(HAVE_VAMPIR TRUE) +else() + set(HAVE_VAMPIR FALSE) +endif(ENABLE_VAMPIR AND VAMPIR_FOUND) + +if(ENABLE_OPENMP ) + find_package(OpenMP REQUIRED) + if(OPENMP_FOUND) + list(APPEND MTL_CXX_DEFINITIONS "-DMTL_WITH_OPENMP") + list(APPEND MTL_CXX_DEFINITIONS ${OpenMP_CXX_FLAGS}) + list(APPEND MTL_LIBRARIES ${OpenMP_CXX_FLAGS}) + else() + message(FATAL_ERROR "OpenMP not found") + endif() +endif() +#message("find components: ${MTL_FIND_COMPONENTS}") +#we found nothing.. +set(MTL_NOT_FOUND ) +#remove? +foreach(CURCOMP ${MTL_FIND_COMPONENTS}) +#look for a file called COMPONENT.cmake in the mtl-directory (/usr/share/mtl/) + string(TOUPPER ${CURCOMP} CURCOMP_UPPER) + set(curfile "${MTL_DIR}/tools/cmake/${CURCOMP_UPPER}.cmake") + if(EXISTS ${curfile}) + include(${curfile}) + #look for component + #check if the component was correctly found + if(HAVE_${CURCOMP_UPPER}) + list(APPEND MTL_INCLUDE_DIRS ${${CURCOMP_UPPER}_INCLUDE_DIRS}) + list(APPEND MTL_LIBRARIES ${${CURCOMP_UPPER}_LIBRARIES}) + list(APPEND MTL_CXX_DEFINITIONS "-DMTL_HAS_${CURCOMP_UPPER}") + else() + list(APPEND MTL_NOT_FOUND ${CURCOMP}) + endif() + else() + list(APPEND MTL_NOT_FOUND ${CURCOMP}) + endif() +endforeach() + +if(MTL_FIND_REQUIRED AND MTL_NOT_FOUND) + message(SEND_ERROR "could not find all components: ${MTL_NOT_FOUND}") +endif() +#include_directories(${MTL_INCLUDE_DIRS}) + +macro(mtl_check_cxx_compiler_flag FLAG RESULT) + # counts entirely on compiler's return code, maybe better to combine it with check_cxx_compiler_flag + file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx" "int main() { return 0;}\n") + try_compile(${RESULT} + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx + COMPILE_DEFINITIONS ${FLAG}) +endmacro() + diff --git a/AMDiS/lib/mtl4/tools/cmake/RANGEDFOR_CHECK.cpp b/AMDiS/lib/mtl4/tools/cmake/RANGEDFOR_CHECK.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b82def0b738a56689a33c139ee2d0a5b8c4e125b --- /dev/null +++ b/AMDiS/lib/mtl4/tools/cmake/RANGEDFOR_CHECK.cpp @@ -0,0 +1,12 @@ +// #include <iostream> + +int main() +{ + int array[]= {3, 7, 9, 4}; + + int s= 0; + for (int i : array) + s+= i; + // std::cout << "s = " << s << '\n'; + return 0; +} diff --git a/AMDiS/lib/mtl4/tools/cmake/STATICASSERT_CHECK.cpp b/AMDiS/lib/mtl4/tools/cmake/STATICASSERT_CHECK.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a995698696e10a6bf794584d9c61bb76f21e3b4a --- /dev/null +++ b/AMDiS/lib/mtl4/tools/cmake/STATICASSERT_CHECK.cpp @@ -0,0 +1,6 @@ + +int main() +{ + static_assert(sizeof(int) > 1, "int too small"); + return 0; +} diff --git a/AMDiS/lib/mtl4/tools/cmake/UMFPACK.cmake b/AMDiS/lib/mtl4/tools/cmake/UMFPACK.cmake new file mode 100644 index 0000000000000000000000000000000000000000..1341ff22a6f067dd88b5ee9f5b3fd9f44d09680a --- /dev/null +++ b/AMDiS/lib/mtl4/tools/cmake/UMFPACK.cmake @@ -0,0 +1,12 @@ +find_file(UMFPACK_H umfpack.h) +find_library(UMFPACK_LIBRARY umfpack) +set(HAVE_UMFPACK false) +if(UMFPACK_H AND UMFPACK_LIBRARY) + get_filename_component(UMFPACK_INCLUDE_DIRS ${UMFPACK_H} PATH) + find_library(AMD_LIBRARY amd) + find_library(BLAS_LIBRARY blas) + if(AMD_LIBRARY AND BLAS_LIBRARY) + set(UMFPACK_LIBRARIES "${UMFPACK_LIBRARY};${AMD_LIBRARY};${BLAS_LIBRARY}") + set(HAVE_UMFPACK true) + endif() +endif() diff --git a/AMDiS/lib/mtl4/tools/cmake/Vampir.cmake b/AMDiS/lib/mtl4/tools/cmake/Vampir.cmake new file mode 100644 index 0000000000000000000000000000000000000000..785a339c821f9cf6cba2398a1c3512495c4d0a75 --- /dev/null +++ b/AMDiS/lib/mtl4/tools/cmake/Vampir.cmake @@ -0,0 +1,150 @@ +find_program(VAMPIR_CXX vtc++) +option(ENABLE_VAMPIR "enable or disable vampir trace" OFF) +if(VAMPIR_CXX) + #function to compute the compile flags, libraries, linker directories and linker flags used by the vampir compiler + #cflags: name of the global variable which will contain the compilerflags + #libs: name of the global variable which will contain the libraries + #ldirs: name of the global variable which will contain the linker directories + #lflags: name of the global variable which will contain the linker flags + #addArgs: additional arguments passed to the vampir compiler + function(GetVampirData cflags libs ldirs lflags _addArgs) + set(addArgs "${${_addArgs}}") + #request only compile arguments + execute_process(COMMAND ${VAMPIR_CXX} "-vt:show" "-vt:inst" "manual" ${addArgs} "-c" RESULT_VARIABLE VT_RES OUTPUT_VARIABLE VT_OUT) + #message("vt_res: ${VT_RES}") + #message("vt_out: ${VT_OUT}") + string(REPLACE " " ";" asList ${VT_OUT} ) + list(LENGTH asList length) + #message("asList: ${asList}") + #message("length: ${length}") + list(GET asList 0 VT_COMPILER) + #remove the compiler + list(REMOVE_AT asList 0) + #add each flag except the last to the vampir compile flags + while(length GREATER 1) + list(GET asList 0 CURFLAG) + #save the results in internal variable + list(APPEND _VT_COMPILE_FLAGS ${CURFLAG}) + list(REMOVE_AT asList 0) + list(LENGTH asList length) + endwhile() + #message("asList: ${asList}") + #request all other flags + execute_process(COMMAND ${VAMPIR_CXX} "-vt:show" "-vt:inst" "manual" ${addArgs} RESULT_VARIABLE VT_RES OUTPUT_VARIABLE VT_OUT) + string(REPLACE " " ";" asList ${VT_OUT} ) + list(LENGTH asList length) + #remove the compiler + list(REMOVE_AT asList 0) + while(length GREATER 1) + list(GET asList 0 CURFLAG) + #if the current flag is not a compile flag, add it + list(FIND _VT_COMPILE_FLAGS ${CURFLAG} ISCOMPILEFLAG) + #message("iscompileflag: ${ISCOMPILEFLAG}") + if(ISCOMPILEFLAG EQUAL -1) + string(SUBSTRING "${CURFLAG}" 0 2 FLAGBEG) + + string(REGEX MATCHALL "-L([^\" ]+|\"[^\"]+\")" CURLINKDIR "${CURFLAG}") + set(CURLINKDIR ${CMAKE_MATCH_1}) + if(CURLINKDIR) + list(APPEND _VT_LINKER_DIRECTORIES ${CURLINKDIR}) + endif() + #save the results in internal variable + #list(APPEND _VT_LINKER_DIRECTORIES ${CURLINKDIR}) + + string(REGEX MATCHALL "-l([^\" ]+|\"[^\"]+\")" CURLIBRARY "${CURFLAG}") + set(CURLIBRARY ${CMAKE_MATCH_1}) + if(CURLIBRARY) + list(APPEND _VT_LIBRARIES ${CURLIBRARY}) + endif() + #save the results in internal variable + #list(APPEND _VT_LIBRARIES ${CURLIBRARY}) + #set(_VT_LINK_FLAGS "${_VT_LINK_FLAGS} ${CURFLAG}") + if(NOT (CURLIBRARY OR CURLINKDIR)) + set(VT_LINK_FLAGS "${VT_LINK_FLAGS} ${CURFLAG}") + endif() + + endif() + list(REMOVE_AT asList 0) + list(LENGTH asList length) + endwhile() + #propagate the values to parent scope + set(${cflags} ${_VT_COMPILE_FLAGS} PARENT_SCOPE) + set(${libs} ${_VT_LIBRARIES} PARENT_SCOPE) + set(${ldirs} ${_VT_LINKER_DIRECTORIES} PARENT_SCOPE) + set(${lflags} "${_VT_LINK_FLAGS}" PARENT_SCOPE) + endfunction() + set(VAMPIR_FOUND TRUE) + #request only compile arguments +# execute_process(COMMAND ${VAMPIR_CXX} "-vt:show" "-vt:mt" "-vt:noopari" "-vt:inst" "manual" "-c" RESULT_VARIABLE VT_RES OUTPUT_VARIABLE VT_OUT) +# string(REPLACE " " ";" asList ${VT_OUT} ) +# list(LENGTH asList length) +# list(GET asList 0 VT_COMPILER) + #remove the compiler +# list(REMOVE_AT asList 0) + #add each flag except the last to the vampir compile flags +# set(VT_COMPILE_FLAGS ) +# while(length GREATER 1) +# list(GET asList 0 CURFLAG) +# list(APPEND VT_COMPILE_FLAGS ${CURFLAG}) +# list(REMOVE_AT asList 0) +# list(LENGTH asList length) +# endwhile() + #request all other flags +# execute_process(COMMAND ${VAMPIR_CXX} "-vt:show" "-vt:mt" "-vt:noopari" "-vt:inst" "manual" RESULT_VARIABLE VT_RES OUTPUT_VARIABLE VT_OUT) +# string(REPLACE " " ";" asList ${VT_OUT} ) +# list(LENGTH asList length) + #remove the compiler +# list(REMOVE_AT asList 0) +# set(VT_LIBRARIES ) +# set(VT_LINKER_DIRECTORIES ) +# set(VT_LINK_FLAGS "") +# while(length GREATER 1) +# list(GET asList 0 CURFLAG) + #if the current flag is not a compile flag, add it +# list(FIND VT_COMPILE_FLAGS ${CURFLAG} ISCOMPILEFLAG) +# if(ISCOMPILEFLAG EQUAL -1) +# string(SUBSTRING "${CURFLAG}" 0 2 FLAGBEG) + +# string(REGEX MATCHALL "-L([^\" ]+|\"[^\"]+\")" CURLINKDIR "${CURFLAG}") +# set(CURLINKDIR ${CMAKE_MATCH_1}) +# if(CURLINKDIR) +# list(APPEND VT_LINKER_DIRECTORIES ${CURLINKDIR}) +# endif() + +# string(REGEX MATCHALL "-l([^\" ]+|\"[^\"]+\")" CURLIBRARY "${CURFLAG}") +# set(CURLIBRARY ${CMAKE_MATCH_1}) +# if(CURLIBRARY) +# list(APPEND VT_LIBRARIES_REL ${CURLIBRARY}) +# endif() + +# if(NOT (CURLIBRARY OR CURLINKDIR)) +# set(VT_LINK_FLAGS "${VT_LINK_FLAGS} ${CURFLAG}") +# endif() +# endif() +# list(REMOVE_AT asList 0) +# list(LENGTH asList length) +# endwhile() + +set(_ADD_VT_FLAGS "") +if(ENABLE_OPENMP) + set(_ADD_VT_FLAGS "${VT_FLGAS};-vt:mt;-vt:noopari") +endif(ENABLE_OPENMP) +GetVampirData(VT_COMPILE_FLAGS VT_LIBRARIES_REL VT_LINKER_DIRECTORIES VT_LINK_FLAGS _ADD_VT_FLAGS) + +#look for fullpath of vampir libraries +foreach(curLib IN LISTS VT_LIBRARIES_REL) + find_library(CURRELLIB_${curLib} ${curLib} PATHS ${VT_LINKER_DIRECTORIES} NO_DEFAULT_PATH) + if(CURRELLIB_${curLib}) + list(APPEND VT_LIBRARIES ${CURRELLIB_${curLib}}) + else() + list(APPEND VT_LIBRARIES ${curLib}) + endif() +endforeach() +#message("vt_compiler: ${VT_COMPILER}") +#message("vt_compiler flags: ${VT_COMPILE_FLAGS}") +#message("vt_linker flags: ${VT_LINK_FLAGS}") +#message("vt_linker directories: ${VT_LINKER_DIRECTORIES}") +#message("vt_linker libraries: ${VT_LIBRARIES}") +else(VAMPIR_CXX) + set(VAMPIR_FOUND FALSE) +endif() diff --git a/AMDiS/lib/mtl4/tools/cmake/dokumentation.odt b/AMDiS/lib/mtl4/tools/cmake/dokumentation.odt new file mode 100644 index 0000000000000000000000000000000000000000..c5b6444269874dfca0b40067f792ec8ec6979697 Binary files /dev/null and b/AMDiS/lib/mtl4/tools/cmake/dokumentation.odt differ diff --git a/AMDiS/lib/mtl4/tools/doxygen/mtl_doxygen b/AMDiS/lib/mtl4/tools/doxygen/mtl_doxygen new file mode 100755 index 0000000000000000000000000000000000000000..85695ab3efe1ae690d2a21d1bfb39cba522cc887 --- /dev/null +++ b/AMDiS/lib/mtl4/tools/doxygen/mtl_doxygen @@ -0,0 +1,7 @@ +#!/bin/sh +cd libs/numeric/mtl/examples +./update_footer +cd ../../../.. + +doxygen +svn revert libs/numeric/mtl/examples/doxygen_footer.html # to avoid conflicts later diff --git a/AMDiS/lib/mtl4/tools/eclipse/mtl4_profile.xml b/AMDiS/lib/mtl4/tools/eclipse/mtl4_profile.xml new file mode 100644 index 0000000000000000000000000000000000000000..0eeb234795ffd2ee80385cfa80fc9919a1727a5c --- /dev/null +++ b/AMDiS/lib/mtl4/tools/eclipse/mtl4_profile.xml @@ -0,0 +1,166 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<profiles version="1"> +<profile kind="CodeFormatterProfile" name="MTL" version="1"> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_new_line_in_empty_block" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.lineSplit" value="140"/> +<setting id="org.eclipse.cdt.core.formatter.alignment_for_member_access" value="2"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_base_types" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.keep_else_statement_on_same_line" value="false"/> +<setting id="org.eclipse.cdt.core.formatter.alignment_for_constructor_initializer_list" value="36"/> +<setting id="org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_exception_specification" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_base_types" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_access_specifier" value="true"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_exception_specification" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_template_arguments" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_colon_in_case" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.comment.min_distance_between_code_and_line_comment" value="1"/> +<setting id="org.eclipse.cdt.core.formatter.alignment_for_expressions_in_array_initializer" value="18"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_declarator_list" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_bracket" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.tabulation.size" value="4"/> +<setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.alignment_for_enumerator_list" value="16"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.alignment_for_declarator_list" value="16"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.indent_empty_lines" value="false"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.put_empty_statement_on_new_line" value="true"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.brace_position_for_method_declaration" value="next_line"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_semicolon" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_closing_angle_bracket_in_template_arguments" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_colon_in_base_clause" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.indent_breaks_compare_to_cases" value="true"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_declarator_list" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.join_wrapped_lines" value="false"/> +<setting id="org.eclipse.cdt.core.formatter.alignment_for_arguments_in_method_invocation" value="18"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_bracket" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_between_empty_brackets" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/> +<setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/> +<setting id="org.eclipse.cdt.core.formatter.brace_position_for_block" value="end_of_line"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_assignment_operator" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.brace_position_for_type_declaration" value="next_line"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_expression_list" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_template_arguments" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_template_parameters" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.continuation_indentation" value="2"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.alignment_for_expression_list" value="0"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_template_parameters" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_binary_operator" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.alignment_for_conditional_expression" value="2"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.format_guardian_clause_on_one_line" value="false"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.indent_access_specifier_extra_spaces" value="0"/> +<setting id="org.eclipse.cdt.core.formatter.indent_access_specifier_compare_to_type_header" value="false"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_namespace_header" value="true"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_assignment_operator" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.alignment_for_compact_if" value="16"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.alignment_for_assignment" value="18"/> +<setting id="org.eclipse.cdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_template_parameters" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.alignment_for_conditional_expression_chain" value="18"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_expression_list" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_exception_specification" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_binary_operator" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.alignment_for_base_clause_in_type_declaration" value="36"/> +<setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_identifier_in_function_declaration" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.indent_declaration_compare_to_template_header" value="false"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_exception_specification" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.indent_statements_compare_to_body" value="true"/> +<setting id="org.eclipse.cdt.core.formatter.alignment_for_binary_expression" value="18"/> +<setting id="org.eclipse.cdt.core.formatter.indent_statements_compare_to_block" value="true"/> +<setting id="org.eclipse.cdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/> +<setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_template_arguments" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_template_parameters" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.tabulation.char" value="space"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_template_parameters" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_colon_in_constructor_initializer_list" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.compact_else_if" value="true"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_colon_in_base_clause" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_new_line_after_template_declaration" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.keep_then_statement_on_same_line" value="false"/> +<setting id="org.eclipse.cdt.core.formatter.brace_position_for_switch" value="end_of_line"/> +<setting id="org.eclipse.cdt.core.formatter.alignment_for_overloaded_left_shift_chain" value="18"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.indentation.size" value="4"/> +<setting id="org.eclipse.cdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.keep_imple_if_on_one_line" value="false"/> +<setting id="org.eclipse.cdt.core.formatter.brace_position_for_namespace_declaration" value="next_line"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_template_arguments" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_namespace_declaration" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_bracket" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_closing_angle_bracket_in_template_parameters" value="insert"/> +<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_template_arguments" value="do not insert"/> +</profile> +</profiles> diff --git a/AMDiS/lib/mtl4/tools/license/insert_license.py b/AMDiS/lib/mtl4/tools/license/insert_license.py new file mode 100755 index 0000000000000000000000000000000000000000..0c05cf59d932661ab10bd2a1ec23479ae062e5a2 --- /dev/null +++ b/AMDiS/lib/mtl4/tools/license/insert_license.py @@ -0,0 +1,89 @@ +#!/usr/bin/env python +import os, os.path, shutil, sys, re, fileinput + +if len(sys.argv) < 2: + print "syntax:", sys.argv[0], "licensefile [filepattern] .." + sys.exit(1) + +# replace some patterns or wildcard for all files +if len(sys.argv) == 2: + filepatterns= ["^.*$"] +else: + filepatterns= [] + for i in range(2, len(sys.argv)): + if sys.argv[i] == "cpppattern": + filepatterns.append("^\w*\..pp$|^\w*\.cc") + elif sys.argv[i] == "cpattern": + filepatterns.append("^\w*\.h$|^\w*\.c$") + elif sys.argv[i] == "scriptpattern": + filepatterns.append("^\w*\.csh$|^\w*\.tcsh$|^\w*\.sh$|^\w*\.bash$") + else: + filepatterns.append(sys.argv[i]) + + +# read files of dir without stopping on empty dirs +def myFiles(): + files= [] + try: + files= os.listdir(".") + except OSError: + pass # ignore No such file Error + return files + +# filter list of files w.r.t. list of patterns +# if filepattern isn't a list it sort a weird error message +def filterFiles(files, filepatterns): + #print files, filepatterns + return filter(lambda s : reduce (lambda x,y: x or y, + map (lambda i : re.search(i, s), filepatterns)), files) + +def dirs(files): + return filter(lambda f : os.path.isdir(f), files) + +def regfiles(files): + return filter(lambda f : os.path.isfile(f), files) + +def recFilterFiles( dir, path, filepatterns ) : + olddir= os.getcwd() + os.chdir(dir) + files= myFiles() + myAbsFiles= map (lambda f : os.path.join(path, f), filterFiles(regfiles(files), filepatterns)) + # print "in", path, "matches", myAbsFiles + for d in dirs(files) : + if not re.search( "^\.svn$|^CVS$", d ) : # filter out svn and CVS dirs + myAbsFiles.extend( recFilterFiles( d, os.path.join(path, d), filepatterns ) ) + os.chdir(olddir) + return myAbsFiles + +def allFiles(filepatterns = ["^.*$"]): + return recFilterFiles(".", "", filepatterns) + +allMyFiles= allFiles(filepatterns) + + +def insertCopyright(licName, files) : + for fname in files : + fcopyname= fname + ".new" + fcopy= open(fcopyname, "w") + f= open(fname) + for l in f : + match= re.search("^(.*)\$COPYRIGHT\$", l) + if match : + comment= match.group(1) + fLic= open(licName) + # now copy license as comment + for lLic in fLic : + fcopy.write(comment + lLic) + fLic.close() + # copy rest of file 1 to 1 + for ll in f : + fcopy.write(ll) + else: + # before match copy 1 to 1 + fcopy.write(l) + f.close() + fcopy.close() + os.remove(fname) + os.rename(fcopyname, fname) + +insertCopyright(sys.argv[1], allMyFiles) diff --git a/AMDiS/lib/mtl4/tools/license/license.mtl.txt b/AMDiS/lib/mtl4/tools/license/license.mtl.txt new file mode 100644 index 0000000000000000000000000000000000000000..ead095a7c9fb0a748066404cfde7315641696201 --- /dev/null +++ b/AMDiS/lib/mtl4/tools/license/license.mtl.txt @@ -0,0 +1,53 @@ +Software License for MTL + +Copyright (c) 2007 The Trustees of Indiana University. + 2008 Dresden University of Technology and the Trustees of Indiana University. + 2010 SimuNova UG (haftungsbeschränkt), www.simunova.com. +All rights reserved. +Authors: Peter Gottschling and Andrew Lumsdaine + +This file is part of the Matrix Template Library + +Dresden University of Technology -- short TUD -- and Indiana University -- short IU -- +have the exclusive rights to license this product under the following license. + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + 1. All redistributions of source code must retain the above copyright notice, + the list of authors in the original source code, this list of conditions and + the disclaimer listed in this license; + 2. All redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the disclaimer listed in this license in the + documentation and/or other materials provided with the distribution; + 3. Any documentation included with all redistributions must include the + following acknowledgement: + "This product includes software developed at the University of Notre Dame, + the Pervasive Technology Labs at Indiana University, and Dresden University of + Technology. For technical information + contact Andrew Lumsdaine at the Pervasive Technology Labs at Indiana University. + For administrative and license questions contact the Advanced Research and + Technology Institute at 1100 Waterway Blvd. Indianapolis, Indiana 46202, + phone 317-274-5905, fax 317-274-5902." + Alternatively, this acknowledgement may appear in the software itself, and + wherever such third-party acknowledgments normally appear. + 4. The name "MTL" shall not be used to endorse or promote products derived from + this software without prior written permission from IU or TUD. For + written permission, please contact Indiana University Advanced Research + & Technology Institute. + 5. Products derived from this software may not be called "MTL", nor may "MTL" + appear in their name, without prior written permission of Indiana University + Advanced Research & Technology Institute. + +TUD and IU provide no reassurances that the source code provided does not infringe the +patent or any other intellectual property rights of any other entity. TUD and IU disclaim +any liability to any recipient for claims brought by any other entity based on infringement of +intellectual property rights or otherwise. + +LICENSEE UNDERSTANDS THAT SOFTWARE IS PROVIDED "AS IS" FOR WHICH NO WARRANTIES AS TO CAPABILITIES +OR ACCURACY ARE MADE. DRESDEN UNIVERSITY OF TECHNOLOGY AND INDIANA UNIVERSITY GIVE NO WARRANTIES +AND MAKE NO REPRESENTATION THAT SOFTWARE IS FREE OF INFRINGEMENT OF THIRD PARTY PATENT, COPYRIGHT, +OR OTHER PROPRIETARY RIGHTS. DRESDEN UNIVERSITY OF TECHNOLOGY AND INDIANA UNIVERSITY MAKE NO +WARRANTIES THAT SOFTWARE IS FREE FROM "BUGS", "VIRUSES", "TROJAN HORSES", "TRAP DOORS", "WORMS", +OR OTHER HARMFUL CODE. LICENSEE ASSUMES THE ENTIRE RISK AS TO THE PERFORMANCE OF SOFTWARE AND/OR +ASSOCIATED MATERIALS, AND TO THE PERFORMANCE AND VALIDITY OF INFORMATION GENERATED USING SOFTWARE. + diff --git a/AMDiS/lib/mtl4/tools/license/license.short.txt b/AMDiS/lib/mtl4/tools/license/license.short.txt new file mode 100644 index 0000000000000000000000000000000000000000..a9747439e67f451454a351a006d20e46bd3d7a19 --- /dev/null +++ b/AMDiS/lib/mtl4/tools/license/license.short.txt @@ -0,0 +1,11 @@ +Software License for MTL + +Copyright (c) 2007 The Trustees of Indiana University. + 2008 Dresden University of Technology and the Trustees of Indiana University. + 2010 SimuNova UG, www.simunova.com. +All rights reserved. +Authors: Peter Gottschling and Andrew Lumsdaine + +This file is part of the Matrix Template Library + +See also tools/license/license.mtl.txt in the distribution. diff --git a/AMDiS/lib/mtl4/tools/vampir/make_vampir_groups.py b/AMDiS/lib/mtl4/tools/vampir/make_vampir_groups.py new file mode 100755 index 0000000000000000000000000000000000000000..59fd7453398cca67b00748634f1db6d5d4bf7c86 --- /dev/null +++ b/AMDiS/lib/mtl4/tools/vampir/make_vampir_groups.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python +import re + +vptfile= open("../../boost/numeric/mtl/interface/vpt.cpp") +groupfile= open("vampir_groups.dat", "w") + +group_names=['mtl_utilities', 'mtl_fsize', 'mtl_vector', 'mtl_vecmat', 'mtl_matrix', 'mtl_factor', 'mtl_fused', 'mtl_solver', 'mtl_mg', 'mtl_app'] +groups=[[],[],[],[],[],[],[],[],[],[]] +assert len(group_names) == len(groups) + +pat= re.compile('template <> std::string vampir_trace<(\d+)>::name\("(.*)"\);') + +for s in vptfile.readlines() : + mm= pat.search(s) + if mm and mm.group(2): + groups[int(mm.group(1))/1000].append(mm.group(2)) + +for i in range(len(groups)): + if group_names[i]: + groupfile.write(group_names[i]+"="+";".join(groups[i])+'\n') +groupfile.close() diff --git a/AMDiS/lib/mtl4/tools/vampir/vampir_groups.dat b/AMDiS/lib/mtl4/tools/vampir/vampir_groups.dat new file mode 100644 index 0000000000000000000000000000000000000000..7fdd8a24571e6f48b2165ba41aa33a17a804b00f --- /dev/null +++ b/AMDiS/lib/mtl4/tools/vampir/vampir_groups.dat @@ -0,0 +1,10 @@ +mtl_utilities=copysign;Elem_raw_copy;Get_real_part;Info_contruct_vector;right_scale_inplace;sign_real_part_of_complex;unrolling_expresion;squared_abs_magnitudes;squared_abs_complex;squared_abs_magnitudes_template;update_store;update_plus;update_minus;update_times;update_adapter;update_proxy_<<;update_proxy_=;update_proxy_+=;sfunctor::plus;sfunctor::minus;sfunctor::times;sfunctor::divide;sfunctor::assign;sfunctor::plus_assign;sfunctor::minus_assign;sfunctor::times_assign;sfunctor::divide_assign;sfunctor::identity;sfunctor::abs;sfunctor::sqrt;sfunctor::square;sfunctor::negate;sfunctor::compose;sfunctor::compose_first;sfunctor::compose_second;sfunctor::compose_both;sfunctor::compose_binary;Vector_swapped_row +mtl_fsize=stat_vec_expr;fsize_dmat_dmat_mult;vector_size_static;static_dispatch;copy_blocks_forward;copy_blocks_backward;Static_Size;fsize_mat_vect_mult +mtl_vector=gen_vector_copy;cross;dot;householder;householder_s;vector::infinity_norm;vector::look_at_each_nonzero;vector::look_at_each_nonzero_pos;vector::reduction;vector::max;vector::max_abs_pos;max_of_sums;vector::max_pos;merge_complex_vector;vector::one_norm;vector::diagonal;dyn_vec_expr;Orthogonalize_Vectors;Orthogonalize_Factors;Vector_product;Vector_random;Vec_Vec_rank_update;Vector_dispatch;Vector_rscale;Multi-vector_mult;Transp_Multi-vector_mult;Hermitian_Multi-vector_mult;Vector_scal;Vector_set_zero;Vector_size1D;Vector_size_runtime;Vect_quicksort_lo_to_hi;Vect_quicksort_permutaion_lo_to_hi;split_complex_vector;Vect_entries_sum;Vector_const_trans;Vector_trans;vector::two_norm;dot_simple;unary_dot;dense_vector::copy_ctor;dense_vector::tpl_copy_ctor +mtl_vecmat=matrix_copy_ele_times;gen_matrix_copy;copy;clone;compute_summand;crop;matrix::diagonal;assign_each_nonzero;fill;frobenius_norm;matrix::infinity_norm;invert_diagonal;iota;left_scale_inplace;matrix::look_at_each_nonzero;matrix::look_at_each_nonzero_pos;fsize_dense_mat_cvec_mult;dense_mat_cvec_mult;mvec_cvec_mult;trans_mvec_cvec_mult;herm_mvec_cvec_mult;sparse_row_cvec_mult;ccs_cvec_mult;matrix::max_abs_pos;matrix::one_norm;invert_diagonal(compressed);mat_vect_mult;Vect_sparse_mat_mult;Matrix_scal;Vector_Secular_Equation;Matrix_set_zero;Matrix_size1D;Matrix_size_runtime;Matrix_LU;Vector_Matrix_LU;Sub_matrix_indices;Matrix_svd_reference;Matrix_svd_triplet;Matrix_swapped;Matrix_Trace;Matrix_const_trans;Matrix_trans;Matrix_upper_trisolve;Matrix_upper_trisolve_diagonal;Matrix_upper_trisolve_invers_diag;Matrix_upper_trisolve_DiaTag;scalar_assign;elest_cvec_mult;crs_cvec_mult;sparse_ins::ctor;sparse_ins::dtor;sparse_ins::stretch;sparse_ins::final_place;sparse_ins::insert_spare;mat_crtp_scal_assign;mat_crtp_mat_assign;mat_crtp_sum_assign;mat_crtp_diff_assign;mat_crtp_array_assign;mat_crtp_mvec_assign;copy_band_to_sparse;block_dia_times_cvec;laplacian_setup;vsmat_cvec_mult;adapt_crs_cvec_mult;dense2D_cvec_mult;square_cvec_mult;mat_cvec_multiplier;sbanded_cvec_mult +mtl_matrix=cursor_dmat_dmat_mult;dmat_dmat_mult;tiling_dmat_dmat_mult;tiling_44_dmat_dmat_mult;tiling_22_dmat_dmat_mult;wrec_dmat_dmat_mult;recursive_dmat_dmat_mult;xgemm;mult;gen_mult;mat_mat_mult;matrix_qr;matrix_qr_factors;matrix_random;matrix_scale_inplace;matrix_rscale;matrix_gen_smat_dmat_mult;matrix_gen_tiling_smat_dmat_mult;matrix_smat_smat_mult;read_el_matrix +mtl_factor=cholesky_base;cholesky_solve_base;cholesky_schur_base;cholesky_update_base;cholesky_schur_update;cholesky_tri_solve;cholesky_tri_schur;recursive cholesky;fill_matrix_for_cholesky;qr_sym_imp;qr_algo;eigenvalue_symmetric;hessenberg_q;hessenberg_factors;extract_householder_hessenberg;householder_hessenberg;extract_hessenberg;hessenberg;inv_upper;inv_lower;inv;lower_trisolve;lu;lu(pivot);lu_f;lu_solve_straight;lu_apply;lu_solve;lu_adjoint_apply;lu_adjoint_solve;pc::id::solve;pc::id.solve;pc::id::adjoint_solve;pc::id.adjoint_solve;ic_0::factorize;ic_0::solve;ic_0::solve_nocopy;ilu_0::factorize;ilu_0::solve;ilu_0::adjoint_solve;lower_trisolve_kernel;upper_trisolve_row;upper_trisolve_col;ic_0::adjoint_solve;ic_0::adjoint_solve_nocopy;upper_trisolve_crs_compact;lower_trisolve_crs_compact;lower_unit_trisolve_crs_compact;ilut::factorize;diagonal::setup;diagonal::solve;imf::factor;imf::ctor;imf::solve;pc::solver::assign_to;sub_matrix_pc::solve;sub_matrix_pc::adjoint_solve;pc::concat::solve;pc::concat::adjoint_solve;umfpack::solver::ctor;umfpack::solver::dtor;umfpack::solve +mtl_fused=fused::fwd_eval_loop;fused::fwd_eval_loop_unrolled;fused::bwd_eval_loop;fused::bwd_eval_loop_unrolled +mtl_solver=cg_without_pc;cg;bicg;bicgstab;bicgstab_2;bicgstab_ell;cgs;qmr;tfqmr;idr_s +mtl_mg=omp::dot;omp::reduction;omp::dyn_vec_expr;omp::crs_cvec_mult;mtl::mg::v_cycle;mtl::mg::w_cycle;mtl::mg::fmg;mtl::mg::two_grid_cycle;mtl::mg::geometric_multigrid_solver_impl;mtl::mg::geometric_multigrid_solver_solve1;mtl::mg::geometric_multigrid_solver_solve2;mtl::mg::algebraic_multigrid_solver;amg_pc::solve;mtl::mg::linear_restriction;mtl::mg::linear_prolongation;mtl::mg::gauss_elimination;mtl::mg::back_substitution;mtl::mg::jacobi;mtl::mg::gauss_seidel;mtl::mg::jor;mtl::mg::sor;boundaries;viscosity;pressure_correction;mtl::mg::util::vtk_exporter;mtl::mg::util::csv_exporter;amg::amg_matrix_hierarchy;amg::compute_influence;amg::default_coarse_grid_detection::compute_C;amg::utils::compute_potentials;amg::utils::find_max_pos;amg::amg_prolongation;amg::compute_weight;amg::compute_mfactors;amg::strongly_influenced_points;amg::is_strongly_influenced;amg::strongly_influencing_points;amg::amg_operators::amg_restriction;amg::amg_operators::amg_prolongation;amg::amg_operators::amg_weight;NaSto::solve();NaSto::computeGamma();NaSto::computeBoundaries();NaSto::computeImplViscosity();NaSto::computePressureCorr() +mtl_app=tb1;tb2;tb3;tb4;main;helper_function;function diff --git a/AMDiS/lib/muparser_v134/Changes.txt b/AMDiS/lib/muparser_v134/Changes.txt new file mode 100644 index 0000000000000000000000000000000000000000..458ab7505ebcb285745039c24cd1ecd87a4b92f6 --- /dev/null +++ b/AMDiS/lib/muparser_v134/Changes.txt @@ -0,0 +1,396 @@ + + __________ + _____ __ __\______ \_____ _______ ______ ____ _______ + / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ + | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ + |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| + \/ \/ \/ \/ + + Copyright (C) 2010 + Ingo Berg + +History: +-------- + +Rev 1.00 : July 21 2004 +----------------------- + + * Initial release + + +Rev 1.01 : July 23 2004 +----------------------- + + * Support for user defined functions has been added; new functions: AddFun(), ClearFun(), + InitFunctions(). + * Built in constants have been removed; the parser contained undocumented built in + constants pi, e. + There was the possibility of name conflicts with user defined variables. + * Setting multiple variables with SetVar can now be done with a map of names and pointers as the only + argument. For this reason, a new type Parser::varmap_type was added. The old version that took 3 + arguments (array of names, array of pointers, and array length) is now marked as deprecated. + * The names of logarithm functions have changed. The new names are: log2 for base 2, log10 or log for + base 10, and ln for base e. + + +Rev 1.02 : July 30 2004 +----------------------- + + * Support for user defined constants added; new functions: InitConst(), AddConst(), SetConst(), + ClearConst(). + * Single variables can now be added using AddVar(); you have now the choice of adding them either + one by one or all at the same time using SetVar(const varmap_type &a_vVar). + * Internal handling of variables changed, is now similar to function handling. + * Virtual destructor added; InitFun(), InitConst() are now virtual too thus making it possible to + derive new parsers with a modified set of default functions and constants. + * Support for user defined functions with 2 or 3 parameters added; bytecode format changed to hold + function parameter count. + + +Rev 1.03 : August 10 2004 +------------------------- + + * Support for user-defined unary post value operators added; new functions: AddPostOp(), InitPostOp(), + ClearPostOp(). + * Minor changes to the bytecode parsing routine. + * User defined functions can now have up to four parameters. + * Performance optimized: simple formula optimization added; (precalculation of constant parts of the + expression). + * Bug fixes: Multi-arg function parameters, constant name lookup, unary minus did not work correctly. + + +Rev 1.04 : August 16 2004 +------------------------- + + * Support for functions with variable number of arguments added. + * Internal structure changed; new: ParserBase.h, ParserBase.cpp; removed: ParserException.h; + changed: Parser.h, Parser.cpp. + * Bug in the bytecode calculation function fixed (affected the unary minus operator). + * Optimizer can be deactivated; new function: EnableOptimizer(bool bStat). + + +Rev 1.05 : August 20 2004 +------------------------- + + * Variable/constant names will now be checked for invalid characters. + * Querying the names of all variables used in an expression is now possible; new function: GetUsedVar(). + * Disabling bytecode parsing is now possible; new function: EnableByteCode(bool bStat). + * Predefined functions with variable number of arguments added: sum, avg, min, max. + * Unary prefix operators added; new functions: AddPrefixOp(...), ClearPrefixOp(). + * Postfix operator interface names changed; new function names: AddPostfixOp(...), ClearPostfixOp(). + * Hardcoded sign operators removed in favor of prefix operators; bytecode format changed accordingly. + * Internal changes: static array removed in Command code calculation routine; misc. changes. + + +Rev 1.06 : August 20 2004 +------------------------- + + * Volatile functions added; All overloaded AddFun(...) functions can now take a third parameter + indicating that the function can not be optimized. + * Internal changes: muParserStack.h simplified; refactorings + * Parser is now distributed under the MIT License; all comments changed accordingly. + + +Rev 1.07 : September 4 2004 +--------------------------- + + * Improved portability; Changes to make life for MSVC 6 user easier, there are probably still some + issues left. + * Improved portability; Changes in order to allow compiling on BCB. + * New function; value_type Diff(value_type *a_Var, value_type a_fPos) 4th order Differentiation with + respect to a certain variable; added in muParser.h. + + +Rev 1.08 : November, 2004 +------------------------- + + * unpublished; experimental template version with respect to data type and underlying string + type (string <-> widestring). + + +Rev 1.09 : November 20, 2004 +---------------------------- + + * New member function: RemoveVar(...) can be used for removing a single variable from the internal + storage. + * Internal structure changed; changing base datatype at compile time is now possible. + * Bug fix: Postfix operator parsing could fail in certain cases; This has been fixed now. + * Internal change: Removed most dependancies from the C-string libraries. + * Internal change: Bytecode is now stored in a seperate class: ParserByteCode.h. + * Internal change: GetUsedVar() does no longer require that variables are defined at time of call. + * Internal change: Error treatment changed. ParserException is no longer derived from + std::runtime_error; Internal treatment of Error messages changed. + * New functions in Parser interface; ValidNameChars(), ValidOprtChars() and ValidPrefixOprtChars() + they are used for defining the charset allowed for variable-, operator- and function names. + + +Rev 1.10 : December 30, 2004 +---------------------------- + +Release Notes: +This version does not contain major new feature compared to V1.07 but its internal structure has +changed significantly. The String parsing routine is slower than the one of V1.07 but bytecode +parsing is equally fast. On the other hand the error messages of V1.09 are more flexible and you +can change its value datatype. It should work on 64-bit systems. For this reason I supply both +versions for download. If you use V1.07 and are happy with it there is no need for updating +your version. + + * New example program: Archive now contains two demo programs: One for standard C++ and one for + managed C++. + * New member function: RemoveVar(...) can be used for removing a single variable from the internal + storage. + * New member function: GetVar() can be used for querying the variable names and pointers of all + variables defined in the parser. + * New member function: GetConst() can be used for querying all defined constants and their values. + * New member function: GetFunDef() can be used for querying all defined functions and the number of + arguments they expect. + * Internal structure changed; hanging base datatype at compile time is now possible. + * Bugfix: Postfix operator parsing could fail in certain cases; This has been fixed now. + * Bugfix: Variable names must will now be tested if they conflict with constant or function names. + * Internal change: Removed most dependencies from the C-string libraries. + * Internal change: Bytecode is now stored in a separate class: ParserByteCode.h + * Internal change: GetUsedVar() does no longer require that variables are defined at time of call. + * Internal change: Error treatment changed. ParserException is no longer derived from + std::runtime_error; Internal treatment of Error messages changed. + * New functions in Parser interface: ValidNameChars(), ValidOprtChars() and ValidPrefixOprtChars() + they are used for defining the charset allowed for variable-, operator- and + function names. + + +Rev 1.2 / 1.21: April, 2005 +--------------------------- + +Release Notes: +First of all the interface has changed so this version is not backwards compatible. +After receiving a couple of questions about it, this version features support for +user defined binary operators. Consequently the built in operators can now be +turned off, thus you can deactivate them and write complete customized parser +subclasses that only contain the functionality you want. Another new feature is +the introduction of callback functions taking string arguments, implicit +generation of variables and the Assignement operator. + + Functionality + * New built in operator: xor; Logical xor. + * New built in operator: Assignement operator; Defining variables in terms of + other variables/constants + * New feature: Strings as arguments for callback functions + * New feature: User defined binary operators + * New feature: ParserInt a class with a sample implementation for + integer numbers. + * New feature: Callbacks to value regognition functions. + + * Removed: all predefined postfix operators have been removed. + * New project file: Now comes with a ready to use windows DLL. + * New project file: Makefile for cygwin now included. + * New example: Example3 shows usage of the DLL. + + Interface changes + * New member function: DefineOprt For adding user defined binary operators. + * New member function: EnableBuiltInOprt(bool) Enables/Disables built in + binary operators. + * New member function: AddValIdent(...) to add callbacks for custom value + recognition functions. + * Removed: SetVar(), SetConst(). + * Renamed: Most interface functions have been renamed + * Changed: The type for multiargument callbacks multfun_type has changed. + It no longer takes a std::vector as input. + + Internal changes + * new class muParserTokenReader.h encapsulates the token identification + and token assignement. + * Internal handling of function callbacks unified as a result the performance + of the bytecode evaluation increased. + + +Rev 1.22: October, 2005 +----------------------- + +Release notes: + +All features of Version 1.22 are similar to Version 1.21. Version 1.22 fixes a compilation issue with +gcc 4.0. In order to fix this issue I rewrote part of the library to remove some unnecessary templates. +This should make the code cleaner. The Borland Project files have been removed. If you want to use it +with Borland either use the dll version or create your own project files. I can't do it since I don't +have this compiler at hand. + +Changes: + + Project Changes: + * Borland project files removed + (The code should still compile with BCB but I cant provide you with project files) + + Internal Changes: + * unnecessary template files have been removed: + - new files: muParserError.cpp, muParserTokenReader.cpp, muParserCallback.cpp + - removed Files: muIParserTypes.h + + +Rev 1.23: 19. October, 2005 +--------------------------- + +Changes: + + Bugfixes: + * Variable factory examples in Example1.cpp and Example3.cpp contained a subtle bug. + + New features: + * Added a MSVC6 project file and introduced muParserFixes.h in order to make it compile with MSVC6 + + +Rev 1.24: 29. October, 2005 +--------------------------- + +Changes: + + Compatibility improvements: + * parser now works on 64 bit compilers + * (bytecode base datatype can now be changed freely) + + +Rev 1.25: 5. February, 2006 +--------------------------- + + Build system: (special thanks to Francesco Montorsi for implementing it!) + * created a bakefile-based build system which adds support for the following win32 compilers: + -> MS visual C++ (6 and .NET) + -> BorlandC++ (5 or greater) + -> Mingw32 (tested with gcc 3.2) + -> Watcom (not tested) + and for GCC on Unix (using a standard autoconf's configure script). + + Compatibility improvements: + * fixed some small warnings when using -Wall with GCC on Unix + * added inclusion guards for win32-specific portions of code + * added fixes that remove compiler warnings on Intel C++ and the Solaris C++ compiler. + + +Rev 1.26: (unofficial release) +--------------------------- + + New Features: + * Unary operator precedence can now be changed by the user. + + +Rev 1.27: +--------------------------- + + Build system: + * Modified build\ directory layout introducing some subfolders + for the various IDE supported + * Project files for BCB and MSVC7 added + * Switched to use bakefile 0.2.1 which now correctly creates the + "make uninstall" target for autoconf's Makefile.in + * Now the library debug builds are named "muparserd" instead of "muparser" + to allow multiple mixed release/debug builds to coexist; so e.g. on Windows + when building with DEBUG=1, you'll get "muparserd.lib" instead of "muparser.lib" + + New Features: + * Factory functions can now take a user defined pointer + * String functions can now be used with up to two additional + double parameters + * Support for UNICODE character types added + * Infix operator priority can now be changed by the user + + Bugfixes: + * An internal error was raised when evaluating an empty + expressions + * The error message raised in case of name collisions between + implicitely defined variables and postfix operators did contain + misleading data. + + +Rev 1.28: 02. July, 2007 +--------------------------- + + Library changes: + * Interface for the dynamic library changed and extended to create an interface + using pure C functions only. + * mupInit() removed + + Build system: + * MSVC7 Project files removed in favor of MSVC8 + + Bugfixes: + * The dynamic library did not build on other systems than linux due to a misplaced + preprocessor definition. This is fixed now. + +Rev 1.29: Januar 2008 +--------------------- + + Unrelease Version available only via SVN. + + +Rev 1.30: 09.06.2008 +-------------------- + + Changes: + * Epsilon of the numerical differentiation algorithm changed to allow greater accuracy. + + New features: + * Setting thousands separator and decimal separator is now possible + + Bugfixes: + * The dll interface did not provide a callback for functions without any arguments. + +Rev 1.31cp: 15.01.2010 (Maintainance release for CodeProject) +---------------------- + + Changes: + * Archive structure changed + * C# wrapper added + * Fixed issued that prevented compiling with VS2010 Beta2 + +Rev 1.32: 29.01.2010 +-------------------- + + Changes: + * "example3" renamed to "example2" + * Project/Makefiles files are now provided for: + - msvc2003 + - msvc2005 + - msvc2008 + - watcom (makefile) + - mingw (makefile) + - bcc (makefile) + * Project files for borland cpp builder were removed + + + New features: + + * Added function returning muparsers version number + + * Added function for resetting the locale + + + Bugfixes: + * Changes example1 in order to fix issues with irritating memory leak reports. + Added conditional code for memory leak detection with MSVC in example1. + (see: http://www.codeproject.com/KB/recipes/FastMathParser.aspx?msg=3286367#xx3286367xx) + * Fixed some warnings for gcc + + +Rev 1.34: 04.09.2010 +-------------------- + Changes: + * The prefix needed for parsing hex values is now "0x" and no longer "$". + * AddValIdent reintroduced into the DLL interface + + New features: + * The associativity of binary operators can now be changed. The pow operator is now right associative. + (This is what mathematica is using) + * Seperator can now be used outside of functions. This allows compund expressions like: + "a=10,b=20,c=a*b" The last "argument" will be taken as the return value + + Bugfixes: + * The copy constructor did not copy binary operator definitions. Those were lost in the copied parser + instance. + * Mixing special characters and alphabetic characters in binary operator names + led to inconsistent parsing behaviour when parsing expressions like + "a ++ b" and "a++b" when "++" is defined as a binary operator. Binary operators must now consist + entirely of special characters or of alphabetic ones. + (original bug report: https://sourceforge.net/projects/muparser/forums/forum/462843/topic/3696881/index/page/1) + * User defined operators were not exactly handled like built in operators. This led to inconsistencies + in expression evaluation when using them. The results differed due to slightly different precedence rules. + * Using empty string arguments ("") would cause a crash of muParser + + diff --git a/AMDiS/lib/muparser_v134/Credits.txt b/AMDiS/lib/muparser_v134/Credits.txt new file mode 100644 index 0000000000000000000000000000000000000000..2b859a440f25f27a9f0e08288e095af7184c1963 --- /dev/null +++ b/AMDiS/lib/muparser_v134/Credits.txt @@ -0,0 +1,28 @@ +###################################################################### +# # +# __________ # +# _____ __ __\______ \_____ _______ ______ ____ _______ # +# / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ # +# | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ # +# |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| # +# \/ \/ \/ \/ # +# # +# Copyright (C) 2010 # +# Ingo Berg # +# # +###################################################################### + +Credits: +-------- + +I'd like to thank all the people contacting me with suggestions and +bug reports. Your feedback is always welcome and helps to improve this +project. + +Especially I'd like to thank: +----------------------------- + +Francesco Montorsi for setting up the new parser build system as well +as the SVN server at sourceforge. Ion Vasilief for Feedback, +suggestions and help with the MSVC6 adaptation, Giampaolo Belini for +his help in fixing bugs. \ No newline at end of file diff --git a/AMDiS/lib/muparser_v134/Install.txt b/AMDiS/lib/muparser_v134/Install.txt new file mode 100644 index 0000000000000000000000000000000000000000..bfa9b9bfb77b4bd3ae371d6d332e3fcf8b4c754a --- /dev/null +++ b/AMDiS/lib/muparser_v134/Install.txt @@ -0,0 +1,126 @@ + + __________ + _____ __ __\______ \_____ _______ ______ ____ _______ + / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ + | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ + |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| + \/ \/ \/ \/ + + Mathematical expressions parser library + Copyright (C) 2010 Ingo Berg (muparser{at}gmx.de) + + + + Contents + ======== + + 1. Installation on win32 + 2. Installation on unix + 2.1 Other miscellaneous info Unix-specific + 3. Where to ask for help + + + + 1. Installation on win32 + ======================== + + muParser supports various win32 command-line compilers: + -> mingw + -> borland + -> watcom + -> microsoft CL + and provides also the project files for MSVC6 IDE. + + In order to compile muParser from makefiles, open an MSDOS + prompt and then move to the muParser/build directory and + type: + + mingw32-make -fmakefile.mingw for mingw + nmake -fmakefile.vc for msvc + make -fmakefile.bcc for borland + wmake -fmakefile.wat for watcom + + All makefiles supports the following options: + + # Set to 1 to build debug version [0,1] + # 0 - Release + # 1 - Debug + DEBUG = 0 + + # Set to 1 to build shared (DLL) version [0,1] + # 0 - Static + # 1 - DLL + SHARED = 0 + + # Set to 1 to compile samples [0,1] + SAMPLES = 1 + + The muParser library is created in the 'lib' folder and the sample + binaries are created in samples\example1 or samples\example2. + + NOTE: samples\example1 can be compiled *only* when building + muParser as a STATIC library (SHARED=0). + samples\example2 can be compiled *only* when building + muParser as a SHARED library (SHARED=1). + + + + 2. Installation on Unix/Linux + ============================= + + muParser can be installed just extracting the sources somewhere + and then, from a terminal, typing: + + cd [path to muParser] + ./configure [--enable-shared=yes/no] [--enable-samples=yes/no] + [--enable-debug=yes/no] + make + [sudo*] make install + [sudo*] ldconfig + cd samples/example1 + ./example1 + + * = this command must be executed with root permissions and thus + you have to use 'sudo' or just 'su' to gain root access. + Note that installation and ldconfig are not strictly required unless + you built in shared mode. + + The "make" step will create the muParser library in 'lib' and the + sample binary in samples/example1. + The samples/example2 is win32-specific and thus won't be built. + + + + 2.1 Other miscellaneous info Unix-specific + ========================================== + + If you don't like to have your muParser folder filled by temporary + files created by GCC, then you can do the following: + + mkdir mybuild && cd mybuild && ../configure && make + + to put all object files in the "mybuild" directory. + + If you want to use muParser library in your programs, you can use + the pkg-config program (this works only if muParser was installed + with 'make install' !). The commands: + + pkg-config muparser --cflags + pkg-config muparser --libs + + will return all useful info you need to build your programs against + muParser ! + + + + 3. Where to ask for help + ======================== + + If you find problems with either compilation, installation or usage + of muParser, then you can ask in the muParser forum at: + + https://sourceforge.net/forum/forum.php?forum_id=462843 + + For more info about muParser, visit: + http://sourceforge.net/projects/muparser/ + http://muparser.sourceforge.net diff --git a/AMDiS/lib/muparser_v134/License.txt b/AMDiS/lib/muparser_v134/License.txt new file mode 100644 index 0000000000000000000000000000000000000000..5730c36d22fb230a4ee9205601f24a72843e754b --- /dev/null +++ b/AMDiS/lib/muparser_v134/License.txt @@ -0,0 +1,28 @@ + + __________ + _____ __ __\______ \_____ _______ ______ ____ _______ + / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ + | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ + |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| + \/ \/ \/ \/ + + Version 1.27 + + Copyright (C) 2004-2006 Ingo Berg (ingo_berg{at}gmx.de) + + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/AMDiS/lib/muparser_v134/Makefile.in b/AMDiS/lib/muparser_v134/Makefile.in new file mode 100644 index 0000000000000000000000000000000000000000..f62353008d0584e4efac6b4bca7768d11b5b0827 --- /dev/null +++ b/AMDiS/lib/muparser_v134/Makefile.in @@ -0,0 +1,376 @@ +# ========================================================================= +# This makefile was generated by +# Bakefile 0.2.8 (http://www.bakefile.org) +# Do not modify, all changes will be overwritten! +# ========================================================================= + + +@MAKE_SET@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +datarootdir = @datarootdir@ +INSTALL = @INSTALL@ +SHARED_LD_CXX = @SHARED_LD_CXX@ +LIBEXT = @LIBEXT@ +LIBPREFIX = @LIBPREFIX@ +SO_SUFFIX = @SO_SUFFIX@ +DLLIMP_SUFFIX = @DLLIMP_SUFFIX@ +EXEEXT = @EXEEXT@ +LN_S = @LN_S@ +SETFILE = @SETFILE@ +PIC_FLAG = @PIC_FLAG@ +SONAME_FLAG = @SONAME_FLAG@ +STRIP = @STRIP@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_DIR = @INSTALL_DIR@ +BK_DEPS = @BK_DEPS@ +srcdir = @srcdir@ +top_builddir = @top_builddir@ +libdir = @libdir@ +DLLPREFIX = @DLLPREFIX@ +LIBS = @LIBS@ +AR = @AR@ +AROPTIONS = @AROPTIONS@ +RANLIB = @RANLIB@ +CXX = @CXX@ +CXXFLAGS = @CXXFLAGS@ +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ + +### Variables: ### + +DESTDIR = +MUPARSER_LIB_CXXFLAGS = $(____DEBUG) $(____SHARED) $(____SHARED_0) \ + -I$(srcdir)/include $(CPPFLAGS) $(CXXFLAGS) +MUPARSER_LIB_OBJECTS = \ + muParser_lib_muParser.o \ + muParser_lib_muParserBase.o \ + muParser_lib_muParserBytecode.o \ + muParser_lib_muParserCallback.o \ + muParser_lib_muParserComplex.o \ + muParser_lib_muParserDLL.o \ + muParser_lib_muParserError.o \ + muParser_lib_muParserInt.o \ + muParser_lib_muParserTest.o \ + muParser_lib_muParserTokenReader.o +MUPARSER_LIB_HEADERS = \ + include/muParser.h \ + include/muParserBase.h \ + include/muParserBytecode.h \ + include/muParserCallback.h \ + include/muParserComplex.h \ + include/muParserDLL.h \ + include/muParserDef.h \ + include/muParserError.h \ + include/muParserFixes.h \ + include/muParserInt.h \ + include/muParserStack.h \ + include/muParserTest.h \ + include/muParserToken.h \ + include/muParserTokenReader.h +MUPARSER_DLL_CXXFLAGS = $(____DEBUG) $(____SHARED) $(____SHARED_0) \ + -I$(srcdir)/include $(PIC_FLAG) $(CPPFLAGS) $(CXXFLAGS) +MUPARSER_DLL_OBJECTS = \ + muParser_dll_muParser.o \ + muParser_dll_muParserBase.o \ + muParser_dll_muParserBytecode.o \ + muParser_dll_muParserCallback.o \ + muParser_dll_muParserComplex.o \ + muParser_dll_muParserDLL.o \ + muParser_dll_muParserError.o \ + muParser_dll_muParserInt.o \ + muParser_dll_muParserTest.o \ + muParser_dll_muParserTokenReader.o +MUPARSER_DLL_HEADERS = \ + include/muParser.h \ + include/muParserBase.h \ + include/muParserBytecode.h \ + include/muParserCallback.h \ + include/muParserComplex.h \ + include/muParserDLL.h \ + include/muParserDef.h \ + include/muParserError.h \ + include/muParserFixes.h \ + include/muParserInt.h \ + include/muParserStack.h \ + include/muParserTest.h \ + include/muParserToken.h \ + include/muParserTokenReader.h +EXAMPLE1_CXXFLAGS = $(____DEBUG) -I$(srcdir)/include $(CPPFLAGS) $(CXXFLAGS) +EXAMPLE1_OBJECTS = \ + example1_Example1.o + +### Conditionally set variables: ### + +@COND_DEPS_TRACKING_0@CXXC = $(CXX) +@COND_DEPS_TRACKING_1@CXXC = $(BK_DEPS) $(CXX) +@COND_DEBUG_0@DEBUG_BUILD_POSTFIX = +@COND_DEBUG_1@DEBUG_BUILD_POSTFIX = d +@COND_SHARED_0@__muParser_lib___depname = \ +@COND_SHARED_0@ $(top_builddir)/lib/$(LIBPREFIX)muparser$(DEBUG_BUILD_POSTFIX)$(LIBEXT) +@COND_SHARED_0@__install_muParser_lib___depname = install_muParser_lib +@COND_SHARED_0@__uninstall_muParser_lib___depname = uninstall_muParser_lib +@COND_SHARED_0@__install_muParser_lib_headers___depname = \ +@COND_SHARED_0@ install_muParser_lib_headers +@COND_SHARED_0@__uninstall_muParser_lib_headers___depname = \ +@COND_SHARED_0@ uninstall_muParser_lib_headers +COND_SHARED_1___muParser_dll___depname = \ + $(top_builddir)/lib/$(DLLPREFIX)muparser$(DEBUG_BUILD_POSTFIX)$(__muParser_dll___targetsuf3) +@COND_SHARED_1@__muParser_dll___depname = $(COND_SHARED_1___muParser_dll___depname) +@COND_SHARED_1@__install_muParser_dll___depname = install_muParser_dll +@COND_SHARED_1@__uninstall_muParser_dll___depname = uninstall_muParser_dll +COND_PLATFORM_MACOSX_1___muParser_dll___macinstnamecmd = -install_name \ + $(libdir)/$(DLLPREFIX)muparser$(DEBUG_BUILD_POSTFIX)$(__muParser_dll___targetsuf2) +@COND_PLATFORM_MACOSX_1@__muParser_dll___macinstnamecmd = $(COND_PLATFORM_MACOSX_1___muParser_dll___macinstnamecmd) +@COND_SHARED_1@__install_muParser_dll_headers___depname = \ +@COND_SHARED_1@ install_muParser_dll_headers +@COND_SHARED_1@__uninstall_muParser_dll_headers___depname = \ +@COND_SHARED_1@ uninstall_muParser_dll_headers +COND_PLATFORM_OS2_1___muParser_dll___importlib = -import \ + $(top_builddir)/lib/$(LIBPREFIX)muparser$(DEBUG_BUILD_POSTFIX).$(DLLIMP_SUFFIX) +@COND_PLATFORM_OS2_1@__muParser_dll___importlib = $(COND_PLATFORM_OS2_1___muParser_dll___importlib) +COND_WINDOWS_IMPLIB_1___muParser_dll___importlib = \ + -Wl,--out-implib=$(top_builddir)/lib/$(LIBPREFIX)muparser$(DEBUG_BUILD_POSTFIX).$(DLLIMP_SUFFIX) +@COND_WINDOWS_IMPLIB_1@__muParser_dll___importlib = $(COND_WINDOWS_IMPLIB_1___muParser_dll___importlib) +@COND_PLATFORM_MACOSX_0_USE_SOVERSION_1@__muParser_dll___targetsuf2 \ +@COND_PLATFORM_MACOSX_0_USE_SOVERSION_1@ = .$(SO_SUFFIX).0 +@COND_PLATFORM_MACOSX_1_USE_SOVERSION_1@__muParser_dll___targetsuf2 \ +@COND_PLATFORM_MACOSX_1_USE_SOVERSION_1@ = .0.$(SO_SUFFIX) +@COND_USE_SOVERSION_0@__muParser_dll___targetsuf2 = .$(SO_SUFFIX) +@COND_PLATFORM_MACOSX_0_USE_SOVERCYGWIN_0_USE_SOVERSION_1@__muParser_dll___targetsuf3 \ +@COND_PLATFORM_MACOSX_0_USE_SOVERCYGWIN_0_USE_SOVERSION_1@ = \ +@COND_PLATFORM_MACOSX_0_USE_SOVERCYGWIN_0_USE_SOVERSION_1@ .$(SO_SUFFIX).0.0.0 +@COND_PLATFORM_MACOSX_1_USE_SOVERSION_1@__muParser_dll___targetsuf3 \ +@COND_PLATFORM_MACOSX_1_USE_SOVERSION_1@ = .0.0.0.$(SO_SUFFIX) +@COND_USE_SOVERSION_1_USE_SOVERSOLARIS_1@__muParser_dll___targetsuf3 \ +@COND_USE_SOVERSION_1_USE_SOVERSOLARIS_1@ = .$(SO_SUFFIX).0 +@COND_USE_SOVERCYGWIN_1_USE_SOVERSION_1@__muParser_dll___targetsuf3 \ +@COND_USE_SOVERCYGWIN_1_USE_SOVERSION_1@ = -0.$(SO_SUFFIX) +@COND_USE_SOVERSION_0@__muParser_dll___targetsuf3 = .$(SO_SUFFIX) +COND_USE_SOVERLINUX_1___muParser_dll___soname_flags = \ + $(SONAME_FLAG)$(DLLPREFIX)muparser$(DEBUG_BUILD_POSTFIX)$(__muParser_dll___targetsuf2) +@COND_USE_SOVERLINUX_1@__muParser_dll___soname_flags = $(COND_USE_SOVERLINUX_1___muParser_dll___soname_flags) +COND_USE_SOVERSOLARIS_1___muParser_dll___soname_flags = \ + $(SONAME_FLAG)$(DLLPREFIX)muparser$(DEBUG_BUILD_POSTFIX)$(__muParser_dll___targetsuf3) +@COND_USE_SOVERSOLARIS_1@__muParser_dll___soname_flags = $(COND_USE_SOVERSOLARIS_1___muParser_dll___soname_flags) +COND_USE_SOTWOSYMLINKS_1___muParser_dll___so_symlinks_cmd = (cd \ + $(top_builddir)/lib/; rm -f \ + $(LIBPREFIX)muparser$(DEBUG_BUILD_POSTFIX).$(DLLIMP_SUFFIX) \ + $(DLLPREFIX)muparser$(DEBUG_BUILD_POSTFIX)$(__muParser_dll___targetsuf2); \ + $(LN_S) \ + $(DLLPREFIX)muparser$(DEBUG_BUILD_POSTFIX)$(__muParser_dll___targetsuf3) \ + $(DLLPREFIX)muparser$(DEBUG_BUILD_POSTFIX)$(__muParser_dll___targetsuf2); \ + $(LN_S) \ + $(DLLPREFIX)muparser$(DEBUG_BUILD_POSTFIX)$(__muParser_dll___targetsuf2) \ + $(LIBPREFIX)muparser$(DEBUG_BUILD_POSTFIX).$(DLLIMP_SUFFIX)) +@COND_USE_SOTWOSYMLINKS_1@__muParser_dll___so_symlinks_cmd = $(COND_USE_SOTWOSYMLINKS_1___muParser_dll___so_symlinks_cmd) +COND_USE_SOVERSOLARIS_1___muParser_dll___so_symlinks_cmd = (cd \ + $(top_builddir)/lib/; rm -f \ + $(LIBPREFIX)muparser$(DEBUG_BUILD_POSTFIX).$(DLLIMP_SUFFIX); $(LN_S) \ + $(DLLPREFIX)muparser$(DEBUG_BUILD_POSTFIX)$(__muParser_dll___targetsuf3) \ + $(LIBPREFIX)muparser$(DEBUG_BUILD_POSTFIX).$(DLLIMP_SUFFIX)) +@COND_USE_SOVERSOLARIS_1@__muParser_dll___so_symlinks_cmd = $(COND_USE_SOVERSOLARIS_1___muParser_dll___so_symlinks_cmd) +COND_USE_SOTWOSYMLINKS_1___muParser_dll___so_symlinks_inst_cmd = rm -f \ + $(LIBPREFIX)muparser$(DEBUG_BUILD_POSTFIX).$(DLLIMP_SUFFIX) \ + $(DLLPREFIX)muparser$(DEBUG_BUILD_POSTFIX)$(__muParser_dll___targetsuf2); \ + $(LN_S) \ + $(DLLPREFIX)muparser$(DEBUG_BUILD_POSTFIX)$(__muParser_dll___targetsuf3) \ + $(DLLPREFIX)muparser$(DEBUG_BUILD_POSTFIX)$(__muParser_dll___targetsuf2); \ + $(LN_S) \ + $(DLLPREFIX)muparser$(DEBUG_BUILD_POSTFIX)$(__muParser_dll___targetsuf2) \ + $(LIBPREFIX)muparser$(DEBUG_BUILD_POSTFIX).$(DLLIMP_SUFFIX) +@COND_USE_SOTWOSYMLINKS_1@__muParser_dll___so_symlinks_inst_cmd = $(COND_USE_SOTWOSYMLINKS_1___muParser_dll___so_symlinks_inst_cmd) +COND_USE_SOVERSOLARIS_1___muParser_dll___so_symlinks_inst_cmd = rm -f \ + $(LIBPREFIX)muparser$(DEBUG_BUILD_POSTFIX).$(DLLIMP_SUFFIX); $(LN_S) \ + $(DLLPREFIX)muparser$(DEBUG_BUILD_POSTFIX)$(__muParser_dll___targetsuf3) \ + $(LIBPREFIX)muparser$(DEBUG_BUILD_POSTFIX).$(DLLIMP_SUFFIX); +@COND_USE_SOVERSOLARIS_1@__muParser_dll___so_symlinks_inst_cmd = $(COND_USE_SOVERSOLARIS_1___muParser_dll___so_symlinks_inst_cmd) +COND_USE_SOTWOSYMLINKS_1___muParser_dll___so_symlinks_uninst_cmd = rm -f \ + $(DLLPREFIX)muparser$(DEBUG_BUILD_POSTFIX)$(__muParser_dll___targetsuf2) \ + $(LIBPREFIX)muparser$(DEBUG_BUILD_POSTFIX).$(DLLIMP_SUFFIX) +@COND_USE_SOTWOSYMLINKS_1@__muParser_dll___so_symlinks_uninst_cmd = $(COND_USE_SOTWOSYMLINKS_1___muParser_dll___so_symlinks_uninst_cmd) +@COND_USE_SOVERSOLARIS_1@__muParser_dll___so_symlinks_uninst_cmd \ +@COND_USE_SOVERSOLARIS_1@ = rm -f \ +@COND_USE_SOVERSOLARIS_1@ $(LIBPREFIX)muparser$(DEBUG_BUILD_POSTFIX).$(DLLIMP_SUFFIX) +@COND_PLATFORM_MACOSX_1@__muParser_dll___macver = \ +@COND_PLATFORM_MACOSX_1@ -compatibility_version 1 -current_version 1 +@COND_SAMPLES_1@__example1___depname = \ +@COND_SAMPLES_1@ $(top_builddir)/samples/example1/example1$(EXEEXT) +@COND_PLATFORM_MAC_0@__example1___mac_setfilecmd = @true +@COND_PLATFORM_MAC_1@__example1___mac_setfilecmd = \ +@COND_PLATFORM_MAC_1@ $(SETFILE) -t APPL \ +@COND_PLATFORM_MAC_1@ $(top_builddir)/samples/example1/example1$(EXEEXT) +@COND_SHARED_0@____SHARED = +@COND_SHARED_1@____SHARED = -DMUPARSER_DLL +@COND_SHARED_0@____SHARED_0 = +@COND_SHARED_1@____SHARED_0 = -DMUPARSERLIB_EXPORTS +@COND_DEBUG_0@____DEBUG = -DNDEBUG +@COND_DEBUG_1@____DEBUG = + +### Targets: ### + +all: $(__muParser_lib___depname) $(__muParser_dll___depname) $(__example1___depname) + +install: $(__install_muParser_lib___depname) $(__install_muParser_lib_headers___depname) $(__install_muParser_dll___depname) $(__install_muParser_dll_headers___depname) + $(INSTALL_DIR) $(DESTDIR)$(libdir)/pkgconfig + $(INSTALL_DATA) build/autoconf/muparser.pc $(DESTDIR)$(libdir)/pkgconfig + +uninstall: $(__uninstall_muParser_lib___depname) $(__uninstall_muParser_lib_headers___depname) $(__uninstall_muParser_dll___depname) $(__uninstall_muParser_dll_headers___depname) + +install-strip: install + $(STRIP) $(DESTDIR)$(libdir)/$(DLLPREFIX)muparser$(DEBUG_BUILD_POSTFIX)$(__muParser_dll___targetsuf3) + +clean: + rm -rf ./.deps ./.pch + rm -f ./*.o + rm -f $(top_builddir)/lib/$(LIBPREFIX)muparser$(DEBUG_BUILD_POSTFIX)$(LIBEXT) + rm -f $(top_builddir)/lib/$(DLLPREFIX)muparser$(DEBUG_BUILD_POSTFIX)$(__muParser_dll___targetsuf3) + rm -f $(top_builddir)/lib/$(LIBPREFIX)muparser$(DEBUG_BUILD_POSTFIX).$(DLLIMP_SUFFIX) + rm -f $(top_builddir)/lib/$(LIBPREFIX)muparser$(DEBUG_BUILD_POSTFIX).$(DLLIMP_SUFFIX) $(top_builddir)/lib/$(DLLPREFIX)muparser$(DEBUG_BUILD_POSTFIX)$(__muParser_dll___targetsuf2) + rm -f $(top_builddir)/samples/example1/example1$(EXEEXT) + +distclean: clean + rm -f config.cache config.log config.status bk-deps bk-make-pch shared-ld-sh Makefile + rm -f build/autoconf/muparser.pc + +@COND_SHARED_0@$(top_builddir)/lib/$(LIBPREFIX)muparser$(DEBUG_BUILD_POSTFIX)$(LIBEXT): $(MUPARSER_LIB_OBJECTS) +@COND_SHARED_0@ rm -f $@ +@COND_SHARED_0@ $(AR) $(AROPTIONS) $@ $(MUPARSER_LIB_OBJECTS) +@COND_SHARED_0@ $(RANLIB) $@ + +@COND_SHARED_0@install_muParser_lib: $(__muParser_lib___depname) +@COND_SHARED_0@ $(INSTALL_DIR) $(DESTDIR)$(libdir) +@COND_SHARED_0@ $(INSTALL_DATA) $(top_builddir)/lib/$(LIBPREFIX)muparser$(DEBUG_BUILD_POSTFIX)$(LIBEXT) $(DESTDIR)$(libdir) + +@COND_SHARED_0@uninstall_muParser_lib: +@COND_SHARED_0@ rm -f $(DESTDIR)$(libdir)/$(LIBPREFIX)muparser$(DEBUG_BUILD_POSTFIX)$(LIBEXT) + +@COND_SHARED_0@install_muParser_lib_headers: +@COND_SHARED_0@ $(INSTALL_DIR) $(DESTDIR)$(prefix) +@COND_SHARED_0@ for f in $(MUPARSER_LIB_HEADERS); do \ +@COND_SHARED_0@ if test ! -d $(DESTDIR)$(prefix)/`dirname $$f` ; then \ +@COND_SHARED_0@ $(INSTALL_DIR) $(DESTDIR)$(prefix)/`dirname $$f`; \ +@COND_SHARED_0@ fi; \ +@COND_SHARED_0@ $(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)$(prefix)/$$f; \ +@COND_SHARED_0@ done + +@COND_SHARED_0@uninstall_muParser_lib_headers: +@COND_SHARED_0@ for f in $(MUPARSER_LIB_HEADERS); do \ +@COND_SHARED_0@ rm -f $(DESTDIR)$(prefix)/$$f; \ +@COND_SHARED_0@ done + +@COND_SHARED_1@$(top_builddir)/lib/$(DLLPREFIX)muparser$(DEBUG_BUILD_POSTFIX)$(__muParser_dll___targetsuf3): $(MUPARSER_DLL_OBJECTS) +@COND_SHARED_1@ $(SHARED_LD_CXX) $@ $(MUPARSER_DLL_OBJECTS) $(__muParser_dll___macinstnamecmd) $(__muParser_dll___importlib) $(__muParser_dll___soname_flags) $(__muParser_dll___macver) $(LDFLAGS) $(LIBS) +@COND_SHARED_1@ +@COND_SHARED_1@ $(__muParser_dll___so_symlinks_cmd) + +@COND_SHARED_1@install_muParser_dll: $(__muParser_dll___depname) +@COND_SHARED_1@ $(INSTALL_DIR) $(DESTDIR)$(libdir) +@COND_SHARED_1@ $(INSTALL_DATA) $(top_builddir)/lib/$(LIBPREFIX)muparser$(DEBUG_BUILD_POSTFIX).$(DLLIMP_SUFFIX) $(DESTDIR)$(libdir) +@COND_SHARED_1@ $(INSTALL_PROGRAM) $(top_builddir)/lib/$(DLLPREFIX)muparser$(DEBUG_BUILD_POSTFIX)$(__muParser_dll___targetsuf3) $(DESTDIR)$(libdir) +@COND_SHARED_1@ (cd $(DESTDIR)$(libdir) ; $(__muParser_dll___so_symlinks_inst_cmd)) + +@COND_SHARED_1@uninstall_muParser_dll: +@COND_SHARED_1@ rm -f $(DESTDIR)$(libdir)/$(LIBPREFIX)muparser$(DEBUG_BUILD_POSTFIX).$(DLLIMP_SUFFIX) +@COND_SHARED_1@ rm -f $(DESTDIR)$(libdir)/$(DLLPREFIX)muparser$(DEBUG_BUILD_POSTFIX)$(__muParser_dll___targetsuf3) +@COND_SHARED_1@ (cd $(DESTDIR)$(libdir) ; $(__muParser_dll___so_symlinks_uninst_cmd)) + +@COND_SHARED_1@install_muParser_dll_headers: +@COND_SHARED_1@ $(INSTALL_DIR) $(DESTDIR)$(prefix) +@COND_SHARED_1@ for f in $(MUPARSER_DLL_HEADERS); do \ +@COND_SHARED_1@ if test ! -d $(DESTDIR)$(prefix)/`dirname $$f` ; then \ +@COND_SHARED_1@ $(INSTALL_DIR) $(DESTDIR)$(prefix)/`dirname $$f`; \ +@COND_SHARED_1@ fi; \ +@COND_SHARED_1@ $(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)$(prefix)/$$f; \ +@COND_SHARED_1@ done + +@COND_SHARED_1@uninstall_muParser_dll_headers: +@COND_SHARED_1@ for f in $(MUPARSER_DLL_HEADERS); do \ +@COND_SHARED_1@ rm -f $(DESTDIR)$(prefix)/$$f; \ +@COND_SHARED_1@ done + +@COND_SAMPLES_1@$(top_builddir)/samples/example1/example1$(EXEEXT): $(EXAMPLE1_OBJECTS) $(__muParser_lib___depname) +@COND_SAMPLES_1@ $(CXX) -o $@ $(EXAMPLE1_OBJECTS) -L$(top_builddir)/lib -L$(srcdir)/lib $(LDFLAGS) -lmuparser$(DEBUG_BUILD_POSTFIX) $(LIBS) +@COND_SAMPLES_1@ +@COND_SAMPLES_1@ $(__example1___mac_setfilecmd) + +lib: $(__muParser_lib___depname) $(__muParser_dll___depname) + +samples: $(__example1___depname) + +documentation: + ( cd $(srcdir)/docs && doxygen ) + +muParser_lib_muParser.o: $(srcdir)/src/muParser.cpp + $(CXXC) -c -o $@ $(MUPARSER_LIB_CXXFLAGS) $(srcdir)/src/muParser.cpp + +muParser_lib_muParserBase.o: $(srcdir)/src/muParserBase.cpp + $(CXXC) -c -o $@ $(MUPARSER_LIB_CXXFLAGS) $(srcdir)/src/muParserBase.cpp + +muParser_lib_muParserBytecode.o: $(srcdir)/src/muParserBytecode.cpp + $(CXXC) -c -o $@ $(MUPARSER_LIB_CXXFLAGS) $(srcdir)/src/muParserBytecode.cpp + +muParser_lib_muParserCallback.o: $(srcdir)/src/muParserCallback.cpp + $(CXXC) -c -o $@ $(MUPARSER_LIB_CXXFLAGS) $(srcdir)/src/muParserCallback.cpp + +muParser_lib_muParserComplex.o: $(srcdir)/src/muParserComplex.cpp + $(CXXC) -c -o $@ $(MUPARSER_LIB_CXXFLAGS) $(srcdir)/src/muParserComplex.cpp + +muParser_lib_muParserDLL.o: $(srcdir)/src/muParserDLL.cpp + $(CXXC) -c -o $@ $(MUPARSER_LIB_CXXFLAGS) $(srcdir)/src/muParserDLL.cpp + +muParser_lib_muParserError.o: $(srcdir)/src/muParserError.cpp + $(CXXC) -c -o $@ $(MUPARSER_LIB_CXXFLAGS) $(srcdir)/src/muParserError.cpp + +muParser_lib_muParserInt.o: $(srcdir)/src/muParserInt.cpp + $(CXXC) -c -o $@ $(MUPARSER_LIB_CXXFLAGS) $(srcdir)/src/muParserInt.cpp + +muParser_lib_muParserTest.o: $(srcdir)/src/muParserTest.cpp + $(CXXC) -c -o $@ $(MUPARSER_LIB_CXXFLAGS) $(srcdir)/src/muParserTest.cpp + +muParser_lib_muParserTokenReader.o: $(srcdir)/src/muParserTokenReader.cpp + $(CXXC) -c -o $@ $(MUPARSER_LIB_CXXFLAGS) $(srcdir)/src/muParserTokenReader.cpp + +muParser_dll_muParser.o: $(srcdir)/src/muParser.cpp + $(CXXC) -c -o $@ $(MUPARSER_DLL_CXXFLAGS) $(srcdir)/src/muParser.cpp + +muParser_dll_muParserBase.o: $(srcdir)/src/muParserBase.cpp + $(CXXC) -c -o $@ $(MUPARSER_DLL_CXXFLAGS) $(srcdir)/src/muParserBase.cpp + +muParser_dll_muParserBytecode.o: $(srcdir)/src/muParserBytecode.cpp + $(CXXC) -c -o $@ $(MUPARSER_DLL_CXXFLAGS) $(srcdir)/src/muParserBytecode.cpp + +muParser_dll_muParserCallback.o: $(srcdir)/src/muParserCallback.cpp + $(CXXC) -c -o $@ $(MUPARSER_DLL_CXXFLAGS) $(srcdir)/src/muParserCallback.cpp + +muParser_dll_muParserComplex.o: $(srcdir)/src/muParserComplex.cpp + $(CXXC) -c -o $@ $(MUPARSER_DLL_CXXFLAGS) $(srcdir)/src/muParserComplex.cpp + +muParser_dll_muParserDLL.o: $(srcdir)/src/muParserDLL.cpp + $(CXXC) -c -o $@ $(MUPARSER_DLL_CXXFLAGS) $(srcdir)/src/muParserDLL.cpp + +muParser_dll_muParserError.o: $(srcdir)/src/muParserError.cpp + $(CXXC) -c -o $@ $(MUPARSER_DLL_CXXFLAGS) $(srcdir)/src/muParserError.cpp + +muParser_dll_muParserInt.o: $(srcdir)/src/muParserInt.cpp + $(CXXC) -c -o $@ $(MUPARSER_DLL_CXXFLAGS) $(srcdir)/src/muParserInt.cpp + +muParser_dll_muParserTest.o: $(srcdir)/src/muParserTest.cpp + $(CXXC) -c -o $@ $(MUPARSER_DLL_CXXFLAGS) $(srcdir)/src/muParserTest.cpp + +muParser_dll_muParserTokenReader.o: $(srcdir)/src/muParserTokenReader.cpp + $(CXXC) -c -o $@ $(MUPARSER_DLL_CXXFLAGS) $(srcdir)/src/muParserTokenReader.cpp + +example1_Example1.o: $(srcdir)/samples/example1/Example1.cpp + $(CXXC) -c -o $@ $(EXAMPLE1_CXXFLAGS) $(srcdir)/samples/example1/Example1.cpp + + +# Include dependency info, if present: +@IF_GNU_MAKE@-include ./.deps/*.d + +.PHONY: all install uninstall clean distclean install_muParser_lib \ + uninstall_muParser_lib install_muParser_lib_headers \ + uninstall_muParser_lib_headers install_muParser_dll uninstall_muParser_dll \ + install_muParser_dll_headers uninstall_muParser_dll_headers lib samples diff --git a/AMDiS/lib/muparser_v134/build/autoconf/aclocal.m4 b/AMDiS/lib/muparser_v134/build/autoconf/aclocal.m4 new file mode 100644 index 0000000000000000000000000000000000000000..e15c360cb4b8be67f364402b156cf50fa2cb8e88 --- /dev/null +++ b/AMDiS/lib/muparser_v134/build/autoconf/aclocal.m4 @@ -0,0 +1,1991 @@ +# generated automatically by aclocal 1.11 -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +AC_DEFUN([AC_BAKEFILE_CREATE_FILE_DLLAR_SH], +[ +dnl ===================== dllar.sh begins here ===================== +dnl (Created by merge-scripts.py from dllar.sh +dnl file do not edit here!) +D='$' +cat <<EOF >dllar.sh +#!/bin/sh +# +# dllar - a tool to build both a .dll and an .a file +# from a set of object (.o) files for EMX/OS2. +# +# Written by Andrew Zabolotny, bit@freya.etu.ru +# Ported to Unix like shell by Stefan Neis, Stefan.Neis@t-online.de +# +# This script will accept a set of files on the command line. +# All the public symbols from the .o files will be exported into +# a .DEF file, then linker will be run (through gcc) against them to +# build a shared library consisting of all given .o files. All libraries +# (.a) will be first decompressed into component .o files then act as +# described above. You can optionally give a description (-d "description") +# which will be put into .DLL. To see the list of accepted options (as well +# as command-line format) simply run this program without options. The .DLL +# is built to be imported by name (there is no guarantee that new versions +# of the library you build will have same ordinals for same symbols). +# +# dllar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# dllar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with dllar; see the file COPYING. If not, write to the Free +# Software Foundation, 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# To successfuly run this program you will need: +# - Current drive should have LFN support (HPFS, ext2, network, etc) +# (Sometimes dllar generates filenames which won't fit 8.3 scheme) +# - gcc +# (used to build the .dll) +# - emxexp +# (used to create .def file from .o files) +# - emximp +# (used to create .a file from .def file) +# - GNU text utilites (cat, sort, uniq) +# used to process emxexp output +# - GNU file utilities (mv, rm) +# - GNU sed +# - lxlite (optional, see flag below) +# (used for general .dll cleanup) +# + +flag_USE_LXLITE=1; + +# +# helper functions +# basnam, variant of basename, which does _not_ remove the path, _iff_ +# second argument (suffix to remove) is given +basnam(){ + case ${D}# in + 1) + echo ${D}1 | sed 's/.*\\///' | sed 's/.*\\\\//' + ;; + 2) + echo ${D}1 | sed 's/'${D}2'${D}//' + ;; + *) + echo "error in basnam ${D}*" + exit 8 + ;; + esac +} + +# Cleanup temporary files and output +CleanUp() { + cd ${D}curDir + for i in ${D}inputFiles ; do + case ${D}i in + *!) + rm -rf \`basnam ${D}i !\` + ;; + *) + ;; + esac + done + + # Kill result in case of failure as there is just to many stupid make/nmake + # things out there which doesn't do this. + if @<:@ ${D}# -eq 0 @:>@; then + rm -f ${D}arcFile ${D}arcFile2 ${D}defFile ${D}dllFile + fi +} + +# Print usage and exit script with rc=1. +PrintHelp() { + echo 'Usage: dllar.sh @<:@-o@<:@utput@:>@ output_file@:>@ @<:@-i@<:@mport@:>@ importlib_name@:>@' + echo ' @<:@-name-mangler-script script.sh@:>@' + echo ' @<:@-d@<:@escription@:>@ "dll descrption"@:>@ @<:@-cc "CC"@:>@ @<:@-f@<:@lags@:>@ "CFLAGS"@:>@' + echo ' @<:@-ord@<:@inals@:>@@:>@ -ex@<:@clude@:>@ "symbol(s)"' + echo ' @<:@-libf@<:@lags@:>@ "{INIT|TERM}{GLOBAL|INSTANCE}"@:>@ @<:@-nocrt@<:@dll@:>@@:>@ @<:@-nolxl@<:@ite@:>@@:>@' + echo ' @<:@*.o@:>@ @<:@*.a@:>@' + echo '*> "output_file" should have no extension.' + echo ' If it has the .o, .a or .dll extension, it is automatically removed.' + echo ' The import library name is derived from this and is set to "name".a,' + echo ' unless overridden by -import' + echo '*> "importlib_name" should have no extension.' + echo ' If it has the .o, or .a extension, it is automatically removed.' + echo ' This name is used as the import library name and may be longer and' + echo ' more descriptive than the DLL name which has to follow the old ' + echo ' 8.3 convention of FAT.' + echo '*> "script.sh may be given to override the output_file name by a' + echo ' different name. It is mainly useful if the regular make process' + echo ' of some package does not take into account OS/2 restriction of' + echo ' DLL name lengths. It takes the importlib name as input and is' + echo ' supposed to procude a shorter name as output. The script should' + echo ' expect to get importlib_name without extension and should produce' + echo ' a (max.) 8 letter name without extension.' + echo '*> "cc" is used to use another GCC executable. (default: gcc.exe)' + echo '*> "flags" should be any set of valid GCC flags. (default: -s -Zcrtdll)' + echo ' These flags will be put at the start of GCC command line.' + echo '*> -ord@<:@inals@:>@ tells dllar to export entries by ordinals. Be careful.' + echo '*> -ex@<:@clude@:>@ defines symbols which will not be exported. You can define' + echo ' multiple symbols, for example -ex "myfunc yourfunc _GLOBAL*".' + echo ' If the last character of a symbol is "*", all symbols beginning' + echo ' with the prefix before "*" will be exclude, (see _GLOBAL* above).' + echo '*> -libf@<:@lags@:>@ can be used to add INITGLOBAL/INITINSTANCE and/or' + echo ' TERMGLOBAL/TERMINSTANCE flags to the dynamically-linked library.' + echo '*> -nocrt@<:@dll@:>@ switch will disable linking the library against emx''s' + echo ' C runtime DLLs.' + echo '*> -nolxl@<:@ite@:>@ switch will disable running lxlite on the resulting DLL.' + echo '*> All other switches (for example -L./ or -lmylib) will be passed' + echo ' unchanged to GCC at the end of command line.' + echo '*> If you create a DLL from a library and you do not specify -o,' + echo ' the basename for DLL and import library will be set to library name,' + echo ' the initial library will be renamed to 'name'_s.a (_s for static)' + echo ' i.e. "dllar gcc.a" will create gcc.dll and gcc.a, and the initial' + echo ' library will be renamed into gcc_s.a.' + echo '--------' + echo 'Example:' + echo ' dllar -o gcc290.dll libgcc.a -d "GNU C runtime library" -ord' + echo ' -ex "__main __ctordtor*" -libf "INITINSTANCE TERMINSTANCE"' + CleanUp + exit 1 +} + +# Execute a command. +# If exit code of the commnad <> 0 CleanUp() is called and we'll exit the script. +# @Uses Whatever CleanUp() uses. +doCommand() { + echo "${D}*" + eval ${D}* + rcCmd=${D}? + + if @<:@ ${D}rcCmd -ne 0 @:>@; then + echo "command failed, exit code="${D}rcCmd + CleanUp + exit ${D}rcCmd + fi +} + +# main routine +# setup globals +cmdLine=${D}* +outFile="" +outimpFile="" +inputFiles="" +renameScript="" +description="" +CC=gcc.exe +CFLAGS="-s -Zcrtdll" +EXTRA_CFLAGS="" +EXPORT_BY_ORDINALS=0 +exclude_symbols="" +library_flags="" +curDir=\`pwd\` +curDirS=curDir +case ${D}curDirS in +*/) + ;; +*) + curDirS=${D}{curDirS}"/" + ;; +esac +# Parse commandline +libsToLink=0 +omfLinking=0 +while @<:@ ${D}1 @:>@; do + case ${D}1 in + -ord*) + EXPORT_BY_ORDINALS=1; + ;; + -o*) + shift + outFile=${D}1 + ;; + -i*) + shift + outimpFile=${D}1 + ;; + -name-mangler-script) + shift + renameScript=${D}1 + ;; + -d*) + shift + description=${D}1 + ;; + -f*) + shift + CFLAGS=${D}1 + ;; + -c*) + shift + CC=${D}1 + ;; + -h*) + PrintHelp + ;; + -ex*) + shift + exclude_symbols=${D}{exclude_symbols}${D}1" " + ;; + -libf*) + shift + library_flags=${D}{library_flags}${D}1" " + ;; + -nocrt*) + CFLAGS="-s" + ;; + -nolxl*) + flag_USE_LXLITE=0 + ;; + -* | /*) + case ${D}1 in + -L* | -l*) + libsToLink=1 + ;; + -Zomf) + omfLinking=1 + ;; + *) + ;; + esac + EXTRA_CFLAGS=${D}{EXTRA_CFLAGS}" "${D}1 + ;; + *.dll) + EXTRA_CFLAGS="${D}{EXTRA_CFLAGS} \`basnam ${D}1 .dll\`" + if @<:@ ${D}omfLinking -eq 1 @:>@; then + EXTRA_CFLAGS="${D}{EXTRA_CFLAGS}.lib" + else + EXTRA_CFLAGS="${D}{EXTRA_CFLAGS}.a" + fi + ;; + *) + found=0; + if @<:@ ${D}libsToLink -ne 0 @:>@; then + EXTRA_CFLAGS=${D}{EXTRA_CFLAGS}" "${D}1 + else + for file in ${D}1 ; do + if @<:@ -f ${D}file @:>@; then + inputFiles="${D}{inputFiles} ${D}file" + found=1 + fi + done + if @<:@ ${D}found -eq 0 @:>@; then + echo "ERROR: No file(s) found: "${D}1 + exit 8 + fi + fi + ;; + esac + shift +done # iterate cmdline words + +# +if @<:@ -z "${D}inputFiles" @:>@; then + echo "dllar: no input files" + PrintHelp +fi + +# Now extract all .o files from .a files +newInputFiles="" +for file in ${D}inputFiles ; do + case ${D}file in + *.a | *.lib) + case ${D}file in + *.a) + suffix=".a" + AR="ar" + ;; + *.lib) + suffix=".lib" + AR="emxomfar" + EXTRA_CFLAGS="${D}EXTRA_CFLAGS -Zomf" + ;; + *) + ;; + esac + dirname=\`basnam ${D}file ${D}suffix\`"_%" + mkdir ${D}dirname + if @<:@ ${D}? -ne 0 @:>@; then + echo "Failed to create subdirectory ./${D}dirname" + CleanUp + exit 8; + fi + # Append '!' to indicate archive + newInputFiles="${D}newInputFiles ${D}{dirname}!" + doCommand "cd ${D}dirname; ${D}AR x ../${D}file" + cd ${D}curDir + found=0; + for subfile in ${D}dirname/*.o* ; do + if @<:@ -f ${D}subfile @:>@; then + found=1 + if @<:@ -s ${D}subfile @:>@; then + # FIXME: This should be: is file size > 32 byte, _not_ > 0! + newInputFiles="${D}newInputFiles ${D}subfile" + fi + fi + done + if @<:@ ${D}found -eq 0 @:>@; then + echo "WARNING: there are no files in archive \\'${D}file\\'" + fi + ;; + *) + newInputFiles="${D}{newInputFiles} ${D}file" + ;; + esac +done +inputFiles="${D}newInputFiles" + +# Output filename(s). +do_backup=0; +if @<:@ -z ${D}outFile @:>@; then + do_backup=1; + set outFile ${D}inputFiles; outFile=${D}2 +fi + +# If it is an archive, remove the '!' and the '_%' suffixes +case ${D}outFile in +*_%!) + outFile=\`basnam ${D}outFile _%!\` + ;; +*) + ;; +esac +case ${D}outFile in +*.dll) + outFile=\`basnam ${D}outFile .dll\` + ;; +*.DLL) + outFile=\`basnam ${D}outFile .DLL\` + ;; +*.o) + outFile=\`basnam ${D}outFile .o\` + ;; +*.obj) + outFile=\`basnam ${D}outFile .obj\` + ;; +*.a) + outFile=\`basnam ${D}outFile .a\` + ;; +*.lib) + outFile=\`basnam ${D}outFile .lib\` + ;; +*) + ;; +esac +case ${D}outimpFile in +*.a) + outimpFile=\`basnam ${D}outimpFile .a\` + ;; +*.lib) + outimpFile=\`basnam ${D}outimpFile .lib\` + ;; +*) + ;; +esac +if @<:@ -z ${D}outimpFile @:>@; then + outimpFile=${D}outFile +fi +defFile="${D}{outFile}.def" +arcFile="${D}{outimpFile}.a" +arcFile2="${D}{outimpFile}.lib" + +#create ${D}dllFile as something matching 8.3 restrictions, +if @<:@ -z ${D}renameScript @:>@ ; then + dllFile="${D}outFile" +else + dllFile=\`${D}renameScript ${D}outimpFile\` +fi + +if @<:@ ${D}do_backup -ne 0 @:>@ ; then + if @<:@ -f ${D}arcFile @:>@ ; then + doCommand "mv ${D}arcFile ${D}{outFile}_s.a" + fi + if @<:@ -f ${D}arcFile2 @:>@ ; then + doCommand "mv ${D}arcFile2 ${D}{outFile}_s.lib" + fi +fi + +# Extract public symbols from all the object files. +tmpdefFile=${D}{defFile}_% +rm -f ${D}tmpdefFile +for file in ${D}inputFiles ; do + case ${D}file in + *!) + ;; + *) + doCommand "emxexp -u ${D}file >> ${D}tmpdefFile" + ;; + esac +done + +# Create the def file. +rm -f ${D}defFile +echo "LIBRARY \`basnam ${D}dllFile\` ${D}library_flags" >> ${D}defFile +dllFile="${D}{dllFile}.dll" +if @<:@ ! -z ${D}description @:>@; then + echo "DESCRIPTION \\"${D}{description}\\"" >> ${D}defFile +fi +echo "EXPORTS" >> ${D}defFile + +doCommand "cat ${D}tmpdefFile | sort.exe | uniq.exe > ${D}{tmpdefFile}%" +grep -v "^ *;" < ${D}{tmpdefFile}% | grep -v "^ *${D}" >${D}tmpdefFile + +# Checks if the export is ok or not. +for word in ${D}exclude_symbols; do + grep -v ${D}word < ${D}tmpdefFile >${D}{tmpdefFile}% + mv ${D}{tmpdefFile}% ${D}tmpdefFile +done + + +if @<:@ ${D}EXPORT_BY_ORDINALS -ne 0 @:>@; then + sed "=" < ${D}tmpdefFile | \\ + sed ' + N + : loop + s/^\\(@<:@0-9@:>@\\+\\)\\(@<:@^;@:>@*\\)\\(;.*\\)\\?/\\2 @\\1 NONAME/ + t loop + ' > ${D}{tmpdefFile}% + grep -v "^ *${D}" < ${D}{tmpdefFile}% > ${D}tmpdefFile +else + rm -f ${D}{tmpdefFile}% +fi +cat ${D}tmpdefFile >> ${D}defFile +rm -f ${D}tmpdefFile + +# Do linking, create implib, and apply lxlite. +gccCmdl=""; +for file in ${D}inputFiles ; do + case ${D}file in + *!) + ;; + *) + gccCmdl="${D}gccCmdl ${D}file" + ;; + esac +done +doCommand "${D}CC ${D}CFLAGS -Zdll -o ${D}dllFile ${D}defFile ${D}gccCmdl ${D}EXTRA_CFLAGS" +touch "${D}{outFile}.dll" + +doCommand "emximp -o ${D}arcFile ${D}defFile" +if @<:@ ${D}flag_USE_LXLITE -ne 0 @:>@; then + add_flags=""; + if @<:@ ${D}EXPORT_BY_ORDINALS -ne 0 @:>@; then + add_flags="-ynd" + fi + doCommand "lxlite -cs -t: -mrn -mln ${D}add_flags ${D}dllFile" +fi +doCommand "emxomf -s -l ${D}arcFile" + +# Successful exit. +CleanUp 1 +exit 0 +EOF +dnl ===================== dllar.sh ends here ===================== +]) + +dnl +dnl This file is part of Bakefile (http://www.bakefile.org) +dnl +dnl Copyright (C) 2003-2007 Vaclav Slavik, David Elliott and others +dnl +dnl Permission is hereby granted, free of charge, to any person obtaining a +dnl copy of this software and associated documentation files (the "Software"), +dnl to deal in the Software without restriction, including without limitation +dnl the rights to use, copy, modify, merge, publish, distribute, sublicense, +dnl and/or sell copies of the Software, and to permit persons to whom the +dnl Software is furnished to do so, subject to the following conditions: +dnl +dnl The above copyright notice and this permission notice shall be included in +dnl all copies or substantial portions of the Software. +dnl +dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +dnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +dnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +dnl DEALINGS IN THE SOFTWARE. +dnl +dnl $Id: bakefile-lang.m4 1278 2008-11-17 22:26:10Z vadz $ +dnl +dnl Compiler detection macros by David Elliott and Vadim Zeitlin +dnl + + +dnl =========================================================================== +dnl Macros to detect different C/C++ compilers +dnl =========================================================================== + +dnl Based on autoconf _AC_LANG_COMPILER_GNU +dnl _AC_BAKEFILE_LANG_COMPILER(NAME, LANG, SYMBOL, IF-YES, IF-NO) +AC_DEFUN([_AC_BAKEFILE_LANG_COMPILER], +[ + AC_LANG_PUSH($2) + AC_CACHE_CHECK( + [whether we are using the $1 $2 compiler], + [bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_[]$3], + [AC_TRY_COMPILE( + [], + [ + #ifndef $3 + choke me + #endif + ], + [bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_[]$3=yes], + [bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_[]$3=no] + ) + ] + ) + if test "x$bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_[]$3" = "xyes"; then + :; $4 + else + :; $5 + fi + AC_LANG_POP($2) +]) + +dnl More specific version of the above macro checking whether the compiler +dnl version is at least the given one (assumes that we do use this compiler) +dnl +dnl _AC_BAKEFILE_LANG_COMPILER_LATER_THAN(NAME, LANG, SYMBOL, VER, VERMSG, IF-YES, IF-NO) +AC_DEFUN([_AC_BAKEFILE_LANG_COMPILER_LATER_THAN], +[ + AC_LANG_PUSH($2) + AC_CACHE_CHECK( + [whether we are using $1 $2 compiler v$5 or later], + [bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_[]$3[]_lt_[]$4], + [AC_TRY_COMPILE( + [], + [ + #ifndef $3 || $3 < $4 + choke me + #endif + ], + [bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_[]$3[]_lt_[]$4=yes], + [bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_[]$3[]_lt_[]$4=no] + ) + ] + ) + if test "x$bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_[]$3[]_lt_[]$4" = "xyes"; then + :; $6 + else + :; $7 + fi + AC_LANG_POP($2) +]) + +dnl CodeWarrior Metrowerks compiler defines __MWERKS__ for both C and C++ +AC_DEFUN([AC_BAKEFILE_PROG_MWCC], +[ + _AC_BAKEFILE_LANG_COMPILER(Metrowerks, C, __MWERKS__, MWCC=yes) +]) + +AC_DEFUN([AC_BAKEFILE_PROG_MWCXX], +[ + _AC_BAKEFILE_LANG_COMPILER(Metrowerks, C++, __MWERKS__, MWCXX=yes) +]) + +dnl IBM xlC compiler defines __xlC__ for both C and C++ +AC_DEFUN([AC_BAKEFILE_PROG_XLCC], +[ + _AC_BAKEFILE_LANG_COMPILER([IBM xlC], C, __xlC__, XLCC=yes) +]) + +AC_DEFUN([AC_BAKEFILE_PROG_XLCXX], +[ + _AC_BAKEFILE_LANG_COMPILER([IBM xlC], C++, __xlC__, XLCXX=yes) +]) + +dnl recent versions of SGI mipsPro compiler define _SGI_COMPILER_VERSION +dnl +dnl NB: old versions define _COMPILER_VERSION but this could probably be +dnl defined by other compilers too so don't test for it to be safe +AC_DEFUN([AC_BAKEFILE_PROG_SGICC], +[ + _AC_BAKEFILE_LANG_COMPILER(SGI, C, _SGI_COMPILER_VERSION, SGICC=yes) +]) + +AC_DEFUN([AC_BAKEFILE_PROG_SGICXX], +[ + _AC_BAKEFILE_LANG_COMPILER(SGI, C++, _SGI_COMPILER_VERSION, SGICXX=yes) +]) + +dnl Sun compiler defines __SUNPRO_C/__SUNPRO_CC +AC_DEFUN([AC_BAKEFILE_PROG_SUNCC], +[ + _AC_BAKEFILE_LANG_COMPILER(Sun, C, __SUNPRO_C, SUNCC=yes) +]) + +AC_DEFUN([AC_BAKEFILE_PROG_SUNCXX], +[ + _AC_BAKEFILE_LANG_COMPILER(Sun, C++, __SUNPRO_CC, SUNCXX=yes) +]) + +dnl Intel icc compiler defines __INTEL_COMPILER for both C and C++ +AC_DEFUN([AC_BAKEFILE_PROG_INTELCC], +[ + _AC_BAKEFILE_LANG_COMPILER(Intel, C, __INTEL_COMPILER, INTELCC=yes) +]) + +AC_DEFUN([AC_BAKEFILE_PROG_INTELCXX], +[ + _AC_BAKEFILE_LANG_COMPILER(Intel, C++, __INTEL_COMPILER, INTELCXX=yes) +]) + +dnl Intel compiler command line options changed in incompatible ways sometimes +dnl before v8 (-KPIC was replaced with gcc-compatible -fPIC) and again in v10 +dnl (-create-pch deprecated in favour of -pch-create) so we need to test for +dnl its exact version too +AC_DEFUN([AC_BAKEFILE_PROG_INTELCC_8], +[ + _AC_BAKEFILE_LANG_COMPILER_LATER_THAN(Intel, C, __INTEL_COMPILER, 800, 8, INTELCC8=yes) +]) +AC_DEFUN([AC_BAKEFILE_PROG_INTELCXX_8], +[ + _AC_BAKEFILE_LANG_COMPILER_LATER_THAN(Intel, C++, __INTEL_COMPILER, 800, 8, INTELCXX8=yes) +]) + +AC_DEFUN([AC_BAKEFILE_PROG_INTELCC_10], +[ + _AC_BAKEFILE_LANG_COMPILER_LATER_THAN(Intel, C, __INTEL_COMPILER, 1000, 10, INTELCC10=yes) +]) + +AC_DEFUN([AC_BAKEFILE_PROG_INTELCXX_10], +[ + _AC_BAKEFILE_LANG_COMPILER_LATER_THAN(Intel, C++, __INTEL_COMPILER, 1000, 10, INTELCXX10=yes) +]) + +dnl HP-UX aCC: see http://docs.hp.com/en/6162/preprocess.htm#macropredef +AC_DEFUN([AC_BAKEFILE_PROG_HPCC], +[ + _AC_BAKEFILE_LANG_COMPILER(HP, C, __HP_cc, HPCC=yes) +]) + +AC_DEFUN([AC_BAKEFILE_PROG_HPCXX], +[ + _AC_BAKEFILE_LANG_COMPILER(HP, C++, __HP_aCC, HPCXX=yes) +]) + +dnl Tru64 cc and cxx +AC_DEFUN([AC_BAKEFILE_PROG_COMPAQCC], +[ + _AC_BAKEFILE_LANG_COMPILER(Compaq, C, __DECC, COMPAQCC=yes) +]) + +AC_DEFUN([AC_BAKEFILE_PROG_COMPAQCXX], +[ + _AC_BAKEFILE_LANG_COMPILER(Compaq, C++, __DECCXX, COMPAQCXX=yes) +]) + +dnl =========================================================================== +dnl macros to detect specialty compiler options +dnl =========================================================================== + +dnl Figure out if we need to pass -ext o to compiler (MetroWerks) +AC_DEFUN([AC_BAKEFILE_METROWERKS_EXTO], +[AC_CACHE_CHECK([if the _AC_LANG compiler requires -ext o], bakefile_cv_[]_AC_LANG_ABBREV[]_exto, +dnl First create an empty conf test +[AC_LANG_CONFTEST([AC_LANG_PROGRAM()]) +dnl Now remove .o and .c.o or .cc.o +rm -f conftest.$ac_objext conftest.$ac_ext.o +dnl Now compile the test +AS_IF([AC_TRY_EVAL(ac_compile)], +dnl If the test succeeded look for conftest.c.o or conftest.cc.o +[for ac_file in `(ls conftest.* 2>/dev/null)`; do + case $ac_file in + conftest.$ac_ext.o) + bakefile_cv_[]_AC_LANG_ABBREV[]_exto="-ext o" + ;; + *) + ;; + esac +done], +[AC_MSG_FAILURE([cannot figure out if compiler needs -ext o: cannot compile]) +]) dnl AS_IF + +rm -f conftest.$ac_ext.o conftest.$ac_objext conftest.$ac_ext +]) dnl AC_CACHE_CHECK + +if test "x$bakefile_cv_[]_AC_LANG_ABBREV[]_exto" '!=' "x"; then + if test "[]_AC_LANG_ABBREV[]" = "c"; then + CFLAGS="$bakefile_cv_[]_AC_LANG_ABBREV[]_exto $CFLAGS" + fi + if test "[]_AC_LANG_ABBREV[]" = "cxx"; then + CXXFLAGS="$bakefile_cv_[]_AC_LANG_ABBREV[]_exto $CXXFLAGS" + fi +fi +]) dnl AC_DEFUN + + +dnl =========================================================================== +dnl Macros to do all of the compiler detections as one macro +dnl =========================================================================== + +dnl check for different proprietary compilers depending on target platform +dnl _AC_BAKEFILE_PROG_COMPILER(LANG) +AC_DEFUN([_AC_BAKEFILE_PROG_COMPILER], +[ + AC_PROG_$1 + + dnl Intel compiler can be used under several different OS and even + dnl different architectures (x86, amd64 and Itanium) so it's easier to just + dnl always test for it + AC_BAKEFILE_PROG_INTEL$1 + + dnl If we use Intel compiler we also need to know its version + if test "$INTEL$1" = "yes"; then + AC_BAKEFILE_PROG_INTEL$1_8 + AC_BAKEFILE_PROG_INTEL$1_10 + fi + + dnl if we're using gcc, we can't be using any of incompatible compilers + if test "x$G$1" != "xyes"; then + if test "x$1" = "xC"; then + AC_BAKEFILE_METROWERKS_EXTO + if test "x$bakefile_cv_c_exto" '!=' "x"; then + unset ac_cv_prog_cc_g + _AC_PROG_CC_G + fi + fi + + dnl most of these compilers are only used under well-defined OS so + dnl don't waste time checking for them on other ones + case `uname -s` in + AIX*) + AC_BAKEFILE_PROG_XL$1 + ;; + + Darwin) + AC_BAKEFILE_PROG_MW$1 + if test "$MW$1" != "yes"; then + AC_BAKEFILE_PROG_XL$1 + fi + ;; + + IRIX*) + AC_BAKEFILE_PROG_SGI$1 + ;; + + Linux*) + dnl Sun CC is now available under Linux too, test for it unless + dnl we already found that we were using a different compiler + if test "$INTEL$1" != "yes"; then + AC_BAKEFILE_PROG_SUN$1 + fi + ;; + + HP-UX*) + AC_BAKEFILE_PROG_HP$1 + ;; + + OSF1) + AC_BAKEFILE_PROG_COMPAQ$1 + ;; + + SunOS) + AC_BAKEFILE_PROG_SUN$1 + ;; + esac + fi +]) + +AC_DEFUN([AC_BAKEFILE_PROG_CC], +[ + _AC_BAKEFILE_PROG_COMPILER(CC) +]) + +AC_DEFUN([AC_BAKEFILE_PROG_CXX], +[ + _AC_BAKEFILE_PROG_COMPILER(CXX) +]) + + +dnl +dnl This file is part of Bakefile (http://www.bakefile.org) +dnl +dnl Copyright (C) 2003-2007 Vaclav Slavik and others +dnl +dnl Permission is hereby granted, free of charge, to any person obtaining a +dnl copy of this software and associated documentation files (the "Software"), +dnl to deal in the Software without restriction, including without limitation +dnl the rights to use, copy, modify, merge, publish, distribute, sublicense, +dnl and/or sell copies of the Software, and to permit persons to whom the +dnl Software is furnished to do so, subject to the following conditions: +dnl +dnl The above copyright notice and this permission notice shall be included in +dnl all copies or substantial portions of the Software. +dnl +dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +dnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +dnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +dnl DEALINGS IN THE SOFTWARE. +dnl +dnl $Id: bakefile.m4 1327 2009-10-24 10:10:38Z vaclavslavik $ +dnl +dnl Support macros for makefiles generated by BAKEFILE. +dnl + + +dnl --------------------------------------------------------------------------- +dnl Lots of compiler & linker detection code contained here was taken from +dnl wxWidgets configure.in script (see http://www.wxwidgets.org) +dnl --------------------------------------------------------------------------- + + + +dnl --------------------------------------------------------------------------- +dnl AC_BAKEFILE_GNUMAKE +dnl +dnl Detects GNU make +dnl --------------------------------------------------------------------------- + +AC_DEFUN([AC_BAKEFILE_GNUMAKE], +[ + dnl does make support "-include" (only GNU make does AFAIK)? + AC_CACHE_CHECK([if make is GNU make], bakefile_cv_prog_makeisgnu, + [ + if ( ${SHELL-sh} -c "${MAKE-make} --version" 2> /dev/null | + egrep -s GNU > /dev/null); then + bakefile_cv_prog_makeisgnu="yes" + else + bakefile_cv_prog_makeisgnu="no" + fi + ]) + + if test "x$bakefile_cv_prog_makeisgnu" = "xyes"; then + IF_GNU_MAKE="" + else + IF_GNU_MAKE="#" + fi + AC_SUBST(IF_GNU_MAKE) +]) + +dnl --------------------------------------------------------------------------- +dnl AC_BAKEFILE_PLATFORM +dnl +dnl Detects platform and sets PLATFORM_XXX variables accordingly +dnl --------------------------------------------------------------------------- + +AC_DEFUN([AC_BAKEFILE_PLATFORM], +[ + PLATFORM_UNIX=0 + PLATFORM_WIN32=0 + PLATFORM_MSDOS=0 + PLATFORM_MAC=0 + PLATFORM_MACOS=0 + PLATFORM_MACOSX=0 + PLATFORM_OS2=0 + PLATFORM_BEOS=0 + + if test "x$BAKEFILE_FORCE_PLATFORM" = "x"; then + case "${BAKEFILE_HOST}" in + *-*-mingw32* ) + PLATFORM_WIN32=1 + ;; + *-pc-msdosdjgpp ) + PLATFORM_MSDOS=1 + ;; + *-pc-os2_emx | *-pc-os2-emx ) + PLATFORM_OS2=1 + ;; + *-*-darwin* ) + PLATFORM_MAC=1 + PLATFORM_MACOSX=1 + ;; + *-*-beos* ) + PLATFORM_BEOS=1 + ;; + powerpc-apple-macos* ) + PLATFORM_MAC=1 + PLATFORM_MACOS=1 + ;; + * ) + PLATFORM_UNIX=1 + ;; + esac + else + case "$BAKEFILE_FORCE_PLATFORM" in + win32 ) + PLATFORM_WIN32=1 + ;; + msdos ) + PLATFORM_MSDOS=1 + ;; + os2 ) + PLATFORM_OS2=1 + ;; + darwin ) + PLATFORM_MAC=1 + PLATFORM_MACOSX=1 + ;; + unix ) + PLATFORM_UNIX=1 + ;; + beos ) + PLATFORM_BEOS=1 + ;; + * ) + AC_MSG_ERROR([Unknown platform: $BAKEFILE_FORCE_PLATFORM]) + ;; + esac + fi + + AC_SUBST(PLATFORM_UNIX) + AC_SUBST(PLATFORM_WIN32) + AC_SUBST(PLATFORM_MSDOS) + AC_SUBST(PLATFORM_MAC) + AC_SUBST(PLATFORM_MACOS) + AC_SUBST(PLATFORM_MACOSX) + AC_SUBST(PLATFORM_OS2) + AC_SUBST(PLATFORM_BEOS) +]) + + +dnl --------------------------------------------------------------------------- +dnl AC_BAKEFILE_PLATFORM_SPECIFICS +dnl +dnl Sets misc platform-specific settings +dnl --------------------------------------------------------------------------- + +AC_DEFUN([AC_BAKEFILE_PLATFORM_SPECIFICS], +[ + AC_ARG_ENABLE([omf], AS_HELP_STRING([--enable-omf], + [use OMF object format (OS/2)]), + [bk_os2_use_omf="$enableval"]) + + case "${BAKEFILE_HOST}" in + *-*-darwin* ) + dnl For Unix to MacOS X porting instructions, see: + dnl http://fink.sourceforge.net/doc/porting/porting.html + if test "x$GCC" = "xyes"; then + CFLAGS="$CFLAGS -fno-common" + CXXFLAGS="$CXXFLAGS -fno-common" + fi + if test "x$XLCC" = "xyes"; then + CFLAGS="$CFLAGS -qnocommon" + CXXFLAGS="$CXXFLAGS -qnocommon" + fi + ;; + + *-pc-os2_emx | *-pc-os2-emx ) + if test "x$bk_os2_use_omf" = "xyes" ; then + AR=emxomfar + RANLIB=: + LDFLAGS="-Zomf $LDFLAGS" + CFLAGS="-Zomf $CFLAGS" + CXXFLAGS="-Zomf $CXXFLAGS" + OS2_LIBEXT="lib" + else + OS2_LIBEXT="a" + fi + ;; + + i*86-*-beos* ) + LDFLAGS="-L/boot/develop/lib/x86 $LDFLAGS" + ;; + esac +]) + +dnl --------------------------------------------------------------------------- +dnl AC_BAKEFILE_SUFFIXES +dnl +dnl Detects shared various suffixes for shared libraries, libraries, programs, +dnl plugins etc. +dnl --------------------------------------------------------------------------- + +AC_DEFUN([AC_BAKEFILE_SUFFIXES], +[ + SO_SUFFIX="so" + SO_SUFFIX_MODULE="so" + EXEEXT="" + LIBPREFIX="lib" + LIBEXT=".a" + DLLPREFIX="lib" + DLLPREFIX_MODULE="" + DLLIMP_SUFFIX="" + dlldir="$libdir" + + case "${BAKEFILE_HOST}" in + dnl PA-RISC HP systems used .sl but IA64 use ELF-64 and so use the + dnl standard .so extension + ia64-hp-hpux* ) + ;; + *-hp-hpux* ) + SO_SUFFIX="sl" + SO_SUFFIX_MODULE="sl" + ;; + *-*-aix* ) + dnl quoting from + dnl http://www-1.ibm.com/servers/esdd/articles/gnu.html: + dnl Both archive libraries and shared libraries on AIX have an + dnl .a extension. This will explain why you can't link with an + dnl .so and why it works with the name changed to .a. + SO_SUFFIX="a" + SO_SUFFIX_MODULE="a" + ;; + *-*-cygwin* ) + SO_SUFFIX="dll" + SO_SUFFIX_MODULE="dll" + DLLIMP_SUFFIX="dll.a" + EXEEXT=".exe" + DLLPREFIX="cyg" + dlldir="$bindir" + ;; + *-*-mingw32* ) + SO_SUFFIX="dll" + SO_SUFFIX_MODULE="dll" + DLLIMP_SUFFIX="dll.a" + EXEEXT=".exe" + DLLPREFIX="" + dlldir="$bindir" + ;; + *-pc-msdosdjgpp ) + EXEEXT=".exe" + DLLPREFIX="" + dlldir="$bindir" + ;; + *-pc-os2_emx | *-pc-os2-emx ) + SO_SUFFIX="dll" + SO_SUFFIX_MODULE="dll" + DLLIMP_SUFFIX=$OS2_LIBEXT + EXEEXT=".exe" + DLLPREFIX="" + LIBPREFIX="" + LIBEXT=".$OS2_LIBEXT" + dlldir="$bindir" + ;; + *-*-darwin* ) + SO_SUFFIX="dylib" + SO_SUFFIX_MODULE="bundle" + ;; + esac + + if test "x$DLLIMP_SUFFIX" = "x" ; then + DLLIMP_SUFFIX="$SO_SUFFIX" + fi + + AC_SUBST(SO_SUFFIX) + AC_SUBST(SO_SUFFIX_MODULE) + AC_SUBST(DLLIMP_SUFFIX) + AC_SUBST(EXEEXT) + AC_SUBST(LIBPREFIX) + AC_SUBST(LIBEXT) + AC_SUBST(DLLPREFIX) + AC_SUBST(DLLPREFIX_MODULE) + AC_SUBST(dlldir) +]) + + +dnl --------------------------------------------------------------------------- +dnl AC_BAKEFILE_SHARED_LD +dnl +dnl Detects command for making shared libraries, substitutes SHARED_LD_CC +dnl and SHARED_LD_CXX. +dnl --------------------------------------------------------------------------- + +AC_DEFUN([AC_BAKEFILE_SHARED_LD], +[ + dnl the extra compiler flags needed for compilation of shared library + PIC_FLAG="" + if test "x$GCC" = "xyes"; then + dnl the switch for gcc is the same under all platforms + PIC_FLAG="-fPIC" + fi + + dnl Defaults for GCC and ELF .so shared libs: + SHARED_LD_CC="\$(CC) -shared ${PIC_FLAG} -o" + SHARED_LD_CXX="\$(CXX) -shared ${PIC_FLAG} -o" + WINDOWS_IMPLIB=0 + + case "${BAKEFILE_HOST}" in + *-hp-hpux* ) + dnl default settings are good for gcc but not for the native HP-UX + if test "x$GCC" != "xyes"; then + dnl no idea why it wants it, but it does + LDFLAGS="$LDFLAGS -L/usr/lib" + + SHARED_LD_CC="${CC} -b -o" + SHARED_LD_CXX="${CXX} -b -o" + PIC_FLAG="+Z" + fi + ;; + + *-*-linux* ) + dnl newer icc versions use -fPIC just as gcc does and, in fact, the + dnl newest (v10+) ones don't even understand -KPIC any longer + if test "$INTELCC" = "yes" -a "$INTELCC8" != "yes"; then + PIC_FLAG="-KPIC" + elif test "x$SUNCXX" = "xyes"; then + SHARED_LD_CC="${CC} -G -o" + SHARED_LD_CXX="${CXX} -G -o" + PIC_FLAG="-KPIC" + fi + ;; + + *-*-solaris2* ) + if test "x$SUNCXX" = xyes ; then + SHARED_LD_CC="${CC} -G -o" + SHARED_LD_CXX="${CXX} -G -o" + PIC_FLAG="-KPIC" + fi + ;; + + *-*-darwin* ) + AC_BAKEFILE_CREATE_FILE_SHARED_LD_SH + chmod +x shared-ld-sh + + SHARED_LD_MODULE_CC="`pwd`/shared-ld-sh -bundle -headerpad_max_install_names -o" + SHARED_LD_MODULE_CXX="CXX=\"\$(CXX)\" $SHARED_LD_MODULE_CC" + + dnl Most apps benefit from being fully binded (its faster and static + dnl variables initialized at startup work). + dnl This can be done either with the exe linker flag -Wl,-bind_at_load + dnl or with a double stage link in order to create a single module + dnl "-init _wxWindowsDylibInit" not useful with lazy linking solved + + dnl If using newer dev tools then there is a -single_module flag that + dnl we can use to do this for dylibs, otherwise we'll need to use a helper + dnl script. Check the version of gcc to see which way we can go: + AC_CACHE_CHECK([for gcc 3.1 or later], bakefile_cv_gcc31, [ + AC_TRY_COMPILE([], + [ + #if (__GNUC__ < 3) || \ + ((__GNUC__ == 3) && (__GNUC_MINOR__ < 1)) + This is old gcc + #endif + ], + [ + bakefile_cv_gcc31=yes + ], + [ + bakefile_cv_gcc31=no + ] + ) + ]) + if test "$bakefile_cv_gcc31" = "no"; then + dnl Use the shared-ld-sh helper script + SHARED_LD_CC="`pwd`/shared-ld-sh -dynamiclib -headerpad_max_install_names -o" + SHARED_LD_CXX="$SHARED_LD_CC" + else + dnl Use the -single_module flag and let the linker do it for us + SHARED_LD_CC="\${CC} -dynamiclib -single_module -headerpad_max_install_names -o" + SHARED_LD_CXX="\${CXX} -dynamiclib -single_module -headerpad_max_install_names -o" + fi + + if test "x$GCC" == "xyes"; then + PIC_FLAG="-dynamic -fPIC" + fi + if test "x$XLCC" = "xyes"; then + PIC_FLAG="-dynamic -DPIC" + fi + ;; + + *-*-aix* ) + if test "x$GCC" = "xyes"; then + dnl at least gcc 2.95 warns that -fPIC is ignored when + dnl compiling each and every file under AIX which is annoying, + dnl so don't use it there (it's useless as AIX runs on + dnl position-independent architectures only anyhow) + PIC_FLAG="" + + dnl -bexpfull is needed by AIX linker to export all symbols (by + dnl default it doesn't export any and even with -bexpall it + dnl doesn't export all C++ support symbols, e.g. vtable + dnl pointers) but it's only available starting from 5.1 (with + dnl maintenance pack 2, whatever this is), see + dnl http://www-128.ibm.com/developerworks/eserver/articles/gnu.html + case "${BAKEFILE_HOST}" in + *-*-aix5* ) + LD_EXPFULL="-Wl,-bexpfull" + ;; + esac + + SHARED_LD_CC="\$(CC) -shared $LD_EXPFULL -o" + SHARED_LD_CXX="\$(CXX) -shared $LD_EXPFULL -o" + else + dnl FIXME: makeC++SharedLib is obsolete, what should we do for + dnl recent AIX versions? + AC_CHECK_PROG(AIX_CXX_LD, makeC++SharedLib, + makeC++SharedLib, /usr/lpp/xlC/bin/makeC++SharedLib) + SHARED_LD_CC="$AIX_CC_LD -p 0 -o" + SHARED_LD_CXX="$AIX_CXX_LD -p 0 -o" + fi + ;; + + *-*-beos* ) + dnl can't use gcc under BeOS for shared library creation because it + dnl complains about missing 'main' + SHARED_LD_CC="${LD} -nostart -o" + SHARED_LD_CXX="${LD} -nostart -o" + ;; + + *-*-irix* ) + dnl default settings are ok for gcc + if test "x$GCC" != "xyes"; then + PIC_FLAG="-KPIC" + fi + ;; + + *-*-cygwin* | *-*-mingw32* ) + PIC_FLAG="" + SHARED_LD_CC="\$(CC) -shared -o" + SHARED_LD_CXX="\$(CXX) -shared -o" + WINDOWS_IMPLIB=1 + ;; + + *-pc-os2_emx | *-pc-os2-emx ) + SHARED_LD_CC="`pwd`/dllar.sh -libf INITINSTANCE -libf TERMINSTANCE -o" + SHARED_LD_CXX="`pwd`/dllar.sh -libf INITINSTANCE -libf TERMINSTANCE -o" + PIC_FLAG="" + AC_BAKEFILE_CREATE_FILE_DLLAR_SH + chmod +x dllar.sh + ;; + + powerpc-apple-macos* | \ + *-*-freebsd* | *-*-openbsd* | *-*-netbsd* | *-*-k*bsd*-gnu | \ + *-*-mirbsd* | \ + *-*-sunos4* | \ + *-*-osf* | \ + *-*-dgux5* | \ + *-*-sysv5* | \ + *-pc-msdosdjgpp ) + dnl defaults are ok + ;; + + *) + AC_MSG_ERROR(unknown system type $BAKEFILE_HOST.) + esac + + if test "x$PIC_FLAG" != "x" ; then + PIC_FLAG="$PIC_FLAG -DPIC" + fi + + if test "x$SHARED_LD_MODULE_CC" = "x" ; then + SHARED_LD_MODULE_CC="$SHARED_LD_CC" + fi + if test "x$SHARED_LD_MODULE_CXX" = "x" ; then + SHARED_LD_MODULE_CXX="$SHARED_LD_CXX" + fi + + AC_SUBST(SHARED_LD_CC) + AC_SUBST(SHARED_LD_CXX) + AC_SUBST(SHARED_LD_MODULE_CC) + AC_SUBST(SHARED_LD_MODULE_CXX) + AC_SUBST(PIC_FLAG) + AC_SUBST(WINDOWS_IMPLIB) +]) + + +dnl --------------------------------------------------------------------------- +dnl AC_BAKEFILE_SHARED_VERSIONS +dnl +dnl Detects linker options for attaching versions (sonames) to shared libs. +dnl --------------------------------------------------------------------------- + +AC_DEFUN([AC_BAKEFILE_SHARED_VERSIONS], +[ + USE_SOVERSION=0 + USE_SOVERLINUX=0 + USE_SOVERSOLARIS=0 + USE_SOVERCYGWIN=0 + USE_SOTWOSYMLINKS=0 + USE_MACVERSION=0 + SONAME_FLAG= + + case "${BAKEFILE_HOST}" in + *-*-linux* | *-*-freebsd* | *-*-openbsd* | *-*-netbsd* | \ + *-*-k*bsd*-gnu | *-*-mirbsd* ) + if test "x$SUNCXX" = "xyes"; then + SONAME_FLAG="-h " + else + SONAME_FLAG="-Wl,-soname," + fi + USE_SOVERSION=1 + USE_SOVERLINUX=1 + USE_SOTWOSYMLINKS=1 + ;; + + *-*-solaris2* ) + SONAME_FLAG="-h " + USE_SOVERSION=1 + USE_SOVERSOLARIS=1 + ;; + + *-*-darwin* ) + USE_MACVERSION=1 + USE_SOVERSION=1 + USE_SOTWOSYMLINKS=1 + ;; + + *-*-cygwin* ) + USE_SOVERSION=1 + USE_SOVERCYGWIN=1 + ;; + esac + + AC_SUBST(USE_SOVERSION) + AC_SUBST(USE_SOVERLINUX) + AC_SUBST(USE_SOVERSOLARIS) + AC_SUBST(USE_SOVERCYGWIN) + AC_SUBST(USE_MACVERSION) + AC_SUBST(USE_SOTWOSYMLINKS) + AC_SUBST(SONAME_FLAG) +]) + + +dnl --------------------------------------------------------------------------- +dnl AC_BAKEFILE_DEPS +dnl +dnl Detects available C/C++ dependency tracking options +dnl --------------------------------------------------------------------------- + +AC_DEFUN([AC_BAKEFILE_DEPS], +[ + AC_ARG_ENABLE([dependency-tracking], + AS_HELP_STRING([--disable-dependency-tracking], + [don't use dependency tracking even if the compiler can]), + [bk_use_trackdeps="$enableval"]) + + AC_MSG_CHECKING([for dependency tracking method]) + + BK_DEPS="" + if test "x$bk_use_trackdeps" = "xno" ; then + DEPS_TRACKING=0 + AC_MSG_RESULT([disabled]) + else + DEPS_TRACKING=1 + + if test "x$GCC" = "xyes"; then + DEPSMODE=gcc + case "${BAKEFILE_HOST}" in + *-*-darwin* ) + dnl -cpp-precomp (the default) conflicts with -MMD option + dnl used by bk-deps (see also http://developer.apple.com/documentation/Darwin/Conceptual/PortingUnix/compiling/chapter_4_section_3.html) + DEPSFLAG="-no-cpp-precomp -MMD" + ;; + * ) + DEPSFLAG="-MMD" + ;; + esac + AC_MSG_RESULT([gcc]) + elif test "x$MWCC" = "xyes"; then + DEPSMODE=mwcc + DEPSFLAG="-MM" + AC_MSG_RESULT([mwcc]) + elif test "x$SUNCC" = "xyes"; then + DEPSMODE=unixcc + DEPSFLAG="-xM1" + AC_MSG_RESULT([Sun cc]) + elif test "x$SGICC" = "xyes"; then + DEPSMODE=unixcc + DEPSFLAG="-M" + AC_MSG_RESULT([SGI cc]) + elif test "x$HPCC" = "xyes"; then + DEPSMODE=unixcc + DEPSFLAG="+make" + AC_MSG_RESULT([HP cc]) + elif test "x$COMPAQCC" = "xyes"; then + DEPSMODE=gcc + DEPSFLAG="-MD" + AC_MSG_RESULT([Compaq cc]) + else + DEPS_TRACKING=0 + AC_MSG_RESULT([none]) + fi + + if test $DEPS_TRACKING = 1 ; then + AC_BAKEFILE_CREATE_FILE_BK_DEPS + chmod +x bk-deps + dnl FIXME: make this $(top_builddir)/bk-deps once autoconf-2.60 + dnl is required (and so top_builddir is never empty): + BK_DEPS="`pwd`/bk-deps" + fi + fi + + AC_SUBST(DEPS_TRACKING) + AC_SUBST(BK_DEPS) +]) + +dnl --------------------------------------------------------------------------- +dnl AC_BAKEFILE_CHECK_BASIC_STUFF +dnl +dnl Checks for presence of basic programs, such as C and C++ compiler, "ranlib" +dnl or "install" +dnl --------------------------------------------------------------------------- + +AC_DEFUN([AC_BAKEFILE_CHECK_BASIC_STUFF], +[ + AC_PROG_RANLIB + AC_PROG_INSTALL + AC_PROG_LN_S + + AC_PROG_MAKE_SET + AC_SUBST(MAKE_SET) + + if test "x$SUNCXX" = "xyes"; then + dnl Sun C++ compiler requires special way of creating static libs; + dnl see here for more details: + dnl https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1229751&group_id=9863 + AR=$CXX + AROPTIONS="-xar -o" + AC_SUBST(AR) + elif test "x$SGICC" = "xyes"; then + dnl Almost the same as above for SGI mipsPro compiler + AR=$CXX + AROPTIONS="-ar -o" + AC_SUBST(AR) + else + AC_CHECK_TOOL(AR, ar, ar) + AROPTIONS=rcu + fi + AC_SUBST(AROPTIONS) + + AC_CHECK_TOOL(STRIP, strip, :) + AC_CHECK_TOOL(NM, nm, :) + + dnl This check is necessary because "install -d" doesn't exist on + dnl all platforms (e.g. HP/UX), see http://www.bakefile.org/ticket/80 + AC_MSG_CHECKING([for command to install directories]) + INSTALL_TEST_DIR=acbftest$$ + $INSTALL -d $INSTALL_TEST_DIR > /dev/null 2>&1 + if test $? = 0 -a -d $INSTALL_TEST_DIR; then + rmdir $INSTALL_TEST_DIR + dnl we must refer to makefile's $(INSTALL) variable and not + dnl current value of shell variable, hence the single quoting: + INSTALL_DIR='$(INSTALL) -d' + AC_MSG_RESULT([$INSTALL -d]) + else + INSTALL_DIR="mkdir -p" + AC_MSG_RESULT([mkdir -p]) + fi + AC_SUBST(INSTALL_DIR) + + LDFLAGS_GUI= + case ${BAKEFILE_HOST} in + *-*-cygwin* | *-*-mingw32* ) + LDFLAGS_GUI="-mwindows" + esac + AC_SUBST(LDFLAGS_GUI) +]) + + +dnl --------------------------------------------------------------------------- +dnl AC_BAKEFILE_RES_COMPILERS +dnl +dnl Checks for presence of resource compilers for win32 or mac +dnl --------------------------------------------------------------------------- + +AC_DEFUN([AC_BAKEFILE_RES_COMPILERS], +[ + case ${BAKEFILE_HOST} in + *-*-cygwin* | *-*-mingw32* ) + dnl Check for win32 resources compiler: + AC_CHECK_TOOL(WINDRES, windres) + ;; + + *-*-darwin* | powerpc-apple-macos* ) + AC_CHECK_PROG(REZ, Rez, Rez, /Developer/Tools/Rez) + AC_CHECK_PROG(SETFILE, SetFile, SetFile, /Developer/Tools/SetFile) + ;; + esac + + AC_SUBST(WINDRES) + AC_SUBST(REZ) + AC_SUBST(SETFILE) +]) + +dnl --------------------------------------------------------------------------- +dnl AC_BAKEFILE_PRECOMP_HEADERS +dnl +dnl Check for precompiled headers support (GCC >= 3.4) +dnl --------------------------------------------------------------------------- + +AC_DEFUN([AC_BAKEFILE_PRECOMP_HEADERS], +[ + + AC_ARG_ENABLE([precomp-headers], + AS_HELP_STRING([--disable-precomp-headers], + [don't use precompiled headers even if compiler can]), + [bk_use_pch="$enableval"]) + + GCC_PCH=0 + ICC_PCH=0 + USE_PCH=0 + BK_MAKE_PCH="" + + case ${BAKEFILE_HOST} in + *-*-cygwin* ) + dnl PCH support is broken in cygwin gcc because of unportable + dnl assumptions about mmap() in gcc code which make PCH generation + dnl fail erratically; disable PCH completely until this is fixed + bk_use_pch="no" + ;; + esac + + if test "x$bk_use_pch" = "x" -o "x$bk_use_pch" = "xyes" ; then + if test "x$GCC" = "xyes"; then + dnl test if we have gcc-3.4: + AC_MSG_CHECKING([if the compiler supports precompiled headers]) + AC_TRY_COMPILE([], + [ + #if !defined(__GNUC__) || !defined(__GNUC_MINOR__) + There is no PCH support + #endif + #if (__GNUC__ < 3) + There is no PCH support + #endif + #if (__GNUC__ == 3) && \ + ((!defined(__APPLE_CC__) && (__GNUC_MINOR__ < 4)) || \ + ( defined(__APPLE_CC__) && (__GNUC_MINOR__ < 3))) || \ + ( defined(__INTEL_COMPILER) ) + There is no PCH support + #endif + ], + [ + AC_MSG_RESULT([yes]) + GCC_PCH=1 + ], + [ + if test "$INTELCXX8" = "yes"; then + AC_MSG_RESULT([yes]) + ICC_PCH=1 + if test "$INTELCXX10" = "yes"; then + ICC_PCH_CREATE_SWITCH="-pch-create" + ICC_PCH_USE_SWITCH="-pch-use" + else + ICC_PCH_CREATE_SWITCH="-create-pch" + ICC_PCH_USE_SWITCH="-use-pch" + fi + else + AC_MSG_RESULT([no]) + fi + ]) + if test $GCC_PCH = 1 -o $ICC_PCH = 1 ; then + USE_PCH=1 + AC_BAKEFILE_CREATE_FILE_BK_MAKE_PCH + chmod +x bk-make-pch + dnl FIXME: make this $(top_builddir)/bk-make-pch once + dnl autoconf-2.60 is required (and so top_builddir is + dnl never empty): + BK_MAKE_PCH="`pwd`/bk-make-pch" + fi + fi + fi + + AC_SUBST(GCC_PCH) + AC_SUBST(ICC_PCH) + AC_SUBST(ICC_PCH_CREATE_SWITCH) + AC_SUBST(ICC_PCH_USE_SWITCH) + AC_SUBST(BK_MAKE_PCH) +]) + + + +dnl --------------------------------------------------------------------------- +dnl AC_BAKEFILE([autoconf_inc.m4 inclusion]) +dnl +dnl To be used in configure.in of any project using Bakefile-generated mks +dnl +dnl Behaviour can be modified by setting following variables: +dnl BAKEFILE_CHECK_BASICS set to "no" if you don't want bakefile to +dnl to perform check for basic tools like ranlib +dnl BAKEFILE_HOST set this to override host detection, defaults +dnl to ${host} +dnl BAKEFILE_FORCE_PLATFORM set to override platform detection +dnl +dnl Example usage: +dnl +dnl AC_BAKEFILE([FOO(autoconf_inc.m4)]) +dnl +dnl (replace FOO with m4_include above, aclocal would die otherwise) +dnl (yes, it's ugly, but thanks to a bug in aclocal, it's the only thing +dnl we can do...) +dnl --------------------------------------------------------------------------- + +AC_DEFUN([AC_BAKEFILE], +[ + AC_PREREQ([2.58]) + + dnl We need to always run C/C++ compiler tests, but it's also possible + dnl for the user to call these macros manually, hence this instead of + dnl simply calling these macros. See http://www.bakefile.org/ticket/64 + AC_REQUIRE([AC_BAKEFILE_PROG_CC]) + AC_REQUIRE([AC_BAKEFILE_PROG_CXX]) + + if test "x$BAKEFILE_HOST" = "x"; then + if test "x${host}" = "x" ; then + AC_MSG_ERROR([You must call the autoconf "CANONICAL_HOST" macro in your configure.ac (or .in) file.]) + fi + + BAKEFILE_HOST="${host}" + fi + + if test "x$BAKEFILE_CHECK_BASICS" != "xno"; then + AC_BAKEFILE_CHECK_BASIC_STUFF + fi + AC_BAKEFILE_GNUMAKE + AC_BAKEFILE_PLATFORM + AC_BAKEFILE_PLATFORM_SPECIFICS + AC_BAKEFILE_SUFFIXES + AC_BAKEFILE_SHARED_LD + AC_BAKEFILE_SHARED_VERSIONS + AC_BAKEFILE_DEPS + AC_BAKEFILE_RES_COMPILERS + + dnl OBJCFLAGS is set by Autoconf, but OBJCXXFLAGS is not: + AC_SUBST(OBJCXXFLAGS) + + + BAKEFILE_BAKEFILE_M4_VERSION="0.2.8" + + dnl includes autoconf_inc.m4: + $1 + + if test "$BAKEFILE_AUTOCONF_INC_M4_VERSION" = "" ; then + AC_MSG_ERROR([No version found in autoconf_inc.m4 - bakefile macro was changed to take additional argument, perhaps configure.in wasn't updated (see the documentation)?]) + fi + + if test "$BAKEFILE_BAKEFILE_M4_VERSION" != "$BAKEFILE_AUTOCONF_INC_M4_VERSION" ; then + AC_MSG_ERROR([Versions of Bakefile used to generate makefiles ($BAKEFILE_AUTOCONF_INC_M4_VERSION) and configure ($BAKEFILE_BAKEFILE_M4_VERSION) do not match.]) + fi +]) + + +dnl --------------------------------------------------------------------------- +dnl Embedded copies of helper scripts follow: +dnl --------------------------------------------------------------------------- + +AC_DEFUN([AC_BAKEFILE_CREATE_FILE_BK_DEPS], +[ +dnl ===================== bk-deps begins here ===================== +dnl (Created by merge-scripts.py from bk-deps +dnl file do not edit here!) +D='$' +cat <<EOF >bk-deps +#!/bin/sh + +# This script is part of Bakefile (http://www.bakefile.org) autoconf +# script. It is used to track C/C++ files dependencies in portable way. +# +# Permission is given to use this file in any way. + +DEPSMODE=${DEPSMODE} +DEPSFLAG="${DEPSFLAG}" +DEPSDIRBASE=.deps + +if test ${D}DEPSMODE = gcc ; then + ${D}* ${D}{DEPSFLAG} + status=${D}? + + # determine location of created files: + while test ${D}# -gt 0; do + case "${D}1" in + -o ) + shift + objfile=${D}1 + ;; + -* ) + ;; + * ) + srcfile=${D}1 + ;; + esac + shift + done + objfilebase=\`basename ${D}objfile\` + builddir=\`dirname ${D}objfile\` + depfile=\`basename ${D}srcfile | sed -e 's/\\..*${D}/.d/g'\` + depobjname=\`echo ${D}depfile |sed -e 's/\\.d/.o/g'\` + depsdir=${D}builddir/${D}DEPSDIRBASE + mkdir -p ${D}depsdir + + # if the compiler failed, we're done: + if test ${D}{status} != 0 ; then + rm -f ${D}depfile + exit ${D}{status} + fi + + # move created file to the location we want it in: + if test -f ${D}depfile ; then + sed -e "s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{depsdir}/${D}{objfilebase}.d + rm -f ${D}depfile + else + # "g++ -MMD -o fooobj.o foosrc.cpp" produces fooobj.d + depfile=\`echo "${D}objfile" | sed -e 's/\\..*${D}/.d/g'\` + if test ! -f ${D}depfile ; then + # "cxx -MD -o fooobj.o foosrc.cpp" creates fooobj.o.d (Compaq C++) + depfile="${D}objfile.d" + fi + if test -f ${D}depfile ; then + sed -e "\\,^${D}objfile,!s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{depsdir}/${D}{objfilebase}.d + rm -f ${D}depfile + fi + fi + exit 0 + +elif test ${D}DEPSMODE = mwcc ; then + ${D}* || exit ${D}? + # Run mwcc again with -MM and redirect into the dep file we want + # NOTE: We can't use shift here because we need ${D}* to be valid + prevarg= + for arg in ${D}* ; do + if test "${D}prevarg" = "-o"; then + objfile=${D}arg + else + case "${D}arg" in + -* ) + ;; + * ) + srcfile=${D}arg + ;; + esac + fi + prevarg="${D}arg" + done + + objfilebase=\`basename ${D}objfile\` + builddir=\`dirname ${D}objfile\` + depsdir=${D}builddir/${D}DEPSDIRBASE + mkdir -p ${D}depsdir + + ${D}* ${D}DEPSFLAG >${D}{depsdir}/${D}{objfilebase}.d + exit 0 + +elif test ${D}DEPSMODE = unixcc; then + ${D}* || exit ${D}? + # Run compiler again with deps flag and redirect into the dep file. + # It doesn't work if the '-o FILE' option is used, but without it the + # dependency file will contain the wrong name for the object. So it is + # removed from the command line, and the dep file is fixed with sed. + cmd="" + while test ${D}# -gt 0; do + case "${D}1" in + -o ) + shift + objfile=${D}1 + ;; + * ) + eval arg${D}#=\\${D}1 + cmd="${D}cmd \\${D}arg${D}#" + ;; + esac + shift + done + + objfilebase=\`basename ${D}objfile\` + builddir=\`dirname ${D}objfile\` + depsdir=${D}builddir/${D}DEPSDIRBASE + mkdir -p ${D}depsdir + + eval "${D}cmd ${D}DEPSFLAG" | sed "s|.*:|${D}objfile:|" >${D}{depsdir}/${D}{objfilebase}.d + exit 0 + +else + ${D}* + exit ${D}? +fi +EOF +dnl ===================== bk-deps ends here ===================== +]) + +AC_DEFUN([AC_BAKEFILE_CREATE_FILE_SHARED_LD_SH], +[ +dnl ===================== shared-ld-sh begins here ===================== +dnl (Created by merge-scripts.py from shared-ld-sh +dnl file do not edit here!) +D='$' +cat <<EOF >shared-ld-sh +#!/bin/sh +#----------------------------------------------------------------------------- +#-- Name: distrib/mac/shared-ld-sh +#-- Purpose: Link a mach-o dynamic shared library for Darwin / Mac OS X +#-- Author: Gilles Depeyrot +#-- Copyright: (c) 2002 Gilles Depeyrot +#-- Licence: any use permitted +#----------------------------------------------------------------------------- + +verbose=0 +args="" +objects="" +linking_flag="-dynamiclib" +ldargs="-r -keep_private_externs -nostdlib" + +if test "x${D}CXX" = "x"; then + CXX="c++" +fi + +while test ${D}# -gt 0; do + case ${D}1 in + + -v) + verbose=1 + ;; + + -o|-compatibility_version|-current_version|-framework|-undefined|-install_name) + # collect these options and values + args="${D}{args} ${D}1 ${D}2" + shift + ;; + + -arch|-isysroot) + # collect these options and values + ldargs="${D}{ldargs} ${D}1 ${D}2" + shift + ;; + + -s|-Wl,*) + # collect these load args + ldargs="${D}{ldargs} ${D}1" + ;; + + -l*|-L*|-flat_namespace|-headerpad_max_install_names) + # collect these options + args="${D}{args} ${D}1" + ;; + + -dynamiclib|-bundle) + linking_flag="${D}1" + ;; + + -*) + echo "shared-ld: unhandled option '${D}1'" + exit 1 + ;; + + *.o | *.a | *.dylib) + # collect object files + objects="${D}{objects} ${D}1" + ;; + + *) + echo "shared-ld: unhandled argument '${D}1'" + exit 1 + ;; + + esac + shift +done + +status=0 + +# +# Link one module containing all the others +# +if test ${D}{verbose} = 1; then + echo "${D}CXX ${D}{ldargs} ${D}{objects} -o master.${D}${D}.o" +fi +${D}CXX ${D}{ldargs} ${D}{objects} -o master.${D}${D}.o +status=${D}? + +# +# Link the shared library from the single module created, but only if the +# previous command didn't fail: +# +if test ${D}{status} = 0; then + if test ${D}{verbose} = 1; then + echo "${D}CXX ${D}{linking_flag} master.${D}${D}.o ${D}{args}" + fi + ${D}CXX ${D}{linking_flag} master.${D}${D}.o ${D}{args} + status=${D}? +fi + +# +# Remove intermediate module +# +rm -f master.${D}${D}.o + +exit ${D}status +EOF +dnl ===================== shared-ld-sh ends here ===================== +]) + +AC_DEFUN([AC_BAKEFILE_CREATE_FILE_BK_MAKE_PCH], +[ +dnl ===================== bk-make-pch begins here ===================== +dnl (Created by merge-scripts.py from bk-make-pch +dnl file do not edit here!) +D='$' +cat <<EOF >bk-make-pch +#!/bin/sh + +# This script is part of Bakefile (http://www.bakefile.org) autoconf +# script. It is used to generated precompiled headers. +# +# Permission is given to use this file in any way. + +outfile="${D}{1}" +header="${D}{2}" +shift +shift + +builddir=\`echo ${D}outfile | sed -e 's,/\\.pch/.*${D},,g'\` + +compiler="" +headerfile="" + +while test ${D}{#} -gt 0; do + add_to_cmdline=1 + case "${D}{1}" in + -I* ) + incdir=\`echo ${D}{1} | sed -e 's/-I\\(.*\\)/\\1/g'\` + if test "x${D}{headerfile}" = "x" -a -f "${D}{incdir}/${D}{header}" ; then + headerfile="${D}{incdir}/${D}{header}" + fi + ;; + -use-pch|-use_pch|-pch-use ) + shift + add_to_cmdline=0 + ;; + esac + if test ${D}add_to_cmdline = 1 ; then + compiler="${D}{compiler} ${D}{1}" + fi + shift +done + +if test "x${D}{headerfile}" = "x" ; then + echo "error: can't find header ${D}{header} in include paths" >&2 +else + if test -f ${D}{outfile} ; then + rm -f ${D}{outfile} + else + mkdir -p \`dirname ${D}{outfile}\` + fi + depsfile="${D}{builddir}/.deps/\`echo ${D}{outfile} | tr '/.' '__'\`.d" + mkdir -p ${D}{builddir}/.deps + if test "x${GCC_PCH}" = "x1" ; then + # can do this because gcc is >= 3.4: + ${D}{compiler} -o ${D}{outfile} -MMD -MF "${D}{depsfile}" "${D}{headerfile}" + elif test "x${ICC_PCH}" = "x1" ; then + filename=pch_gen-${D}${D} + file=${D}{filename}.c + dfile=${D}{filename}.d + cat > ${D}file <<EOT +#include "${D}header" +EOT + # using -MF icc complains about differing command lines in creation/use + ${D}compiler -c ${ICC_PCH_CREATE_SWITCH} ${D}outfile -MMD ${D}file && \\ + sed -e "s,^.*:,${D}outfile:," -e "s, ${D}file,," < ${D}dfile > ${D}depsfile && \\ + rm -f ${D}file ${D}dfile ${D}{filename}.o + fi + exit ${D}{?} +fi +EOF +dnl ===================== bk-make-pch ends here ===================== +]) + diff --git a/AMDiS/lib/muparser_v134/build/autoconf/acregen.sh b/AMDiS/lib/muparser_v134/build/autoconf/acregen.sh new file mode 100755 index 0000000000000000000000000000000000000000..ef0ed37bd4f5068c5a324d22f2e7dad4cfbde679 --- /dev/null +++ b/AMDiS/lib/muparser_v134/build/autoconf/acregen.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# +# Author: Francesco Montorsi +# RCS-ID: $Id: acregen.sh 236 2009-11-24 23:12:00Z frm $ +# Creation date: 14/9/2005 +# +# A simple script to generate the configure script +# Some features of this version: +# - automatic test for aclocal version +# - able to be called from any folder +# (i.e. you can call it typing 'build/autoconf/acregen.sh', not only './acregen.sh') + + +# called when an old version of aclocal is found +function aclocalold() +{ + echo "Your aclocal version is $aclocal_maj.$aclocal_min.$aclocal_rel" + echo "Your automake installation is too old; please install automake >= $aclocal_minimal_maj.$aclocal_minimal_min.$aclocal_minimal_rel" + echo "You can download automake from ftp://sources.redhat.com/pub/automake/" + exit 1 +} + +# first check if we have an ACLOCAL version recent enough +aclocal_verfull=$(aclocal --version) +aclocal_maj=`echo $aclocal_verfull | sed 's/aclocal (GNU automake) \([0-9]*\).\([0-9]*\).\([0-9]*\).*/\1/'` +aclocal_min=`echo $aclocal_verfull | sed 's/aclocal (GNU automake) \([0-9]*\).\([0-9]*\).\([0-9]*\).*/\2/'` +aclocal_rel=`echo $aclocal_verfull | sed 's/aclocal (GNU automake) \([0-9]*\).\([0-9]*\).\([0-9]*\).*/\3/'` +if [[ "$aclocal_rel" = "" ]]; then aclocal_rel="0"; fi + +#echo "Your aclocal version is $aclocal_maj.$aclocal_min.$aclocal_rel" # for debugging + +aclocal_minimal_maj=1 +aclocal_minimal_min=9 +aclocal_minimal_rel=6 + +majok=$(($aclocal_maj > $aclocal_minimal_maj)) +minok=$(($aclocal_maj == $aclocal_minimal_maj && $aclocal_min > $aclocal_minimal_min)) +relok=$(($aclocal_maj == $aclocal_minimal_maj && $aclocal_min == $aclocal_minimal_min && \ + $aclocal_rel >= $aclocal_minimal_rel)) + +versionok=$(($majok == 1 || $minok == 1 || $relok == 1)) +if [[ "$versionok" = "0" ]]; then aclocalold; fi + +# we can safely proceed +me=$(basename $0) +path=${0%%/$me} # path from which the script has been launched +current=$(pwd) +cd $path +aclocal && autoconf && mv configure ../.. +cd $current diff --git a/AMDiS/lib/muparser_v134/build/autoconf/autoconf_inc.m4 b/AMDiS/lib/muparser_v134/build/autoconf/autoconf_inc.m4 new file mode 100644 index 0000000000000000000000000000000000000000..9faed0793d9eb974f66f40bf4a52a0e8289cde1b --- /dev/null +++ b/AMDiS/lib/muparser_v134/build/autoconf/autoconf_inc.m4 @@ -0,0 +1,134 @@ +dnl ### begin block 00_header[muparser.bkl] ### +dnl +dnl This macro was generated by +dnl Bakefile 0.2.8 (http://www.bakefile.org) +dnl Do not modify, all changes will be overwritten! + +BAKEFILE_AUTOCONF_INC_M4_VERSION="0.2.8" + +dnl ### begin block 20_COND_DEBUG_0[muparser.bkl] ### + COND_DEBUG_0="#" + if test "x$DEBUG" = "x0" ; then + COND_DEBUG_0="" + fi + AC_SUBST(COND_DEBUG_0) +dnl ### begin block 20_COND_DEBUG_1[muparser.bkl] ### + COND_DEBUG_1="#" + if test "x$DEBUG" = "x1" ; then + COND_DEBUG_1="" + fi + AC_SUBST(COND_DEBUG_1) +dnl ### begin block 20_COND_DEPS_TRACKING_0[muparser.bkl] ### + COND_DEPS_TRACKING_0="#" + if test "x$DEPS_TRACKING" = "x0" ; then + COND_DEPS_TRACKING_0="" + fi + AC_SUBST(COND_DEPS_TRACKING_0) +dnl ### begin block 20_COND_DEPS_TRACKING_1[muparser.bkl] ### + COND_DEPS_TRACKING_1="#" + if test "x$DEPS_TRACKING" = "x1" ; then + COND_DEPS_TRACKING_1="" + fi + AC_SUBST(COND_DEPS_TRACKING_1) +dnl ### begin block 20_COND_PLATFORM_MACOSX_0_USE_SOVERCYGWIN_0_USE_SOVERSION_1[muparser.bkl] ### + COND_PLATFORM_MACOSX_0_USE_SOVERCYGWIN_0_USE_SOVERSION_1="#" + if test "x$PLATFORM_MACOSX" = "x0" -a "x$USE_SOVERCYGWIN" = "x0" -a "x$USE_SOVERSION" = "x1" ; then + COND_PLATFORM_MACOSX_0_USE_SOVERCYGWIN_0_USE_SOVERSION_1="" + fi + AC_SUBST(COND_PLATFORM_MACOSX_0_USE_SOVERCYGWIN_0_USE_SOVERSION_1) +dnl ### begin block 20_COND_PLATFORM_MACOSX_0_USE_SOVERSION_1[muparser.bkl] ### + COND_PLATFORM_MACOSX_0_USE_SOVERSION_1="#" + if test "x$PLATFORM_MACOSX" = "x0" -a "x$USE_SOVERSION" = "x1" ; then + COND_PLATFORM_MACOSX_0_USE_SOVERSION_1="" + fi + AC_SUBST(COND_PLATFORM_MACOSX_0_USE_SOVERSION_1) +dnl ### begin block 20_COND_PLATFORM_MACOSX_1[muparser.bkl] ### + COND_PLATFORM_MACOSX_1="#" + if test "x$PLATFORM_MACOSX" = "x1" ; then + COND_PLATFORM_MACOSX_1="" + fi + AC_SUBST(COND_PLATFORM_MACOSX_1) +dnl ### begin block 20_COND_PLATFORM_MACOSX_1_USE_SOVERSION_1[muparser.bkl] ### + COND_PLATFORM_MACOSX_1_USE_SOVERSION_1="#" + if test "x$PLATFORM_MACOSX" = "x1" -a "x$USE_SOVERSION" = "x1" ; then + COND_PLATFORM_MACOSX_1_USE_SOVERSION_1="" + fi + AC_SUBST(COND_PLATFORM_MACOSX_1_USE_SOVERSION_1) +dnl ### begin block 20_COND_PLATFORM_MAC_0[muparser.bkl] ### + COND_PLATFORM_MAC_0="#" + if test "x$PLATFORM_MAC" = "x0" ; then + COND_PLATFORM_MAC_0="" + fi + AC_SUBST(COND_PLATFORM_MAC_0) +dnl ### begin block 20_COND_PLATFORM_MAC_1[muparser.bkl] ### + COND_PLATFORM_MAC_1="#" + if test "x$PLATFORM_MAC" = "x1" ; then + COND_PLATFORM_MAC_1="" + fi + AC_SUBST(COND_PLATFORM_MAC_1) +dnl ### begin block 20_COND_PLATFORM_OS2_1[muparser.bkl] ### + COND_PLATFORM_OS2_1="#" + if test "x$PLATFORM_OS2" = "x1" ; then + COND_PLATFORM_OS2_1="" + fi + AC_SUBST(COND_PLATFORM_OS2_1) +dnl ### begin block 20_COND_SAMPLES_1[muparser.bkl] ### + COND_SAMPLES_1="#" + if test "x$SAMPLES" = "x1" ; then + COND_SAMPLES_1="" + fi + AC_SUBST(COND_SAMPLES_1) +dnl ### begin block 20_COND_SHARED_0[muparser.bkl] ### + COND_SHARED_0="#" + if test "x$SHARED" = "x0" ; then + COND_SHARED_0="" + fi + AC_SUBST(COND_SHARED_0) +dnl ### begin block 20_COND_SHARED_1[muparser.bkl] ### + COND_SHARED_1="#" + if test "x$SHARED" = "x1" ; then + COND_SHARED_1="" + fi + AC_SUBST(COND_SHARED_1) +dnl ### begin block 20_COND_USE_SOTWOSYMLINKS_1[muparser.bkl] ### + COND_USE_SOTWOSYMLINKS_1="#" + if test "x$USE_SOTWOSYMLINKS" = "x1" ; then + COND_USE_SOTWOSYMLINKS_1="" + fi + AC_SUBST(COND_USE_SOTWOSYMLINKS_1) +dnl ### begin block 20_COND_USE_SOVERCYGWIN_1_USE_SOVERSION_1[muparser.bkl] ### + COND_USE_SOVERCYGWIN_1_USE_SOVERSION_1="#" + if test "x$USE_SOVERCYGWIN" = "x1" -a "x$USE_SOVERSION" = "x1" ; then + COND_USE_SOVERCYGWIN_1_USE_SOVERSION_1="" + fi + AC_SUBST(COND_USE_SOVERCYGWIN_1_USE_SOVERSION_1) +dnl ### begin block 20_COND_USE_SOVERLINUX_1[muparser.bkl] ### + COND_USE_SOVERLINUX_1="#" + if test "x$USE_SOVERLINUX" = "x1" ; then + COND_USE_SOVERLINUX_1="" + fi + AC_SUBST(COND_USE_SOVERLINUX_1) +dnl ### begin block 20_COND_USE_SOVERSION_0[muparser.bkl] ### + COND_USE_SOVERSION_0="#" + if test "x$USE_SOVERSION" = "x0" ; then + COND_USE_SOVERSION_0="" + fi + AC_SUBST(COND_USE_SOVERSION_0) +dnl ### begin block 20_COND_USE_SOVERSION_1_USE_SOVERSOLARIS_1[muparser.bkl] ### + COND_USE_SOVERSION_1_USE_SOVERSOLARIS_1="#" + if test "x$USE_SOVERSION" = "x1" -a "x$USE_SOVERSOLARIS" = "x1" ; then + COND_USE_SOVERSION_1_USE_SOVERSOLARIS_1="" + fi + AC_SUBST(COND_USE_SOVERSION_1_USE_SOVERSOLARIS_1) +dnl ### begin block 20_COND_USE_SOVERSOLARIS_1[muparser.bkl] ### + COND_USE_SOVERSOLARIS_1="#" + if test "x$USE_SOVERSOLARIS" = "x1" ; then + COND_USE_SOVERSOLARIS_1="" + fi + AC_SUBST(COND_USE_SOVERSOLARIS_1) +dnl ### begin block 20_COND_WINDOWS_IMPLIB_1[muparser.bkl] ### + COND_WINDOWS_IMPLIB_1="#" + if test "x$WINDOWS_IMPLIB" = "x1" ; then + COND_WINDOWS_IMPLIB_1="" + fi + AC_SUBST(COND_WINDOWS_IMPLIB_1) diff --git a/AMDiS/lib/muparser_v134/build/autoconf/bakefile-presets.m4 b/AMDiS/lib/muparser_v134/build/autoconf/bakefile-presets.m4 new file mode 100644 index 0000000000000000000000000000000000000000..3a0dc90c6657d6f957b91b72350e967dd68a7805 --- /dev/null +++ b/AMDiS/lib/muparser_v134/build/autoconf/bakefile-presets.m4 @@ -0,0 +1,151 @@ +dnl --------------------------------------------------------------------------- +dnl Support macros for makefiles generated with Bakefile presets +dnl --------------------------------------------------------------------------- + + +dnl --------------------------------------------------------------------------- +dnl AM_YESNO_OPTCHECK([name of the boolean variable to set], +dnl [name of the variable with yes/no values], +dnl [name of the --enable/--with option]) +dnl +dnl Converts the $3 variable, supposed to contain a yes/no value to a 1/0 +dnl boolean variable and saves the result into $1. +dnl Outputs also the standard checking-option message. +dnl Used by the m4 macros of the presets. +dnl --------------------------------------------------------------------------- +AC_DEFUN([AC_BAKEFILE_YESNO_OPTCHECK], +[ + AC_MSG_CHECKING([for the $3 option]) + if [[ "x$$2" = "xyes" ]]; then + AC_MSG_RESULT([yes]) + $1=1 + else + AC_MSG_RESULT([no]) + $1=0 + fi +]) + +dnl --------------------------------------------------------------------------- +dnl AC_BAKEFILE_UNICODEOPT([default value for the --enable-unicode option]) +dnl +dnl Adds the --enable-unicode option to the configure script and sets the +dnl UNICODE=0/1 variable accordingly to the value of the option. +dnl To be used with unicodeopt.bkl preset. +dnl --------------------------------------------------------------------------- +AC_DEFUN([AC_BAKEFILE_UNICODEOPT], +[ + default="$1" + if [[ -z "$default" ]]; then + default="no" + fi + + AC_ARG_ENABLE([unicode], + AC_HELP_STRING([--enable-unicode], [Builds in Unicode mode]), + [], [enableval="$default"]) + + AC_BAKEFILE_YESNO_OPTCHECK([UNICODE], [enableval], [--enable-unicode]) +]) + +dnl --------------------------------------------------------------------------- +dnl AC_BAKEFILE_DEBUGOPT([default value for the --enable-debug option]) +dnl +dnl Adds the --enable-debug option to the configure script and sets the +dnl DEBUG=0/1 variable accordingly to the value of the option. +dnl To be used with debugopt.bkl preset. +dnl --------------------------------------------------------------------------- +AC_DEFUN([AC_BAKEFILE_DEBUGOPT], +[ + default="$1" + if [[ -z "$default" ]]; then + default="no" + fi + + AC_ARG_ENABLE([debug], + AC_HELP_STRING([--enable-debug], [Builds in debug mode]), + [], [enableval="$default"]) + + AC_BAKEFILE_YESNO_OPTCHECK([DEBUG], [enableval], [--enable-debug]) + + dnl add the optimize/debug flags + if [[ "x$DEBUG" = "x1" ]]; then + + dnl NOTE: the -Wundef and -Wno-ctor-dtor-privacy are not enabled automatically by -Wall + dnl NOTE2: the '-Wno-ctor-dtor-privacy' has sense only when compiling C++ source files + dnl and thus we must be careful to add it only to CXXFLAGS and not to CFLAGS + dnl (remember that CPPFLAGS is reserved for both C and C++ compilers while + dnl CFLAGS is intended as flags for C compiler only and CXXFLAGS for C++ only) + CXXFLAGS="$CXXFLAGS -g -O0 -Wall -Wundef -Wno-ctor-dtor-privacy" + CFLAGS="$CFLAGS -g -O0 -Wall -Wundef" + else + CXXFLAGS="$CXXFLAGS -O2" + CFLAGS="$CFLAGS -O2" + fi +]) + +dnl --------------------------------------------------------------------------- +dnl AC_BAKEFILE_SHAREDOPT([default value for the --enable-shared option]) +dnl +dnl Adds the --enable-shared option to the configure script and sets the +dnl SHARED=0/1 variable accordingly to the value of the option. +dnl To be used with sharedopt.bkl preset. +dnl --------------------------------------------------------------------------- +AC_DEFUN([AC_BAKEFILE_SHAREDOPT], +[ + default="$1" + if [[ -z "$default" ]]; then + default="no" + fi + + AC_ARG_ENABLE([shared], + AC_HELP_STRING([--enable-shared], [Builds in shared mode]), + [], [enableval="$default"]) + + AC_BAKEFILE_YESNO_OPTCHECK([SHARED], [enableval], [--enable-shared]) +]) + +dnl --------------------------------------------------------------------------- +dnl AC_BAKEFILE_SHOW_DEBUGOPT +dnl +dnl Prints a message on stdout about the value of the DEBUG variable. +dnl This macro is useful to show summary messages at the end of the configure scripts. +dnl --------------------------------------------------------------------------- +AC_DEFUN([AC_BAKEFILE_SHOW_DEBUGOPT], +[ + if [[ "$DEBUG" = "1" ]]; then + echo " - DEBUG build" + else + echo " - RELEASE build" + fi +]) + +dnl --------------------------------------------------------------------------- +dnl AC_BAKEFILE_SHOW_SHAREDOPT +dnl +dnl Prints a message on stdout about the value of the SHARED variable. +dnl This macro is useful to show summary messages at the end of the configure scripts. +dnl --------------------------------------------------------------------------- +AC_DEFUN([AC_BAKEFILE_SHOW_SHAREDOPT], +[ + if [[ "$SHARED" = "1" ]]; then + echo " - SHARED mode" + else + echo " - STATIC mode" + fi +]) + +dnl --------------------------------------------------------------------------- +dnl AC_BAKEFILE_SHOW_UNICODEOPT +dnl +dnl Prints a message on stdout about the value of the UNICODE variable. +dnl This macro is useful to show summary messages at the end of the configure scripts. +dnl --------------------------------------------------------------------------- +AC_DEFUN([AC_BAKEFILE_SHOW_UNICODEOPT], +[ + if [[ "$UNICODE" = "1" ]]; then + echo " - UNICODE mode" + else + echo " - ANSI mode" + fi +]) + + diff --git a/AMDiS/lib/muparser_v134/build/autoconf/config.guess b/AMDiS/lib/muparser_v134/build/autoconf/config.guess new file mode 100755 index 0000000000000000000000000000000000000000..c38553dc74bb4f06a43f734903d1e1c0f1ed6fdb --- /dev/null +++ b/AMDiS/lib/muparser_v134/build/autoconf/config.guess @@ -0,0 +1,1497 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + +timestamp='2006-02-23' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + + +# Originally written by Per Bothner <per@bothner.com>. +# Please send patches to <config-patches@gnu.org>. Submit a context +# diff and a properly formatted ChangeLog entry. +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# The plan is that this can be called by configure scripts if you +# don't specify an explicit build system type. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to <config-patches@gnu.org>." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap 'exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac ; set_cc_for_build= ;' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE_ARCH}" in + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep __ELF__ >/dev/null + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + exit ;; + *:ekkoBSD:*:*) + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + exit ;; + *:SolidBSD:*:*) + echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + exit ;; + macppc:MirBSD:*:*) + echo powerppc-unknown-mirbsd${UNAME_RELEASE} + exit ;; + *:MirBSD:*:*) + echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + exit ;; + alpha:OSF1:*:*) + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE="alpha" ;; + "EV4.5 (21064)") + UNAME_MACHINE="alpha" ;; + "LCA4 (21066/21068)") + UNAME_MACHINE="alpha" ;; + "EV5 (21164)") + UNAME_MACHINE="alphaev5" ;; + "EV5.6 (21164A)") + UNAME_MACHINE="alphaev56" ;; + "EV5.6 (21164PC)") + UNAME_MACHINE="alphapca56" ;; + "EV5.7 (21164PC)") + UNAME_MACHINE="alphapca57" ;; + "EV6 (21264)") + UNAME_MACHINE="alphaev6" ;; + "EV6.7 (21264A)") + UNAME_MACHINE="alphaev67" ;; + "EV6.8CB (21264C)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8AL (21264B)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8CX (21264D)") + UNAME_MACHINE="alphaev68" ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE="alphaev69" ;; + "EV7 (21364)") + UNAME_MACHINE="alphaev7" ;; + "EV7.9 (21364A)") + UNAME_MACHINE="alphaev79" ;; + esac + # A Pn.n version is a patched version. + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + exit ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos + exit ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit ;; + arm:riscos:*:*|arm:RISCOS:*:*) + echo arm-unknown-riscos + exit ;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit ;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7; exit ;; + esac ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + i86pc:SunOS:5.*:*) + echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; + m68k:machten:*:*) + echo m68k-apple-machten${UNAME_RELEASE} + exit ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include <stdio.h> /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && + dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`$dummy $dummyarg` && + { echo "$SYSTEM_NAME"; exit; } + echo mips-mips-riscos${UNAME_RELEASE} + exit ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include <sys/systemcfg.h> + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit ;; + *:AIX:*:[45]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include <stdlib.h> + #include <unistd.h> + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if [ ${HP_ARCH} = "hppa2.0w" ] + then + eval $set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + grep __LP64__ >/dev/null + then + HP_ARCH="hppa2.0w" + else + HP_ARCH="hppa64" + fi + fi + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit ;; + 3050*:HI-UX:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include <unistd.h> + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + echo unknown-hitachi-hiuxwe2 + exit ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + *:UNICOS/mp:*:*) + echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:FreeBSD:*:*) + case ${UNAME_MACHINE} in + pc98) + echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + *) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + esac + exit ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit ;; + i*:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit ;; + i*:MSYS_NT-*:*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit ;; + i*:windows32*:*) + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 + exit ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit ;; + x86:Interix*:[345]*) + echo i586-pc-interix${UNAME_RELEASE} + exit ;; + EM64T:Interix*:[345]*) + echo x86_64-unknown-interix${UNAME_RELEASE} + exit ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i586-pc-interix + exit ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + echo x86_64-unknown-cygwin + exit ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + *:GNU:*:*) + # the GNU system + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu + exit ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit ;; + arm*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + cris:Linux:*:*) + echo cris-axis-linux-gnu + exit ;; + crisv32:Linux:*:*) + echo crisv32-axis-linux-gnu + exit ;; + frv:Linux:*:*) + echo frv-unknown-linux-gnu + exit ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + m32r*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + mips:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips + #undef mipsel + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mipsel + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips + #else + CPU= + #endif + #endif +EOF + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^CPU/{ + s: ::g + p + }'`" + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } + ;; + mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips64 + #undef mips64el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mips64el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips64 + #else + CPU= + #endif + #endif +EOF + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^CPU/{ + s: ::g + p + }'`" + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } + ;; + or32:Linux:*:*) + echo or32-unknown-linux-gnu + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu + exit ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-gnu + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + exit ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-gnu ;; + PA8*) echo hppa2.0-unknown-linux-gnu ;; + *) echo hppa-unknown-linux-gnu ;; + esac + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-gnu + exit ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux + exit ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + vax:Linux:*:*) + echo ${UNAME_MACHINE}-dec-linux-gnu + exit ;; + x86_64:Linux:*:*) + echo x86_64-unknown-linux-gnu + exit ;; + i*86:Linux:*:*) + # The BFD linker knows what the default object file format is, so + # first see if it will tell us. cd to the root directory to prevent + # problems with other programs or directories called `ld' in the path. + # Set LC_ALL=C to ensure ld outputs messages in English. + ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ + | sed -ne '/supported targets:/!d + s/[ ][ ]*/ /g + s/.*supported targets: *// + s/ .*// + p'` + case "$ld_supported_targets" in + elf32-i386) + TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" + ;; + a.out-i386-linux) + echo "${UNAME_MACHINE}-pc-linux-gnuaout" + exit ;; + coff-i386) + echo "${UNAME_MACHINE}-pc-linux-gnucoff" + exit ;; + "") + # Either a pre-BFD a.out linker (linux-gnuoldld) or + # one that does not give us useful --help. + echo "${UNAME_MACHINE}-pc-linux-gnuoldld" + exit ;; + esac + # Determine whether the default compiler is a.out or elf + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include <features.h> + #ifdef __ELF__ + # ifdef __GLIBC__ + # if __GLIBC__ >= 2 + LIBC=gnu + # else + LIBC=gnulibc1 + # endif + # else + LIBC=gnulibc1 + # endif + #else + #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__sun) + LIBC=gnu + #else + LIBC=gnuaout + #endif + #endif + #ifdef __dietlibc__ + LIBC=dietlibc + #endif +EOF + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^LIBC/{ + s: ::g + p + }'`" + test x"${LIBC}" != x && { + echo "${UNAME_MACHINE}-pc-linux-${LIBC}" + exit + } + test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; } + ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit ;; + i*86:syllable:*:*) + echo ${UNAME_MACHINE}-pc-syllable + exit ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name` + echo ${UNAME_MACHINE}-pc-isc$UNAME_REL + elif /bin/uname -X 2>/dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i386. + echo i386-pc-msdosdjgpp + exit ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says <Richard.M.Bartel@ccMail.Census.GOV> + echo i586-unisys-sysv4 + exit ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes <hewes@openmarket.com>. + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. + echo ${UNAME_MACHINE}-stratus-vos + exit ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown + case $UNAME_PROCESSOR in + unknown) UNAME_PROCESSOR=powerpc ;; + esac + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + exit ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit ;; + NSE-?:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk${UNAME_RELEASE} + exit ;; + NSR-?:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} + exit ;; + *:DragonFly:*:*) + echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "${UNAME_MACHINE}" in + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit ;; + i*86:skyos:*:*) + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + exit ;; + i*86:rdos:*:*) + echo ${UNAME_MACHINE}-pc-rdos + exit ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +eval $set_cc_for_build +cat >$dummy.c <<EOF +#ifdef _SEQUENT_ +# include <sys/types.h> +# include <sys/utsname.h> +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include <sys/param.h> + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix\n"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +# if !defined (ultrix) +# include <sys/param.h> +# if defined (BSD) +# if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +# else +# if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# endif +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# else + printf ("vax-dec-ultrix\n"); exit (0); +# endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + c34*) + echo c34-convex-bsd + exit ;; + c38*) + echo c38-convex-bsd + exit ;; + c4*) + echo c4-convex-bsd + exit ;; + esac +fi + +cat >&2 <<EOF +$0: unable to guess system type + +This script, last modified $timestamp, has failed to recognize +the operating system you are using. It is advised that you +download the most up to date version of the config scripts from + + http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess +and + http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub + +If the version you run ($0) is already up to date, please +send the following data and any information you think might be +pertinent to <config-patches@gnu.org> in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/AMDiS/lib/muparser_v134/build/autoconf/config.sub b/AMDiS/lib/muparser_v134/build/autoconf/config.sub new file mode 100755 index 0000000000000000000000000000000000000000..ad9f39571183b5c22b2d269bb52eb9ad50227430 --- /dev/null +++ b/AMDiS/lib/muparser_v134/build/autoconf/config.sub @@ -0,0 +1,1608 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + +timestamp='2006-02-23' + +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + + +# Please send patches to <config-patches@gnu.org>. Submit a context +# diff and a properly formatted ChangeLog entry. +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to <config-patches@gnu.org>." + +version="\ +GNU config.sub ($timestamp) + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit ;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ + uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ + storm-chaos* | os2-emx* | rtmk-nova*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis | -knuth | -cray) + os= + basic_machine=$1 + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco6) + os=-sco5v6 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ + | bfin \ + | c4x | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | fr30 | frv \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | i370 | i860 | i960 | ia64 \ + | ip2k | iq2000 \ + | m32r | m32rle | m68000 | m68k | m88k | maxq | mb | microblaze | mcore \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64vr | mips64vrel \ + | mips64orion | mips64orionel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | mt \ + | msp430 \ + | nios | nios2 \ + | ns16k | ns32k \ + | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | pyramid \ + | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc86x | sparclet | sparclite \ + | sparcv8 | sparcv9 | sparcv9b \ + | strongarm \ + | tahoe | thumb | tic4x | tic80 | tron \ + | v850 | v850e \ + | we32k \ + | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \ + | z8k) + basic_machine=$basic_machine-unknown + ;; + m32c) + basic_machine=$basic_machine-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12) + # Motorola 68HC11/12. + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + ms1) + basic_machine=mt-unknown + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ + | clipper-* | craynv-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | elxsi-* \ + | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* | iq2000-* \ + | m32r-* | m32rle-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | maxq-* | mcore-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mips64vr5900-* | mips64vr5900el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | mt-* \ + | msp430-* \ + | nios-* | nios2-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | pyramid-* \ + | romp-* | rs6000-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ + | tahoe-* | thumb-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tron-* \ + | v850-* | v850e-* | vax-* \ + | we32k-* \ + | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \ + | xstormy16-* | xtensa-* \ + | ymp-* \ + | z8k-*) + ;; + m32c-*) + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + abacus) + basic_machine=abacus-unknown + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amd64) + basic_machine=x86_64-pc + ;; + amd64-*) + basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | j90) + basic_machine=j90-cray + os=-unicos + ;; + craynv) + basic_machine=craynv-cray + os=-unicosmp + ;; + cr16c) + basic_machine=cr16c-unknown + os=-elf + ;; + crds | unos) + basic_machine=m68k-crds + ;; + crisv32 | crisv32-* | etraxfs*) + basic_machine=crisv32-axis + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + crx) + basic_machine=crx-unknown + os=-elf + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + djgpp) + basic_machine=i586-pc + os=-msdosdjgpp + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + mingw32) + basic_machine=i386-pc + os=-mingw32 + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + ms1-*) + basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + openrisc | openrisc-*) + basic_machine=or32-unknown + ;; + os400) + basic_machine=powerpc-ibm + os=-os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pc98) + basic_machine=i386-pc + ;; + pc98-*) + basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium | p5 | k5 | k6 | nexgen | viac3) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon | athlon_*) + basic_machine=i686-pc + ;; + pentiumii | pentium2 | pentiumiii | pentium3) + basic_machine=i686-pc + ;; + pentium4) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium4-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc) basic_machine=powerpc-unknown + ;; + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little | ppc64-le | powerpc64-little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rdos) + basic_machine=i386-pc + os=-rdos + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sh64) + basic_machine=sh64-unknown + ;; + sparclite-wrs | simso-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tic54x | c54x*) + basic_machine=tic54x-unknown + os=-coff + ;; + tic55x | c55x*) + basic_machine=tic55x-unknown + os=-coff + ;; + tic6x | c6x*) + basic_machine=tic6x-unknown + os=-coff + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + tpf) + basic_machine=s390x-ibm + os=-tpf + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + xbox) + basic_machine=i686-pc + os=-mingw32 + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + romp) + basic_machine=romp-ibm + ;; + mmix) + basic_machine=mmix-knuth + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele) + basic_machine=sh-unknown + ;; + sparc | sparcv8 | sparcv9 | sparcv9b) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ + | -openbsd* | -solidbsd* \ + | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ + | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ + | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ + | -skyos* | -haiku* | -rdos*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto-qnx*) + ;; + -nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -os400*) + os=-os400 + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -atheos*) + os=-atheos + ;; + -syllable*) + os=-syllable + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -nova*) + os=-rtmk-nova + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -tpf*) + os=-tpf + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -kaos*) + os=-kaos + ;; + -zvmoe) + os=-zvmoe + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + c4x-* | tic4x-*) + os=-coff + ;; + # This must come before the *-dec entry. + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 + ;; + m68*-cisco) + os=-aout + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + or32-*) + os=-coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-haiku) + os=-haiku + ;; + *-ibm) + os=-aix + ;; + *-knuth) + os=-mmixware + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -os400*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -tpf*) + vendor=ibm + ;; + -vxsim* | -vxworks* | -windiss*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/AMDiS/lib/muparser_v134/build/autoconf/configure.ac b/AMDiS/lib/muparser_v134/build/autoconf/configure.ac new file mode 100644 index 0000000000000000000000000000000000000000..cd9068cc4532d58b8c54d056c55f9c14cae82df1 --- /dev/null +++ b/AMDiS/lib/muparser_v134/build/autoconf/configure.ac @@ -0,0 +1,80 @@ +# ====================================================================================== +# Author: Francesco Montorsi +# RCS-ID: $Id: configure.ac 269 2010-01-18 18:30:28Z ibg $ +# ====================================================================================== + + +# NOTE: +# the version of the project must be updated also in docs/Doxyfile ! +AC_INIT([muParser], [1.32], [frm@users.sourceforge.net]) + +AC_PREREQ([2.57]) +AC_CONFIG_AUX_DIR([build/autoconf]) +AC_LANG(C++) + +# some helpers +m4_include(bakefile-presets.m4) + + + +## CONFIGURE CHECKS +##################################################################### + +dnl This allows us to use Bakefile, recognizing the system type +dnl (and sets the AC_CANONICAL_BUILD, AC_CANONICAL_HOST and +dnl AC_CANONICAL_TARGET variables) +AC_CANONICAL_SYSTEM + +dnl we set these vars to avoid that the AC_PROG_C* macros add the "-g -O2" flags; +dnl we will add them later, if needed +CFLAGS= +CXXFLAGS= +CPPFLAGS= + +dnl Checks for basic programs used to compile/install. +AC_PROG_AWK +AC_PROG_INSTALL +AC_PROG_LN_S +AC_PROG_RANLIB +AC_PROG_CC +AC_PROG_CXX +AC_PROG_CXXCPP + + +AC_BAKEFILE_DEBUGOPT([no]) +AC_BAKEFILE_SHAREDOPT([yes]) + +AC_ARG_ENABLE([samples], + AC_HELP_STRING([--enable-samples], [Builds the library samples, too]), + [], [enableval="yes"]) +AC_BAKEFILE_YESNO_OPTCHECK([SAMPLES], [enableval], [--enable-samples]) + +dnl Create the output folders in the current build directory +dnl (this handles cases like: +dnl mkdir mybuild && cd mybuild && ../configure && make ) +AS_MKDIR_P(lib) +AS_MKDIR_P(samples/example1) + +AC_BAKEFILE([m4_include(autoconf_inc.m4)]) +AC_CONFIG_FILES([Makefile build/autoconf/muparser.pc]) +AC_OUTPUT + + + +## CONFIGURE END MESSAGE +##################################################################### + +echo +echo " ----------------------------------------------------------------" +echo " Configuration for $PACKAGE_NAME $PACKAGE_VERSION successfully completed." +echo " Summary of main configuration settings for $PACKAGE_NAME:" +AC_BAKEFILE_SHOW_SHAREDOPT +AC_BAKEFILE_SHOW_DEBUGOPT +if [[ "$SAMPLES" = "1" ]]; then + echo " - SAMPLES enabled" +else + echo " - SAMPLES disabled" +fi +echo " Now, just run make." +echo " ----------------------------------------------------------------" +echo diff --git a/AMDiS/lib/muparser_v134/build/autoconf/install-sh b/AMDiS/lib/muparser_v134/build/autoconf/install-sh new file mode 100755 index 0000000000000000000000000000000000000000..1b3f51d6544f788cdffdd6ca59b40275690e1422 --- /dev/null +++ b/AMDiS/lib/muparser_v134/build/autoconf/install-sh @@ -0,0 +1,2 @@ +#!/bin/sh + diff --git a/AMDiS/lib/muparser_v134/build/autoconf/muparser.pc.in b/AMDiS/lib/muparser_v134/build/autoconf/muparser.pc.in new file mode 100644 index 0000000000000000000000000000000000000000..4c16a24e2eb2f74740fd91e69620cd19449905ca --- /dev/null +++ b/AMDiS/lib/muparser_v134/build/autoconf/muparser.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: @PACKAGE_NAME@ +Description: Mathematical expressions parser library +Version: @PACKAGE_VERSION@ +Requires: +Libs: -L${libdir} -lmuparser +Cflags: -I${includedir} diff --git a/AMDiS/lib/muparser_v134/build/bakefiles/Bakefiles.bkgen b/AMDiS/lib/muparser_v134/build/bakefiles/Bakefiles.bkgen new file mode 100644 index 0000000000000000000000000000000000000000..054fd653d2b9b97d271400e6e2a736d7d2bc1ce5 --- /dev/null +++ b/AMDiS/lib/muparser_v134/build/bakefiles/Bakefiles.bkgen @@ -0,0 +1,35 @@ +<?xml version="1.0" ?> + +<!-- RCS-ID: $Id: Bakefiles.bkgen 268 2010-01-18 18:29:47Z ibg $ --> + +<bakefile-gen xmlns="http://www.bakefile.org/schema/bakefile-gen"> + + <!-- you probably need to edit only this tag --> + <input>muparser.bkl</input> + + <disable-formats>dmars,dmars_smake,cbx_unix,cbuilderx,msevc4prj</disable-formats> + <add-formats>autoconf,borland,mingw,msvc,watcom,msvs2003prj,msvs2005prj,msvs2008prj</add-formats> + + <add-flags formats="borland">-o ../makefile.bcc</add-flags> + <add-flags formats="mingw">-o ../makefile.mingw</add-flags> + <add-flags formats="msvc">-o ../makefile.vc</add-flags> + <add-flags formats="watcom">-o ../makefile.wat</add-flags> + <add-flags formats="msvs2003prj">-o ../msvc2003/muparser.sln</add-flags> + <add-flags formats="msvs2005prj">-o ../msvc2005/muparser.sln</add-flags> + <add-flags formats="msvs2008prj">-o ../msvc2008/muparser.sln</add-flags> + + <!-- since it's standard on Unix to have Makefile.in and the configure script in + the root folder of the component to build, we put Makefile.in one directory up... --> + <add-flags formats="autoconf"> + -o../../Makefile.in + </add-flags> + + <!-- ...anyway, we don't want to fill the component's root with files which are + useless for the user and just make the component looks "messy"; thus all + autoconf files are still kept in build\; only "configure" and "Makefile.in" + will go in the component's root --> + <add-flags formats="autoconf"> + -DAUTOCONF_MACROS_FILE=../autoconf/autoconf_inc.m4 + </add-flags> + +</bakefile-gen> diff --git a/AMDiS/lib/muparser_v134/build/bakefiles/howto.txt b/AMDiS/lib/muparser_v134/build/bakefiles/howto.txt new file mode 100644 index 0000000000000000000000000000000000000000..6045a71e6f09dfed74990325cfa67b7042f559a4 --- /dev/null +++ b/AMDiS/lib/muparser_v134/build/bakefiles/howto.txt @@ -0,0 +1,16 @@ +These are basic instructions for recreating the project files: + +Clearing olf project and makefiles: +bakefile_gen -c + +Remaking Projects and Makefiles: +bakefile_gen + +In addition to that automake must be started to create the new configure script: +rm -rf autoconf/autom4te.cache autoconf/aclocal.m4 +../autoconf/acregen.sh + +!!! IMPORTANT !!! +When building bakefile from the tar.gz archive make sure to +use the option --prefix=/usr wit the config file since its +path will default to /usr/local. This would cause strange errors! diff --git a/AMDiS/lib/muparser_v134/build/bakefiles/muparser.bkl b/AMDiS/lib/muparser_v134/build/bakefiles/muparser.bkl new file mode 100644 index 0000000000000000000000000000000000000000..023eecfe157cfebe87f4de8a2dae87298afe2fd3 --- /dev/null +++ b/AMDiS/lib/muparser_v134/build/bakefiles/muparser.bkl @@ -0,0 +1,160 @@ +<?xml version="1.0" ?> + +<!-- RCS-ID: $Id: muparser.bkl 247 2010-01-17 20:29:05Z ibg $ --> + +<makefile> + + <requires version="0.2.5"/> + <using module="pkgconfig"/> + + <include file="presets/debugopt.bkl"/> + <include file="presets/sharedopt.bkl"/> + <include file="presets/setbuilddir.bkl"/> + + <!-- put all object files under the OBJ folder --> + <if cond="FORMAT!='autoconf'"> + <set var="BUILDDIR">obj$(DIRSEP)$(BUILDDIR)</set> + </if> + + <set var="DEBUG_BUILD_POSTFIX"> + <if cond="DEBUG=='0'"></if> + <if cond="DEBUG=='1'">d</if> + </set> + + + <!-- Sources for this library --> + <!-- ======================== --> + + <if cond="FORMAT=='autoconf'"> + <!-- Note that since autoconf 2.60 the top_builddir variable does + not ends with '/' anymore... --> + <set var="LIBOUTPATH">$(top_builddir)/lib</set> + <set var="SAMPLEOUTPATH">$(top_builddir)/samples</set> + </if> + <if cond="'msv' in FORMAT"> + <!-- match all MSVC visual studio formats --> + <set-srcdir>../..</set-srcdir> + </if> + <if cond="FORMAT in [ 'borland', 'mingw', 'watcom', 'msvc' ]"> + <set-srcdir>..</set-srcdir> + </if> + <if cond="FORMAT!='autoconf'"> + <set var="LIBOUTPATH">$(SRCDIR)/lib</set> + <set var="SAMPLEOUTPATH">$(SRCDIR)/samples</set> + </if> + + + + <!-- Settings for this library --> + <!-- ========================= --> + + <template id="muparser_base" template="debugopt"> + <!-- tell Bakefile to define the MUPARSER_DLL symbol when building in shared mode --> + <define>$(substituteFromDict(SHARED, {'1':'MUPARSER_DLL', '0':''}))</define> + <define>$(substituteFromDict(SHARED, {'1':'MUPARSERLIB_EXPORTS', '0':''}))</define> + <if cond="FORMAT!='autoconf'"> + <define>_WIN32</define> + </if> + + <sources>$(fileList('src/*.cpp'))</sources> + <headers>$(fileList('include/*.h'))</headers> + <dirname>$(LIBOUTPATH)</dirname> + <include>$(SRCDIR)/include</include> + + <install-to>$(LIBDIR)</install-to> + <install-headers-to>$(PREFIX)</install-headers-to> + </template> + + <lib id="muParser_lib" template="muparser_base" cond="SHARED=='0'"> + <libname>muparser$(DEBUG_BUILD_POSTFIX)</libname> + </lib> + <dll id="muParser_dll" template="muparser_base" cond="SHARED=='1'"> + <dllname>muparser$(DEBUG_BUILD_POSTFIX)</dllname> + <libname>muparser$(DEBUG_BUILD_POSTFIX)</libname> + + <version>1.0</version> + <so_version>0.0.0</so_version> + <mac_version>1</mac_version> <!-- must be > 0 --> + </dll> + + <!-- this makes the MSVC6 project files much nicer... --> + <set var="MSVC6PRJ_MERGED_TARGETS">muParser=muParser_lib+muParser_dll</set> + + <!-- Installs the PKG-CONFIG file --> + <pkgconfig id="pkgconfig" cond="FORMAT=='autoconf'"> + <src>build/autoconf/muparser.pc</src> + </pkgconfig> + + + + + <!-- Samples for the library --> + <!-- ======================= --> + + <if cond="FORMAT_SUPPORTS_CONDITIONS=='1'"> + <option name="SAMPLES"> + <values>0,1</values> + <default-value>1</default-value> + <description>Set to 1 to compile samples</description> + </option> + </if> + <if cond="FORMAT_SUPPORTS_CONDITIONS=='0'"> + <!-- Avoid to create IDE project files with multiple configurations + which differ only for the SAMPLES=0/1 option! --> + <set var="SAMPLES">1</set> + </if> + + <template id="muparser_sample" template="debugopt"> + <library>muParser_lib</library> + <include>$(SRCDIR)/include</include> + <lib-path>$(SRCDIR)/lib</lib-path> + </template> + + <if cond="FORMAT!='autoconf'"> + <exe id="example1" template="muparser_sample" cond="SAMPLES=='1' and SHARED=='0'"> + <sources>$(fileList('samples/example1/*.cpp'))</sources> + <dirname>$(SAMPLEOUTPATH)/example1</dirname> + <define>$(substituteFromDict(SHARED, {'1':'USINGDLL', '0':''}))</define> + </exe> + </if> + <if cond="FORMAT=='autoconf'"> + <!-- On Unix this sample is always available --> + <exe id="example1" template="muparser_sample" cond="SAMPLES=='1'"> + <sources>$(fileList('samples/example1/*.cpp'))</sources> + <dirname>$(SAMPLEOUTPATH)/example1</dirname> + </exe> + </if> + + <if cond="FORMAT!='autoconf'"> + <!-- This samples is win32-specific (it uses the DLL interface) --> + <exe id="example2" template="muparser_sample" cond="SAMPLES=='1' and SHARED=='1'"> + <sources>$(fileList('samples/example2/*.c'))</sources> + <dirname>$(SAMPLEOUTPATH)/example2</dirname> + <define>$(substituteFromDict(SHARED, {'1':'USINGDLL', '0':''}))</define> + </exe> + </if> + + + + <!-- Some helpers for command-line makefiles --> + <!-- ======================================= --> + + <phony id="lib"> + <depends>muParser_lib</depends> + <depends>muParser_dll</depends> + </phony> + + <phony id="samples"> + <depends>example1</depends> + <!-- <depends cond="FORMAT in [ 'msvc', 'msvc6prj' ]">example2</depends> --> + <depends cond="FORMAT!='autoconf'">example2</depends> + </phony> + + <if cond="FORMAT_SUPPORTS_ACTIONS=='1'"> + <action id="documentation"> + <command>( cd $(SRCDIR)$(DIRSEP)docs && doxygen )</command> + </action> + </if> + +</makefile> + diff --git a/AMDiS/lib/muparser_v134/build/bakefiles/presets/debugopt.bkl b/AMDiS/lib/muparser_v134/build/bakefiles/presets/debugopt.bkl new file mode 100644 index 0000000000000000000000000000000000000000..eb47bc45e0926d4d7ba712413a65b762776b968e --- /dev/null +++ b/AMDiS/lib/muparser_v134/build/bakefiles/presets/debugopt.bkl @@ -0,0 +1,55 @@ +<?xml version="1.0" ?> +<!-- $Id: debugopt.bkl 40 2006-12-02 15:22:02Z frm $ --> + +<!-- + +Adds the logic for handling a DEBUG=0/1 option, which switches between debug and +release builds. + +Usage: use template "debugopt" for your targets: + + <include file="presets/debugopt.bkl"/> + + <exe id="myapp" template="debugopt"> + <sources>myapp.cpp</sources> + </exe> + +--> + +<makefile> + + <set var="DEBUG_DEFAULT" overwrite="0">0</set> + <option name="DEBUG"> + <values>0,1</values> + <default-value>$(DEBUG_DEFAULT)</default-value> + <values-description>Release,Debug</values-description> + <description>Set to 1 to build debug version</description> + </option> + + <template id="debugopt"> + <define> + $(substituteFromDict(DEBUG,{'1':'','0':'NDEBUG'})) + </define> + <optimize> + $(substituteFromDict(DEBUG,{'1':'off','0':'speed'})) + </optimize> + <debug-info> + $(substituteFromDict(DEBUG,{'1':'on','0':'off'})) + </debug-info> + <warnings> + $(substituteFromDict(DEBUG,{'1':'max','0':'no'})) + </warnings> + <debug-runtime-libs> + $(substituteFromDict(DEBUG,{'1':'on','0':'off'})) + </debug-runtime-libs> + </template> + + + <!-- The DEBUGBUILDPOSTFIX variable is useful to set the BUILDDIR variable + as done in presets/setbuilddir.bkl --> + <set var="DEBUGBUILDPOSTFIX"> + <if cond="DEBUG=='0'">rel</if> + <if cond="DEBUG=='1'">dbg</if> + </set> + +</makefile> diff --git a/AMDiS/lib/muparser_v134/build/bakefiles/presets/setbuilddir.bkl b/AMDiS/lib/muparser_v134/build/bakefiles/presets/setbuilddir.bkl new file mode 100644 index 0000000000000000000000000000000000000000..9e7eef0b751087d4e34621ec6a1faa9c6a5b0e2e --- /dev/null +++ b/AMDiS/lib/muparser_v134/build/bakefiles/presets/setbuilddir.bkl @@ -0,0 +1,63 @@ +<?xml version="1.0" ?> +<!-- $Id: setbuilddir.bkl 40 2006-12-02 15:22:02Z frm $ --> + +<!-- + +Adds the logic for setting BUILDDIR in a smart way, checking which other presets have been +included. Include this preset after including all other presets. + +Usage: + + <include file="presets/sharedopt.bkl"/> + <include file="presets/unicodeopt.bkl"/> + <include file="presets/debugopt.bkl"/> + <include file="presets/setbuilddir.bkl"/> + + <lib id="mylib_static" template="debugopt,unicodeopt" cond="SHARED=='0'"> + <sources>mylib.cpp</sources> + </lib> + + <dll id="mylib_shared" template="debugopt,unicodeopt" cond="SHARED=='1'"> + <sources>mylib.cpp</sources> + </dll> + + <set var="MSVC6PRJ_MERGED_TARGETS">mylib=mylib_static+mylib_shared</set> +--> + +<makefile> + + <!-- + Setting the BUILDDIR variable using the + SHAREDBUILDPOSTFIX/DEBUGBUILDPOSTFIX/UNICODEBUILDPOSTFIX + variables we will keep separed the intermediate files (objects, compiled resources, exes, libs) + generated using SHARED/DEBUG/UNICODE=0 from those generated using SHARED/DEBUG/UNICODE=1. + + Using the same BUILDDIR for these different configurations would force the + user to call a "make clean" (or equivalent) before rebuilding since it's not wise + mixing a shared build with a static one or a debug build with a release one + or a unicode build with an ansi one. + + Last, using the COMPILER when setting BUILDDIR keeps separed the object files generated using + different compilers (in case makefiles for different compilers are generated in the same directory). + + NOTE: the autoconf format requires BUILDDIR='.' since using different build directories + is already handled by the configure script. + E.g. + for debug builds: mkdir dbg && cd dbg && ../configure - -enable-debug + for release builds: mkdir rel && cd rel && ../configure - -disable-debug + ... + See autoconf documentation for more info. + --> + + <!-- some helpers --> + <set var="SHRDSTR"><if cond="isdefined('SHAREDBUILDPOSTFIX')">_$(SHAREDBUILDPOSTFIX)</if></set> + <set var="DBGSTR"><if cond="isdefined('DEBUGBUILDPOSTFIX')">_$(DEBUGBUILDPOSTFIX)</if></set> + <set var="UNICSTR"><if cond="isdefined('UNICODEBUILDPOSTFIX')">_$(UNICODEBUILDPOSTFIX)</if></set> + + <if cond="FORMAT!='autoconf'"> + <set var="BUILDDIR"> + $(COMPILER)$(SHRDSTR)$(DBGSTR)$(UNICSTR) + </set> + </if> + +</makefile> diff --git a/AMDiS/lib/muparser_v134/build/bakefiles/presets/sharedopt.bkl b/AMDiS/lib/muparser_v134/build/bakefiles/presets/sharedopt.bkl new file mode 100644 index 0000000000000000000000000000000000000000..461437bfa249a20e104b59be7c95350196bec876 --- /dev/null +++ b/AMDiS/lib/muparser_v134/build/bakefiles/presets/sharedopt.bkl @@ -0,0 +1,42 @@ +<?xml version="1.0" ?> +<!-- $Id: sharedopt.bkl 40 2006-12-02 15:22:02Z frm $ --> + +<!-- + +Adds the logic for handling a SHARED=0/1 option, which switches between static and +shared (DLL) builds. + +Usage: use template "sharedopt" for your targets: + + <include file="presets/sharedopt.bkl"/> + + <lib id="mylib_static" cond="SHARED=='0'"> + <sources>mylib.cpp</sources> + </lib> + + <dll id="mylib_shared" cond="SHARED=='1'"> + <sources>mylib.cpp</sources> + </dll> + + <set var="MSVC6PRJ_MERGED_TARGETS">mylib=mylib_static+mylib_shared</set> +--> + +<makefile> + + <set var="SHARED_DEFAULT" overwrite="0">0</set> + <option name="SHARED"> + <values>0,1</values> + <default-value>$(SHARED_DEFAULT)</default-value> + <values-description>Static,DLL</values-description> + <description>Set to 1 to build shared (DLL) version</description> + </option> + + + <!-- The SHAREDBUILDPOSTFIX variable is useful to set the BUILDDIR variable + as done in presets/setbuilddir.bkl --> + <set var="SHAREDBUILDPOSTFIX"> + <if cond="SHARED=='0'">static</if> + <if cond="SHARED=='1'">shared</if> + </set> + +</makefile> diff --git a/AMDiS/lib/muparser_v134/build/bakefiles/presets/unicodeopt.bkl b/AMDiS/lib/muparser_v134/build/bakefiles/presets/unicodeopt.bkl new file mode 100644 index 0000000000000000000000000000000000000000..5fe3ac25dbcf31a6184903a62c5a0c6f7d3658ff --- /dev/null +++ b/AMDiS/lib/muparser_v134/build/bakefiles/presets/unicodeopt.bkl @@ -0,0 +1,43 @@ +<?xml version="1.0" ?> +<!-- $Id: unicodeopt.bkl 40 2006-12-02 15:22:02Z frm $ --> + +<!-- + +Adds the logic for handling a UNICODE=0/1 option, which switches between unicode and +ansi builds. + +Usage: use template "unicodeopt" for your targets: + + <include file="presets/unicodeopt.bkl"/> + + <exe id="myapp" template="unicodeopt"> + <sources>myapp.cpp</sources> + </exe> + +--> + +<makefile> + + <set var="UNICODE_DEFAULT" overwrite="0">0</set> + <option name="UNICODE"> + <values>0,1</values> + <default-value>$(UNICODE_DEFAULT)</default-value> + <values-description>ANSI,Unicode</values-description> + <description>Set to 1 to build Unicode version</description> + </option> + + <template id="unicodeopt"> + <define> + $(substituteFromDict(UNICODE,{'1':'_UNICODE','0':''})) + </define> + </template> + + + <!-- The UNICODEBUILDPOSTFIX variable is useful to set the BUILDDIR variable + as done in presets/setbuilddir.bkl --> + <set var="UNICODEBUILDPOSTFIX"> + <if cond="UNICODE=='0'">a</if> + <if cond="UNICODE=='1'">u</if> + </set> + +</makefile> diff --git a/AMDiS/lib/muparser_v134/build/makefile.bcc b/AMDiS/lib/muparser_v134/build/makefile.bcc new file mode 100644 index 0000000000000000000000000000000000000000..b2d6480cb59a53525210f59d3bb3df731ac78dd7 --- /dev/null +++ b/AMDiS/lib/muparser_v134/build/makefile.bcc @@ -0,0 +1,317 @@ +# ========================================================================= +# This makefile was generated by +# Bakefile 0.2.8 (http://www.bakefile.org) +# Do not modify, all changes will be overwritten! +# ========================================================================= + +.autodepend + +!ifndef BCCDIR +!ifndef MAKEDIR +!error Your Borland compiler does not define MAKEDIR. Please define the BCCDIR variable, e.g. BCCDIR=d:\bc4 +!endif +BCCDIR = $(MAKEDIR)\.. +!endif + + + +# ------------------------------------------------------------------------- +# These are configurable options: +# ------------------------------------------------------------------------- + +# C compiler +!ifndef CC +CC = bcc32 +!endif + +# C++ compiler +!ifndef CXX +CXX = bcc32 +!endif + +# Standard flags for CC +!ifndef CFLAGS +CFLAGS = +!endif + +# Standard flags for C++ +!ifndef CXXFLAGS +CXXFLAGS = +!endif + +# Standard preprocessor flags (common for CC and CXX) +!ifndef CPPFLAGS +CPPFLAGS = -a8 -g0 +!endif + +# Standard linker flags +!ifndef LDFLAGS +LDFLAGS = +!endif + +# Set to 1 to build debug version [0,1] +!ifndef DEBUG +DEBUG = 0 +!endif + +# Set to 1 to build shared (DLL) version [0,1] +!ifndef SHARED +SHARED = 0 +!endif + +# Set to 1 to compile samples [0,1] +!ifndef SAMPLES +SAMPLES = 1 +!endif + + + +# ------------------------------------------------------------------------- +# Do not modify the rest of this file! +# ------------------------------------------------------------------------- + +### Variables: ### + +MUPARSER_LIB_CXXFLAGS = -I$(BCCDIR)\include $(____DEBUG) $(____DEBUG_5) \ + $(____DEBUG_8) $(____SHARED) $(____SHARED_0) -D_WIN32 -I..\include \ + $(CPPFLAGS) $(CXXFLAGS) +MUPARSER_LIB_OBJECTS = \ + obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParser.obj \ + obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserBase.obj \ + obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserBytecode.obj \ + obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserCallback.obj \ + obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserComplex.obj \ + obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserDLL.obj \ + obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserError.obj \ + obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserInt.obj \ + obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserTest.obj \ + obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserTokenReader.obj +MUPARSER_DLL_CXXFLAGS = -I$(BCCDIR)\include $(____DEBUG) $(____DEBUG_5) \ + $(____DEBUG_8) $(____SHARED) $(____SHARED_0) -D_WIN32 -I..\include \ + $(CPPFLAGS) $(CXXFLAGS) +MUPARSER_DLL_OBJECTS = \ + obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParser.obj \ + obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserBase.obj \ + obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserBytecode.obj \ + obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserCallback.obj \ + obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserComplex.obj \ + obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserDLL.obj \ + obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserError.obj \ + obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserInt.obj \ + obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserTest.obj \ + obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserTokenReader.obj +EXAMPLE1_CXXFLAGS = -I$(BCCDIR)\include $(____DEBUG) $(____DEBUG_5) \ + $(____DEBUG_8) -I..\include $(____SHARED_1) $(CPPFLAGS) $(CXXFLAGS) +EXAMPLE1_OBJECTS = \ + obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example1_Example1.obj +EXAMPLE2_CFLAGS = -I$(BCCDIR)\include $(____DEBUG) $(____DEBUG_5) \ + $(____DEBUG_8) -I..\include $(____SHARED_1) $(CPPFLAGS) $(CFLAGS) +EXAMPLE2_OBJECTS = \ + obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example2_example2.obj + +### Conditionally set variables: ### + +!if "$(DEBUG)" == "0" +DEBUGBUILDPOSTFIX = rel +!endif +!if "$(DEBUG)" == "1" +DEBUGBUILDPOSTFIX = dbg +!endif +!if "$(SHARED)" == "0" +SHAREDBUILDPOSTFIX = static +!endif +!if "$(SHARED)" == "1" +SHAREDBUILDPOSTFIX = shared +!endif +!if "$(DEBUG)" == "0" +DEBUG_BUILD_POSTFIX = +!endif +!if "$(DEBUG)" == "1" +DEBUG_BUILD_POSTFIX = d +!endif +!if "$(SHARED)" == "0" +__muParser_lib___depname = ..\lib\muparser$(DEBUG_BUILD_POSTFIX).lib +!endif +!if "$(SHARED)" == "1" +__muParser_dll___depname = ..\lib\muparser$(DEBUG_BUILD_POSTFIX).dll +!endif +!if "$(SAMPLES)" == "1" && "$(SHARED)" == "0" +__example1___depname = ..\samples\example1\example1.exe +!endif +!if "$(SAMPLES)" == "1" && "$(SHARED)" == "1" +__example2___depname = ..\samples\example2\example2.exe +!endif +!if "$(SHARED)" == "0" +____SHARED = +!endif +!if "$(SHARED)" == "1" +____SHARED = -DMUPARSER_DLL +!endif +!if "$(SHARED)" == "0" +____SHARED_0 = +!endif +!if "$(SHARED)" == "1" +____SHARED_0 = -DMUPARSERLIB_EXPORTS +!endif +!if "$(DEBUG)" == "0" +____DEBUG = -DNDEBUG +!endif +!if "$(DEBUG)" == "1" +____DEBUG = +!endif +!if "$(DEBUG)" == "0" +____DEBUG_5 = -O2 +!endif +!if "$(DEBUG)" == "1" +____DEBUG_5 = -Od +!endif +!if "$(SHARED)" == "0" +____SHARED_1 = +!endif +!if "$(SHARED)" == "1" +____SHARED_1 = -DUSINGDLL +!endif +!if "$(DEBUG)" == "0" +____DEBUG_8 = -v- +!endif +!if "$(DEBUG)" == "1" +____DEBUG_8 = -v +!endif + + +all: obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX) +obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX): + -if not exist obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX) mkdir obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX) + +### Targets: ### + +all: $(__muParser_lib___depname) $(__muParser_dll___depname) $(__example1___depname) $(__example2___depname) + +clean: + -if exist obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\*.obj del obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\*.obj + -if exist obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\*.res del obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\*.res + -if exist obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\*.csm del obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\*.csm + -if exist ..\lib\muparser$(DEBUG_BUILD_POSTFIX).lib del ..\lib\muparser$(DEBUG_BUILD_POSTFIX).lib + -if exist ..\lib\muparser$(DEBUG_BUILD_POSTFIX).dll del ..\lib\muparser$(DEBUG_BUILD_POSTFIX).dll + -if exist ..\lib\muparser$(DEBUG_BUILD_POSTFIX).tds del ..\lib\muparser$(DEBUG_BUILD_POSTFIX).tds + -if exist ..\lib\muparser$(DEBUG_BUILD_POSTFIX).ilc del ..\lib\muparser$(DEBUG_BUILD_POSTFIX).ilc + -if exist ..\lib\muparser$(DEBUG_BUILD_POSTFIX).ild del ..\lib\muparser$(DEBUG_BUILD_POSTFIX).ild + -if exist ..\lib\muparser$(DEBUG_BUILD_POSTFIX).ilf del ..\lib\muparser$(DEBUG_BUILD_POSTFIX).ilf + -if exist ..\lib\muparser$(DEBUG_BUILD_POSTFIX).ils del ..\lib\muparser$(DEBUG_BUILD_POSTFIX).ils + -if exist ..\lib\muparser$(DEBUG_BUILD_POSTFIX).lib del ..\lib\muparser$(DEBUG_BUILD_POSTFIX).lib + -if exist ..\samples\example1\example1.exe del ..\samples\example1\example1.exe + -if exist ..\samples\example1\example1.tds del ..\samples\example1\example1.tds + -if exist ..\samples\example1\example1.ilc del ..\samples\example1\example1.ilc + -if exist ..\samples\example1\example1.ild del ..\samples\example1\example1.ild + -if exist ..\samples\example1\example1.ilf del ..\samples\example1\example1.ilf + -if exist ..\samples\example1\example1.ils del ..\samples\example1\example1.ils + -if exist ..\samples\example2\example2.exe del ..\samples\example2\example2.exe + -if exist ..\samples\example2\example2.tds del ..\samples\example2\example2.tds + -if exist ..\samples\example2\example2.ilc del ..\samples\example2\example2.ilc + -if exist ..\samples\example2\example2.ild del ..\samples\example2\example2.ild + -if exist ..\samples\example2\example2.ilf del ..\samples\example2\example2.ilf + -if exist ..\samples\example2\example2.ils del ..\samples\example2\example2.ils + +!if "$(SHARED)" == "0" +..\lib\muparser$(DEBUG_BUILD_POSTFIX).lib: $(MUPARSER_LIB_OBJECTS) + if exist $@ del $@ + tlib /a /p4096 $@ @&&| + $(MUPARSER_LIB_OBJECTS) +| +!endif + +!if "$(SHARED)" == "1" +..\lib\muparser$(DEBUG_BUILD_POSTFIX).dll: $(MUPARSER_DLL_OBJECTS) + ilink32 -Tpd -q -L$(BCCDIR)\lib -L$(BCCDIR)\lib\psdk $(____DEBUG_8) $(LDFLAGS) @&&| + c0d32.obj $(MUPARSER_DLL_OBJECTS),$@,, import32.lib cw32.lib,, +| + implib -f ..\lib\muparser$(DEBUG_BUILD_POSTFIX) $@ +!endif + +!if "$(SAMPLES)" == "1" && "$(SHARED)" == "0" +..\samples\example1\example1.exe: $(EXAMPLE1_OBJECTS) $(__muParser_lib___depname) + ilink32 -Tpe -q -L$(BCCDIR)\lib -L$(BCCDIR)\lib\psdk $(____DEBUG_8) -L..\lib $(LDFLAGS) @&&| + c0x32.obj $(EXAMPLE1_OBJECTS),$@,, ..\lib\muparser$(DEBUG_BUILD_POSTFIX).lib import32.lib cw32.lib,, +| +!endif + +!if "$(SAMPLES)" == "1" && "$(SHARED)" == "1" +..\samples\example2\example2.exe: $(EXAMPLE2_OBJECTS) $(__muParser_lib___depname) + ilink32 -Tpe -q -L$(BCCDIR)\lib -L$(BCCDIR)\lib\psdk $(____DEBUG_8) -L..\lib $(LDFLAGS) @&&| + c0x32.obj $(EXAMPLE2_OBJECTS),$@,, ..\lib\muparser$(DEBUG_BUILD_POSTFIX).lib import32.lib cw32.lib,, +| +!endif + +lib: $(__muParser_lib___depname) $(__muParser_dll___depname) + +samples: $(__example1___depname) $(__example2___depname) + +documentation: + ( cd ..\docs && doxygen ) + +obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParser.obj: ..\src\muParser.cpp + $(CXX) -q -c -P -o$@ $(MUPARSER_LIB_CXXFLAGS) ..\src\muParser.cpp + +obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserBase.obj: ..\src\muParserBase.cpp + $(CXX) -q -c -P -o$@ $(MUPARSER_LIB_CXXFLAGS) ..\src\muParserBase.cpp + +obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserBytecode.obj: ..\src\muParserBytecode.cpp + $(CXX) -q -c -P -o$@ $(MUPARSER_LIB_CXXFLAGS) ..\src\muParserBytecode.cpp + +obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserCallback.obj: ..\src\muParserCallback.cpp + $(CXX) -q -c -P -o$@ $(MUPARSER_LIB_CXXFLAGS) ..\src\muParserCallback.cpp + +obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserComplex.obj: ..\src\muParserComplex.cpp + $(CXX) -q -c -P -o$@ $(MUPARSER_LIB_CXXFLAGS) ..\src\muParserComplex.cpp + +obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserDLL.obj: ..\src\muParserDLL.cpp + $(CXX) -q -c -P -o$@ $(MUPARSER_LIB_CXXFLAGS) ..\src\muParserDLL.cpp + +obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserError.obj: ..\src\muParserError.cpp + $(CXX) -q -c -P -o$@ $(MUPARSER_LIB_CXXFLAGS) ..\src\muParserError.cpp + +obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserInt.obj: ..\src\muParserInt.cpp + $(CXX) -q -c -P -o$@ $(MUPARSER_LIB_CXXFLAGS) ..\src\muParserInt.cpp + +obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserTest.obj: ..\src\muParserTest.cpp + $(CXX) -q -c -P -o$@ $(MUPARSER_LIB_CXXFLAGS) ..\src\muParserTest.cpp + +obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserTokenReader.obj: ..\src\muParserTokenReader.cpp + $(CXX) -q -c -P -o$@ $(MUPARSER_LIB_CXXFLAGS) ..\src\muParserTokenReader.cpp + +obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParser.obj: ..\src\muParser.cpp + $(CXX) -q -c -P -o$@ $(MUPARSER_DLL_CXXFLAGS) ..\src\muParser.cpp + +obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserBase.obj: ..\src\muParserBase.cpp + $(CXX) -q -c -P -o$@ $(MUPARSER_DLL_CXXFLAGS) ..\src\muParserBase.cpp + +obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserBytecode.obj: ..\src\muParserBytecode.cpp + $(CXX) -q -c -P -o$@ $(MUPARSER_DLL_CXXFLAGS) ..\src\muParserBytecode.cpp + +obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserCallback.obj: ..\src\muParserCallback.cpp + $(CXX) -q -c -P -o$@ $(MUPARSER_DLL_CXXFLAGS) ..\src\muParserCallback.cpp + +obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserComplex.obj: ..\src\muParserComplex.cpp + $(CXX) -q -c -P -o$@ $(MUPARSER_DLL_CXXFLAGS) ..\src\muParserComplex.cpp + +obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserDLL.obj: ..\src\muParserDLL.cpp + $(CXX) -q -c -P -o$@ $(MUPARSER_DLL_CXXFLAGS) ..\src\muParserDLL.cpp + +obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserError.obj: ..\src\muParserError.cpp + $(CXX) -q -c -P -o$@ $(MUPARSER_DLL_CXXFLAGS) ..\src\muParserError.cpp + +obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserInt.obj: ..\src\muParserInt.cpp + $(CXX) -q -c -P -o$@ $(MUPARSER_DLL_CXXFLAGS) ..\src\muParserInt.cpp + +obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserTest.obj: ..\src\muParserTest.cpp + $(CXX) -q -c -P -o$@ $(MUPARSER_DLL_CXXFLAGS) ..\src\muParserTest.cpp + +obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserTokenReader.obj: ..\src\muParserTokenReader.cpp + $(CXX) -q -c -P -o$@ $(MUPARSER_DLL_CXXFLAGS) ..\src\muParserTokenReader.cpp + +obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example1_Example1.obj: ..\samples\example1\Example1.cpp + $(CXX) -q -c -P -o$@ $(EXAMPLE1_CXXFLAGS) ..\samples\example1\Example1.cpp + +obj\bcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example2_example2.obj: ..\samples\example2\example2.c + $(CC) -q -c -P- -o$@ $(EXAMPLE2_CFLAGS) ..\samples\example2\example2.c + diff --git a/AMDiS/lib/muparser_v134/build/makefile.mingw b/AMDiS/lib/muparser_v134/build/makefile.mingw new file mode 100644 index 0000000000000000000000000000000000000000..d122e43a85434615d6f23a69ac7caadc575d82d6 --- /dev/null +++ b/AMDiS/lib/muparser_v134/build/makefile.mingw @@ -0,0 +1,291 @@ +# ========================================================================= +# This makefile was generated by +# Bakefile 0.2.8 (http://www.bakefile.org) +# Do not modify, all changes will be overwritten! +# ========================================================================= + + + +# ------------------------------------------------------------------------- +# These are configurable options: +# ------------------------------------------------------------------------- + +# Compiler flags to link shared library +LINK_DLL_FLAGS ?= -shared + +# C compiler +CC = gcc + +# C++ compiler +CXX = g++ + +# Standard flags for CC +CFLAGS ?= + +# Standard flags for C++ +CXXFLAGS ?= + +# Standard preprocessor flags (common for CC and CXX) +CPPFLAGS ?= + +# Standard linker flags +LDFLAGS ?= + +# Set to 1 to build debug version [0,1] +DEBUG ?= 0 + +# Set to 1 to build shared (DLL) version [0,1] +SHARED ?= 0 + +# Set to 1 to compile samples [0,1] +SAMPLES ?= 1 + + + +# ------------------------------------------------------------------------- +# Do not modify the rest of this file! +# ------------------------------------------------------------------------- + +### Variables: ### + +CPPDEPS = -MT$@ -MF$@.d -MD -MP +MUPARSER_LIB_CXXFLAGS = $(____DEBUG) $(____DEBUG_3) $(____DEBUG_9) \ + $(____DEBUG_8) $(____SHARED) $(____SHARED_0) -D_WIN32 -I..\include \ + $(CPPFLAGS) $(CXXFLAGS) +MUPARSER_LIB_OBJECTS = \ + obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParser.o \ + obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserBase.o \ + obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserBytecode.o \ + obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserCallback.o \ + obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserComplex.o \ + obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserDLL.o \ + obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserError.o \ + obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserInt.o \ + obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserTest.o \ + obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserTokenReader.o +MUPARSER_DLL_CXXFLAGS = $(____DEBUG) $(____DEBUG_3) $(____DEBUG_9) \ + $(____DEBUG_8) $(____SHARED) $(____SHARED_0) -D_WIN32 -I..\include \ + $(CPPFLAGS) $(CXXFLAGS) +MUPARSER_DLL_OBJECTS = \ + obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParser.o \ + obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserBase.o \ + obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserBytecode.o \ + obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserCallback.o \ + obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserComplex.o \ + obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserDLL.o \ + obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserError.o \ + obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserInt.o \ + obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserTest.o \ + obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserTokenReader.o +EXAMPLE1_CXXFLAGS = $(____DEBUG) $(____DEBUG_3) $(____DEBUG_9) $(____DEBUG_8) \ + -I..\include $(____SHARED_1) $(CPPFLAGS) $(CXXFLAGS) +EXAMPLE1_OBJECTS = \ + obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example1_Example1.o +EXAMPLE2_CFLAGS = $(____DEBUG) $(____DEBUG_3) $(____DEBUG_9) $(____DEBUG_8) \ + -I..\include $(____SHARED_1) $(CPPFLAGS) $(CFLAGS) +EXAMPLE2_OBJECTS = \ + obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example2_example2.o + +### Conditionally set variables: ### + +ifeq ($(DEBUG),0) +DEBUGBUILDPOSTFIX = rel +endif +ifeq ($(DEBUG),1) +DEBUGBUILDPOSTFIX = dbg +endif +ifeq ($(SHARED),0) +SHAREDBUILDPOSTFIX = static +endif +ifeq ($(SHARED),1) +SHAREDBUILDPOSTFIX = shared +endif +ifeq ($(DEBUG),0) +DEBUG_BUILD_POSTFIX = +endif +ifeq ($(DEBUG),1) +DEBUG_BUILD_POSTFIX = d +endif +ifeq ($(SHARED),0) +__muParser_lib___depname = ..\lib\libmuparser$(DEBUG_BUILD_POSTFIX).a +endif +ifeq ($(SHARED),1) +__muParser_dll___depname = ..\lib\muparser$(DEBUG_BUILD_POSTFIX).dll +endif +ifeq ($(SAMPLES),1) +ifeq ($(SHARED),0) +__example1___depname = ..\samples\example1\example1.exe +endif +endif +ifeq ($(SAMPLES),1) +ifeq ($(SHARED),1) +__example2___depname = ..\samples\example2\example2.exe +endif +endif +ifeq ($(SHARED),0) +____SHARED = +endif +ifeq ($(SHARED),1) +____SHARED = -DMUPARSER_DLL +endif +ifeq ($(SHARED),0) +____SHARED_0 = +endif +ifeq ($(SHARED),1) +____SHARED_0 = -DMUPARSERLIB_EXPORTS +endif +ifeq ($(DEBUG),0) +____DEBUG = -DNDEBUG +endif +ifeq ($(DEBUG),1) +____DEBUG = +endif +ifeq ($(DEBUG),0) +____DEBUG_3 = -O2 +endif +ifeq ($(DEBUG),1) +____DEBUG_3 = -O0 +endif +ifeq ($(DEBUG),0) +____DEBUG_8 = +endif +ifeq ($(DEBUG),1) +____DEBUG_8 = -W -Wall +endif +ifeq ($(SHARED),0) +____SHARED_1 = +endif +ifeq ($(SHARED),1) +____SHARED_1 = -DUSINGDLL +endif +ifeq ($(DEBUG),0) +____DEBUG_9 = +endif +ifeq ($(DEBUG),1) +____DEBUG_9 = -g +endif + + +all: obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX) +obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX): + -if not exist obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX) mkdir obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX) + +### Targets: ### + +all: $(__muParser_lib___depname) $(__muParser_dll___depname) $(__example1___depname) $(__example2___depname) + +clean: + -if exist obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\*.o del obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\*.o + -if exist obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\*.d del obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\*.d + -if exist ..\lib\libmuparser$(DEBUG_BUILD_POSTFIX).a del ..\lib\libmuparser$(DEBUG_BUILD_POSTFIX).a + -if exist ..\lib\muparser$(DEBUG_BUILD_POSTFIX).dll del ..\lib\muparser$(DEBUG_BUILD_POSTFIX).dll + -if exist ..\lib\libmuparser$(DEBUG_BUILD_POSTFIX).a del ..\lib\libmuparser$(DEBUG_BUILD_POSTFIX).a + -if exist ..\samples\example1\example1.exe del ..\samples\example1\example1.exe + -if exist ..\samples\example2\example2.exe del ..\samples\example2\example2.exe + +ifeq ($(SHARED),0) +..\lib\libmuparser$(DEBUG_BUILD_POSTFIX).a: $(MUPARSER_LIB_OBJECTS) + if exist $@ del $@ + ar rcu $@ $(MUPARSER_LIB_OBJECTS) + ranlib $@ +endif + +ifeq ($(SHARED),1) +..\lib\muparser$(DEBUG_BUILD_POSTFIX).dll: $(MUPARSER_DLL_OBJECTS) + $(CXX) $(LINK_DLL_FLAGS) -fPIC -o $@ $(MUPARSER_DLL_OBJECTS) $(____DEBUG_9) -Wl,--out-implib=..\lib\libmuparser$(DEBUG_BUILD_POSTFIX).a $(LDFLAGS) +endif + +ifeq ($(SAMPLES),1) +ifeq ($(SHARED),0) +..\samples\example1\example1.exe: $(EXAMPLE1_OBJECTS) $(__muParser_lib___depname) + $(CXX) -o $@ $(EXAMPLE1_OBJECTS) $(____DEBUG_9) -L..\lib $(LDFLAGS) ..\lib\libmuparser$(DEBUG_BUILD_POSTFIX).a +endif +endif + +ifeq ($(SAMPLES),1) +ifeq ($(SHARED),1) +..\samples\example2\example2.exe: $(EXAMPLE2_OBJECTS) $(__muParser_lib___depname) + $(CC) -o $@ $(EXAMPLE2_OBJECTS) $(____DEBUG_9) -L..\lib $(LDFLAGS) ..\lib\libmuparser$(DEBUG_BUILD_POSTFIX).a +endif +endif + +lib: $(__muParser_lib___depname) $(__muParser_dll___depname) + +samples: $(__example1___depname) $(__example2___depname) + +documentation: + ( cd ..\docs && doxygen ) + +obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParser.o: ../src/muParser.cpp + $(CXX) -c -o $@ $(MUPARSER_LIB_CXXFLAGS) $(CPPDEPS) $< + +obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserBase.o: ../src/muParserBase.cpp + $(CXX) -c -o $@ $(MUPARSER_LIB_CXXFLAGS) $(CPPDEPS) $< + +obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserBytecode.o: ../src/muParserBytecode.cpp + $(CXX) -c -o $@ $(MUPARSER_LIB_CXXFLAGS) $(CPPDEPS) $< + +obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserCallback.o: ../src/muParserCallback.cpp + $(CXX) -c -o $@ $(MUPARSER_LIB_CXXFLAGS) $(CPPDEPS) $< + +obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserComplex.o: ../src/muParserComplex.cpp + $(CXX) -c -o $@ $(MUPARSER_LIB_CXXFLAGS) $(CPPDEPS) $< + +obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserDLL.o: ../src/muParserDLL.cpp + $(CXX) -c -o $@ $(MUPARSER_LIB_CXXFLAGS) $(CPPDEPS) $< + +obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserError.o: ../src/muParserError.cpp + $(CXX) -c -o $@ $(MUPARSER_LIB_CXXFLAGS) $(CPPDEPS) $< + +obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserInt.o: ../src/muParserInt.cpp + $(CXX) -c -o $@ $(MUPARSER_LIB_CXXFLAGS) $(CPPDEPS) $< + +obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserTest.o: ../src/muParserTest.cpp + $(CXX) -c -o $@ $(MUPARSER_LIB_CXXFLAGS) $(CPPDEPS) $< + +obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserTokenReader.o: ../src/muParserTokenReader.cpp + $(CXX) -c -o $@ $(MUPARSER_LIB_CXXFLAGS) $(CPPDEPS) $< + +obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParser.o: ../src/muParser.cpp + $(CXX) -c -o $@ $(MUPARSER_DLL_CXXFLAGS) $(CPPDEPS) $< + +obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserBase.o: ../src/muParserBase.cpp + $(CXX) -c -o $@ $(MUPARSER_DLL_CXXFLAGS) $(CPPDEPS) $< + +obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserBytecode.o: ../src/muParserBytecode.cpp + $(CXX) -c -o $@ $(MUPARSER_DLL_CXXFLAGS) $(CPPDEPS) $< + +obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserCallback.o: ../src/muParserCallback.cpp + $(CXX) -c -o $@ $(MUPARSER_DLL_CXXFLAGS) $(CPPDEPS) $< + +obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserComplex.o: ../src/muParserComplex.cpp + $(CXX) -c -o $@ $(MUPARSER_DLL_CXXFLAGS) $(CPPDEPS) $< + +obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserDLL.o: ../src/muParserDLL.cpp + $(CXX) -c -o $@ $(MUPARSER_DLL_CXXFLAGS) $(CPPDEPS) $< + +obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserError.o: ../src/muParserError.cpp + $(CXX) -c -o $@ $(MUPARSER_DLL_CXXFLAGS) $(CPPDEPS) $< + +obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserInt.o: ../src/muParserInt.cpp + $(CXX) -c -o $@ $(MUPARSER_DLL_CXXFLAGS) $(CPPDEPS) $< + +obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserTest.o: ../src/muParserTest.cpp + $(CXX) -c -o $@ $(MUPARSER_DLL_CXXFLAGS) $(CPPDEPS) $< + +obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserTokenReader.o: ../src/muParserTokenReader.cpp + $(CXX) -c -o $@ $(MUPARSER_DLL_CXXFLAGS) $(CPPDEPS) $< + +obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example1_Example1.o: ../samples/example1/Example1.cpp + $(CXX) -c -o $@ $(EXAMPLE1_CXXFLAGS) $(CPPDEPS) $< + +obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example2_example2.o: ../samples/example2/example2.c + $(CC) -c -o $@ $(EXAMPLE2_CFLAGS) $(CPPDEPS) $< + +.PHONY: all clean lib samples + + +SHELL := $(COMSPEC) + +# Dependencies tracking: +-include obj\gcc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)/*.d diff --git a/AMDiS/lib/muparser_v134/build/makefile.vc b/AMDiS/lib/muparser_v134/build/makefile.vc new file mode 100644 index 0000000000000000000000000000000000000000..bdd9a7ff8626e637a725e0826b9d6c457f6e15fd --- /dev/null +++ b/AMDiS/lib/muparser_v134/build/makefile.vc @@ -0,0 +1,330 @@ +# ========================================================================= +# This makefile was generated by +# Bakefile 0.2.8 (http://www.bakefile.org) +# Do not modify, all changes will be overwritten! +# ========================================================================= + + + +# ------------------------------------------------------------------------- +# These are configurable options: +# ------------------------------------------------------------------------- + +# C compiler +CC = cl + +# C++ compiler +CXX = cl + +# Standard flags for CC +CFLAGS = + +# Standard flags for C++ +CXXFLAGS = + +# Standard preprocessor flags (common for CC and CXX) +CPPFLAGS = + +# Standard linker flags +LDFLAGS = + +# Set to 1 to build debug version [0,1] +# 0 - Release +# 1 - Debug +DEBUG = 0 + +# Set to 1 to build shared (DLL) version [0,1] +# 0 - Static +# 1 - DLL +SHARED = 0 + +# Set to 1 to compile samples [0,1] +SAMPLES = 1 + + + +# ------------------------------------------------------------------------- +# Do not modify the rest of this file! +# ------------------------------------------------------------------------- + +### Variables: ### + +MUPARSER_LIB_CXXFLAGS = /MD$(DEBUG_3) /DWIN32 $(____DEBUG_8) $(____DEBUG) \ + $(____DEBUG_9) /Fd..\lib\muparser$(DEBUG_3).pdb $(____DEBUG_6) \ + $(______DEBUG) $(____SHARED) $(____SHARED_0) /D_WIN32 /I..\include /GR /EHsc \ + $(CPPFLAGS) $(CXXFLAGS) +MUPARSER_LIB_OBJECTS = \ + obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParser.obj \ + obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserBase.obj \ + obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserBytecode.obj \ + obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserCallback.obj \ + obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserComplex.obj \ + obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserDLL.obj \ + obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserError.obj \ + obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserInt.obj \ + obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserTest.obj \ + obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserTokenReader.obj +MUPARSER_DLL_CXXFLAGS = /MD$(DEBUG_3) /DWIN32 $(____DEBUG_8) $(____DEBUG) \ + $(____DEBUG_9) /Fd..\lib\muparser$(DEBUG_3).pdb $(____DEBUG_6) \ + $(______DEBUG) $(____SHARED) $(____SHARED_0) /D_WIN32 /I..\include /GR /EHsc \ + $(CPPFLAGS) $(CXXFLAGS) +MUPARSER_DLL_OBJECTS = \ + obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParser.obj \ + obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserBase.obj \ + obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserBytecode.obj \ + obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserCallback.obj \ + obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserComplex.obj \ + obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserDLL.obj \ + obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserError.obj \ + obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserInt.obj \ + obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserTest.obj \ + obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserTokenReader.obj +EXAMPLE1_CXXFLAGS = /MD$(DEBUG_3) /DWIN32 $(____DEBUG_8) $(____DEBUG) \ + $(____DEBUG_9) /Fd..\samples\example1\example1.pdb $(____DEBUG_6) \ + $(______DEBUG) /I..\include $(____SHARED_1) /GR /EHsc $(CPPFLAGS) $(CXXFLAGS) +EXAMPLE1_OBJECTS = \ + obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example1_Example1.obj +EXAMPLE2_CFLAGS = /MD$(DEBUG_3) /DWIN32 $(____DEBUG_8) $(____DEBUG) \ + $(____DEBUG_9) /Fd..\samples\example2\example2.pdb $(____DEBUG_6) \ + $(______DEBUG) /I..\include $(____SHARED_1) $(CPPFLAGS) $(CFLAGS) +EXAMPLE2_OBJECTS = \ + obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example2_example2.obj + +### Conditionally set variables: ### + +!if "$(DEBUG)" == "0" +DEBUGBUILDPOSTFIX = rel +!endif +!if "$(DEBUG)" == "1" +DEBUGBUILDPOSTFIX = dbg +!endif +!if "$(SHARED)" == "0" +SHAREDBUILDPOSTFIX = static +!endif +!if "$(SHARED)" == "1" +SHAREDBUILDPOSTFIX = shared +!endif +!if "$(SHARED)" == "0" +__muParser_lib___depname = ..\lib\muparser$(DEBUG_3).lib +!endif +!if "$(SHARED)" == "1" +__muParser_dll___depname = ..\lib\muparser$(DEBUG_3).dll +!endif +!if "$(DEBUG)" == "0" +____DEBUG_23_26 = +!endif +!if "$(DEBUG)" == "1" +____DEBUG_23_26 = $(____DEBUG_10) +!endif +!if "$(SAMPLES)" == "1" && "$(SHARED)" == "0" +__example1___depname = ..\samples\example1\example1.exe +!endif +!if "$(DEBUG)" == "0" +____DEBUG_40_43 = +!endif +!if "$(DEBUG)" == "1" +____DEBUG_40_43 = $(____DEBUG_10) +!endif +!if "$(SAMPLES)" == "1" && "$(SHARED)" == "1" +__example2___depname = ..\samples\example2\example2.exe +!endif +!if "$(DEBUG)" == "0" +____DEBUG_56_59 = +!endif +!if "$(DEBUG)" == "1" +____DEBUG_56_59 = $(____DEBUG_10) +!endif +!if "$(SHARED)" == "0" +____SHARED = +!endif +!if "$(SHARED)" == "1" +____SHARED = /DMUPARSER_DLL +!endif +!if "$(SHARED)" == "0" +____SHARED_0 = +!endif +!if "$(SHARED)" == "1" +____SHARED_0 = /DMUPARSERLIB_EXPORTS +!endif +!if "$(DEBUG)" == "0" +____DEBUG_8 = /DNDEBUG +!endif +!if "$(DEBUG)" == "1" +____DEBUG_8 = +!endif +!if "$(DEBUG)" == "0" +____DEBUG = /O2 +!endif +!if "$(DEBUG)" == "1" +____DEBUG = /Od +!endif +!if "$(DEBUG)" == "0" +____DEBUG_9 = +!endif +!if "$(DEBUG)" == "1" +____DEBUG_9 = /Zi +!endif +!if "$(DEBUG)" == "0" +____DEBUG_5 = +!endif +!if "$(DEBUG)" == "1" +____DEBUG_5 = /DEBUG +!endif +!if "$(DEBUG)" == "0" +____DEBUG_6 = /w +!endif +!if "$(DEBUG)" == "1" +____DEBUG_6 = /W4 +!endif +!if "$(DEBUG)" == "0" +______DEBUG = +!endif +!if "$(DEBUG)" == "1" +______DEBUG = /D_DEBUG +!endif +!if "$(DEBUG)" == "0" +DEBUG_3 = +!endif +!if "$(DEBUG)" == "1" +DEBUG_3 = d +!endif +!if "$(DEBUG)" == "0" +____DEBUG_10 = /opt:ref /opt:icf +!endif +!if "$(DEBUG)" == "1" +____DEBUG_10 = +!endif +!if "$(SHARED)" == "0" +____SHARED_1 = +!endif +!if "$(SHARED)" == "1" +____SHARED_1 = /DUSINGDLL +!endif + + +all: obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX) +obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX): + -if not exist obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX) mkdir obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX) + +### Targets: ### + +all: $(__muParser_lib___depname) $(__muParser_dll___depname) $(__example1___depname) $(__example2___depname) + +clean: + -if exist obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\*.obj del obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\*.obj + -if exist obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\*.res del obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\*.res + -if exist obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\*.pch del obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\*.pch + -if exist ..\lib\muparser$(DEBUG_3).lib del ..\lib\muparser$(DEBUG_3).lib + -if exist ..\lib\muparser$(DEBUG_3).dll del ..\lib\muparser$(DEBUG_3).dll + -if exist ..\lib\muparser$(DEBUG_3).ilk del ..\lib\muparser$(DEBUG_3).ilk + -if exist ..\lib\muparser$(DEBUG_3).pdb del ..\lib\muparser$(DEBUG_3).pdb + -if exist ..\lib\muparser$(DEBUG_3).lib del ..\lib\muparser$(DEBUG_3).lib + -if exist ..\samples\example1\example1.exe del ..\samples\example1\example1.exe + -if exist ..\samples\example1\example1.ilk del ..\samples\example1\example1.ilk + -if exist ..\samples\example1\example1.pdb del ..\samples\example1\example1.pdb + -if exist ..\samples\example2\example2.exe del ..\samples\example2\example2.exe + -if exist ..\samples\example2\example2.ilk del ..\samples\example2\example2.ilk + -if exist ..\samples\example2\example2.pdb del ..\samples\example2\example2.pdb + +!if "$(SHARED)" == "0" +..\lib\muparser$(DEBUG_3).lib: $(MUPARSER_LIB_OBJECTS) + if exist $@ del $@ + link /LIB /NOLOGO /OUT:$@ @<< + $(MUPARSER_LIB_OBJECTS) +<< +!endif + +!if "$(SHARED)" == "1" +..\lib\muparser$(DEBUG_3).dll: $(MUPARSER_DLL_OBJECTS) + link /DLL /NOLOGO /OUT:$@ $(____DEBUG_5) /pdb:"..\lib\muparser$(DEBUG_3).pdb" $(____DEBUG_23_26) $(LDFLAGS) @<< + $(MUPARSER_DLL_OBJECTS) /IMPLIB:..\lib\muparser$(DEBUG_3).lib +<< +!endif + +!if "$(SAMPLES)" == "1" && "$(SHARED)" == "0" +..\samples\example1\example1.exe: $(EXAMPLE1_OBJECTS) $(__muParser_lib___depname) + link /NOLOGO /OUT:$@ $(____DEBUG_5) /pdb:"..\samples\example1\example1.pdb" $(____DEBUG_40_43) /LIBPATH:..\lib $(LDFLAGS) @<< + $(EXAMPLE1_OBJECTS) ..\lib\muparser$(DEBUG_3).lib +<< +!endif + +!if "$(SAMPLES)" == "1" && "$(SHARED)" == "1" +..\samples\example2\example2.exe: $(EXAMPLE2_OBJECTS) $(__muParser_lib___depname) + link /NOLOGO /OUT:$@ $(____DEBUG_5) /pdb:"..\samples\example2\example2.pdb" $(____DEBUG_56_59) /LIBPATH:..\lib $(LDFLAGS) @<< + $(EXAMPLE2_OBJECTS) ..\lib\muparser$(DEBUG_3).lib +<< +!endif + +lib: $(__muParser_lib___depname) $(__muParser_dll___depname) + +samples: $(__example1___depname) $(__example2___depname) + +documentation: + ( cd ..\docs && doxygen ) + +obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParser.obj: ..\src\muParser.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MUPARSER_LIB_CXXFLAGS) ..\src\muParser.cpp + +obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserBase.obj: ..\src\muParserBase.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MUPARSER_LIB_CXXFLAGS) ..\src\muParserBase.cpp + +obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserBytecode.obj: ..\src\muParserBytecode.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MUPARSER_LIB_CXXFLAGS) ..\src\muParserBytecode.cpp + +obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserCallback.obj: ..\src\muParserCallback.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MUPARSER_LIB_CXXFLAGS) ..\src\muParserCallback.cpp + +obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserComplex.obj: ..\src\muParserComplex.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MUPARSER_LIB_CXXFLAGS) ..\src\muParserComplex.cpp + +obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserDLL.obj: ..\src\muParserDLL.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MUPARSER_LIB_CXXFLAGS) ..\src\muParserDLL.cpp + +obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserError.obj: ..\src\muParserError.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MUPARSER_LIB_CXXFLAGS) ..\src\muParserError.cpp + +obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserInt.obj: ..\src\muParserInt.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MUPARSER_LIB_CXXFLAGS) ..\src\muParserInt.cpp + +obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserTest.obj: ..\src\muParserTest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MUPARSER_LIB_CXXFLAGS) ..\src\muParserTest.cpp + +obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserTokenReader.obj: ..\src\muParserTokenReader.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MUPARSER_LIB_CXXFLAGS) ..\src\muParserTokenReader.cpp + +obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParser.obj: ..\src\muParser.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MUPARSER_DLL_CXXFLAGS) ..\src\muParser.cpp + +obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserBase.obj: ..\src\muParserBase.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MUPARSER_DLL_CXXFLAGS) ..\src\muParserBase.cpp + +obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserBytecode.obj: ..\src\muParserBytecode.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MUPARSER_DLL_CXXFLAGS) ..\src\muParserBytecode.cpp + +obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserCallback.obj: ..\src\muParserCallback.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MUPARSER_DLL_CXXFLAGS) ..\src\muParserCallback.cpp + +obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserComplex.obj: ..\src\muParserComplex.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MUPARSER_DLL_CXXFLAGS) ..\src\muParserComplex.cpp + +obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserDLL.obj: ..\src\muParserDLL.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MUPARSER_DLL_CXXFLAGS) ..\src\muParserDLL.cpp + +obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserError.obj: ..\src\muParserError.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MUPARSER_DLL_CXXFLAGS) ..\src\muParserError.cpp + +obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserInt.obj: ..\src\muParserInt.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MUPARSER_DLL_CXXFLAGS) ..\src\muParserInt.cpp + +obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserTest.obj: ..\src\muParserTest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MUPARSER_DLL_CXXFLAGS) ..\src\muParserTest.cpp + +obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserTokenReader.obj: ..\src\muParserTokenReader.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MUPARSER_DLL_CXXFLAGS) ..\src\muParserTokenReader.cpp + +obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example1_Example1.obj: ..\samples\example1\Example1.cpp + $(CXX) /c /nologo /TP /Fo$@ $(EXAMPLE1_CXXFLAGS) ..\samples\example1\Example1.cpp + +obj\vc_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example2_example2.obj: ..\samples\example2\example2.c + $(CC) /c /nologo /TC /Fo$@ $(EXAMPLE2_CFLAGS) ..\samples\example2\example2.c + diff --git a/AMDiS/lib/muparser_v134/build/makefile.wat b/AMDiS/lib/muparser_v134/build/makefile.wat new file mode 100644 index 0000000000000000000000000000000000000000..43f69b4395b427d2a86fed5c8a67e45db79a0e3f --- /dev/null +++ b/AMDiS/lib/muparser_v134/build/makefile.wat @@ -0,0 +1,355 @@ +# ========================================================================= +# This makefile was generated by +# Bakefile 0.2.8 (http://www.bakefile.org) +# Do not modify, all changes will be overwritten! +# ========================================================================= + + + +# ------------------------------------------------------------------------- +# These are configurable options: +# ------------------------------------------------------------------------- + +# C compiler +CC = wcc386 + +# C++ compiler +CXX = wpp386 + +# Standard flags for CC +CFLAGS = + +# Standard flags for C++ +CXXFLAGS = + +# Standard preprocessor flags (common for CC and CXX) +CPPFLAGS = + +# Standard linker flags +LDFLAGS = + +# Set to 1 to build debug version [0,1] +# 0 - Release +# 1 - Debug +DEBUG = 0 + +# Set to 1 to build shared (DLL) version [0,1] +# 0 - Static +# 1 - DLL +SHARED = 0 + +# Set to 1 to compile samples [0,1] +SAMPLES = 1 + + + +# ------------------------------------------------------------------------- +# Do not modify the rest of this file! +# ------------------------------------------------------------------------- + +# Speed up compilation a bit: +!ifdef __LOADDLL__ +! loaddll wcc wccd +! loaddll wccaxp wccdaxp +! loaddll wcc386 wccd386 +! loaddll wpp wppdi86 +! loaddll wppaxp wppdaxp +! loaddll wpp386 wppd386 +! if $(__VERSION__) >= 1280 +! loaddll wlink wlinkd +! else +! loaddll wlink wlink +! endif +! loaddll wlib wlibd +!endif + +# We need these variables in some bakefile-made rules: +WATCOM_CWD = $+ $(%cdrive):$(%cwd) $- + +### Conditionally set variables: ### + +DEBUGBUILDPOSTFIX = +!ifeq DEBUG 0 +DEBUGBUILDPOSTFIX = rel +!endif +!ifeq DEBUG 1 +DEBUGBUILDPOSTFIX = dbg +!endif +SHAREDBUILDPOSTFIX = +!ifeq SHARED 0 +SHAREDBUILDPOSTFIX = static +!endif +!ifeq SHARED 1 +SHAREDBUILDPOSTFIX = shared +!endif +DEBUG_BUILD_POSTFIX = +!ifeq DEBUG 0 +DEBUG_BUILD_POSTFIX = +!endif +!ifeq DEBUG 1 +DEBUG_BUILD_POSTFIX = d +!endif +__muParser_lib___depname = +!ifeq SHARED 0 +__muParser_lib___depname = ..\lib\muparser$(DEBUG_BUILD_POSTFIX).lib +!endif +__muParser_dll___depname = +!ifeq SHARED 1 +__muParser_dll___depname = ..\lib\muparser$(DEBUG_BUILD_POSTFIX).dll +!endif +__example1___depname = +!ifeq SAMPLES 1 +!ifeq SHARED 0 +__example1___depname = ..\samples\example1\example1.exe +!endif +!endif +__example2___depname = +!ifeq SAMPLES 1 +!ifeq SHARED 1 +__example2___depname = ..\samples\example2\example2.exe +!endif +!endif +____SHARED = +!ifeq SHARED 0 +____SHARED = +!endif +!ifeq SHARED 1 +____SHARED = -dMUPARSER_DLL +!endif +____SHARED_0 = +!ifeq SHARED 0 +____SHARED_0 = +!endif +!ifeq SHARED 1 +____SHARED_0 = -dMUPARSERLIB_EXPORTS +!endif +____DEBUG = +!ifeq DEBUG 0 +____DEBUG = -dNDEBUG +!endif +!ifeq DEBUG 1 +____DEBUG = +!endif +____DEBUG_3 = +!ifeq DEBUG 0 +____DEBUG_3 = -ot -ox +!endif +!ifeq DEBUG 1 +____DEBUG_3 = -od +!endif +____DEBUG_6 = +!ifeq DEBUG 0 +____DEBUG_6 = -d0 +!endif +!ifeq DEBUG 1 +____DEBUG_6 = -d2 +!endif +____DEBUG_7 = +!ifeq DEBUG 0 +____DEBUG_7 = +!endif +!ifeq DEBUG 1 +____DEBUG_7 = debug all +!endif +____DEBUG_8 = +!ifeq DEBUG 0 +____DEBUG_8 = +!endif +!ifeq DEBUG 1 +____DEBUG_8 = -wx +!endif +____SHARED_1 = +!ifeq SHARED 0 +____SHARED_1 = +!endif +!ifeq SHARED 1 +____SHARED_1 = -dUSINGDLL +!endif + +### Variables: ### + +MUPARSER_LIB_CXXFLAGS = $(____DEBUG) $(____DEBUG_3) $(____DEBUG_6) & + $(____DEBUG_8) $(____SHARED) $(____SHARED_0) -d_WIN32 -i=..\include & + $(CPPFLAGS) $(CXXFLAGS) +MUPARSER_LIB_OBJECTS = & + obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParser.obj & + obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserBase.obj & + obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserBytecode.obj & + obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserCallback.obj & + obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserComplex.obj & + obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserDLL.obj & + obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserError.obj & + obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserInt.obj & + obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserTest.obj & + obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserTokenReader.obj +MUPARSER_DLL_CXXFLAGS = -bd $(____DEBUG) $(____DEBUG_3) $(____DEBUG_6) & + $(____DEBUG_8) $(____SHARED) $(____SHARED_0) -d_WIN32 -i=..\include & + $(CPPFLAGS) $(CXXFLAGS) +MUPARSER_DLL_OBJECTS = & + obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParser.obj & + obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserBase.obj & + obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserBytecode.obj & + obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserCallback.obj & + obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserComplex.obj & + obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserDLL.obj & + obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserError.obj & + obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserInt.obj & + obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserTest.obj & + obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserTokenReader.obj +EXAMPLE1_CXXFLAGS = $(____DEBUG) $(____DEBUG_3) $(____DEBUG_6) $(____DEBUG_8) & + -i=..\include $(____SHARED_1) $(CPPFLAGS) $(CXXFLAGS) +EXAMPLE1_OBJECTS = & + obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example1_Example1.obj +EXAMPLE2_CFLAGS = $(____DEBUG) $(____DEBUG_3) $(____DEBUG_6) $(____DEBUG_8) & + -i=..\include $(____SHARED_1) $(CPPFLAGS) $(CFLAGS) +EXAMPLE2_OBJECTS = & + obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example2_example2.obj + + +all : obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX) +obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX) : + -if not exist obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX) mkdir obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX) + +### Targets: ### + +all : .SYMBOLIC $(__muParser_lib___depname) $(__muParser_dll___depname) $(__example1___depname) $(__example2___depname) + +clean : .SYMBOLIC + -if exist obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\*.obj del obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\*.obj + -if exist obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\*.res del obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\*.res + -if exist obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\*.lbc del obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\*.lbc + -if exist obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\*.ilk del obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\*.ilk + -if exist obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\*.pch del obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\*.pch + -if exist ..\lib\muparser$(DEBUG_BUILD_POSTFIX).lib del ..\lib\muparser$(DEBUG_BUILD_POSTFIX).lib + -if exist ..\lib\muparser$(DEBUG_BUILD_POSTFIX).dll del ..\lib\muparser$(DEBUG_BUILD_POSTFIX).dll + -if exist ..\lib\muparser$(DEBUG_BUILD_POSTFIX).lib del ..\lib\muparser$(DEBUG_BUILD_POSTFIX).lib + -if exist ..\samples\example1\example1.exe del ..\samples\example1\example1.exe + -if exist ..\samples\example2\example2.exe del ..\samples\example2\example2.exe + +!ifeq SHARED 0 +..\lib\muparser$(DEBUG_BUILD_POSTFIX).lib : $(MUPARSER_LIB_OBJECTS) + @%create obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib.lbc + @for %i in ($(MUPARSER_LIB_OBJECTS)) do @%append obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib.lbc +%i + wlib -q -p4096 -n -b $^@ @obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib.lbc +!endif + +!ifeq SHARED 1 +..\lib\muparser$(DEBUG_BUILD_POSTFIX).dll : $(MUPARSER_DLL_OBJECTS) + @%create obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll.lbc + @%append obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll.lbc option quiet + @%append obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll.lbc name $^@ + @%append obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll.lbc option caseexact + @%append obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll.lbc $(____DEBUG_7) $(LDFLAGS) + @for %i in ($(MUPARSER_DLL_OBJECTS)) do @%append obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll.lbc file %i + @for %i in () do @%append obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll.lbc library %i + @%append obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll.lbc + @%append obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll.lbc system nt_dll + wlink @obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll.lbc + wlib -q -n -b ..\lib\muparser$(DEBUG_BUILD_POSTFIX).lib +$^@ +!endif + +!ifeq SAMPLES 1 +!ifeq SHARED 0 +..\samples\example1\example1.exe : $(EXAMPLE1_OBJECTS) $(__muParser_lib___depname) + @%create obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example1.lbc + @%append obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example1.lbc option quiet + @%append obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example1.lbc name $^@ + @%append obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example1.lbc option caseexact + @%append obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example1.lbc $(____DEBUG_7) libpath ..\lib $(LDFLAGS) + @for %i in ($(EXAMPLE1_OBJECTS)) do @%append obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example1.lbc file %i + @for %i in ( ..\lib\muparser$(DEBUG_BUILD_POSTFIX).lib) do @%append obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example1.lbc library %i + @%append obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example1.lbc + @for %i in () do @%append obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example1.lbc option stack=%i + wlink @obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example1.lbc +!endif +!endif + +!ifeq SAMPLES 1 +!ifeq SHARED 1 +..\samples\example2\example2.exe : $(EXAMPLE2_OBJECTS) $(__muParser_lib___depname) + @%create obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example2.lbc + @%append obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example2.lbc option quiet + @%append obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example2.lbc name $^@ + @%append obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example2.lbc option caseexact + @%append obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example2.lbc $(____DEBUG_7) libpath ..\lib $(LDFLAGS) + @for %i in ($(EXAMPLE2_OBJECTS)) do @%append obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example2.lbc file %i + @for %i in ( ..\lib\muparser$(DEBUG_BUILD_POSTFIX).lib) do @%append obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example2.lbc library %i + @%append obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example2.lbc + @for %i in () do @%append obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example2.lbc option stack=%i + wlink @obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example2.lbc +!endif +!endif + +lib : .SYMBOLIC $(__muParser_lib___depname) $(__muParser_dll___depname) + +samples : .SYMBOLIC $(__example1___depname) $(__example2___depname) + +documentation : + ( cd ..\docs && doxygen ) + +obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParser.obj : .AUTODEPEND ..\src\muParser.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MUPARSER_LIB_CXXFLAGS) $< + +obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserBase.obj : .AUTODEPEND ..\src\muParserBase.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MUPARSER_LIB_CXXFLAGS) $< + +obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserBytecode.obj : .AUTODEPEND ..\src\muParserBytecode.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MUPARSER_LIB_CXXFLAGS) $< + +obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserCallback.obj : .AUTODEPEND ..\src\muParserCallback.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MUPARSER_LIB_CXXFLAGS) $< + +obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserComplex.obj : .AUTODEPEND ..\src\muParserComplex.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MUPARSER_LIB_CXXFLAGS) $< + +obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserDLL.obj : .AUTODEPEND ..\src\muParserDLL.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MUPARSER_LIB_CXXFLAGS) $< + +obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserError.obj : .AUTODEPEND ..\src\muParserError.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MUPARSER_LIB_CXXFLAGS) $< + +obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserInt.obj : .AUTODEPEND ..\src\muParserInt.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MUPARSER_LIB_CXXFLAGS) $< + +obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserTest.obj : .AUTODEPEND ..\src\muParserTest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MUPARSER_LIB_CXXFLAGS) $< + +obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_lib_muParserTokenReader.obj : .AUTODEPEND ..\src\muParserTokenReader.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MUPARSER_LIB_CXXFLAGS) $< + +obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParser.obj : .AUTODEPEND ..\src\muParser.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MUPARSER_DLL_CXXFLAGS) $< + +obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserBase.obj : .AUTODEPEND ..\src\muParserBase.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MUPARSER_DLL_CXXFLAGS) $< + +obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserBytecode.obj : .AUTODEPEND ..\src\muParserBytecode.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MUPARSER_DLL_CXXFLAGS) $< + +obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserCallback.obj : .AUTODEPEND ..\src\muParserCallback.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MUPARSER_DLL_CXXFLAGS) $< + +obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserComplex.obj : .AUTODEPEND ..\src\muParserComplex.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MUPARSER_DLL_CXXFLAGS) $< + +obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserDLL.obj : .AUTODEPEND ..\src\muParserDLL.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MUPARSER_DLL_CXXFLAGS) $< + +obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserError.obj : .AUTODEPEND ..\src\muParserError.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MUPARSER_DLL_CXXFLAGS) $< + +obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserInt.obj : .AUTODEPEND ..\src\muParserInt.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MUPARSER_DLL_CXXFLAGS) $< + +obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserTest.obj : .AUTODEPEND ..\src\muParserTest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MUPARSER_DLL_CXXFLAGS) $< + +obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\muParser_dll_muParserTokenReader.obj : .AUTODEPEND ..\src\muParserTokenReader.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MUPARSER_DLL_CXXFLAGS) $< + +obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example1_Example1.obj : .AUTODEPEND ..\samples\example1\Example1.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(EXAMPLE1_CXXFLAGS) $< + +obj\wat_$(SHAREDBUILDPOSTFIX)_$(DEBUGBUILDPOSTFIX)\example2_example2.obj : .AUTODEPEND ..\samples\example2\example2.c + $(CC) -bt=nt -zq -fo=$^@ $(EXAMPLE2_CFLAGS) $< + diff --git a/AMDiS/lib/muparser_v134/build/msvc2003/muparser.sln b/AMDiS/lib/muparser_v134/build/msvc2003/muparser.sln new file mode 100644 index 0000000000000000000000000000000000000000..a2ae21fab1beed657b0a19d1aa6fa9b45ef675e8 --- /dev/null +++ b/AMDiS/lib/muparser_v134/build/msvc2003/muparser.sln @@ -0,0 +1,47 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "muParser", "muparser_muParser.vcproj", "{2A1F639A-7642-57CC-BF97-3EC5B5C89D91}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example1", "muparser_example1.vcproj", "{A1DCD664-8803-54E2-B35F-84D96B9CA6DF}" + ProjectSection(ProjectDependencies) = postProject + {2A1F639A-7642-57CC-BF97-3EC5B5C89D91} = {2A1F639A-7642-57CC-BF97-3EC5B5C89D91} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example2", "muparser_example2.vcproj", "{B405983E-B929-5BCF-8CC8-03CF34796A23}" + ProjectSection(ProjectDependencies) = postProject + {2A1F639A-7642-57CC-BF97-3EC5B5C89D91} = {2A1F639A-7642-57CC-BF97-3EC5B5C89D91} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Release Static|Win32 = Release Static|Win32 + Release DLL|Win32 = Release DLL|Win32 + Debug Static|Win32 = Debug Static|Win32 + Debug DLL|Win32 = Debug DLL|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2A1F639A-7642-57CC-BF97-3EC5B5C89D91}.Release Static|Win32.ActiveCfg = Release Static|Win32 + {2A1F639A-7642-57CC-BF97-3EC5B5C89D91}.Release Static|Win32.Build.0 = Release Static|Win32 + {2A1F639A-7642-57CC-BF97-3EC5B5C89D91}.Release DLL|Win32.ActiveCfg = Release DLL|Win32 + {2A1F639A-7642-57CC-BF97-3EC5B5C89D91}.Release DLL|Win32.Build.0 = Release DLL|Win32 + {2A1F639A-7642-57CC-BF97-3EC5B5C89D91}.Debug Static|Win32.ActiveCfg = Debug Static|Win32 + {2A1F639A-7642-57CC-BF97-3EC5B5C89D91}.Debug Static|Win32.Build.0 = Debug Static|Win32 + {2A1F639A-7642-57CC-BF97-3EC5B5C89D91}.Debug DLL|Win32.ActiveCfg = Debug DLL|Win32 + {2A1F639A-7642-57CC-BF97-3EC5B5C89D91}.Debug DLL|Win32.Build.0 = Debug DLL|Win32 + {A1DCD664-8803-54E2-B35F-84D96B9CA6DF}.Release Static|Win32.ActiveCfg = Release Static|Win32 + {A1DCD664-8803-54E2-B35F-84D96B9CA6DF}.Release Static|Win32.Build.0 = Release Static|Win32 + {A1DCD664-8803-54E2-B35F-84D96B9CA6DF}.Release DLL|Win32.ActiveCfg = Release DLL|Win32 + {A1DCD664-8803-54E2-B35F-84D96B9CA6DF}.Debug Static|Win32.ActiveCfg = Debug Static|Win32 + {A1DCD664-8803-54E2-B35F-84D96B9CA6DF}.Debug Static|Win32.Build.0 = Debug Static|Win32 + {A1DCD664-8803-54E2-B35F-84D96B9CA6DF}.Debug DLL|Win32.ActiveCfg = Debug DLL|Win32 + {B405983E-B929-5BCF-8CC8-03CF34796A23}.Release Static|Win32.ActiveCfg = Release Static|Win32 + {B405983E-B929-5BCF-8CC8-03CF34796A23}.Release DLL|Win32.ActiveCfg = Release DLL|Win32 + {B405983E-B929-5BCF-8CC8-03CF34796A23}.Release DLL|Win32.Build.0 = Release DLL|Win32 + {B405983E-B929-5BCF-8CC8-03CF34796A23}.Debug Static|Win32.ActiveCfg = Debug Static|Win32 + {B405983E-B929-5BCF-8CC8-03CF34796A23}.Debug DLL|Win32.ActiveCfg = Debug DLL|Win32 + {B405983E-B929-5BCF-8CC8-03CF34796A23}.Debug DLL|Win32.Build.0 = Debug DLL|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal + diff --git a/AMDiS/lib/muparser_v134/build/msvc2003/muparser_example1.vcproj b/AMDiS/lib/muparser_v134/build/msvc2003/muparser_example1.vcproj new file mode 100644 index 0000000000000000000000000000000000000000..8e60152fcc28050876191d09e2dec477bd8726c2 --- /dev/null +++ b/AMDiS/lib/muparser_v134/build/msvc2003/muparser_example1.vcproj @@ -0,0 +1,161 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<!-- + + This project was generated by + Bakefile 0.2.8 (http://www.bakefile.org) + Do not modify, all changes will be overwritten! + +--> +<VisualStudioProject + ProjectType="Visual C++" + Version="7.10" + Name="example1" + ProjectGUID="{A1DCD664-8803-54E2-B35F-84D96B9CA6DF}"> + <Platforms> + <Platform + Name="Win32"/> + </Platforms> + <Configurations> + <Configuration + Name="Release Static|Win32" + OutputDirectory="..\..\samples\example1" + IntermediateDirectory="obj\vc_static_rel\example1" + ConfigurationType="1" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="FALSE"> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + AdditionalIncludeDirectories="..\..\include" + PreprocessorDefinitions="WIN32;_CONSOLE;NDEBUG" + ExceptionHandling="TRUE" + RuntimeLibrary="2" + RuntimeTypeInfo="TRUE" + ObjectFile="obj\vc_static_rel\example1\" + ProgramDataBaseFileName="..\..\samples\example1\example1.pdb" + WarningLevel="0" + SuppressStartupBanner="TRUE" + Detect64BitPortabilityProblems="TRUE" + DebugInformationFormat="0"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLinkerTool" + AdditionalOptions="" + AdditionalDependencies="..\..\lib\muparser.lib" + OutputFile="..\..\samples\example1\example1.exe" + LinkIncremental="1" + SuppressStartupBanner="TRUE" + AdditionalLibraryDirectories="..\..\lib" + ProgramDatabaseFile="..\..\samples\example1\example1.pdb" + SubSystem="1" + TargetMachine="1"/> + <Tool + Name="VCMIDLTool" + PreprocessorDefinitions="WIN32;_CONSOLE;NDEBUG" + AdditionalIncludeDirectories="..\..\include"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="_CONSOLE;NDEBUG" + Culture="1033" + AdditionalIncludeDirectories="..\..\include"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCWebDeploymentTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + <Configuration + Name="Debug Static|Win32" + OutputDirectory="..\..\samples\example1" + IntermediateDirectory="obj\vc_static_dbg\example1" + ConfigurationType="1" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="FALSE"> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\include" + PreprocessorDefinitions="WIN32;_CONSOLE;_DEBUG" + MinimalRebuild="TRUE" + ExceptionHandling="TRUE" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + BufferSecurityCheck="TRUE" + RuntimeTypeInfo="TRUE" + ObjectFile="obj\vc_static_dbg\example1\" + ProgramDataBaseFileName="..\..\samples\example1\example1.pdb" + WarningLevel="4" + SuppressStartupBanner="TRUE" + Detect64BitPortabilityProblems="TRUE" + DebugInformationFormat="3"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLinkerTool" + AdditionalOptions="" + AdditionalDependencies="..\..\lib\muparserd.lib" + OutputFile="..\..\samples\example1\example1.exe" + LinkIncremental="2" + SuppressStartupBanner="TRUE" + AdditionalLibraryDirectories="..\..\lib" + GenerateDebugInformation="TRUE" + ProgramDatabaseFile="..\..\samples\example1\example1.pdb" + SubSystem="1" + TargetMachine="1"/> + <Tool + Name="VCMIDLTool" + PreprocessorDefinitions="WIN32;_CONSOLE;_DEBUG" + AdditionalIncludeDirectories="..\..\include"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="_CONSOLE;_DEBUG" + Culture="1033" + AdditionalIncludeDirectories="..\..\include"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCWebDeploymentTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + </Configurations> + <References> + + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> + <File + RelativePath="..\..\samples\example1\Example1.cpp"> + </File> + </Filter> + </Files> + <Globals> + + </Globals> +</VisualStudioProject> + diff --git a/AMDiS/lib/muparser_v134/build/msvc2003/muparser_example2.vcproj b/AMDiS/lib/muparser_v134/build/msvc2003/muparser_example2.vcproj new file mode 100644 index 0000000000000000000000000000000000000000..ef0b776e415456e39d43367354c843822fe4dde8 --- /dev/null +++ b/AMDiS/lib/muparser_v134/build/msvc2003/muparser_example2.vcproj @@ -0,0 +1,161 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<!-- + + This project was generated by + Bakefile 0.2.8 (http://www.bakefile.org) + Do not modify, all changes will be overwritten! + +--> +<VisualStudioProject + ProjectType="Visual C++" + Version="7.10" + Name="example2" + ProjectGUID="{B405983E-B929-5BCF-8CC8-03CF34796A23}"> + <Platforms> + <Platform + Name="Win32"/> + </Platforms> + <Configurations> + <Configuration + Name="Release DLL|Win32" + OutputDirectory="..\..\samples\example2" + IntermediateDirectory="obj\vc_shared_rel\example2" + ConfigurationType="1" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="FALSE"> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + AdditionalIncludeDirectories="..\..\include" + PreprocessorDefinitions="WIN32;_CONSOLE;NDEBUG;USINGDLL" + ExceptionHandling="TRUE" + RuntimeLibrary="2" + RuntimeTypeInfo="TRUE" + ObjectFile="obj\vc_shared_rel\example2\" + ProgramDataBaseFileName="..\..\samples\example2\example2.pdb" + WarningLevel="0" + SuppressStartupBanner="TRUE" + Detect64BitPortabilityProblems="TRUE" + DebugInformationFormat="0"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLinkerTool" + AdditionalOptions="" + AdditionalDependencies="..\..\lib\muparser.lib" + OutputFile="..\..\samples\example2\example2.exe" + LinkIncremental="1" + SuppressStartupBanner="TRUE" + AdditionalLibraryDirectories="..\..\lib" + ProgramDatabaseFile="..\..\samples\example2\example2.pdb" + SubSystem="1" + TargetMachine="1"/> + <Tool + Name="VCMIDLTool" + PreprocessorDefinitions="WIN32;_CONSOLE;NDEBUG;USINGDLL" + AdditionalIncludeDirectories="..\..\include"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="_CONSOLE;NDEBUG;USINGDLL" + Culture="1033" + AdditionalIncludeDirectories="..\..\include"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCWebDeploymentTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + <Configuration + Name="Debug DLL|Win32" + OutputDirectory="..\..\samples\example2" + IntermediateDirectory="obj\vc_shared_dbg\example2" + ConfigurationType="1" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="FALSE"> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\include" + PreprocessorDefinitions="WIN32;_CONSOLE;_DEBUG;USINGDLL" + MinimalRebuild="TRUE" + ExceptionHandling="TRUE" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + BufferSecurityCheck="TRUE" + RuntimeTypeInfo="TRUE" + ObjectFile="obj\vc_shared_dbg\example2\" + ProgramDataBaseFileName="..\..\samples\example2\example2.pdb" + WarningLevel="4" + SuppressStartupBanner="TRUE" + Detect64BitPortabilityProblems="TRUE" + DebugInformationFormat="3"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLinkerTool" + AdditionalOptions="" + AdditionalDependencies="..\..\lib\muparserd.lib" + OutputFile="..\..\samples\example2\example2.exe" + LinkIncremental="2" + SuppressStartupBanner="TRUE" + AdditionalLibraryDirectories="..\..\lib" + GenerateDebugInformation="TRUE" + ProgramDatabaseFile="..\..\samples\example2\example2.pdb" + SubSystem="1" + TargetMachine="1"/> + <Tool + Name="VCMIDLTool" + PreprocessorDefinitions="WIN32;_CONSOLE;_DEBUG;USINGDLL" + AdditionalIncludeDirectories="..\..\include"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="_CONSOLE;_DEBUG;USINGDLL" + Culture="1033" + AdditionalIncludeDirectories="..\..\include"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCWebDeploymentTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + </Configurations> + <References> + + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> + <File + RelativePath="..\..\samples\example2\example2.c"> + </File> + </Filter> + </Files> + <Globals> + + </Globals> +</VisualStudioProject> + diff --git a/AMDiS/lib/muparser_v134/build/msvc2003/muparser_muParser.vcproj b/AMDiS/lib/muparser_v134/build/msvc2003/muparser_muParser.vcproj new file mode 100644 index 0000000000000000000000000000000000000000..b37584423713f8dfaba043633faaa6b1144cd608 --- /dev/null +++ b/AMDiS/lib/muparser_v134/build/msvc2003/muparser_muParser.vcproj @@ -0,0 +1,344 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<!-- + + This project was generated by + Bakefile 0.2.8 (http://www.bakefile.org) + Do not modify, all changes will be overwritten! + +--> +<VisualStudioProject + ProjectType="Visual C++" + Version="7.10" + Name="muParser" + ProjectGUID="{2A1F639A-7642-57CC-BF97-3EC5B5C89D91}"> + <Platforms> + <Platform + Name="Win32"/> + </Platforms> + <Configurations> + <Configuration + Name="Release Static|Win32" + OutputDirectory="..\..\lib" + IntermediateDirectory="obj\vc_static_rel\muParser" + ConfigurationType="4" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="FALSE"> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + AdditionalIncludeDirectories="..\..\include" + PreprocessorDefinitions="WIN32;_LIB;NDEBUG;_WIN32" + ExceptionHandling="TRUE" + RuntimeLibrary="2" + RuntimeTypeInfo="TRUE" + ObjectFile="obj\vc_static_rel\muParser\" + ProgramDataBaseFileName="..\..\lib\muparser.pdb" + WarningLevel="0" + SuppressStartupBanner="TRUE" + Detect64BitPortabilityProblems="TRUE" + DebugInformationFormat="0"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLibrarianTool" + OutputFile="..\..\lib\muparser.lib" + SuppressStartupBanner="TRUE"/> + <Tool + Name="VCMIDLTool" + PreprocessorDefinitions="WIN32;_LIB;NDEBUG;_WIN32" + AdditionalIncludeDirectories="..\..\include"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="NDEBUG;_WIN32" + Culture="1033" + AdditionalIncludeDirectories="..\..\include"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCWebDeploymentTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + <Configuration + Name="Release DLL|Win32" + OutputDirectory="..\..\lib" + IntermediateDirectory="obj\vc_shared_rel\muParser" + ConfigurationType="2" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="FALSE"> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + AdditionalIncludeDirectories="..\..\include" + PreprocessorDefinitions="WIN32;_USRDLL;DLL_EXPORTS;NDEBUG;MUPARSER_DLL;MUPARSERLIB_EXPORTS;_WIN32" + ExceptionHandling="TRUE" + RuntimeLibrary="2" + RuntimeTypeInfo="TRUE" + ObjectFile="obj\vc_shared_rel\muParser\" + ProgramDataBaseFileName="..\..\lib\muparser.pdb" + WarningLevel="0" + SuppressStartupBanner="TRUE" + Detect64BitPortabilityProblems="TRUE" + DebugInformationFormat="0"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLinkerTool" + AdditionalOptions="" + AdditionalDependencies="" + OutputFile="..\..\lib\muparser.dll" + LinkIncremental="1" + ImportLibrary="..\..\lib\muparser.lib" + SuppressStartupBanner="TRUE" + AdditionalLibraryDirectories="" + ProgramDatabaseFile="..\..\lib\muparser.pdb" + TargetMachine="1"/> + <Tool + Name="VCMIDLTool" + PreprocessorDefinitions="WIN32;_USRDLL;DLL_EXPORTS;NDEBUG;MUPARSER_DLL;MUPARSERLIB_EXPORTS;_WIN32" + AdditionalIncludeDirectories="..\..\include"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="NDEBUG;MUPARSER_DLL;MUPARSERLIB_EXPORTS;_WIN32" + Culture="1033" + AdditionalIncludeDirectories="..\..\include"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCWebDeploymentTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + <Configuration + Name="Debug Static|Win32" + OutputDirectory="..\..\lib" + IntermediateDirectory="obj\vc_static_dbg\muParser" + ConfigurationType="4" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="FALSE"> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\include" + PreprocessorDefinitions="WIN32;_LIB;_DEBUG;_WIN32" + MinimalRebuild="TRUE" + ExceptionHandling="TRUE" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + BufferSecurityCheck="TRUE" + RuntimeTypeInfo="TRUE" + ObjectFile="obj\vc_static_dbg\muParser\" + ProgramDataBaseFileName="..\..\lib\muparserd.pdb" + WarningLevel="4" + SuppressStartupBanner="TRUE" + Detect64BitPortabilityProblems="TRUE" + DebugInformationFormat="3"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLibrarianTool" + OutputFile="..\..\lib\muparserd.lib" + SuppressStartupBanner="TRUE"/> + <Tool + Name="VCMIDLTool" + PreprocessorDefinitions="WIN32;_LIB;_DEBUG;_WIN32" + AdditionalIncludeDirectories="..\..\include"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="_DEBUG;_WIN32" + Culture="1033" + AdditionalIncludeDirectories="..\..\include"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCWebDeploymentTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + <Configuration + Name="Debug DLL|Win32" + OutputDirectory="..\..\lib" + IntermediateDirectory="obj\vc_shared_dbg\muParser" + ConfigurationType="2" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="FALSE"> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\include" + PreprocessorDefinitions="WIN32;_USRDLL;DLL_EXPORTS;_DEBUG;MUPARSER_DLL;MUPARSERLIB_EXPORTS;_WIN32" + MinimalRebuild="TRUE" + ExceptionHandling="TRUE" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + BufferSecurityCheck="TRUE" + RuntimeTypeInfo="TRUE" + ObjectFile="obj\vc_shared_dbg\muParser\" + ProgramDataBaseFileName="..\..\lib\muparserd.pdb" + WarningLevel="4" + SuppressStartupBanner="TRUE" + Detect64BitPortabilityProblems="TRUE" + DebugInformationFormat="3"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLinkerTool" + AdditionalOptions="" + AdditionalDependencies="" + OutputFile="..\..\lib\muparserd.dll" + LinkIncremental="2" + ImportLibrary="..\..\lib\muparserd.lib" + SuppressStartupBanner="TRUE" + AdditionalLibraryDirectories="" + GenerateDebugInformation="TRUE" + ProgramDatabaseFile="..\..\lib\muparserd.pdb" + TargetMachine="1"/> + <Tool + Name="VCMIDLTool" + PreprocessorDefinitions="WIN32;_USRDLL;DLL_EXPORTS;_DEBUG;MUPARSER_DLL;MUPARSERLIB_EXPORTS;_WIN32" + AdditionalIncludeDirectories="..\..\include"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="_DEBUG;MUPARSER_DLL;MUPARSERLIB_EXPORTS;_WIN32" + Culture="1033" + AdditionalIncludeDirectories="..\..\include"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCWebDeploymentTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + </Configurations> + <References> + + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> + <File + RelativePath="..\..\src\muParser.cpp"> + </File> + <File + RelativePath="..\..\src\muParserBase.cpp"> + </File> + <File + RelativePath="..\..\src\muParserBytecode.cpp"> + </File> + <File + RelativePath="..\..\src\muParserCallback.cpp"> + </File> + <File + RelativePath="..\..\src\muParserComplex.cpp"> + </File> + <File + RelativePath="..\..\src\muParserDLL.cpp"> + </File> + <File + RelativePath="..\..\src\muParserError.cpp"> + </File> + <File + RelativePath="..\..\src\muParserInt.cpp"> + </File> + <File + RelativePath="..\..\src\muParserTest.cpp"> + </File> + <File + RelativePath="..\..\src\muParserTokenReader.cpp"> + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> + <File + RelativePath="..\..\include\muParser.h"> + </File> + <File + RelativePath="..\..\include\muParserBase.h"> + </File> + <File + RelativePath="..\..\include\muParserBytecode.h"> + </File> + <File + RelativePath="..\..\include\muParserCallback.h"> + </File> + <File + RelativePath="..\..\include\muParserComplex.h"> + </File> + <File + RelativePath="..\..\include\muParserDLL.h"> + </File> + <File + RelativePath="..\..\include\muParserDef.h"> + </File> + <File + RelativePath="..\..\include\muParserError.h"> + </File> + <File + RelativePath="..\..\include\muParserFixes.h"> + </File> + <File + RelativePath="..\..\include\muParserInt.h"> + </File> + <File + RelativePath="..\..\include\muParserStack.h"> + </File> + <File + RelativePath="..\..\include\muParserTest.h"> + </File> + <File + RelativePath="..\..\include\muParserToken.h"> + </File> + <File + RelativePath="..\..\include\muParserTokenReader.h"> + </File> + </Filter> + </Files> + <Globals> + + </Globals> +</VisualStudioProject> + diff --git a/AMDiS/lib/muparser_v134/build/msvc2005/muparser.sln b/AMDiS/lib/muparser_v134/build/msvc2005/muparser.sln new file mode 100644 index 0000000000000000000000000000000000000000..2e1bc7d275f7205e5c3ccf752c0297b1d7ae14bf --- /dev/null +++ b/AMDiS/lib/muparser_v134/build/msvc2005/muparser.sln @@ -0,0 +1,48 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "muParser", "muparser_muParser.vcproj", "{2A1F639A-7642-57CC-BF97-3EC5B5C89D91}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example1", "muparser_example1.vcproj", "{A1DCD664-8803-54E2-B35F-84D96B9CA6DF}" + ProjectSection(ProjectDependencies) = postProject + {2A1F639A-7642-57CC-BF97-3EC5B5C89D91} = {2A1F639A-7642-57CC-BF97-3EC5B5C89D91} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example2", "muparser_example2.vcproj", "{B405983E-B929-5BCF-8CC8-03CF34796A23}" + ProjectSection(ProjectDependencies) = postProject + {2A1F639A-7642-57CC-BF97-3EC5B5C89D91} = {2A1F639A-7642-57CC-BF97-3EC5B5C89D91} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Release Static|Win32 = Release Static|Win32 + Release DLL|Win32 = Release DLL|Win32 + Debug Static|Win32 = Debug Static|Win32 + Debug DLL|Win32 = Debug DLL|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2A1F639A-7642-57CC-BF97-3EC5B5C89D91}.Release Static|Win32.ActiveCfg = Release Static|Win32 + {2A1F639A-7642-57CC-BF97-3EC5B5C89D91}.Release Static|Win32.Build.0 = Release Static|Win32 + {2A1F639A-7642-57CC-BF97-3EC5B5C89D91}.Release DLL|Win32.ActiveCfg = Release DLL|Win32 + {2A1F639A-7642-57CC-BF97-3EC5B5C89D91}.Release DLL|Win32.Build.0 = Release DLL|Win32 + {2A1F639A-7642-57CC-BF97-3EC5B5C89D91}.Debug Static|Win32.ActiveCfg = Debug Static|Win32 + {2A1F639A-7642-57CC-BF97-3EC5B5C89D91}.Debug Static|Win32.Build.0 = Debug Static|Win32 + {2A1F639A-7642-57CC-BF97-3EC5B5C89D91}.Debug DLL|Win32.ActiveCfg = Debug DLL|Win32 + {2A1F639A-7642-57CC-BF97-3EC5B5C89D91}.Debug DLL|Win32.Build.0 = Debug DLL|Win32 + {A1DCD664-8803-54E2-B35F-84D96B9CA6DF}.Release Static|Win32.ActiveCfg = Release Static|Win32 + {A1DCD664-8803-54E2-B35F-84D96B9CA6DF}.Release Static|Win32.Build.0 = Release Static|Win32 + {A1DCD664-8803-54E2-B35F-84D96B9CA6DF}.Release DLL|Win32.ActiveCfg = Release DLL|Win32 + {A1DCD664-8803-54E2-B35F-84D96B9CA6DF}.Debug Static|Win32.ActiveCfg = Debug Static|Win32 + {A1DCD664-8803-54E2-B35F-84D96B9CA6DF}.Debug Static|Win32.Build.0 = Debug Static|Win32 + {A1DCD664-8803-54E2-B35F-84D96B9CA6DF}.Debug DLL|Win32.ActiveCfg = Debug DLL|Win32 + {B405983E-B929-5BCF-8CC8-03CF34796A23}.Release Static|Win32.ActiveCfg = Release Static|Win32 + {B405983E-B929-5BCF-8CC8-03CF34796A23}.Release DLL|Win32.ActiveCfg = Release DLL|Win32 + {B405983E-B929-5BCF-8CC8-03CF34796A23}.Release DLL|Win32.Build.0 = Release DLL|Win32 + {B405983E-B929-5BCF-8CC8-03CF34796A23}.Debug Static|Win32.ActiveCfg = Debug Static|Win32 + {B405983E-B929-5BCF-8CC8-03CF34796A23}.Debug DLL|Win32.ActiveCfg = Debug DLL|Win32 + {B405983E-B929-5BCF-8CC8-03CF34796A23}.Debug DLL|Win32.Build.0 = Debug DLL|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal + diff --git a/AMDiS/lib/muparser_v134/build/msvc2005/muparser_example1.vcproj b/AMDiS/lib/muparser_v134/build/msvc2005/muparser_example1.vcproj new file mode 100644 index 0000000000000000000000000000000000000000..65d71c89e4c774c3cdbf59e36d9bad3a5bba5731 --- /dev/null +++ b/AMDiS/lib/muparser_v134/build/msvc2005/muparser_example1.vcproj @@ -0,0 +1,232 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<!-- + + This project was generated by + Bakefile 0.2.8 (http://www.bakefile.org) + Do not modify, all changes will be overwritten! + +--> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="example1" + ProjectGUID="{A1DCD664-8803-54E2-B35F-84D96B9CA6DF}" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + + </ToolFiles> + <Configurations> + <Configuration + Name="Release Static|Win32" + OutputDirectory="..\..\samples\example1" + IntermediateDirectory="obj\vc_static_rel\example1" + ConfigurationType="1" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="false" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + PreprocessorDefinitions="WIN32;_CONSOLE;NDEBUG" + AdditionalIncludeDirectories="..\..\include" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + AdditionalIncludeDirectories="..\..\include" + PreprocessorDefinitions="WIN32;_CONSOLE;NDEBUG" + ExceptionHandling="1" + RuntimeLibrary="2" + RuntimeTypeInfo="true" + ObjectFile="obj\vc_static_rel\example1\" + ProgramDataBaseFileName="..\..\samples\example1\example1.pdb" + WarningLevel="0" + SuppressStartupBanner="true" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="0" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="_CONSOLE;NDEBUG" + Culture="1033" + AdditionalIncludeDirectories="..\..\include" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalOptions="" + AdditionalDependencies="..\..\lib\muparser.lib" + OutputFile="..\..\samples\example1\example1.exe" + LinkIncremental="1" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="..\..\lib" + GenerateManifest="true" + ProgramDatabaseFile="..\..\samples\example1\example1.pdb" + SubSystem="1" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + OutputFile="..\..\samples\example1\muparser_example1.bsc" + SuppressStartupBanner="true" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Debug Static|Win32" + OutputDirectory="..\..\samples\example1" + IntermediateDirectory="obj\vc_static_dbg\example1" + ConfigurationType="1" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="false" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + PreprocessorDefinitions="WIN32;_CONSOLE;_DEBUG" + AdditionalIncludeDirectories="..\..\include" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\include" + PreprocessorDefinitions="WIN32;_CONSOLE;_DEBUG" + MinimalRebuild="true" + ExceptionHandling="1" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + BufferSecurityCheck="true" + RuntimeTypeInfo="true" + ObjectFile="obj\vc_static_dbg\example1\" + ProgramDataBaseFileName="..\..\samples\example1\example1.pdb" + WarningLevel="4" + SuppressStartupBanner="true" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="_CONSOLE;_DEBUG" + Culture="1033" + AdditionalIncludeDirectories="..\..\include" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalOptions="" + AdditionalDependencies="..\..\lib\muparserd.lib" + OutputFile="..\..\samples\example1\example1.exe" + LinkIncremental="2" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="..\..\lib" + GenerateManifest="true" + GenerateDebugInformation="true" + ProgramDatabaseFile="..\..\samples\example1\example1.pdb" + SubSystem="1" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + OutputFile="..\..\samples\example1\muparser_example1.bsc" + SuppressStartupBanner="true" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath="..\..\samples\example1\Example1.cpp" + > + </File> + </Filter> + </Files> + <Globals> + + </Globals> +</VisualStudioProject> + diff --git a/AMDiS/lib/muparser_v134/build/msvc2005/muparser_example2.vcproj b/AMDiS/lib/muparser_v134/build/msvc2005/muparser_example2.vcproj new file mode 100644 index 0000000000000000000000000000000000000000..9d3c0fe7355db81b3d9fdb8fabb7ef84f858c39f --- /dev/null +++ b/AMDiS/lib/muparser_v134/build/msvc2005/muparser_example2.vcproj @@ -0,0 +1,232 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<!-- + + This project was generated by + Bakefile 0.2.8 (http://www.bakefile.org) + Do not modify, all changes will be overwritten! + +--> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="example2" + ProjectGUID="{B405983E-B929-5BCF-8CC8-03CF34796A23}" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + + </ToolFiles> + <Configurations> + <Configuration + Name="Release DLL|Win32" + OutputDirectory="..\..\samples\example2" + IntermediateDirectory="obj\vc_shared_rel\example2" + ConfigurationType="1" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="false" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + PreprocessorDefinitions="WIN32;_CONSOLE;NDEBUG;USINGDLL" + AdditionalIncludeDirectories="..\..\include" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + AdditionalIncludeDirectories="..\..\include" + PreprocessorDefinitions="WIN32;_CONSOLE;NDEBUG;USINGDLL" + ExceptionHandling="1" + RuntimeLibrary="2" + RuntimeTypeInfo="true" + ObjectFile="obj\vc_shared_rel\example2\" + ProgramDataBaseFileName="..\..\samples\example2\example2.pdb" + WarningLevel="0" + SuppressStartupBanner="true" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="0" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="_CONSOLE;NDEBUG;USINGDLL" + Culture="1033" + AdditionalIncludeDirectories="..\..\include" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalOptions="" + AdditionalDependencies="..\..\lib\muparser.lib" + OutputFile="..\..\samples\example2\example2.exe" + LinkIncremental="1" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="..\..\lib" + GenerateManifest="true" + ProgramDatabaseFile="..\..\samples\example2\example2.pdb" + SubSystem="1" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + OutputFile="..\..\samples\example2\muparser_example2.bsc" + SuppressStartupBanner="true" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Debug DLL|Win32" + OutputDirectory="..\..\samples\example2" + IntermediateDirectory="obj\vc_shared_dbg\example2" + ConfigurationType="1" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="false" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + PreprocessorDefinitions="WIN32;_CONSOLE;_DEBUG;USINGDLL" + AdditionalIncludeDirectories="..\..\include" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\include" + PreprocessorDefinitions="WIN32;_CONSOLE;_DEBUG;USINGDLL" + MinimalRebuild="true" + ExceptionHandling="1" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + BufferSecurityCheck="true" + RuntimeTypeInfo="true" + ObjectFile="obj\vc_shared_dbg\example2\" + ProgramDataBaseFileName="..\..\samples\example2\example2.pdb" + WarningLevel="4" + SuppressStartupBanner="true" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="_CONSOLE;_DEBUG;USINGDLL" + Culture="1033" + AdditionalIncludeDirectories="..\..\include" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalOptions="" + AdditionalDependencies="..\..\lib\muparserd.lib" + OutputFile="..\..\samples\example2\example2.exe" + LinkIncremental="2" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="..\..\lib" + GenerateManifest="true" + GenerateDebugInformation="true" + ProgramDatabaseFile="..\..\samples\example2\example2.pdb" + SubSystem="1" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + OutputFile="..\..\samples\example2\muparser_example2.bsc" + SuppressStartupBanner="true" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath="..\..\samples\example2\example2.c" + > + </File> + </Filter> + </Files> + <Globals> + + </Globals> +</VisualStudioProject> + diff --git a/AMDiS/lib/muparser_v134/build/msvc2005/muparser_muParser.vcproj b/AMDiS/lib/muparser_v134/build/msvc2005/muparser_muParser.vcproj new file mode 100644 index 0000000000000000000000000000000000000000..724105dc91a310bdc3e6be138a951dd5784ea39d --- /dev/null +++ b/AMDiS/lib/muparser_v134/build/msvc2005/muparser_muParser.vcproj @@ -0,0 +1,477 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<!-- + + This project was generated by + Bakefile 0.2.8 (http://www.bakefile.org) + Do not modify, all changes will be overwritten! + +--> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="muParser" + ProjectGUID="{2A1F639A-7642-57CC-BF97-3EC5B5C89D91}" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + + </ToolFiles> + <Configurations> + <Configuration + Name="Release Static|Win32" + OutputDirectory="..\..\lib" + IntermediateDirectory="obj\vc_static_rel\muParser" + ConfigurationType="4" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="false" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + PreprocessorDefinitions="WIN32;_LIB;NDEBUG;_WIN32" + AdditionalIncludeDirectories="..\..\include" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + AdditionalIncludeDirectories="..\..\include" + PreprocessorDefinitions="WIN32;_LIB;NDEBUG;_WIN32" + ExceptionHandling="1" + RuntimeLibrary="2" + RuntimeTypeInfo="true" + ObjectFile="obj\vc_static_rel\muParser\" + ProgramDataBaseFileName="..\..\lib\muparser.pdb" + WarningLevel="0" + SuppressStartupBanner="true" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="0" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="NDEBUG;_WIN32" + Culture="1033" + AdditionalIncludeDirectories="..\..\include" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLibrarianTool" + OutputFile="..\..\lib\muparser.lib" + SuppressStartupBanner="true" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + OutputFile="..\..\lib\muparser_muParser.bsc" + SuppressStartupBanner="true" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release DLL|Win32" + OutputDirectory="..\..\lib" + IntermediateDirectory="obj\vc_shared_rel\muParser" + ConfigurationType="2" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="false" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + PreprocessorDefinitions="WIN32;_USRDLL;DLL_EXPORTS;NDEBUG;MUPARSER_DLL;MUPARSERLIB_EXPORTS;_WIN32" + AdditionalIncludeDirectories="..\..\include" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + AdditionalIncludeDirectories="..\..\include" + PreprocessorDefinitions="WIN32;_USRDLL;DLL_EXPORTS;NDEBUG;MUPARSER_DLL;MUPARSERLIB_EXPORTS;_WIN32" + ExceptionHandling="1" + RuntimeLibrary="2" + RuntimeTypeInfo="true" + ObjectFile="obj\vc_shared_rel\muParser\" + ProgramDataBaseFileName="..\..\lib\muparser.pdb" + WarningLevel="0" + SuppressStartupBanner="true" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="0" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="NDEBUG;MUPARSER_DLL;MUPARSERLIB_EXPORTS;_WIN32" + Culture="1033" + AdditionalIncludeDirectories="..\..\include" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalOptions="" + AdditionalDependencies="" + OutputFile="..\..\lib\muparser.dll" + LinkIncremental="1" + ImportLibrary="..\..\lib\muparser.lib" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="" + GenerateManifest="true" + ProgramDatabaseFile="..\..\lib\muparser.pdb" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + OutputFile="..\..\lib\muparser_muParser.bsc" + SuppressStartupBanner="true" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Debug Static|Win32" + OutputDirectory="..\..\lib" + IntermediateDirectory="obj\vc_static_dbg\muParser" + ConfigurationType="4" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="false" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + PreprocessorDefinitions="WIN32;_LIB;_DEBUG;_WIN32" + AdditionalIncludeDirectories="..\..\include" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\include" + PreprocessorDefinitions="WIN32;_LIB;_DEBUG;_WIN32" + MinimalRebuild="true" + ExceptionHandling="1" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + BufferSecurityCheck="true" + RuntimeTypeInfo="true" + ObjectFile="obj\vc_static_dbg\muParser\" + ProgramDataBaseFileName="..\..\lib\muparserd.pdb" + WarningLevel="4" + SuppressStartupBanner="true" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="_DEBUG;_WIN32" + Culture="1033" + AdditionalIncludeDirectories="..\..\include" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLibrarianTool" + OutputFile="..\..\lib\muparserd.lib" + SuppressStartupBanner="true" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + OutputFile="..\..\lib\muparser_muParser.bsc" + SuppressStartupBanner="true" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Debug DLL|Win32" + OutputDirectory="..\..\lib" + IntermediateDirectory="obj\vc_shared_dbg\muParser" + ConfigurationType="2" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="false" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + PreprocessorDefinitions="WIN32;_USRDLL;DLL_EXPORTS;_DEBUG;MUPARSER_DLL;MUPARSERLIB_EXPORTS;_WIN32" + AdditionalIncludeDirectories="..\..\include" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\include" + PreprocessorDefinitions="WIN32;_USRDLL;DLL_EXPORTS;_DEBUG;MUPARSER_DLL;MUPARSERLIB_EXPORTS;_WIN32" + MinimalRebuild="true" + ExceptionHandling="1" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + BufferSecurityCheck="true" + RuntimeTypeInfo="true" + ObjectFile="obj\vc_shared_dbg\muParser\" + ProgramDataBaseFileName="..\..\lib\muparserd.pdb" + WarningLevel="4" + SuppressStartupBanner="true" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="_DEBUG;MUPARSER_DLL;MUPARSERLIB_EXPORTS;_WIN32" + Culture="1033" + AdditionalIncludeDirectories="..\..\include" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalOptions="" + AdditionalDependencies="" + OutputFile="..\..\lib\muparserd.dll" + LinkIncremental="2" + ImportLibrary="..\..\lib\muparserd.lib" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="" + GenerateManifest="true" + GenerateDebugInformation="true" + ProgramDatabaseFile="..\..\lib\muparserd.pdb" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + OutputFile="..\..\lib\muparser_muParser.bsc" + SuppressStartupBanner="true" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath="..\..\src\muParser.cpp" + > + </File> + <File + RelativePath="..\..\src\muParserBase.cpp" + > + </File> + <File + RelativePath="..\..\src\muParserBytecode.cpp" + > + </File> + <File + RelativePath="..\..\src\muParserCallback.cpp" + > + </File> + <File + RelativePath="..\..\src\muParserComplex.cpp" + > + </File> + <File + RelativePath="..\..\src\muParserDLL.cpp" + > + </File> + <File + RelativePath="..\..\src\muParserError.cpp" + > + </File> + <File + RelativePath="..\..\src\muParserInt.cpp" + > + </File> + <File + RelativePath="..\..\src\muParserTest.cpp" + > + </File> + <File + RelativePath="..\..\src\muParserTokenReader.cpp" + > + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" + > + <File + RelativePath="..\..\include\muParser.h" + > + </File> + <File + RelativePath="..\..\include\muParserBase.h" + > + </File> + <File + RelativePath="..\..\include\muParserBytecode.h" + > + </File> + <File + RelativePath="..\..\include\muParserCallback.h" + > + </File> + <File + RelativePath="..\..\include\muParserComplex.h" + > + </File> + <File + RelativePath="..\..\include\muParserDLL.h" + > + </File> + <File + RelativePath="..\..\include\muParserDef.h" + > + </File> + <File + RelativePath="..\..\include\muParserError.h" + > + </File> + <File + RelativePath="..\..\include\muParserFixes.h" + > + </File> + <File + RelativePath="..\..\include\muParserInt.h" + > + </File> + <File + RelativePath="..\..\include\muParserStack.h" + > + </File> + <File + RelativePath="..\..\include\muParserTest.h" + > + </File> + <File + RelativePath="..\..\include\muParserToken.h" + > + </File> + <File + RelativePath="..\..\include\muParserTokenReader.h" + > + </File> + </Filter> + </Files> + <Globals> + + </Globals> +</VisualStudioProject> + diff --git a/AMDiS/lib/muparser_v134/build/msvc2008/muparser.sln b/AMDiS/lib/muparser_v134/build/msvc2008/muparser.sln new file mode 100644 index 0000000000000000000000000000000000000000..039129090eeb3e1b72a9b0472c40942ce1e5a462 --- /dev/null +++ b/AMDiS/lib/muparser_v134/build/msvc2008/muparser.sln @@ -0,0 +1,48 @@ +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "muParser", "muparser_muParser.vcproj", "{2A1F639A-7642-57CC-BF97-3EC5B5C89D91}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example1", "muparser_example1.vcproj", "{A1DCD664-8803-54E2-B35F-84D96B9CA6DF}" + ProjectSection(ProjectDependencies) = postProject + {2A1F639A-7642-57CC-BF97-3EC5B5C89D91} = {2A1F639A-7642-57CC-BF97-3EC5B5C89D91} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example2", "muparser_example2.vcproj", "{B405983E-B929-5BCF-8CC8-03CF34796A23}" + ProjectSection(ProjectDependencies) = postProject + {2A1F639A-7642-57CC-BF97-3EC5B5C89D91} = {2A1F639A-7642-57CC-BF97-3EC5B5C89D91} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Release Static|Win32 = Release Static|Win32 + Release DLL|Win32 = Release DLL|Win32 + Debug Static|Win32 = Debug Static|Win32 + Debug DLL|Win32 = Debug DLL|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2A1F639A-7642-57CC-BF97-3EC5B5C89D91}.Release Static|Win32.ActiveCfg = Release Static|Win32 + {2A1F639A-7642-57CC-BF97-3EC5B5C89D91}.Release Static|Win32.Build.0 = Release Static|Win32 + {2A1F639A-7642-57CC-BF97-3EC5B5C89D91}.Release DLL|Win32.ActiveCfg = Release DLL|Win32 + {2A1F639A-7642-57CC-BF97-3EC5B5C89D91}.Release DLL|Win32.Build.0 = Release DLL|Win32 + {2A1F639A-7642-57CC-BF97-3EC5B5C89D91}.Debug Static|Win32.ActiveCfg = Debug Static|Win32 + {2A1F639A-7642-57CC-BF97-3EC5B5C89D91}.Debug Static|Win32.Build.0 = Debug Static|Win32 + {2A1F639A-7642-57CC-BF97-3EC5B5C89D91}.Debug DLL|Win32.ActiveCfg = Debug DLL|Win32 + {2A1F639A-7642-57CC-BF97-3EC5B5C89D91}.Debug DLL|Win32.Build.0 = Debug DLL|Win32 + {A1DCD664-8803-54E2-B35F-84D96B9CA6DF}.Release Static|Win32.ActiveCfg = Release Static|Win32 + {A1DCD664-8803-54E2-B35F-84D96B9CA6DF}.Release Static|Win32.Build.0 = Release Static|Win32 + {A1DCD664-8803-54E2-B35F-84D96B9CA6DF}.Release DLL|Win32.ActiveCfg = Release DLL|Win32 + {A1DCD664-8803-54E2-B35F-84D96B9CA6DF}.Debug Static|Win32.ActiveCfg = Debug Static|Win32 + {A1DCD664-8803-54E2-B35F-84D96B9CA6DF}.Debug Static|Win32.Build.0 = Debug Static|Win32 + {A1DCD664-8803-54E2-B35F-84D96B9CA6DF}.Debug DLL|Win32.ActiveCfg = Debug DLL|Win32 + {B405983E-B929-5BCF-8CC8-03CF34796A23}.Release Static|Win32.ActiveCfg = Release Static|Win32 + {B405983E-B929-5BCF-8CC8-03CF34796A23}.Release DLL|Win32.ActiveCfg = Release DLL|Win32 + {B405983E-B929-5BCF-8CC8-03CF34796A23}.Release DLL|Win32.Build.0 = Release DLL|Win32 + {B405983E-B929-5BCF-8CC8-03CF34796A23}.Debug Static|Win32.ActiveCfg = Debug Static|Win32 + {B405983E-B929-5BCF-8CC8-03CF34796A23}.Debug DLL|Win32.ActiveCfg = Debug DLL|Win32 + {B405983E-B929-5BCF-8CC8-03CF34796A23}.Debug DLL|Win32.Build.0 = Debug DLL|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal + diff --git a/AMDiS/lib/muparser_v134/build/msvc2008/muparser_example1.vcproj b/AMDiS/lib/muparser_v134/build/msvc2008/muparser_example1.vcproj new file mode 100644 index 0000000000000000000000000000000000000000..af55da1fe76734117283f1efda0e47f493cb56e9 --- /dev/null +++ b/AMDiS/lib/muparser_v134/build/msvc2008/muparser_example1.vcproj @@ -0,0 +1,216 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9,00" + Name="example1" + ProjectGUID="{A1DCD664-8803-54E2-B35F-84D96B9CA6DF}" + TargetFrameworkVersion="0" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Release Static|Win32" + OutputDirectory="..\..\samples\example1" + IntermediateDirectory="obj\vc_static_rel\example1" + ConfigurationType="1" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="false" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + PreprocessorDefinitions="WIN32;_CONSOLE;NDEBUG" + AdditionalIncludeDirectories="..\..\include" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalOptions="/MP" + Optimization="2" + AdditionalIncludeDirectories="..\..\include" + PreprocessorDefinitions="WIN32;_CONSOLE;NDEBUG" + ExceptionHandling="1" + RuntimeLibrary="2" + RuntimeTypeInfo="true" + ObjectFile="obj\vc_static_rel\example1\" + ProgramDataBaseFileName="..\..\samples\example1\example1.pdb" + WarningLevel="0" + SuppressStartupBanner="true" + DebugInformationFormat="0" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="_CONSOLE;NDEBUG" + Culture="1033" + AdditionalIncludeDirectories="..\..\include" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalOptions="" + AdditionalDependencies="..\..\lib\muparser.lib" + OutputFile="..\..\samples\example1\example1.exe" + LinkIncremental="1" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="..\..\lib" + GenerateManifest="true" + ProgramDatabaseFile="..\..\samples\example1\example1.pdb" + SubSystem="1" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + SuppressStartupBanner="true" + OutputFile="..\..\samples\example1\muparser_example1.bsc" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Debug Static|Win32" + OutputDirectory="..\..\samples\example1" + IntermediateDirectory="obj\vc_static_dbg\example1" + ConfigurationType="1" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="false" + CharacterSet="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + PreprocessorDefinitions="WIN32;_CONSOLE;_DEBUG" + AdditionalIncludeDirectories="..\..\include" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalOptions="/MP" + Optimization="0" + AdditionalIncludeDirectories="..\..\include" + PreprocessorDefinitions="WIN32;_CONSOLE;_DEBUG" + ExceptionHandling="1" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + BufferSecurityCheck="true" + RuntimeTypeInfo="true" + ObjectFile="obj\vc_static_dbg\example1\" + ProgramDataBaseFileName="..\..\samples\example1\example1.pdb" + WarningLevel="4" + SuppressStartupBanner="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="_CONSOLE;_DEBUG" + Culture="1033" + AdditionalIncludeDirectories="..\..\include" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalOptions="" + AdditionalDependencies="..\..\lib\muparserd.lib" + OutputFile="..\..\samples\example1\example1.exe" + LinkIncremental="2" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="..\..\lib" + GenerateManifest="true" + GenerateDebugInformation="true" + ProgramDatabaseFile="..\..\samples\example1\example1.pdb" + SubSystem="1" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + SuppressStartupBanner="true" + OutputFile="..\..\samples\example1\muparser_example1.bsc" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath="..\..\samples\example1\Example1.cpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/AMDiS/lib/muparser_v134/build/msvc2008/muparser_example2.vcproj b/AMDiS/lib/muparser_v134/build/msvc2008/muparser_example2.vcproj new file mode 100644 index 0000000000000000000000000000000000000000..946430b40ebb2c1c44c4e604b78bd1ebbe43b439 --- /dev/null +++ b/AMDiS/lib/muparser_v134/build/msvc2008/muparser_example2.vcproj @@ -0,0 +1,225 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<!-- + + This project was generated by + Bakefile 0.2.8 (http://www.bakefile.org) + Do not modify, all changes will be overwritten! + +--> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="example2" + ProjectGUID="{B405983E-B929-5BCF-8CC8-03CF34796A23}" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + + </ToolFiles> + <Configurations> + <Configuration + Name="Release DLL|Win32" + OutputDirectory="..\..\samples\example2" + IntermediateDirectory="obj\vc_shared_rel\example2" + ConfigurationType="1" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="false" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + PreprocessorDefinitions="WIN32;_CONSOLE;NDEBUG;USINGDLL" + AdditionalIncludeDirectories="..\..\include" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalOptions="/MP" + Optimization="2" + AdditionalIncludeDirectories="..\..\include" + PreprocessorDefinitions="WIN32;_CONSOLE;NDEBUG;USINGDLL" + ExceptionHandling="1" + RuntimeLibrary="2" + RuntimeTypeInfo="true" + ObjectFile="obj\vc_shared_rel\example2\" + ProgramDataBaseFileName="..\..\samples\example2\example2.pdb" + WarningLevel="0" + SuppressStartupBanner="true" + DebugInformationFormat="0" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="_CONSOLE;NDEBUG;USINGDLL" + Culture="1033" + AdditionalIncludeDirectories="..\..\include" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalOptions="" + AdditionalDependencies="..\..\lib\muparser.lib" + OutputFile="..\..\samples\example2\example2.exe" + LinkIncremental="1" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="..\..\lib" + GenerateManifest="true" + ProgramDatabaseFile="..\..\samples\example2\example2.pdb" + SubSystem="1" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + OutputFile="..\..\samples\example2\muparser_example2.bsc" + SuppressStartupBanner="true" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Debug DLL|Win32" + OutputDirectory="..\..\samples\example2" + IntermediateDirectory="obj\vc_shared_dbg\example2" + ConfigurationType="1" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="false" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + PreprocessorDefinitions="WIN32;_CONSOLE;_DEBUG;USINGDLL" + AdditionalIncludeDirectories="..\..\include" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalOptions="/MP" + Optimization="0" + AdditionalIncludeDirectories="..\..\include" + PreprocessorDefinitions="WIN32;_CONSOLE;_DEBUG;USINGDLL" + ExceptionHandling="1" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + BufferSecurityCheck="true" + RuntimeTypeInfo="true" + ObjectFile="obj\vc_shared_dbg\example2\" + ProgramDataBaseFileName="..\..\samples\example2\example2.pdb" + WarningLevel="4" + SuppressStartupBanner="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="_CONSOLE;_DEBUG;USINGDLL" + Culture="1033" + AdditionalIncludeDirectories="..\..\include" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalOptions="" + AdditionalDependencies="..\..\lib\muparserd.lib" + OutputFile="..\..\samples\example2\example2.exe" + LinkIncremental="2" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="..\..\lib" + GenerateManifest="true" + GenerateDebugInformation="true" + ProgramDatabaseFile="..\..\samples\example2\example2.pdb" + SubSystem="1" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + OutputFile="..\..\samples\example2\muparser_example2.bsc" + SuppressStartupBanner="true" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath="..\..\samples\example2\example2.c" + > + </File> + </Filter> + </Files> + <Globals> + + </Globals> +</VisualStudioProject> + diff --git a/AMDiS/lib/muparser_v134/build/msvc2008/muparser_muParser.vcproj b/AMDiS/lib/muparser_v134/build/msvc2008/muparser_muParser.vcproj new file mode 100644 index 0000000000000000000000000000000000000000..0a6e0c0454a15466869bdd4cee87ea93d6e380ae --- /dev/null +++ b/AMDiS/lib/muparser_v134/build/msvc2008/muparser_muParser.vcproj @@ -0,0 +1,466 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9,00" + Name="muParser" + ProjectGUID="{2A1F639A-7642-57CC-BF97-3EC5B5C89D91}" + TargetFrameworkVersion="0" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Release Static|Win32" + OutputDirectory="..\..\lib" + IntermediateDirectory="obj\vc_static_rel\muParser" + ConfigurationType="4" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="false" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + PreprocessorDefinitions="WIN32;_LIB;NDEBUG;_WIN32" + AdditionalIncludeDirectories="..\..\include" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalOptions="/MP" + Optimization="2" + AdditionalIncludeDirectories="..\..\include" + PreprocessorDefinitions="WIN32;_LIB;NDEBUG;_WIN32" + ExceptionHandling="1" + RuntimeLibrary="2" + RuntimeTypeInfo="true" + ObjectFile="obj\vc_static_rel\muParser\" + ProgramDataBaseFileName="..\..\lib\muparser.pdb" + WarningLevel="0" + SuppressStartupBanner="true" + DebugInformationFormat="0" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="NDEBUG;_WIN32" + Culture="1033" + AdditionalIncludeDirectories="..\..\include" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLibrarianTool" + OutputFile="..\..\lib\muparser.lib" + SuppressStartupBanner="true" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + SuppressStartupBanner="true" + OutputFile="..\..\lib\muparser_muParser.bsc" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release DLL|Win32" + OutputDirectory="..\..\lib" + IntermediateDirectory="obj\vc_shared_rel\muParser" + ConfigurationType="2" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="false" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + PreprocessorDefinitions="WIN32;_USRDLL;DLL_EXPORTS;NDEBUG;MUPARSER_DLL;MUPARSERLIB_EXPORTS;_WIN32" + AdditionalIncludeDirectories="..\..\include" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalOptions="/MP" + Optimization="2" + AdditionalIncludeDirectories="..\..\include" + PreprocessorDefinitions="WIN32;_USRDLL;DLL_EXPORTS;NDEBUG;MUPARSER_DLL;MUPARSERLIB_EXPORTS;_WIN32" + ExceptionHandling="1" + RuntimeLibrary="2" + RuntimeTypeInfo="true" + ObjectFile="obj\vc_shared_rel\muParser\" + ProgramDataBaseFileName="..\..\lib\muparser.pdb" + WarningLevel="0" + SuppressStartupBanner="true" + DebugInformationFormat="0" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="NDEBUG;MUPARSER_DLL;MUPARSERLIB_EXPORTS;_WIN32" + Culture="1033" + AdditionalIncludeDirectories="..\..\include" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalOptions="" + AdditionalDependencies="" + OutputFile="..\..\lib\muparser.dll" + LinkIncremental="1" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="" + GenerateManifest="true" + ProgramDatabaseFile="..\..\lib\muparser.pdb" + ImportLibrary="..\..\lib\muparser.lib" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + SuppressStartupBanner="true" + OutputFile="..\..\lib\muparser_muParser.bsc" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Debug Static|Win32" + OutputDirectory="..\..\lib" + IntermediateDirectory="obj\vc_static_dbg\muParser" + ConfigurationType="4" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="false" + CharacterSet="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + PreprocessorDefinitions="WIN32;_LIB;_DEBUG;_WIN32" + AdditionalIncludeDirectories="..\..\include" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalOptions="/MP" + Optimization="0" + AdditionalIncludeDirectories="..\..\include" + PreprocessorDefinitions="WIN32;_LIB;_DEBUG;_WIN32" + ExceptionHandling="1" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + BufferSecurityCheck="true" + RuntimeTypeInfo="true" + ObjectFile="obj\vc_static_dbg\muParser\" + ProgramDataBaseFileName="..\..\lib\muparserd.pdb" + WarningLevel="4" + SuppressStartupBanner="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="_DEBUG;_WIN32" + Culture="1033" + AdditionalIncludeDirectories="..\..\include" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLibrarianTool" + OutputFile="..\..\lib\muparserd.lib" + SuppressStartupBanner="true" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + SuppressStartupBanner="true" + OutputFile="..\..\lib\muparser_muParser.bsc" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Debug DLL|Win32" + OutputDirectory="..\..\lib" + IntermediateDirectory="obj\vc_shared_dbg\muParser" + ConfigurationType="2" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="false" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + PreprocessorDefinitions="WIN32;_USRDLL;DLL_EXPORTS;_DEBUG;MUPARSER_DLL;MUPARSERLIB_EXPORTS;_WIN32" + AdditionalIncludeDirectories="..\..\include" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalOptions="/MP" + Optimization="0" + AdditionalIncludeDirectories="..\..\include" + PreprocessorDefinitions="WIN32;_USRDLL;DLL_EXPORTS;_DEBUG;MUPARSER_DLL;MUPARSERLIB_EXPORTS;_WIN32;_CRT_SECURE_NO_WARNINGS" + ExceptionHandling="1" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + BufferSecurityCheck="true" + RuntimeTypeInfo="true" + ObjectFile="obj\vc_shared_dbg\muParser\" + ProgramDataBaseFileName="..\..\lib\muparserd.pdb" + WarningLevel="4" + SuppressStartupBanner="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="_DEBUG;MUPARSER_DLL;MUPARSERLIB_EXPORTS;_WIN32" + Culture="1033" + AdditionalIncludeDirectories="..\..\include" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalOptions="" + AdditionalDependencies="" + OutputFile="..\..\lib\muparserd.dll" + LinkIncremental="2" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="" + GenerateManifest="true" + GenerateDebugInformation="true" + ProgramDatabaseFile="..\..\lib\muparserd.pdb" + ImportLibrary="..\..\lib\muparserd.lib" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + SuppressStartupBanner="true" + OutputFile="..\..\lib\muparser_muParser.bsc" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath="..\..\src\muParser.cpp" + > + </File> + <File + RelativePath="..\..\src\muParserBase.cpp" + > + </File> + <File + RelativePath="..\..\src\muParserBytecode.cpp" + > + </File> + <File + RelativePath="..\..\src\muParserCallback.cpp" + > + </File> + <File + RelativePath="..\..\src\muParserComplex.cpp" + > + </File> + <File + RelativePath="..\..\src\muParserDLL.cpp" + > + </File> + <File + RelativePath="..\..\src\muParserError.cpp" + > + </File> + <File + RelativePath="..\..\src\muParserInt.cpp" + > + </File> + <File + RelativePath="..\..\src\muParserTest.cpp" + > + </File> + <File + RelativePath="..\..\src\muParserTokenReader.cpp" + > + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" + > + <File + RelativePath="..\..\include\muParser.h" + > + </File> + <File + RelativePath="..\..\include\muParserBase.h" + > + </File> + <File + RelativePath="..\..\include\muParserBytecode.h" + > + </File> + <File + RelativePath="..\..\include\muParserCallback.h" + > + </File> + <File + RelativePath="..\..\include\muParserComplex.h" + > + </File> + <File + RelativePath="..\..\include\muParserDef.h" + > + </File> + <File + RelativePath="..\..\include\muParserDLL.h" + > + </File> + <File + RelativePath="..\..\include\muParserError.h" + > + </File> + <File + RelativePath="..\..\include\muParserFixes.h" + > + </File> + <File + RelativePath="..\..\include\muParserInt.h" + > + </File> + <File + RelativePath="..\..\include\muParserStack.h" + > + </File> + <File + RelativePath="..\..\include\muParserTest.h" + > + </File> + <File + RelativePath="..\..\include\muParserToken.h" + > + </File> + <File + RelativePath="..\..\include\muParserTokenReader.h" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/AMDiS/lib/muparser_v134/configure b/AMDiS/lib/muparser_v134/configure new file mode 100755 index 0000000000000000000000000000000000000000..f6d74e60bcbf25d114cd981d7c1b2abf9d561841 --- /dev/null +++ b/AMDiS/lib/muparser_v134/configure @@ -0,0 +1,9059 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.64 for muParser 1.34. +# +# Report bugs to <frm@users.sourceforge.net>. +# +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software +# Foundation, Inc. +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +if test "x$CONFIG_SHELL" = x; then + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi +" + as_required="as_fn_return () { (exit \$1); } +as_fn_success () { as_fn_return 0; } +as_fn_failure () { as_fn_return 1; } +as_fn_ret_success () { return 0; } +as_fn_ret_failure () { return 1; } + +exitcode=0 +as_fn_success || { exitcode=1; echo as_fn_success failed.; } +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : + +else + exitcode=1; echo positional parameters were not saved. +fi +test x\$exitcode = x0 || exit 1" + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1" + if (eval "$as_required") 2>/dev/null; then : + as_have_required=yes +else + as_have_required=no +fi + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : + +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + as_found=: + case $as_dir in #( + /*) + for as_base in sh bash ksh sh5; do + # Try only shells that exist, to save several forks. + as_shell=$as_dir/$as_base + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : + CONFIG_SHELL=$as_shell as_have_required=yes + if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : + break 2 +fi +fi + done;; + esac + as_found=false +done +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : + CONFIG_SHELL=$SHELL as_have_required=yes +fi; } +IFS=$as_save_IFS + + + if test "x$CONFIG_SHELL" != x; then : + # We cannot yet assume a decent shell, so we have to provide a + # neutralization value for shells without unset; and this also + # works around shells that cannot unset nonexistent variables. + BASH_ENV=/dev/null + ENV=/dev/null + (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} +fi + + if test x$as_have_required = xno; then : + $as_echo "$0: This script requires a shell more modern than all" + $as_echo "$0: the shells that I found on your system." + if test x${ZSH_VERSION+set} = xset ; then + $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" + $as_echo "$0: be upgraded to zsh 4.3.4 or later." + else + $as_echo "$0: Please tell bug-autoconf@gnu.org and +$0: frm@users.sourceforge.net about your system, including +$0: any error possibly output before this message. Then +$0: install a modern shell, or manually run the script +$0: under such a shell if you do have one." + fi + exit 1 +fi +fi +fi +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL +# Unset more variables known to interfere with behavior of common tools. +CLICOLOR_FORCE= GREP_OPTIONS= +unset CLICOLOR_FORCE GREP_OPTIONS + +## --------------------- ## +## M4sh Shell Functions. ## +## --------------------- ## +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +# as_fn_error ERROR [LINENO LOG_FD] +# --------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with status $?, using 1 if that was 0. +as_fn_error () +{ + as_status=$?; test $as_status -eq 0 && as_status=1 + if test "$3"; then + as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + fi + $as_echo "$as_me: error: $1" >&2 + as_fn_exit $as_status +} # as_fn_error + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + + + as_lineno_1=$LINENO as_lineno_1a=$LINENO + as_lineno_2=$LINENO as_lineno_2a=$LINENO + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -p' + fi +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in #( + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 7<&0 </dev/null 6>&1 + +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= + +# Identity of this package. +PACKAGE_NAME='muParser' +PACKAGE_TARNAME='muparser' +PACKAGE_VERSION='1.34' +PACKAGE_STRING='muParser 1.34' +PACKAGE_BUGREPORT='frm@users.sourceforge.net' +PACKAGE_URL='' + +ac_subst_vars='LTLIBOBJS +LIBOBJS +COND_WINDOWS_IMPLIB_1 +COND_USE_SOVERSOLARIS_1 +COND_USE_SOVERSION_1_USE_SOVERSOLARIS_1 +COND_USE_SOVERSION_0 +COND_USE_SOVERLINUX_1 +COND_USE_SOVERCYGWIN_1_USE_SOVERSION_1 +COND_USE_SOTWOSYMLINKS_1 +COND_SHARED_1 +COND_SHARED_0 +COND_SAMPLES_1 +COND_PLATFORM_OS2_1 +COND_PLATFORM_MAC_1 +COND_PLATFORM_MAC_0 +COND_PLATFORM_MACOSX_1_USE_SOVERSION_1 +COND_PLATFORM_MACOSX_1 +COND_PLATFORM_MACOSX_0_USE_SOVERSION_1 +COND_PLATFORM_MACOSX_0_USE_SOVERCYGWIN_0_USE_SOVERSION_1 +COND_DEPS_TRACKING_1 +COND_DEPS_TRACKING_0 +COND_DEBUG_1 +COND_DEBUG_0 +OBJCXXFLAGS +SETFILE +REZ +WINDRES +BK_DEPS +DEPS_TRACKING +SONAME_FLAG +USE_SOTWOSYMLINKS +USE_MACVERSION +USE_SOVERCYGWIN +USE_SOVERSOLARIS +USE_SOVERLINUX +USE_SOVERSION +WINDOWS_IMPLIB +PIC_FLAG +SHARED_LD_MODULE_CXX +SHARED_LD_MODULE_CC +SHARED_LD_CXX +SHARED_LD_CC +AIX_CXX_LD +dlldir +DLLPREFIX_MODULE +DLLPREFIX +LIBEXT +LIBPREFIX +DLLIMP_SUFFIX +SO_SUFFIX_MODULE +SO_SUFFIX +PLATFORM_BEOS +PLATFORM_OS2 +PLATFORM_MACOSX +PLATFORM_MACOS +PLATFORM_MAC +PLATFORM_MSDOS +PLATFORM_WIN32 +PLATFORM_UNIX +IF_GNU_MAKE +LDFLAGS_GUI +INSTALL_DIR +NM +STRIP +AROPTIONS +AR +MAKE_SET +SET_MAKE +CXXCPP +ac_ct_CXX +CXXFLAGS +CXX +OBJEXT +EXEEXT +ac_ct_CC +CPPFLAGS +LDFLAGS +CFLAGS +CC +RANLIB +LN_S +INSTALL_DATA +INSTALL_SCRIPT +INSTALL_PROGRAM +AWK +target_os +target_vendor +target_cpu +target +host_os +host_vendor +host_cpu +host +build_os +build_vendor +build_cpu +build +target_alias +host_alias +build_alias +LIBS +ECHO_T +ECHO_N +ECHO_C +DEFS +mandir +localedir +libdir +psdir +pdfdir +dvidir +htmldir +infodir +docdir +oldincludedir +includedir +localstatedir +sharedstatedir +sysconfdir +datadir +datarootdir +libexecdir +sbindir +bindir +program_transform_name +prefix +exec_prefix +PACKAGE_URL +PACKAGE_BUGREPORT +PACKAGE_STRING +PACKAGE_VERSION +PACKAGE_TARNAME +PACKAGE_NAME +PATH_SEPARATOR +SHELL' +ac_subst_files='' +ac_user_opts=' +enable_option_checking +enable_debug +enable_shared +enable_samples +enable_omf +enable_dependency_tracking +' + ac_precious_vars='build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +CXX +CXXFLAGS +CCC +CXXCPP' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +ac_unrecognized_opts= +ac_unrecognized_sep= +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=\$ac_optarg ;; + + -without-* | --without-*) + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) as_fn_error "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information." + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) + as_fn_error "invalid variable name: \`$ac_envvar'" ;; + esac + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + as_fn_error "missing argument to $ac_option" +fi + +if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; + fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + esac +fi + +# Check all directory arguments for consistency. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir +do + eval ac_val=\$$ac_var + # Remove trailing slashes. + case $ac_val in + */ ) + ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` + eval $ac_var=\$ac_val;; + esac + # Be sure to have absolute directory names. + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + as_fn_error "expected an absolute directory name for --$ac_var: $ac_val" +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + as_fn_error "working directory cannot be determined" +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + as_fn_error "pwd does not report name of working directory" + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$as_myself" || +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_myself" : 'X\(//\)[^/]' \| \ + X"$as_myself" : 'X\(//\)$' \| \ + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_myself" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + as_fn_error "cannot find sources ($ac_unique_file) in $srcdir" +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg" + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures muParser 1.34 to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/muparser] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST cross-compile to build programs to run on HOST [BUILD] + --target=TARGET configure for building compilers for TARGET [HOST] +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of muParser 1.34:";; + esac + cat <<\_ACEOF + +Optional Features: + --disable-option-checking ignore unrecognized --enable/--with options + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-debug Builds in debug mode + --enable-shared Builds in shared mode + --enable-samples Builds the library samples, too + --enable-omf use OMF object format (OS/2) + --disable-dependency-tracking + don't use dependency tracking even if the compiler + can + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a + nonstandard directory <lib dir> + LIBS libraries to pass to the linker, e.g. -l<library> + CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I<include dir> if + you have headers in a nonstandard directory <include dir> + CXX C++ compiler command + CXXFLAGS C++ compiler flags + CXXCPP C++ preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +Report bugs to <frm@users.sourceforge.net>. +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || + { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || + continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +muParser configure 1.34 +generated by GNU Autoconf 2.64 + +Copyright (C) 2009 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit +fi + +## ------------------------ ## +## Autoconf initialization. ## +## ------------------------ ## + +# ac_fn_c_try_compile LINENO +# -------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + return $ac_retval + +} # ac_fn_c_try_compile + +# ac_fn_cxx_try_compile LINENO +# ---------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_cxx_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + return $ac_retval + +} # ac_fn_cxx_try_compile + +# ac_fn_cxx_try_cpp LINENO +# ------------------------ +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_cxx_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } >/dev/null && { + test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + return $ac_retval + +} # ac_fn_cxx_try_cpp +cat >config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by muParser $as_me 1.34, which was +generated by GNU Autoconf 2.64. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + $as_echo "PATH: $as_dir" + done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; + 2) + as_fn_append ac_configure_args1 " '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + as_fn_append ac_configure_args " '$ac_arg'" + ;; + esac + done +done +{ ac_configure_args0=; unset ac_configure_args0;} +{ ac_configure_args1=; unset ac_configure_args1;} + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + cat <<\_ASBOX +## ---------------- ## +## Cache variables. ## +## ---------------- ## +_ASBOX + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + cat <<\_ASBOX +## ----------------- ## +## Output variables. ## +## ----------------- ## +_ASBOX + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + cat <<\_ASBOX +## ------------------- ## +## File substitutions. ## +## ------------------- ## +_ASBOX + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + $as_echo "$as_me: caught signal $ac_signal" + $as_echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +$as_echo "/* confdefs.h */" > confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_URL "$PACKAGE_URL" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer an explicitly selected file to automatically selected ones. +ac_site_file1=NONE +ac_site_file2=NONE +if test -n "$CONFIG_SITE"; then + ac_site_file1=$CONFIG_SITE +elif test "x$prefix" != xNONE; then + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site +else + ac_site_file1=$ac_default_prefix/share/config.site + ac_site_file2=$ac_default_prefix/etc/config.site +fi +for ac_site_file in "$ac_site_file1" "$ac_site_file2" +do + test "x$ac_site_file" = xNONE && continue + if test -r "$ac_site_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 +$as_echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 +$as_echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 +$as_echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` + if test "$ac_old_val_w" != "$ac_new_val_w"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + ac_cache_corrupted=: + else + { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + eval $ac_var=\$ac_old_val + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 +$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 +$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) as_fn_append ac_configure_args " '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} + as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 +fi +## -------------------- ## +## Main body of script. ## +## -------------------- ## + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + + +ac_aux_dir= +for ac_dir in build/autoconf "$srcdir"/build/autoconf; do + for ac_t in install-sh install.sh shtool; do + if test -f "$ac_dir/$ac_t"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/$ac_t -c" + break 2 + fi + done +done +if test -z "$ac_aux_dir"; then + as_fn_error "cannot find install-sh, install.sh, or shtool in build/autoconf \"$srcdir\"/build/autoconf" "$LINENO" 5 +fi + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + + +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + +# some helpers + + + + + + + + + + + + + + + + + + + + + +## CONFIGURE CHECKS +##################################################################### + +# Make sure we can run config.sub. +$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || + as_fn_error "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 +$as_echo_n "checking build system type... " >&6; } +if test "${ac_cv_build+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` +test "x$ac_build_alias" = x && + as_fn_error "cannot guess build type; you must specify one" "$LINENO" 5 +ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || + as_fn_error "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 +$as_echo "$ac_cv_build" >&6; } +case $ac_cv_build in +*-*-*) ;; +*) as_fn_error "invalid value of canonical build" "$LINENO" 5;; +esac +build=$ac_cv_build +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 +$as_echo_n "checking host system type... " >&6; } +if test "${ac_cv_host+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test "x$host_alias" = x; then + ac_cv_host=$ac_cv_build +else + ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || + as_fn_error "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 +$as_echo "$ac_cv_host" >&6; } +case $ac_cv_host in +*-*-*) ;; +*) as_fn_error "invalid value of canonical host" "$LINENO" 5;; +esac +host=$ac_cv_host +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_host +shift +host_cpu=$1 +host_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +host_os=$* +IFS=$ac_save_IFS +case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5 +$as_echo_n "checking target system type... " >&6; } +if test "${ac_cv_target+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test "x$target_alias" = x; then + ac_cv_target=$ac_cv_host +else + ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` || + as_fn_error "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5 +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5 +$as_echo "$ac_cv_target" >&6; } +case $ac_cv_target in +*-*-*) ;; +*) as_fn_error "invalid value of canonical target" "$LINENO" 5;; +esac +target=$ac_cv_target +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_target +shift +target_cpu=$1 +target_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +target_os=$* +IFS=$ac_save_IFS +case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac + + +# The aliases save the names the user supplied, while $host etc. +# will get canonicalized. +test -n "$target_alias" && + test "$program_prefix$program_suffix$program_transform_name" = \ + NONENONEs,x,x, && + program_prefix=${target_alias}- + + +CFLAGS= +CXXFLAGS= +CPPFLAGS= + +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_AWK+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_AWK="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 +$as_echo "$AWK" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$AWK" && break +done + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +# Reject install programs that cannot install multiple files. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 +$as_echo_n "checking for a BSD-compatible install... " >&6; } +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in #(( + ./ | .// | /[cC]/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + rm -rf conftest.one conftest.two conftest.dir + echo one > conftest.one + echo two > conftest.two + mkdir conftest.dir + if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && + test -s conftest.one && test -s conftest.two && + test -s conftest.dir/conftest.one && + test -s conftest.dir/conftest.two + then + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + fi + done + done + ;; +esac + + done +IFS=$as_save_IFS + +rm -rf conftest.one conftest.two conftest.dir + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. Don't cache a + # value for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + INSTALL=$ac_install_sh + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 +$as_echo "$INSTALL" >&6; } + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 +$as_echo_n "checking whether ln -s works... " >&6; } +LN_S=$as_ln_s +if test "$LN_S" = "ln -s"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 +$as_echo "no, using $LN_S" >&6; } +fi + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_RANLIB+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 +$as_echo "$RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 +$as_echo "$ac_ct_RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_RANLIB" = x; then + RANLIB=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + RANLIB=$ac_ct_RANLIB + fi +else + RANLIB="$ac_cv_prog_RANLIB" +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "no acceptable C compiler found in \$PATH +See \`config.log' for more details." "$LINENO" 5; } + +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + rm -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <stdio.h> +int +main () +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out conftest.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` + +# The possible output files: +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" + +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { { ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else + ac_file='' +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } +if test -z "$ac_file"; then : + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ as_fn_set_status 77 +as_fn_error "C compiler cannot create executables +See \`config.log' for more details." "$LINENO" 5; }; } +fi +ac_exeext=$ac_cv_exeext + +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." "$LINENO" 5; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out conftest.out +ac_clean_files=$ac_clean_files_save +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 +$as_echo_n "checking for suffix of executables... " >&6; } +if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." "$LINENO" 5; } +fi +rm -f conftest$ac_cv_exeext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 +$as_echo "$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 +$as_echo_n "checking for suffix of object files... " >&6; } +if test "${ac_cv_objext+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "cannot compute suffix of object files: cannot compile +See \`config.log' for more details." "$LINENO" 5; } +fi +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 +$as_echo "$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if test "${ac_cv_c_compiler_gnu+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if test "${ac_cv_prog_cc_g+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +else + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if test "${ac_cv_prog_cc_c89+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <stdarg.h> +#include <stdio.h> +#include <sys/types.h> +#include <sys/stat.h> +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + +fi + +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +if test -z "$CXX"; then + if test -n "$CCC"; then + CXX=$CCC + else + if test -n "$ac_tool_prefix"; then + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CXX+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CXX"; then + ac_cv_prog_CXX="$CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CXX=$ac_cv_prog_CXX +if test -n "$CXX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 +$as_echo "$CXX" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CXX" && break + done +fi +if test -z "$CXX"; then + ac_ct_CXX=$CXX + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CXX"; then + ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CXX="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CXX=$ac_cv_prog_ac_ct_CXX +if test -n "$ac_ct_CXX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 +$as_echo "$ac_ct_CXX" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CXX" && break +done + + if test "x$ac_ct_CXX" = x; then + CXX="g++" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CXX=$ac_ct_CXX + fi +fi + + fi +fi +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + rm -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 +$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } +if test "${ac_cv_cxx_compiler_gnu+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_cxx_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 +$as_echo "$ac_cv_cxx_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GXX=yes +else + GXX= +fi +ac_test_CXXFLAGS=${CXXFLAGS+set} +ac_save_CXXFLAGS=$CXXFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 +$as_echo_n "checking whether $CXX accepts -g... " >&6; } +if test "${ac_cv_prog_cxx_g+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_save_cxx_werror_flag=$ac_cxx_werror_flag + ac_cxx_werror_flag=yes + ac_cv_prog_cxx_g=no + CXXFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_prog_cxx_g=yes +else + CXXFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + +else + ac_cxx_werror_flag=$ac_save_cxx_werror_flag + CXXFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_prog_cxx_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cxx_werror_flag=$ac_save_cxx_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 +$as_echo "$ac_cv_prog_cxx_g" >&6; } +if test "$ac_test_CXXFLAGS" = set; then + CXXFLAGS=$ac_save_CXXFLAGS +elif test $ac_cv_prog_cxx_g = yes; then + if test "$GXX" = yes; then + CXXFLAGS="-g -O2" + else + CXXFLAGS="-g" + fi +else + if test "$GXX" = yes; then + CXXFLAGS="-O2" + else + CXXFLAGS= + fi +fi +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 +$as_echo_n "checking how to run the C++ preprocessor... " >&6; } +if test -z "$CXXCPP"; then + if test "${ac_cv_prog_CXXCPP+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CXXCPP needs to be expanded + for CXXCPP in "$CXX -E" "/lib/cpp" + do + ac_preproc_ok=false +for ac_cxx_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + # <limits.h> exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + Syntax error +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <ac_nonexistent.h> +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CXXCPP=$CXXCPP + +fi + CXXCPP=$ac_cv_prog_CXXCPP +else + ac_cv_prog_CXXCPP=$CXXCPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5 +$as_echo "$CXXCPP" >&6; } +ac_preproc_ok=false +for ac_cxx_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + # <limits.h> exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + Syntax error +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <ac_nonexistent.h> +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "C++ preprocessor \"$CXXCPP\" fails sanity check +See \`config.log' for more details." "$LINENO" 5; } +fi + +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + + + default="no" + if [ -z "$default" ]; then + default="no" + fi + + # Check whether --enable-debug was given. +if test "${enable_debug+set}" = set; then : + enableval=$enable_debug; +else + enableval="$default" +fi + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the --enable-debug option" >&5 +$as_echo_n "checking for the --enable-debug option... " >&6; } + if [ "x$enableval" = "xyes" ]; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + DEBUG=1 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + DEBUG=0 + fi + + + if [ "x$DEBUG" = "x1" ]; then + + CXXFLAGS="$CXXFLAGS -g -O0 -Wall -Wundef -Wno-ctor-dtor-privacy" + CFLAGS="$CFLAGS -g -O0 -Wall -Wundef" + else + CXXFLAGS="$CXXFLAGS -O2" + CFLAGS="$CFLAGS -O2" + fi + + + default="yes" + if [ -z "$default" ]; then + default="no" + fi + + # Check whether --enable-shared was given. +if test "${enable_shared+set}" = set; then : + enableval=$enable_shared; +else + enableval="$default" +fi + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the --enable-shared option" >&5 +$as_echo_n "checking for the --enable-shared option... " >&6; } + if [ "x$enableval" = "xyes" ]; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + SHARED=1 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + SHARED=0 + fi + + + +# Check whether --enable-samples was given. +if test "${enable_samples+set}" = set; then : + enableval=$enable_samples; +else + enableval="yes" +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the --enable-samples option" >&5 +$as_echo_n "checking for the --enable-samples option... " >&6; } + if [ "x$enableval" = "xyes" ]; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + SAMPLES=1 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + SAMPLES=0 + fi + + +as_dir=lib; as_fn_mkdir_p +as_dir=samples/example1; as_fn_mkdir_p + + + + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "no acceptable C compiler found in \$PATH +See \`config.log' for more details." "$LINENO" 5; } + +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + rm -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if test "${ac_cv_c_compiler_gnu+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if test "${ac_cv_prog_cc_g+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +else + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if test "${ac_cv_prog_cc_c89+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <stdarg.h> +#include <stdio.h> +#include <sys/types.h> +#include <sys/stat.h> +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + +fi + +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the Intel C compiler" >&5 +$as_echo_n "checking whether we are using the Intel C compiler... " >&6; } +if test "${bakefile_cv_c_compiler___INTEL_COMPILER+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + #ifndef __INTEL_COMPILER + choke me + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bakefile_cv_c_compiler___INTEL_COMPILER=yes +else + bakefile_cv_c_compiler___INTEL_COMPILER=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bakefile_cv_c_compiler___INTEL_COMPILER" >&5 +$as_echo "$bakefile_cv_c_compiler___INTEL_COMPILER" >&6; } + if test "x$bakefile_cv_c_compiler___INTEL_COMPILER" = "xyes"; then + :; INTELCC=yes + else + :; + fi + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + + + if test "$INTELCC" = "yes"; then + + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using Intel C compiler v8 or later" >&5 +$as_echo_n "checking whether we are using Intel C compiler v8 or later... " >&6; } +if test "${bakefile_cv_c_compiler___INTEL_COMPILER_lt_800+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + #ifndef __INTEL_COMPILER || __INTEL_COMPILER < 800 + choke me + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bakefile_cv_c_compiler___INTEL_COMPILER_lt_800=yes +else + bakefile_cv_c_compiler___INTEL_COMPILER_lt_800=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bakefile_cv_c_compiler___INTEL_COMPILER_lt_800" >&5 +$as_echo "$bakefile_cv_c_compiler___INTEL_COMPILER_lt_800" >&6; } + if test "x$bakefile_cv_c_compiler___INTEL_COMPILER_lt_800" = "xyes"; then + :; INTELCC8=yes + else + :; + fi + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + + + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using Intel C compiler v10 or later" >&5 +$as_echo_n "checking whether we are using Intel C compiler v10 or later... " >&6; } +if test "${bakefile_cv_c_compiler___INTEL_COMPILER_lt_1000+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + #ifndef __INTEL_COMPILER || __INTEL_COMPILER < 1000 + choke me + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bakefile_cv_c_compiler___INTEL_COMPILER_lt_1000=yes +else + bakefile_cv_c_compiler___INTEL_COMPILER_lt_1000=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bakefile_cv_c_compiler___INTEL_COMPILER_lt_1000" >&5 +$as_echo "$bakefile_cv_c_compiler___INTEL_COMPILER_lt_1000" >&6; } + if test "x$bakefile_cv_c_compiler___INTEL_COMPILER_lt_1000" = "xyes"; then + :; INTELCC10=yes + else + :; + fi + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + + fi + + if test "x$GCC" != "xyes"; then + if test "xCC" = "xC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the C++ compiler requires -ext o" >&5 +$as_echo_n "checking if the C++ compiler requires -ext o... " >&6; } +if test "${bakefile_cv_cxx_exto+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest.$ac_ext.o +if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + for ac_file in `(ls conftest.* 2>/dev/null)`; do + case $ac_file in + conftest.$ac_ext.o) + bakefile_cv_cxx_exto="-ext o" + ;; + *) + ;; + esac +done +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "cannot figure out if compiler needs -ext o: cannot compile +See \`config.log' for more details." "$LINENO" 5; } + +fi +rm -f conftest.$ac_ext.o conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bakefile_cv_cxx_exto" >&5 +$as_echo "$bakefile_cv_cxx_exto" >&6; } +if test "x$bakefile_cv_cxx_exto" '!=' "x"; then + if test "cxx" = "c"; then + CFLAGS="$bakefile_cv_cxx_exto $CFLAGS" + fi + if test "cxx" = "cxx"; then + CXXFLAGS="$bakefile_cv_cxx_exto $CXXFLAGS" + fi +fi + + if test "x$bakefile_cv_c_exto" '!=' "x"; then + unset ac_cv_prog_cc_g + ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if test "${ac_cv_prog_cc_g+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +else + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi + fi + fi + + case `uname -s` in + AIX*) + + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the IBM xlC C compiler" >&5 +$as_echo_n "checking whether we are using the IBM xlC C compiler... " >&6; } +if test "${bakefile_cv_c_compiler___xlC__+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + #ifndef __xlC__ + choke me + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bakefile_cv_c_compiler___xlC__=yes +else + bakefile_cv_c_compiler___xlC__=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bakefile_cv_c_compiler___xlC__" >&5 +$as_echo "$bakefile_cv_c_compiler___xlC__" >&6; } + if test "x$bakefile_cv_c_compiler___xlC__" = "xyes"; then + :; XLCC=yes + else + :; + fi + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + + ;; + + Darwin) + + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the Metrowerks C compiler" >&5 +$as_echo_n "checking whether we are using the Metrowerks C compiler... " >&6; } +if test "${bakefile_cv_c_compiler___MWERKS__+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + #ifndef __MWERKS__ + choke me + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bakefile_cv_c_compiler___MWERKS__=yes +else + bakefile_cv_c_compiler___MWERKS__=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bakefile_cv_c_compiler___MWERKS__" >&5 +$as_echo "$bakefile_cv_c_compiler___MWERKS__" >&6; } + if test "x$bakefile_cv_c_compiler___MWERKS__" = "xyes"; then + :; MWCC=yes + else + :; + fi + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + + if test "$MWCC" != "yes"; then + + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the IBM xlC C compiler" >&5 +$as_echo_n "checking whether we are using the IBM xlC C compiler... " >&6; } +if test "${bakefile_cv_c_compiler___xlC__+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + #ifndef __xlC__ + choke me + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bakefile_cv_c_compiler___xlC__=yes +else + bakefile_cv_c_compiler___xlC__=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bakefile_cv_c_compiler___xlC__" >&5 +$as_echo "$bakefile_cv_c_compiler___xlC__" >&6; } + if test "x$bakefile_cv_c_compiler___xlC__" = "xyes"; then + :; XLCC=yes + else + :; + fi + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + + fi + ;; + + IRIX*) + + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the SGI C compiler" >&5 +$as_echo_n "checking whether we are using the SGI C compiler... " >&6; } +if test "${bakefile_cv_c_compiler__SGI_COMPILER_VERSION+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + #ifndef _SGI_COMPILER_VERSION + choke me + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bakefile_cv_c_compiler__SGI_COMPILER_VERSION=yes +else + bakefile_cv_c_compiler__SGI_COMPILER_VERSION=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bakefile_cv_c_compiler__SGI_COMPILER_VERSION" >&5 +$as_echo "$bakefile_cv_c_compiler__SGI_COMPILER_VERSION" >&6; } + if test "x$bakefile_cv_c_compiler__SGI_COMPILER_VERSION" = "xyes"; then + :; SGICC=yes + else + :; + fi + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + + ;; + + Linux*) + if test "$INTELCC" != "yes"; then + + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the Sun C compiler" >&5 +$as_echo_n "checking whether we are using the Sun C compiler... " >&6; } +if test "${bakefile_cv_c_compiler___SUNPRO_C+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + #ifndef __SUNPRO_C + choke me + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bakefile_cv_c_compiler___SUNPRO_C=yes +else + bakefile_cv_c_compiler___SUNPRO_C=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bakefile_cv_c_compiler___SUNPRO_C" >&5 +$as_echo "$bakefile_cv_c_compiler___SUNPRO_C" >&6; } + if test "x$bakefile_cv_c_compiler___SUNPRO_C" = "xyes"; then + :; SUNCC=yes + else + :; + fi + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + + fi + ;; + + HP-UX*) + + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the HP C compiler" >&5 +$as_echo_n "checking whether we are using the HP C compiler... " >&6; } +if test "${bakefile_cv_c_compiler___HP_cc+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + #ifndef __HP_cc + choke me + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bakefile_cv_c_compiler___HP_cc=yes +else + bakefile_cv_c_compiler___HP_cc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bakefile_cv_c_compiler___HP_cc" >&5 +$as_echo "$bakefile_cv_c_compiler___HP_cc" >&6; } + if test "x$bakefile_cv_c_compiler___HP_cc" = "xyes"; then + :; HPCC=yes + else + :; + fi + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + + ;; + + OSF1) + + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the Compaq C compiler" >&5 +$as_echo_n "checking whether we are using the Compaq C compiler... " >&6; } +if test "${bakefile_cv_c_compiler___DECC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + #ifndef __DECC + choke me + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bakefile_cv_c_compiler___DECC=yes +else + bakefile_cv_c_compiler___DECC=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bakefile_cv_c_compiler___DECC" >&5 +$as_echo "$bakefile_cv_c_compiler___DECC" >&6; } + if test "x$bakefile_cv_c_compiler___DECC" = "xyes"; then + :; COMPAQCC=yes + else + :; + fi + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + + ;; + + SunOS) + + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the Sun C compiler" >&5 +$as_echo_n "checking whether we are using the Sun C compiler... " >&6; } +if test "${bakefile_cv_c_compiler___SUNPRO_C+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + #ifndef __SUNPRO_C + choke me + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bakefile_cv_c_compiler___SUNPRO_C=yes +else + bakefile_cv_c_compiler___SUNPRO_C=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bakefile_cv_c_compiler___SUNPRO_C" >&5 +$as_echo "$bakefile_cv_c_compiler___SUNPRO_C" >&6; } + if test "x$bakefile_cv_c_compiler___SUNPRO_C" = "xyes"; then + :; SUNCC=yes + else + :; + fi + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + + ;; + esac + fi + + + + + + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +if test -z "$CXX"; then + if test -n "$CCC"; then + CXX=$CCC + else + if test -n "$ac_tool_prefix"; then + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CXX+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CXX"; then + ac_cv_prog_CXX="$CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CXX=$ac_cv_prog_CXX +if test -n "$CXX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 +$as_echo "$CXX" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CXX" && break + done +fi +if test -z "$CXX"; then + ac_ct_CXX=$CXX + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CXX"; then + ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CXX="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CXX=$ac_cv_prog_ac_ct_CXX +if test -n "$ac_ct_CXX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 +$as_echo "$ac_ct_CXX" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CXX" && break +done + + if test "x$ac_ct_CXX" = x; then + CXX="g++" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CXX=$ac_ct_CXX + fi +fi + + fi +fi +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + rm -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 +$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } +if test "${ac_cv_cxx_compiler_gnu+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_cxx_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 +$as_echo "$ac_cv_cxx_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GXX=yes +else + GXX= +fi +ac_test_CXXFLAGS=${CXXFLAGS+set} +ac_save_CXXFLAGS=$CXXFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 +$as_echo_n "checking whether $CXX accepts -g... " >&6; } +if test "${ac_cv_prog_cxx_g+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_save_cxx_werror_flag=$ac_cxx_werror_flag + ac_cxx_werror_flag=yes + ac_cv_prog_cxx_g=no + CXXFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_prog_cxx_g=yes +else + CXXFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + +else + ac_cxx_werror_flag=$ac_save_cxx_werror_flag + CXXFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_prog_cxx_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cxx_werror_flag=$ac_save_cxx_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 +$as_echo "$ac_cv_prog_cxx_g" >&6; } +if test "$ac_test_CXXFLAGS" = set; then + CXXFLAGS=$ac_save_CXXFLAGS +elif test $ac_cv_prog_cxx_g = yes; then + if test "$GXX" = yes; then + CXXFLAGS="-g -O2" + else + CXXFLAGS="-g" + fi +else + if test "$GXX" = yes; then + CXXFLAGS="-O2" + else + CXXFLAGS= + fi +fi +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + + + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the Intel C++ compiler" >&5 +$as_echo_n "checking whether we are using the Intel C++ compiler... " >&6; } +if test "${bakefile_cv_cxx_compiler___INTEL_COMPILER+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + #ifndef __INTEL_COMPILER + choke me + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + bakefile_cv_cxx_compiler___INTEL_COMPILER=yes +else + bakefile_cv_cxx_compiler___INTEL_COMPILER=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bakefile_cv_cxx_compiler___INTEL_COMPILER" >&5 +$as_echo "$bakefile_cv_cxx_compiler___INTEL_COMPILER" >&6; } + if test "x$bakefile_cv_cxx_compiler___INTEL_COMPILER" = "xyes"; then + :; INTELCXX=yes + else + :; + fi + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + + + if test "$INTELCXX" = "yes"; then + + + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using Intel C++ compiler v8 or later" >&5 +$as_echo_n "checking whether we are using Intel C++ compiler v8 or later... " >&6; } +if test "${bakefile_cv_cxx_compiler___INTEL_COMPILER_lt_800+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + #ifndef __INTEL_COMPILER || __INTEL_COMPILER < 800 + choke me + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + bakefile_cv_cxx_compiler___INTEL_COMPILER_lt_800=yes +else + bakefile_cv_cxx_compiler___INTEL_COMPILER_lt_800=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bakefile_cv_cxx_compiler___INTEL_COMPILER_lt_800" >&5 +$as_echo "$bakefile_cv_cxx_compiler___INTEL_COMPILER_lt_800" >&6; } + if test "x$bakefile_cv_cxx_compiler___INTEL_COMPILER_lt_800" = "xyes"; then + :; INTELCXX8=yes + else + :; + fi + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + + + + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using Intel C++ compiler v10 or later" >&5 +$as_echo_n "checking whether we are using Intel C++ compiler v10 or later... " >&6; } +if test "${bakefile_cv_cxx_compiler___INTEL_COMPILER_lt_1000+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + #ifndef __INTEL_COMPILER || __INTEL_COMPILER < 1000 + choke me + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + bakefile_cv_cxx_compiler___INTEL_COMPILER_lt_1000=yes +else + bakefile_cv_cxx_compiler___INTEL_COMPILER_lt_1000=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bakefile_cv_cxx_compiler___INTEL_COMPILER_lt_1000" >&5 +$as_echo "$bakefile_cv_cxx_compiler___INTEL_COMPILER_lt_1000" >&6; } + if test "x$bakefile_cv_cxx_compiler___INTEL_COMPILER_lt_1000" = "xyes"; then + :; INTELCXX10=yes + else + :; + fi + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + + fi + + if test "x$GCXX" != "xyes"; then + if test "xCXX" = "xC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the C++ compiler requires -ext o" >&5 +$as_echo_n "checking if the C++ compiler requires -ext o... " >&6; } +if test "${bakefile_cv_cxx_exto+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest.$ac_ext.o +if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + for ac_file in `(ls conftest.* 2>/dev/null)`; do + case $ac_file in + conftest.$ac_ext.o) + bakefile_cv_cxx_exto="-ext o" + ;; + *) + ;; + esac +done +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "cannot figure out if compiler needs -ext o: cannot compile +See \`config.log' for more details." "$LINENO" 5; } + +fi +rm -f conftest.$ac_ext.o conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bakefile_cv_cxx_exto" >&5 +$as_echo "$bakefile_cv_cxx_exto" >&6; } +if test "x$bakefile_cv_cxx_exto" '!=' "x"; then + if test "cxx" = "c"; then + CFLAGS="$bakefile_cv_cxx_exto $CFLAGS" + fi + if test "cxx" = "cxx"; then + CXXFLAGS="$bakefile_cv_cxx_exto $CXXFLAGS" + fi +fi + + if test "x$bakefile_cv_c_exto" '!=' "x"; then + unset ac_cv_prog_cc_g + ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if test "${ac_cv_prog_cc_g+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +else + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi + fi + fi + + case `uname -s` in + AIX*) + + + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the IBM xlC C++ compiler" >&5 +$as_echo_n "checking whether we are using the IBM xlC C++ compiler... " >&6; } +if test "${bakefile_cv_cxx_compiler___xlC__+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + #ifndef __xlC__ + choke me + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + bakefile_cv_cxx_compiler___xlC__=yes +else + bakefile_cv_cxx_compiler___xlC__=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bakefile_cv_cxx_compiler___xlC__" >&5 +$as_echo "$bakefile_cv_cxx_compiler___xlC__" >&6; } + if test "x$bakefile_cv_cxx_compiler___xlC__" = "xyes"; then + :; XLCXX=yes + else + :; + fi + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + + ;; + + Darwin) + + + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the Metrowerks C++ compiler" >&5 +$as_echo_n "checking whether we are using the Metrowerks C++ compiler... " >&6; } +if test "${bakefile_cv_cxx_compiler___MWERKS__+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + #ifndef __MWERKS__ + choke me + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + bakefile_cv_cxx_compiler___MWERKS__=yes +else + bakefile_cv_cxx_compiler___MWERKS__=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bakefile_cv_cxx_compiler___MWERKS__" >&5 +$as_echo "$bakefile_cv_cxx_compiler___MWERKS__" >&6; } + if test "x$bakefile_cv_cxx_compiler___MWERKS__" = "xyes"; then + :; MWCXX=yes + else + :; + fi + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + + if test "$MWCXX" != "yes"; then + + + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the IBM xlC C++ compiler" >&5 +$as_echo_n "checking whether we are using the IBM xlC C++ compiler... " >&6; } +if test "${bakefile_cv_cxx_compiler___xlC__+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + #ifndef __xlC__ + choke me + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + bakefile_cv_cxx_compiler___xlC__=yes +else + bakefile_cv_cxx_compiler___xlC__=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bakefile_cv_cxx_compiler___xlC__" >&5 +$as_echo "$bakefile_cv_cxx_compiler___xlC__" >&6; } + if test "x$bakefile_cv_cxx_compiler___xlC__" = "xyes"; then + :; XLCXX=yes + else + :; + fi + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + + fi + ;; + + IRIX*) + + + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the SGI C++ compiler" >&5 +$as_echo_n "checking whether we are using the SGI C++ compiler... " >&6; } +if test "${bakefile_cv_cxx_compiler__SGI_COMPILER_VERSION+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + #ifndef _SGI_COMPILER_VERSION + choke me + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + bakefile_cv_cxx_compiler__SGI_COMPILER_VERSION=yes +else + bakefile_cv_cxx_compiler__SGI_COMPILER_VERSION=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bakefile_cv_cxx_compiler__SGI_COMPILER_VERSION" >&5 +$as_echo "$bakefile_cv_cxx_compiler__SGI_COMPILER_VERSION" >&6; } + if test "x$bakefile_cv_cxx_compiler__SGI_COMPILER_VERSION" = "xyes"; then + :; SGICXX=yes + else + :; + fi + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + + ;; + + Linux*) + if test "$INTELCXX" != "yes"; then + + + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the Sun C++ compiler" >&5 +$as_echo_n "checking whether we are using the Sun C++ compiler... " >&6; } +if test "${bakefile_cv_cxx_compiler___SUNPRO_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + #ifndef __SUNPRO_CC + choke me + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + bakefile_cv_cxx_compiler___SUNPRO_CC=yes +else + bakefile_cv_cxx_compiler___SUNPRO_CC=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bakefile_cv_cxx_compiler___SUNPRO_CC" >&5 +$as_echo "$bakefile_cv_cxx_compiler___SUNPRO_CC" >&6; } + if test "x$bakefile_cv_cxx_compiler___SUNPRO_CC" = "xyes"; then + :; SUNCXX=yes + else + :; + fi + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + + fi + ;; + + HP-UX*) + + + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the HP C++ compiler" >&5 +$as_echo_n "checking whether we are using the HP C++ compiler... " >&6; } +if test "${bakefile_cv_cxx_compiler___HP_aCC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + #ifndef __HP_aCC + choke me + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + bakefile_cv_cxx_compiler___HP_aCC=yes +else + bakefile_cv_cxx_compiler___HP_aCC=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bakefile_cv_cxx_compiler___HP_aCC" >&5 +$as_echo "$bakefile_cv_cxx_compiler___HP_aCC" >&6; } + if test "x$bakefile_cv_cxx_compiler___HP_aCC" = "xyes"; then + :; HPCXX=yes + else + :; + fi + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + + ;; + + OSF1) + + + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the Compaq C++ compiler" >&5 +$as_echo_n "checking whether we are using the Compaq C++ compiler... " >&6; } +if test "${bakefile_cv_cxx_compiler___DECCXX+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + #ifndef __DECCXX + choke me + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + bakefile_cv_cxx_compiler___DECCXX=yes +else + bakefile_cv_cxx_compiler___DECCXX=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bakefile_cv_cxx_compiler___DECCXX" >&5 +$as_echo "$bakefile_cv_cxx_compiler___DECCXX" >&6; } + if test "x$bakefile_cv_cxx_compiler___DECCXX" = "xyes"; then + :; COMPAQCXX=yes + else + :; + fi + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + + ;; + + SunOS) + + + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the Sun C++ compiler" >&5 +$as_echo_n "checking whether we are using the Sun C++ compiler... " >&6; } +if test "${bakefile_cv_cxx_compiler___SUNPRO_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + #ifndef __SUNPRO_CC + choke me + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + bakefile_cv_cxx_compiler___SUNPRO_CC=yes +else + bakefile_cv_cxx_compiler___SUNPRO_CC=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bakefile_cv_cxx_compiler___SUNPRO_CC" >&5 +$as_echo "$bakefile_cv_cxx_compiler___SUNPRO_CC" >&6; } + if test "x$bakefile_cv_cxx_compiler___SUNPRO_CC" = "xyes"; then + :; SUNCXX=yes + else + :; + fi + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + + ;; + esac + fi + + + + + + + + + if test "x$BAKEFILE_HOST" = "x"; then + if test "x${host}" = "x" ; then + as_fn_error "You must call the autoconf \"CANONICAL_HOST\" macro in your configure.ac (or .in) file." "$LINENO" 5 + fi + + BAKEFILE_HOST="${host}" + fi + + if test "x$BAKEFILE_CHECK_BASICS" != "xno"; then + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_RANLIB+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 +$as_echo "$RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 +$as_echo "$ac_ct_RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_RANLIB" = x; then + RANLIB=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + RANLIB=$ac_ct_RANLIB + fi +else + RANLIB="$ac_cv_prog_RANLIB" +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 +$as_echo_n "checking whether ln -s works... " >&6; } +LN_S=$as_ln_s +if test "$LN_S" = "ln -s"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 +$as_echo "no, using $LN_S" >&6; } +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } +set x ${MAKE-make} +ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + cat >conftest.make <<\_ACEOF +SHELL = /bin/sh +all: + @echo '@@@%%%=$(MAKE)=@@@%%%' +_ACEOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; + *) + eval ac_cv_prog_make_${ac_make}_set=no;; +esac +rm -f conftest.make +fi +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + SET_MAKE= +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + SET_MAKE="MAKE=${MAKE-make}" +fi + + + + if test "x$SUNCXX" = "xyes"; then + AR=$CXX + AROPTIONS="-xar -o" + + elif test "x$SGICC" = "xyes"; then + AR=$CXX + AROPTIONS="-ar -o" + + else + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. +set dummy ${ac_tool_prefix}ar; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_AR+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AR"; then + ac_cv_prog_AR="$AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_AR="${ac_tool_prefix}ar" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AR=$ac_cv_prog_AR +if test -n "$AR"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 +$as_echo "$AR" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_AR"; then + ac_ct_AR=$AR + # Extract the first word of "ar", so it can be a program name with args. +set dummy ar; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_AR+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_AR"; then + ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_AR="ar" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_AR=$ac_cv_prog_ac_ct_AR +if test -n "$ac_ct_AR"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 +$as_echo "$ac_ct_AR" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_AR" = x; then + AR="ar" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + AR=$ac_ct_AR + fi +else + AR="$ac_cv_prog_AR" +fi + + AROPTIONS=rcu + fi + + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_STRIP+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 +$as_echo "$STRIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_STRIP="strip" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 +$as_echo "$ac_ct_STRIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_STRIP" = x; then + STRIP=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + STRIP=$ac_ct_STRIP + fi +else + STRIP="$ac_cv_prog_STRIP" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}nm", so it can be a program name with args. +set dummy ${ac_tool_prefix}nm; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_NM+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$NM"; then + ac_cv_prog_NM="$NM" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_NM="${ac_tool_prefix}nm" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +NM=$ac_cv_prog_NM +if test -n "$NM"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NM" >&5 +$as_echo "$NM" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_NM"; then + ac_ct_NM=$NM + # Extract the first word of "nm", so it can be a program name with args. +set dummy nm; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_NM+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_NM"; then + ac_cv_prog_ac_ct_NM="$ac_ct_NM" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_NM="nm" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_NM=$ac_cv_prog_ac_ct_NM +if test -n "$ac_ct_NM"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NM" >&5 +$as_echo "$ac_ct_NM" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_NM" = x; then + NM=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + NM=$ac_ct_NM + fi +else + NM="$ac_cv_prog_NM" +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for command to install directories" >&5 +$as_echo_n "checking for command to install directories... " >&6; } + INSTALL_TEST_DIR=acbftest$$ + $INSTALL -d $INSTALL_TEST_DIR > /dev/null 2>&1 + if test $? = 0 -a -d $INSTALL_TEST_DIR; then + rmdir $INSTALL_TEST_DIR + INSTALL_DIR='$(INSTALL) -d' + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL -d" >&5 +$as_echo "$INSTALL -d" >&6; } + else + INSTALL_DIR="mkdir -p" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: mkdir -p" >&5 +$as_echo "mkdir -p" >&6; } + fi + + + LDFLAGS_GUI= + case ${BAKEFILE_HOST} in + *-*-cygwin* | *-*-mingw32* ) + LDFLAGS_GUI="-mwindows" + esac + + + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if make is GNU make" >&5 +$as_echo_n "checking if make is GNU make... " >&6; } +if test "${bakefile_cv_prog_makeisgnu+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + + if ( ${SHELL-sh} -c "${MAKE-make} --version" 2> /dev/null | + egrep -s GNU > /dev/null); then + bakefile_cv_prog_makeisgnu="yes" + else + bakefile_cv_prog_makeisgnu="no" + fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bakefile_cv_prog_makeisgnu" >&5 +$as_echo "$bakefile_cv_prog_makeisgnu" >&6; } + + if test "x$bakefile_cv_prog_makeisgnu" = "xyes"; then + IF_GNU_MAKE="" + else + IF_GNU_MAKE="#" + fi + + + + PLATFORM_UNIX=0 + PLATFORM_WIN32=0 + PLATFORM_MSDOS=0 + PLATFORM_MAC=0 + PLATFORM_MACOS=0 + PLATFORM_MACOSX=0 + PLATFORM_OS2=0 + PLATFORM_BEOS=0 + + if test "x$BAKEFILE_FORCE_PLATFORM" = "x"; then + case "${BAKEFILE_HOST}" in + *-*-mingw32* ) + PLATFORM_WIN32=1 + ;; + *-pc-msdosdjgpp ) + PLATFORM_MSDOS=1 + ;; + *-pc-os2_emx | *-pc-os2-emx ) + PLATFORM_OS2=1 + ;; + *-*-darwin* ) + PLATFORM_MAC=1 + PLATFORM_MACOSX=1 + ;; + *-*-beos* ) + PLATFORM_BEOS=1 + ;; + powerpc-apple-macos* ) + PLATFORM_MAC=1 + PLATFORM_MACOS=1 + ;; + * ) + PLATFORM_UNIX=1 + ;; + esac + else + case "$BAKEFILE_FORCE_PLATFORM" in + win32 ) + PLATFORM_WIN32=1 + ;; + msdos ) + PLATFORM_MSDOS=1 + ;; + os2 ) + PLATFORM_OS2=1 + ;; + darwin ) + PLATFORM_MAC=1 + PLATFORM_MACOSX=1 + ;; + unix ) + PLATFORM_UNIX=1 + ;; + beos ) + PLATFORM_BEOS=1 + ;; + * ) + as_fn_error "Unknown platform: $BAKEFILE_FORCE_PLATFORM" "$LINENO" 5 + ;; + esac + fi + + + + + + + + + + + + # Check whether --enable-omf was given. +if test "${enable_omf+set}" = set; then : + enableval=$enable_omf; bk_os2_use_omf="$enableval" +fi + + + case "${BAKEFILE_HOST}" in + *-*-darwin* ) + if test "x$GCC" = "xyes"; then + CFLAGS="$CFLAGS -fno-common" + CXXFLAGS="$CXXFLAGS -fno-common" + fi + if test "x$XLCC" = "xyes"; then + CFLAGS="$CFLAGS -qnocommon" + CXXFLAGS="$CXXFLAGS -qnocommon" + fi + ;; + + *-pc-os2_emx | *-pc-os2-emx ) + if test "x$bk_os2_use_omf" = "xyes" ; then + AR=emxomfar + RANLIB=: + LDFLAGS="-Zomf $LDFLAGS" + CFLAGS="-Zomf $CFLAGS" + CXXFLAGS="-Zomf $CXXFLAGS" + OS2_LIBEXT="lib" + else + OS2_LIBEXT="a" + fi + ;; + + i*86-*-beos* ) + LDFLAGS="-L/boot/develop/lib/x86 $LDFLAGS" + ;; + esac + + + SO_SUFFIX="so" + SO_SUFFIX_MODULE="so" + EXEEXT="" + LIBPREFIX="lib" + LIBEXT=".a" + DLLPREFIX="lib" + DLLPREFIX_MODULE="" + DLLIMP_SUFFIX="" + dlldir="$libdir" + + case "${BAKEFILE_HOST}" in + ia64-hp-hpux* ) + ;; + *-hp-hpux* ) + SO_SUFFIX="sl" + SO_SUFFIX_MODULE="sl" + ;; + *-*-aix* ) + SO_SUFFIX="a" + SO_SUFFIX_MODULE="a" + ;; + *-*-cygwin* ) + SO_SUFFIX="dll" + SO_SUFFIX_MODULE="dll" + DLLIMP_SUFFIX="dll.a" + EXEEXT=".exe" + DLLPREFIX="cyg" + dlldir="$bindir" + ;; + *-*-mingw32* ) + SO_SUFFIX="dll" + SO_SUFFIX_MODULE="dll" + DLLIMP_SUFFIX="dll.a" + EXEEXT=".exe" + DLLPREFIX="" + dlldir="$bindir" + ;; + *-pc-msdosdjgpp ) + EXEEXT=".exe" + DLLPREFIX="" + dlldir="$bindir" + ;; + *-pc-os2_emx | *-pc-os2-emx ) + SO_SUFFIX="dll" + SO_SUFFIX_MODULE="dll" + DLLIMP_SUFFIX=$OS2_LIBEXT + EXEEXT=".exe" + DLLPREFIX="" + LIBPREFIX="" + LIBEXT=".$OS2_LIBEXT" + dlldir="$bindir" + ;; + *-*-darwin* ) + SO_SUFFIX="dylib" + SO_SUFFIX_MODULE="bundle" + ;; + esac + + if test "x$DLLIMP_SUFFIX" = "x" ; then + DLLIMP_SUFFIX="$SO_SUFFIX" + fi + + + + + + + + + + + + + PIC_FLAG="" + if test "x$GCC" = "xyes"; then + PIC_FLAG="-fPIC" + fi + + SHARED_LD_CC="\$(CC) -shared ${PIC_FLAG} -o" + SHARED_LD_CXX="\$(CXX) -shared ${PIC_FLAG} -o" + WINDOWS_IMPLIB=0 + + case "${BAKEFILE_HOST}" in + *-hp-hpux* ) + if test "x$GCC" != "xyes"; then + LDFLAGS="$LDFLAGS -L/usr/lib" + + SHARED_LD_CC="${CC} -b -o" + SHARED_LD_CXX="${CXX} -b -o" + PIC_FLAG="+Z" + fi + ;; + + *-*-linux* ) + if test "$INTELCC" = "yes" -a "$INTELCC8" != "yes"; then + PIC_FLAG="-KPIC" + elif test "x$SUNCXX" = "xyes"; then + SHARED_LD_CC="${CC} -G -o" + SHARED_LD_CXX="${CXX} -G -o" + PIC_FLAG="-KPIC" + fi + ;; + + *-*-solaris2* ) + if test "x$SUNCXX" = xyes ; then + SHARED_LD_CC="${CC} -G -o" + SHARED_LD_CXX="${CXX} -G -o" + PIC_FLAG="-KPIC" + fi + ;; + + *-*-darwin* ) + +D='$' +cat <<EOF >shared-ld-sh +#!/bin/sh +#----------------------------------------------------------------------------- +#-- Name: distrib/mac/shared-ld-sh +#-- Purpose: Link a mach-o dynamic shared library for Darwin / Mac OS X +#-- Author: Gilles Depeyrot +#-- Copyright: (c) 2002 Gilles Depeyrot +#-- Licence: any use permitted +#----------------------------------------------------------------------------- + +verbose=0 +args="" +objects="" +linking_flag="-dynamiclib" +ldargs="-r -keep_private_externs -nostdlib" + +if test "x${D}CXX" = "x"; then + CXX="c++" +fi + +while test ${D}# -gt 0; do + case ${D}1 in + + -v) + verbose=1 + ;; + + -o|-compatibility_version|-current_version|-framework|-undefined|-install_name) + # collect these options and values + args="${D}{args} ${D}1 ${D}2" + shift + ;; + + -arch|-isysroot) + # collect these options and values + ldargs="${D}{ldargs} ${D}1 ${D}2" + shift + ;; + + -s|-Wl,*) + # collect these load args + ldargs="${D}{ldargs} ${D}1" + ;; + + -l*|-L*|-flat_namespace|-headerpad_max_install_names) + # collect these options + args="${D}{args} ${D}1" + ;; + + -dynamiclib|-bundle) + linking_flag="${D}1" + ;; + + -*) + echo "shared-ld: unhandled option '${D}1'" + exit 1 + ;; + + *.o | *.a | *.dylib) + # collect object files + objects="${D}{objects} ${D}1" + ;; + + *) + echo "shared-ld: unhandled argument '${D}1'" + exit 1 + ;; + + esac + shift +done + +status=0 + +# +# Link one module containing all the others +# +if test ${D}{verbose} = 1; then + echo "${D}CXX ${D}{ldargs} ${D}{objects} -o master.${D}${D}.o" +fi +${D}CXX ${D}{ldargs} ${D}{objects} -o master.${D}${D}.o +status=${D}? + +# +# Link the shared library from the single module created, but only if the +# previous command didn't fail: +# +if test ${D}{status} = 0; then + if test ${D}{verbose} = 1; then + echo "${D}CXX ${D}{linking_flag} master.${D}${D}.o ${D}{args}" + fi + ${D}CXX ${D}{linking_flag} master.${D}${D}.o ${D}{args} + status=${D}? +fi + +# +# Remove intermediate module +# +rm -f master.${D}${D}.o + +exit ${D}status +EOF + + chmod +x shared-ld-sh + + SHARED_LD_MODULE_CC="`pwd`/shared-ld-sh -bundle -headerpad_max_install_names -o" + SHARED_LD_MODULE_CXX="CXX=\"\$(CXX)\" $SHARED_LD_MODULE_CC" + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gcc 3.1 or later" >&5 +$as_echo_n "checking for gcc 3.1 or later... " >&6; } +if test "${bakefile_cv_gcc31+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + #if (__GNUC__ < 3) || \ + ((__GNUC__ == 3) && (__GNUC_MINOR__ < 1)) + This is old gcc + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + + bakefile_cv_gcc31=yes + +else + + bakefile_cv_gcc31=no + + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bakefile_cv_gcc31" >&5 +$as_echo "$bakefile_cv_gcc31" >&6; } + if test "$bakefile_cv_gcc31" = "no"; then + SHARED_LD_CC="`pwd`/shared-ld-sh -dynamiclib -headerpad_max_install_names -o" + SHARED_LD_CXX="$SHARED_LD_CC" + else + SHARED_LD_CC="\${CC} -dynamiclib -single_module -headerpad_max_install_names -o" + SHARED_LD_CXX="\${CXX} -dynamiclib -single_module -headerpad_max_install_names -o" + fi + + if test "x$GCC" == "xyes"; then + PIC_FLAG="-dynamic -fPIC" + fi + if test "x$XLCC" = "xyes"; then + PIC_FLAG="-dynamic -DPIC" + fi + ;; + + *-*-aix* ) + if test "x$GCC" = "xyes"; then + PIC_FLAG="" + + case "${BAKEFILE_HOST}" in + *-*-aix5* ) + LD_EXPFULL="-Wl,-bexpfull" + ;; + esac + + SHARED_LD_CC="\$(CC) -shared $LD_EXPFULL -o" + SHARED_LD_CXX="\$(CXX) -shared $LD_EXPFULL -o" + else + # Extract the first word of "makeC++SharedLib", so it can be a program name with args. +set dummy makeC++SharedLib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_AIX_CXX_LD+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AIX_CXX_LD"; then + ac_cv_prog_AIX_CXX_LD="$AIX_CXX_LD" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_AIX_CXX_LD="makeC++SharedLib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_prog_AIX_CXX_LD" && ac_cv_prog_AIX_CXX_LD="/usr/lpp/xlC/bin/makeC++SharedLib" +fi +fi +AIX_CXX_LD=$ac_cv_prog_AIX_CXX_LD +if test -n "$AIX_CXX_LD"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AIX_CXX_LD" >&5 +$as_echo "$AIX_CXX_LD" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + SHARED_LD_CC="$AIX_CC_LD -p 0 -o" + SHARED_LD_CXX="$AIX_CXX_LD -p 0 -o" + fi + ;; + + *-*-beos* ) + SHARED_LD_CC="${LD} -nostart -o" + SHARED_LD_CXX="${LD} -nostart -o" + ;; + + *-*-irix* ) + if test "x$GCC" != "xyes"; then + PIC_FLAG="-KPIC" + fi + ;; + + *-*-cygwin* | *-*-mingw32* ) + PIC_FLAG="" + SHARED_LD_CC="\$(CC) -shared -o" + SHARED_LD_CXX="\$(CXX) -shared -o" + WINDOWS_IMPLIB=1 + ;; + + *-pc-os2_emx | *-pc-os2-emx ) + SHARED_LD_CC="`pwd`/dllar.sh -libf INITINSTANCE -libf TERMINSTANCE -o" + SHARED_LD_CXX="`pwd`/dllar.sh -libf INITINSTANCE -libf TERMINSTANCE -o" + PIC_FLAG="" + +D='$' +cat <<EOF >dllar.sh +#!/bin/sh +# +# dllar - a tool to build both a .dll and an .a file +# from a set of object (.o) files for EMX/OS2. +# +# Written by Andrew Zabolotny, bit@freya.etu.ru +# Ported to Unix like shell by Stefan Neis, Stefan.Neis@t-online.de +# +# This script will accept a set of files on the command line. +# All the public symbols from the .o files will be exported into +# a .DEF file, then linker will be run (through gcc) against them to +# build a shared library consisting of all given .o files. All libraries +# (.a) will be first decompressed into component .o files then act as +# described above. You can optionally give a description (-d "description") +# which will be put into .DLL. To see the list of accepted options (as well +# as command-line format) simply run this program without options. The .DLL +# is built to be imported by name (there is no guarantee that new versions +# of the library you build will have same ordinals for same symbols). +# +# dllar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# dllar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with dllar; see the file COPYING. If not, write to the Free +# Software Foundation, 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# To successfuly run this program you will need: +# - Current drive should have LFN support (HPFS, ext2, network, etc) +# (Sometimes dllar generates filenames which won't fit 8.3 scheme) +# - gcc +# (used to build the .dll) +# - emxexp +# (used to create .def file from .o files) +# - emximp +# (used to create .a file from .def file) +# - GNU text utilites (cat, sort, uniq) +# used to process emxexp output +# - GNU file utilities (mv, rm) +# - GNU sed +# - lxlite (optional, see flag below) +# (used for general .dll cleanup) +# + +flag_USE_LXLITE=1; + +# +# helper functions +# basnam, variant of basename, which does _not_ remove the path, _iff_ +# second argument (suffix to remove) is given +basnam(){ + case ${D}# in + 1) + echo ${D}1 | sed 's/.*\\///' | sed 's/.*\\\\//' + ;; + 2) + echo ${D}1 | sed 's/'${D}2'${D}//' + ;; + *) + echo "error in basnam ${D}*" + exit 8 + ;; + esac +} + +# Cleanup temporary files and output +CleanUp() { + cd ${D}curDir + for i in ${D}inputFiles ; do + case ${D}i in + *!) + rm -rf \`basnam ${D}i !\` + ;; + *) + ;; + esac + done + + # Kill result in case of failure as there is just to many stupid make/nmake + # things out there which doesn't do this. + if [ ${D}# -eq 0 ]; then + rm -f ${D}arcFile ${D}arcFile2 ${D}defFile ${D}dllFile + fi +} + +# Print usage and exit script with rc=1. +PrintHelp() { + echo 'Usage: dllar.sh [-o[utput] output_file] [-i[mport] importlib_name]' + echo ' [-name-mangler-script script.sh]' + echo ' [-d[escription] "dll descrption"] [-cc "CC"] [-f[lags] "CFLAGS"]' + echo ' [-ord[inals]] -ex[clude] "symbol(s)"' + echo ' [-libf[lags] "{INIT|TERM}{GLOBAL|INSTANCE}"] [-nocrt[dll]] [-nolxl[ite]]' + echo ' [*.o] [*.a]' + echo '*> "output_file" should have no extension.' + echo ' If it has the .o, .a or .dll extension, it is automatically removed.' + echo ' The import library name is derived from this and is set to "name".a,' + echo ' unless overridden by -import' + echo '*> "importlib_name" should have no extension.' + echo ' If it has the .o, or .a extension, it is automatically removed.' + echo ' This name is used as the import library name and may be longer and' + echo ' more descriptive than the DLL name which has to follow the old ' + echo ' 8.3 convention of FAT.' + echo '*> "script.sh may be given to override the output_file name by a' + echo ' different name. It is mainly useful if the regular make process' + echo ' of some package does not take into account OS/2 restriction of' + echo ' DLL name lengths. It takes the importlib name as input and is' + echo ' supposed to procude a shorter name as output. The script should' + echo ' expect to get importlib_name without extension and should produce' + echo ' a (max.) 8 letter name without extension.' + echo '*> "cc" is used to use another GCC executable. (default: gcc.exe)' + echo '*> "flags" should be any set of valid GCC flags. (default: -s -Zcrtdll)' + echo ' These flags will be put at the start of GCC command line.' + echo '*> -ord[inals] tells dllar to export entries by ordinals. Be careful.' + echo '*> -ex[clude] defines symbols which will not be exported. You can define' + echo ' multiple symbols, for example -ex "myfunc yourfunc _GLOBAL*".' + echo ' If the last character of a symbol is "*", all symbols beginning' + echo ' with the prefix before "*" will be exclude, (see _GLOBAL* above).' + echo '*> -libf[lags] can be used to add INITGLOBAL/INITINSTANCE and/or' + echo ' TERMGLOBAL/TERMINSTANCE flags to the dynamically-linked library.' + echo '*> -nocrt[dll] switch will disable linking the library against emx''s' + echo ' C runtime DLLs.' + echo '*> -nolxl[ite] switch will disable running lxlite on the resulting DLL.' + echo '*> All other switches (for example -L./ or -lmylib) will be passed' + echo ' unchanged to GCC at the end of command line.' + echo '*> If you create a DLL from a library and you do not specify -o,' + echo ' the basename for DLL and import library will be set to library name,' + echo ' the initial library will be renamed to 'name'_s.a (_s for static)' + echo ' i.e. "dllar gcc.a" will create gcc.dll and gcc.a, and the initial' + echo ' library will be renamed into gcc_s.a.' + echo '--------' + echo 'Example:' + echo ' dllar -o gcc290.dll libgcc.a -d "GNU C runtime library" -ord' + echo ' -ex "__main __ctordtor*" -libf "INITINSTANCE TERMINSTANCE"' + CleanUp + exit 1 +} + +# Execute a command. +# If exit code of the commnad <> 0 CleanUp() is called and we'll exit the script. +# @Uses Whatever CleanUp() uses. +doCommand() { + echo "${D}*" + eval ${D}* + rcCmd=${D}? + + if [ ${D}rcCmd -ne 0 ]; then + echo "command failed, exit code="${D}rcCmd + CleanUp + exit ${D}rcCmd + fi +} + +# main routine +# setup globals +cmdLine=${D}* +outFile="" +outimpFile="" +inputFiles="" +renameScript="" +description="" +CC=gcc.exe +CFLAGS="-s -Zcrtdll" +EXTRA_CFLAGS="" +EXPORT_BY_ORDINALS=0 +exclude_symbols="" +library_flags="" +curDir=\`pwd\` +curDirS=curDir +case ${D}curDirS in +*/) + ;; +*) + curDirS=${D}{curDirS}"/" + ;; +esac +# Parse commandline +libsToLink=0 +omfLinking=0 +while [ ${D}1 ]; do + case ${D}1 in + -ord*) + EXPORT_BY_ORDINALS=1; + ;; + -o*) + shift + outFile=${D}1 + ;; + -i*) + shift + outimpFile=${D}1 + ;; + -name-mangler-script) + shift + renameScript=${D}1 + ;; + -d*) + shift + description=${D}1 + ;; + -f*) + shift + CFLAGS=${D}1 + ;; + -c*) + shift + CC=${D}1 + ;; + -h*) + PrintHelp + ;; + -ex*) + shift + exclude_symbols=${D}{exclude_symbols}${D}1" " + ;; + -libf*) + shift + library_flags=${D}{library_flags}${D}1" " + ;; + -nocrt*) + CFLAGS="-s" + ;; + -nolxl*) + flag_USE_LXLITE=0 + ;; + -* | /*) + case ${D}1 in + -L* | -l*) + libsToLink=1 + ;; + -Zomf) + omfLinking=1 + ;; + *) + ;; + esac + EXTRA_CFLAGS=${D}{EXTRA_CFLAGS}" "${D}1 + ;; + *.dll) + EXTRA_CFLAGS="${D}{EXTRA_CFLAGS} \`basnam ${D}1 .dll\`" + if [ ${D}omfLinking -eq 1 ]; then + EXTRA_CFLAGS="${D}{EXTRA_CFLAGS}.lib" + else + EXTRA_CFLAGS="${D}{EXTRA_CFLAGS}.a" + fi + ;; + *) + found=0; + if [ ${D}libsToLink -ne 0 ]; then + EXTRA_CFLAGS=${D}{EXTRA_CFLAGS}" "${D}1 + else + for file in ${D}1 ; do + if [ -f ${D}file ]; then + inputFiles="${D}{inputFiles} ${D}file" + found=1 + fi + done + if [ ${D}found -eq 0 ]; then + echo "ERROR: No file(s) found: "${D}1 + exit 8 + fi + fi + ;; + esac + shift +done # iterate cmdline words + +# +if [ -z "${D}inputFiles" ]; then + echo "dllar: no input files" + PrintHelp +fi + +# Now extract all .o files from .a files +newInputFiles="" +for file in ${D}inputFiles ; do + case ${D}file in + *.a | *.lib) + case ${D}file in + *.a) + suffix=".a" + AR="ar" + ;; + *.lib) + suffix=".lib" + AR="emxomfar" + EXTRA_CFLAGS="${D}EXTRA_CFLAGS -Zomf" + ;; + *) + ;; + esac + dirname=\`basnam ${D}file ${D}suffix\`"_%" + mkdir ${D}dirname + if [ ${D}? -ne 0 ]; then + echo "Failed to create subdirectory ./${D}dirname" + CleanUp + exit 8; + fi + # Append '!' to indicate archive + newInputFiles="${D}newInputFiles ${D}{dirname}!" + doCommand "cd ${D}dirname; ${D}AR x ../${D}file" + cd ${D}curDir + found=0; + for subfile in ${D}dirname/*.o* ; do + if [ -f ${D}subfile ]; then + found=1 + if [ -s ${D}subfile ]; then + # FIXME: This should be: is file size > 32 byte, _not_ > 0! + newInputFiles="${D}newInputFiles ${D}subfile" + fi + fi + done + if [ ${D}found -eq 0 ]; then + echo "WARNING: there are no files in archive \\'${D}file\\'" + fi + ;; + *) + newInputFiles="${D}{newInputFiles} ${D}file" + ;; + esac +done +inputFiles="${D}newInputFiles" + +# Output filename(s). +do_backup=0; +if [ -z ${D}outFile ]; then + do_backup=1; + set outFile ${D}inputFiles; outFile=${D}2 +fi + +# If it is an archive, remove the '!' and the '_%' suffixes +case ${D}outFile in +*_%!) + outFile=\`basnam ${D}outFile _%!\` + ;; +*) + ;; +esac +case ${D}outFile in +*.dll) + outFile=\`basnam ${D}outFile .dll\` + ;; +*.DLL) + outFile=\`basnam ${D}outFile .DLL\` + ;; +*.o) + outFile=\`basnam ${D}outFile .o\` + ;; +*.obj) + outFile=\`basnam ${D}outFile .obj\` + ;; +*.a) + outFile=\`basnam ${D}outFile .a\` + ;; +*.lib) + outFile=\`basnam ${D}outFile .lib\` + ;; +*) + ;; +esac +case ${D}outimpFile in +*.a) + outimpFile=\`basnam ${D}outimpFile .a\` + ;; +*.lib) + outimpFile=\`basnam ${D}outimpFile .lib\` + ;; +*) + ;; +esac +if [ -z ${D}outimpFile ]; then + outimpFile=${D}outFile +fi +defFile="${D}{outFile}.def" +arcFile="${D}{outimpFile}.a" +arcFile2="${D}{outimpFile}.lib" + +#create ${D}dllFile as something matching 8.3 restrictions, +if [ -z ${D}renameScript ] ; then + dllFile="${D}outFile" +else + dllFile=\`${D}renameScript ${D}outimpFile\` +fi + +if [ ${D}do_backup -ne 0 ] ; then + if [ -f ${D}arcFile ] ; then + doCommand "mv ${D}arcFile ${D}{outFile}_s.a" + fi + if [ -f ${D}arcFile2 ] ; then + doCommand "mv ${D}arcFile2 ${D}{outFile}_s.lib" + fi +fi + +# Extract public symbols from all the object files. +tmpdefFile=${D}{defFile}_% +rm -f ${D}tmpdefFile +for file in ${D}inputFiles ; do + case ${D}file in + *!) + ;; + *) + doCommand "emxexp -u ${D}file >> ${D}tmpdefFile" + ;; + esac +done + +# Create the def file. +rm -f ${D}defFile +echo "LIBRARY \`basnam ${D}dllFile\` ${D}library_flags" >> ${D}defFile +dllFile="${D}{dllFile}.dll" +if [ ! -z ${D}description ]; then + echo "DESCRIPTION \\"${D}{description}\\"" >> ${D}defFile +fi +echo "EXPORTS" >> ${D}defFile + +doCommand "cat ${D}tmpdefFile | sort.exe | uniq.exe > ${D}{tmpdefFile}%" +grep -v "^ *;" < ${D}{tmpdefFile}% | grep -v "^ *${D}" >${D}tmpdefFile + +# Checks if the export is ok or not. +for word in ${D}exclude_symbols; do + grep -v ${D}word < ${D}tmpdefFile >${D}{tmpdefFile}% + mv ${D}{tmpdefFile}% ${D}tmpdefFile +done + + +if [ ${D}EXPORT_BY_ORDINALS -ne 0 ]; then + sed "=" < ${D}tmpdefFile | \\ + sed ' + N + : loop + s/^\\([0-9]\\+\\)\\([^;]*\\)\\(;.*\\)\\?/\\2 @\\1 NONAME/ + t loop + ' > ${D}{tmpdefFile}% + grep -v "^ *${D}" < ${D}{tmpdefFile}% > ${D}tmpdefFile +else + rm -f ${D}{tmpdefFile}% +fi +cat ${D}tmpdefFile >> ${D}defFile +rm -f ${D}tmpdefFile + +# Do linking, create implib, and apply lxlite. +gccCmdl=""; +for file in ${D}inputFiles ; do + case ${D}file in + *!) + ;; + *) + gccCmdl="${D}gccCmdl ${D}file" + ;; + esac +done +doCommand "${D}CC ${D}CFLAGS -Zdll -o ${D}dllFile ${D}defFile ${D}gccCmdl ${D}EXTRA_CFLAGS" +touch "${D}{outFile}.dll" + +doCommand "emximp -o ${D}arcFile ${D}defFile" +if [ ${D}flag_USE_LXLITE -ne 0 ]; then + add_flags=""; + if [ ${D}EXPORT_BY_ORDINALS -ne 0 ]; then + add_flags="-ynd" + fi + doCommand "lxlite -cs -t: -mrn -mln ${D}add_flags ${D}dllFile" +fi +doCommand "emxomf -s -l ${D}arcFile" + +# Successful exit. +CleanUp 1 +exit 0 +EOF + + chmod +x dllar.sh + ;; + + powerpc-apple-macos* | \ + *-*-freebsd* | *-*-openbsd* | *-*-netbsd* | *-*-k*bsd*-gnu | \ + *-*-mirbsd* | \ + *-*-sunos4* | \ + *-*-osf* | \ + *-*-dgux5* | \ + *-*-sysv5* | \ + *-pc-msdosdjgpp ) + ;; + + *) + as_fn_error "unknown system type $BAKEFILE_HOST." "$LINENO" 5 + esac + + if test "x$PIC_FLAG" != "x" ; then + PIC_FLAG="$PIC_FLAG -DPIC" + fi + + if test "x$SHARED_LD_MODULE_CC" = "x" ; then + SHARED_LD_MODULE_CC="$SHARED_LD_CC" + fi + if test "x$SHARED_LD_MODULE_CXX" = "x" ; then + SHARED_LD_MODULE_CXX="$SHARED_LD_CXX" + fi + + + + + + + + + + USE_SOVERSION=0 + USE_SOVERLINUX=0 + USE_SOVERSOLARIS=0 + USE_SOVERCYGWIN=0 + USE_SOTWOSYMLINKS=0 + USE_MACVERSION=0 + SONAME_FLAG= + + case "${BAKEFILE_HOST}" in + *-*-linux* | *-*-freebsd* | *-*-openbsd* | *-*-netbsd* | \ + *-*-k*bsd*-gnu | *-*-mirbsd* ) + if test "x$SUNCXX" = "xyes"; then + SONAME_FLAG="-h " + else + SONAME_FLAG="-Wl,-soname," + fi + USE_SOVERSION=1 + USE_SOVERLINUX=1 + USE_SOTWOSYMLINKS=1 + ;; + + *-*-solaris2* ) + SONAME_FLAG="-h " + USE_SOVERSION=1 + USE_SOVERSOLARIS=1 + ;; + + *-*-darwin* ) + USE_MACVERSION=1 + USE_SOVERSION=1 + USE_SOTWOSYMLINKS=1 + ;; + + *-*-cygwin* ) + USE_SOVERSION=1 + USE_SOVERCYGWIN=1 + ;; + esac + + + + + + + + + + + # Check whether --enable-dependency-tracking was given. +if test "${enable_dependency_tracking+set}" = set; then : + enableval=$enable_dependency_tracking; bk_use_trackdeps="$enableval" +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dependency tracking method" >&5 +$as_echo_n "checking for dependency tracking method... " >&6; } + + BK_DEPS="" + if test "x$bk_use_trackdeps" = "xno" ; then + DEPS_TRACKING=0 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5 +$as_echo "disabled" >&6; } + else + DEPS_TRACKING=1 + + if test "x$GCC" = "xyes"; then + DEPSMODE=gcc + case "${BAKEFILE_HOST}" in + *-*-darwin* ) + DEPSFLAG="-no-cpp-precomp -MMD" + ;; + * ) + DEPSFLAG="-MMD" + ;; + esac + { $as_echo "$as_me:${as_lineno-$LINENO}: result: gcc" >&5 +$as_echo "gcc" >&6; } + elif test "x$MWCC" = "xyes"; then + DEPSMODE=mwcc + DEPSFLAG="-MM" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: mwcc" >&5 +$as_echo "mwcc" >&6; } + elif test "x$SUNCC" = "xyes"; then + DEPSMODE=unixcc + DEPSFLAG="-xM1" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: Sun cc" >&5 +$as_echo "Sun cc" >&6; } + elif test "x$SGICC" = "xyes"; then + DEPSMODE=unixcc + DEPSFLAG="-M" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: SGI cc" >&5 +$as_echo "SGI cc" >&6; } + elif test "x$HPCC" = "xyes"; then + DEPSMODE=unixcc + DEPSFLAG="+make" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: HP cc" >&5 +$as_echo "HP cc" >&6; } + elif test "x$COMPAQCC" = "xyes"; then + DEPSMODE=gcc + DEPSFLAG="-MD" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: Compaq cc" >&5 +$as_echo "Compaq cc" >&6; } + else + DEPS_TRACKING=0 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 +$as_echo "none" >&6; } + fi + + if test $DEPS_TRACKING = 1 ; then + +D='$' +cat <<EOF >bk-deps +#!/bin/sh + +# This script is part of Bakefile (http://www.bakefile.org) autoconf +# script. It is used to track C/C++ files dependencies in portable way. +# +# Permission is given to use this file in any way. + +DEPSMODE=${DEPSMODE} +DEPSFLAG="${DEPSFLAG}" +DEPSDIRBASE=.deps + +if test ${D}DEPSMODE = gcc ; then + ${D}* ${D}{DEPSFLAG} + status=${D}? + + # determine location of created files: + while test ${D}# -gt 0; do + case "${D}1" in + -o ) + shift + objfile=${D}1 + ;; + -* ) + ;; + * ) + srcfile=${D}1 + ;; + esac + shift + done + objfilebase=\`basename ${D}objfile\` + builddir=\`dirname ${D}objfile\` + depfile=\`basename ${D}srcfile | sed -e 's/\\..*${D}/.d/g'\` + depobjname=\`echo ${D}depfile |sed -e 's/\\.d/.o/g'\` + depsdir=${D}builddir/${D}DEPSDIRBASE + mkdir -p ${D}depsdir + + # if the compiler failed, we're done: + if test ${D}{status} != 0 ; then + rm -f ${D}depfile + exit ${D}{status} + fi + + # move created file to the location we want it in: + if test -f ${D}depfile ; then + sed -e "s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{depsdir}/${D}{objfilebase}.d + rm -f ${D}depfile + else + # "g++ -MMD -o fooobj.o foosrc.cpp" produces fooobj.d + depfile=\`echo "${D}objfile" | sed -e 's/\\..*${D}/.d/g'\` + if test ! -f ${D}depfile ; then + # "cxx -MD -o fooobj.o foosrc.cpp" creates fooobj.o.d (Compaq C++) + depfile="${D}objfile.d" + fi + if test -f ${D}depfile ; then + sed -e "\\,^${D}objfile,!s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{depsdir}/${D}{objfilebase}.d + rm -f ${D}depfile + fi + fi + exit 0 + +elif test ${D}DEPSMODE = mwcc ; then + ${D}* || exit ${D}? + # Run mwcc again with -MM and redirect into the dep file we want + # NOTE: We can't use shift here because we need ${D}* to be valid + prevarg= + for arg in ${D}* ; do + if test "${D}prevarg" = "-o"; then + objfile=${D}arg + else + case "${D}arg" in + -* ) + ;; + * ) + srcfile=${D}arg + ;; + esac + fi + prevarg="${D}arg" + done + + objfilebase=\`basename ${D}objfile\` + builddir=\`dirname ${D}objfile\` + depsdir=${D}builddir/${D}DEPSDIRBASE + mkdir -p ${D}depsdir + + ${D}* ${D}DEPSFLAG >${D}{depsdir}/${D}{objfilebase}.d + exit 0 + +elif test ${D}DEPSMODE = unixcc; then + ${D}* || exit ${D}? + # Run compiler again with deps flag and redirect into the dep file. + # It doesn't work if the '-o FILE' option is used, but without it the + # dependency file will contain the wrong name for the object. So it is + # removed from the command line, and the dep file is fixed with sed. + cmd="" + while test ${D}# -gt 0; do + case "${D}1" in + -o ) + shift + objfile=${D}1 + ;; + * ) + eval arg${D}#=\\${D}1 + cmd="${D}cmd \\${D}arg${D}#" + ;; + esac + shift + done + + objfilebase=\`basename ${D}objfile\` + builddir=\`dirname ${D}objfile\` + depsdir=${D}builddir/${D}DEPSDIRBASE + mkdir -p ${D}depsdir + + eval "${D}cmd ${D}DEPSFLAG" | sed "s|.*:|${D}objfile:|" >${D}{depsdir}/${D}{objfilebase}.d + exit 0 + +else + ${D}* + exit ${D}? +fi +EOF + + chmod +x bk-deps + BK_DEPS="`pwd`/bk-deps" + fi + fi + + + + + + case ${BAKEFILE_HOST} in + *-*-cygwin* | *-*-mingw32* ) + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}windres", so it can be a program name with args. +set dummy ${ac_tool_prefix}windres; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_WINDRES+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$WINDRES"; then + ac_cv_prog_WINDRES="$WINDRES" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_WINDRES="${ac_tool_prefix}windres" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +WINDRES=$ac_cv_prog_WINDRES +if test -n "$WINDRES"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $WINDRES" >&5 +$as_echo "$WINDRES" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_WINDRES"; then + ac_ct_WINDRES=$WINDRES + # Extract the first word of "windres", so it can be a program name with args. +set dummy windres; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_WINDRES+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_WINDRES"; then + ac_cv_prog_ac_ct_WINDRES="$ac_ct_WINDRES" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_WINDRES="windres" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_WINDRES=$ac_cv_prog_ac_ct_WINDRES +if test -n "$ac_ct_WINDRES"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_WINDRES" >&5 +$as_echo "$ac_ct_WINDRES" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_WINDRES" = x; then + WINDRES="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + WINDRES=$ac_ct_WINDRES + fi +else + WINDRES="$ac_cv_prog_WINDRES" +fi + + ;; + + *-*-darwin* | powerpc-apple-macos* ) + # Extract the first word of "Rez", so it can be a program name with args. +set dummy Rez; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_REZ+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$REZ"; then + ac_cv_prog_REZ="$REZ" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_REZ="Rez" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_prog_REZ" && ac_cv_prog_REZ="/Developer/Tools/Rez" +fi +fi +REZ=$ac_cv_prog_REZ +if test -n "$REZ"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $REZ" >&5 +$as_echo "$REZ" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + # Extract the first word of "SetFile", so it can be a program name with args. +set dummy SetFile; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_SETFILE+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$SETFILE"; then + ac_cv_prog_SETFILE="$SETFILE" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_SETFILE="SetFile" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_prog_SETFILE" && ac_cv_prog_SETFILE="/Developer/Tools/SetFile" +fi +fi +SETFILE=$ac_cv_prog_SETFILE +if test -n "$SETFILE"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SETFILE" >&5 +$as_echo "$SETFILE" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + ;; + esac + + + + + + + + + + BAKEFILE_BAKEFILE_M4_VERSION="0.2.8" + + +BAKEFILE_AUTOCONF_INC_M4_VERSION="0.2.8" + + COND_DEBUG_0="#" + if test "x$DEBUG" = "x0" ; then + COND_DEBUG_0="" + fi + + COND_DEBUG_1="#" + if test "x$DEBUG" = "x1" ; then + COND_DEBUG_1="" + fi + + COND_DEPS_TRACKING_0="#" + if test "x$DEPS_TRACKING" = "x0" ; then + COND_DEPS_TRACKING_0="" + fi + + COND_DEPS_TRACKING_1="#" + if test "x$DEPS_TRACKING" = "x1" ; then + COND_DEPS_TRACKING_1="" + fi + + COND_PLATFORM_MACOSX_0_USE_SOVERCYGWIN_0_USE_SOVERSION_1="#" + if test "x$PLATFORM_MACOSX" = "x0" -a "x$USE_SOVERCYGWIN" = "x0" -a "x$USE_SOVERSION" = "x1" ; then + COND_PLATFORM_MACOSX_0_USE_SOVERCYGWIN_0_USE_SOVERSION_1="" + fi + + COND_PLATFORM_MACOSX_0_USE_SOVERSION_1="#" + if test "x$PLATFORM_MACOSX" = "x0" -a "x$USE_SOVERSION" = "x1" ; then + COND_PLATFORM_MACOSX_0_USE_SOVERSION_1="" + fi + + COND_PLATFORM_MACOSX_1="#" + if test "x$PLATFORM_MACOSX" = "x1" ; then + COND_PLATFORM_MACOSX_1="" + fi + + COND_PLATFORM_MACOSX_1_USE_SOVERSION_1="#" + if test "x$PLATFORM_MACOSX" = "x1" -a "x$USE_SOVERSION" = "x1" ; then + COND_PLATFORM_MACOSX_1_USE_SOVERSION_1="" + fi + + COND_PLATFORM_MAC_0="#" + if test "x$PLATFORM_MAC" = "x0" ; then + COND_PLATFORM_MAC_0="" + fi + + COND_PLATFORM_MAC_1="#" + if test "x$PLATFORM_MAC" = "x1" ; then + COND_PLATFORM_MAC_1="" + fi + + COND_PLATFORM_OS2_1="#" + if test "x$PLATFORM_OS2" = "x1" ; then + COND_PLATFORM_OS2_1="" + fi + + COND_SAMPLES_1="#" + if test "x$SAMPLES" = "x1" ; then + COND_SAMPLES_1="" + fi + + COND_SHARED_0="#" + if test "x$SHARED" = "x0" ; then + COND_SHARED_0="" + fi + + COND_SHARED_1="#" + if test "x$SHARED" = "x1" ; then + COND_SHARED_1="" + fi + + COND_USE_SOTWOSYMLINKS_1="#" + if test "x$USE_SOTWOSYMLINKS" = "x1" ; then + COND_USE_SOTWOSYMLINKS_1="" + fi + + COND_USE_SOVERCYGWIN_1_USE_SOVERSION_1="#" + if test "x$USE_SOVERCYGWIN" = "x1" -a "x$USE_SOVERSION" = "x1" ; then + COND_USE_SOVERCYGWIN_1_USE_SOVERSION_1="" + fi + + COND_USE_SOVERLINUX_1="#" + if test "x$USE_SOVERLINUX" = "x1" ; then + COND_USE_SOVERLINUX_1="" + fi + + COND_USE_SOVERSION_0="#" + if test "x$USE_SOVERSION" = "x0" ; then + COND_USE_SOVERSION_0="" + fi + + COND_USE_SOVERSION_1_USE_SOVERSOLARIS_1="#" + if test "x$USE_SOVERSION" = "x1" -a "x$USE_SOVERSOLARIS" = "x1" ; then + COND_USE_SOVERSION_1_USE_SOVERSOLARIS_1="" + fi + + COND_USE_SOVERSOLARIS_1="#" + if test "x$USE_SOVERSOLARIS" = "x1" ; then + COND_USE_SOVERSOLARIS_1="" + fi + + COND_WINDOWS_IMPLIB_1="#" + if test "x$WINDOWS_IMPLIB" = "x1" ; then + COND_WINDOWS_IMPLIB_1="" + fi + + + + if test "$BAKEFILE_AUTOCONF_INC_M4_VERSION" = "" ; then + as_fn_error "No version found in autoconf_inc.m4 - bakefile macro was changed to take additional argument, perhaps configure.in wasn't updated (see the documentation)?" "$LINENO" 5 + fi + + if test "$BAKEFILE_BAKEFILE_M4_VERSION" != "$BAKEFILE_AUTOCONF_INC_M4_VERSION" ; then + as_fn_error "Versions of Bakefile used to generate makefiles ($BAKEFILE_AUTOCONF_INC_M4_VERSION) and configure ($BAKEFILE_BAKEFILE_M4_VERSION) do not match." "$LINENO" 5 + fi + +ac_config_files="$ac_config_files Makefile build/autoconf/muparser.pc" + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes: double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \. + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + test "x$cache_file" != "x/dev/null" && + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 +$as_echo "$as_me: updating cache $cache_file" >&6;} + cat confcache >$cache_file + else + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# Transform confdefs.h into DEFS. +# Protect against shell expansion while executing Makefile rules. +# Protect against Makefile macro expansion. +# +# If the first sed substitution is executed (which looks for macros that +# take arguments), then branch to the quote section. Otherwise, +# look for a macro that doesn't take arguments. +ac_script=' +:mline +/\\$/{ + N + s,\\\n,, + b mline +} +t clear +:clear +s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g +t quote +s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g +t quote +b any +:quote +s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g +s/\[/\\&/g +s/\]/\\&/g +s/\$/$$/g +H +:any +${ + g + s/^\n// + s/\n/ /g + p +} +' +DEFS=`sed -n "$ac_script" confdefs.h` + + +ac_libobjs= +ac_ltlibobjs= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + + +: ${CONFIG_STATUS=./config.status} +ac_write_fail=0 +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} +as_write_fail=0 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false + +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error ERROR [LINENO LOG_FD] +# --------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with status $?, using 1 if that was 0. +as_fn_error () +{ + as_status=$?; test $as_status -eq 0 && as_status=1 + if test "$3"; then + as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + fi + $as_echo "$as_me: error: $1" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -p' + fi +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in #( + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +_ASEOF +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# Save the log message, to keep $0 and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by muParser $as_me 1.34, which was +generated by GNU Autoconf 2.64. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +case $ac_config_files in *" +"*) set x $ac_config_files; shift; ac_config_files=$*;; +esac + + + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# Files that config.status was made for. +config_files="$ac_config_files" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +ac_cs_usage="\ +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. + +Usage: $0 [OPTION]... [TAG]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + +Configuration files: +$config_files + +Report bugs to <frm@users.sourceforge.net>." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_version="\\ +muParser config.status 1.34 +configured by $0, generated by GNU Autoconf 2.64, + with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" + +Copyright (C) 2009 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +INSTALL='$INSTALL' +AWK='$AWK' +test -n "\$AWK" || AWK=awk +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + $as_echo "$ac_cs_version"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" + ac_need_defaults=false;; + --he | --h | --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) as_fn_error "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; + + *) as_fn_append ac_config_targets " $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +if \$ac_cs_recheck; then + set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' + export CONFIG_SHELL + exec "\$@" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + $as_echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "build/autoconf/muparser.pc") CONFIG_FILES="$CONFIG_FILES build/autoconf/muparser.pc" ;; + + *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= + trap 'exit_status=$? + { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status +' 0 + trap 'as_fn_exit 1' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5 + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$tmp/subs1.awk" && +_ACEOF + + +{ + echo "cat >conf$$subs.awk <<_ACEOF" && + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" +} >conf$$subs.sh || + as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + . ./conf$$subs.sh || + as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 + + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then + break + elif $ac_last_try; then + as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done +rm -f conf$$subs.sh + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>"\$tmp/subs1.awk" <<\\_ACAWK && +_ACEOF +sed -n ' +h +s/^/S["/; s/!.*/"]=/ +p +g +s/^[^!]*!// +:repl +t repl +s/'"$ac_delim"'$// +t delim +:nl +h +s/\(.\{148\}\).*/\1/ +t more1 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ +p +n +b repl +:more1 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t nl +:delim +h +s/\(.\{148\}\).*/\1/ +t more2 +s/["\\]/\\&/g; s/^/"/; s/$/"/ +p +b +:more2 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t delim +' <conf$$subs.awk | sed ' +/^[^""]/{ + N + s/\n// +} +' >>$CONFIG_STATUS || ac_write_fail=1 +rm -f conf$$subs.awk +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACAWK +cat >>"\$tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line +} + +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ + || as_fn_error "could not setup config files machinery" "$LINENO" 5 +_ACEOF + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/ +s/:*\${srcdir}:*/:/ +s/:*@srcdir@:*/:/ +s/^\([^=]*=[ ]*\):*/\1/ +s/:*$// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +fi # test -n "$CONFIG_FILES" + + +eval set X " :F $CONFIG_FILES " +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$tmp/stdin" \ + || as_fn_error "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir="$ac_dir"; as_fn_mkdir_p + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; + esac +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_sed_extra="$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ + || as_fn_error "could not create $ac_file" "$LINENO" 5 + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&5 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&2;} + + rm -f "$tmp/stdin" + case $ac_file in + -) cat "$tmp/out" && rm -f "$tmp/out";; + *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; + esac \ + || as_fn_error "could not create $ac_file" "$LINENO" 5 + ;; + + + + esac + +done # for ac_tag + + +as_fn_exit 0 +_ACEOF +ac_clean_files=$ac_clean_files_save + +test $ac_write_fail = 0 || + as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5 + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || as_fn_exit $? +fi +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} +fi + + + + +## CONFIGURE END MESSAGE +##################################################################### + +echo +echo " ----------------------------------------------------------------" +echo " Configuration for $PACKAGE_NAME $PACKAGE_VERSION successfully completed." +echo " Summary of main configuration settings for $PACKAGE_NAME:" + + if [ "$SHARED" = "1" ]; then + echo " - SHARED mode" + else + echo " - STATIC mode" + fi + + + if [ "$DEBUG" = "1" ]; then + echo " - DEBUG build" + else + echo " - RELEASE build" + fi + +if [ "$SAMPLES" = "1" ]; then + echo " - SAMPLES enabled" +else + echo " - SAMPLES disabled" +fi +echo " Now, just run make." +echo " ----------------------------------------------------------------" +echo diff --git a/AMDiS/lib/muparser_v134/docs/Doxyfile b/AMDiS/lib/muparser_v134/docs/Doxyfile new file mode 100644 index 0000000000000000000000000000000000000000..e067e0ea783e714b8cdd2c6f4c66623a4b338f88 --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/Doxyfile @@ -0,0 +1,1504 @@ +# Doxyfile 1.5.8 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = "muParser API -" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = 1.30 + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = html/ + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Farsi, Finnish, French, German, Greek, +# Hungarian, Italian, Japanese, Japanese-en (Japanese with English messages), +# Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, Polish, +# Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, Slovene, +# Spanish, Swedish, and Ukrainian. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = NO + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = YES + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 16 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it parses. +# With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this tag. +# The format is ext=language, where ext is a file extension, and language is one of +# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP, +# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat +# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C + +EXTENSION_MAPPING = + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = YES + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen to replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penality. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will rougly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols + +SYMBOL_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = YES + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = YES + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = YES + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespace are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = NO + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = NO + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command <command> <input-file>, where <command> is the value of +# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by +# doxygen. The layout file controls the global structure of the generated output files +# in an output format independent way. The create the layout file that represents +# doxygen's defaults, run doxygen with the -l option. You can optionally specify a +# file name after the option, if omitted DoxygenLayout.xml will be used as the name +# of the layout file. + +LAYOUT_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = html/misc/Main.txt \ + html/misc/example.txt \ + ../src/ \ + ../include/ + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 + +FILE_PATTERNS = + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = NO + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = html/misc/ + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command <filter> <input-file>, where <filter> +# is the value of the INPUT_FILTER tag, and <input-file> is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# is applied to all files. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = NO + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = NO + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = YES + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = classdocu/ + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = html/misc/footer.html + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = NO + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER +# are set, an additional index file will be generated that can be used as input for +# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated +# HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add. +# For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see +# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">Qt Help Project / Custom Filters</a>. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's +# filter section matches. +# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">Qt Help Project / Filter Attributes</a>. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. + +ENUM_VALUES_PER_LINE = 4 + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to FRAME, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, +# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are +# probably better off using the HTML help feature. Other possible values +# for this tag are: HIERARCHIES, which will generate the Groups, Directories, +# and Class Hierarchy pages using a tree view instead of an ordered list; +# ALL, which combines the behavior of FRAME and HIERARCHIES; and NONE, which +# disables this behavior completely. For backwards compatibility with previous +# releases of Doxygen, the values YES and NO are equivalent to FRAME and NONE +# respectively. + +GENERATE_TREEVIEW = NONE + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = NO + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = NO + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. This is useful +# if you want to understand what is going on. On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# in the INCLUDE_PATH (see below) will be search if a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse +# the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option is superseded by the HAVE_DOT option below. This is only a +# fallback. It is recommended to install and use dot, since it yields more +# powerful graphs. + +CLASS_DIAGRAMS = YES + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = YES + +# By default doxygen will write a font called FreeSans.ttf to the output +# directory and reference it in all dot files that doxygen generates. This +# font does not include all possible unicode characters however, so when you need +# these (or just want a differently looking font) you can specify the font name +# using DOT_FONTNAME. You need need to make sure dot is able to find the font, +# which can be done by putting it in a standard location or by setting the +# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory +# containing the font. + +DOT_FONTNAME = FreeSans + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the output directory to look for the +# FreeSans.ttf font (which doxygen will put there itself). If you specify a +# different font using DOT_FONTNAME you can set the path where dot +# can find it using this tag. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = NO + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are png, jpg, or gif +# If left blank png will be used. + +DOT_IMAGE_FORMAT = jpg + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = "C:\Program Files (x86)\Graphviz2.20\bin" + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES + +#--------------------------------------------------------------------------- +# Options related to the search engine +#--------------------------------------------------------------------------- + +# The SEARCHENGINE tag specifies whether or not a search engine should be +# used. If set to NO the values of all tags below this one will be ignored. + +SEARCHENGINE = NO diff --git a/AMDiS/lib/muparser_v134/docs/html/images/Crystal_Clear_app_utilities.png b/AMDiS/lib/muparser_v134/docs/html/images/Crystal_Clear_app_utilities.png new file mode 100755 index 0000000000000000000000000000000000000000..e38ca2b32e1ef899272b1bf4189140cb9b569988 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/Crystal_Clear_app_utilities.png differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/api.png b/AMDiS/lib/muparser_v134/docs/html/images/api.png new file mode 100755 index 0000000000000000000000000000000000000000..7c3af3b16b2bfb398a08db3b666c4c5c3a5a4e56 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/api.png differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/api_dark.png b/AMDiS/lib/muparser_v134/docs/html/images/api_dark.png new file mode 100755 index 0000000000000000000000000000000000000000..e58e04bc15593eaa63165b1d7c61b9527ed4bba5 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/api_dark.png differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/bench2.jpg b/AMDiS/lib/muparser_v134/docs/html/images/bench2.jpg new file mode 100644 index 0000000000000000000000000000000000000000..2b25fdeb3c2ab635db109e26206cd81866dc50fc Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/bench2.jpg differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/blocks.png b/AMDiS/lib/muparser_v134/docs/html/images/blocks.png new file mode 100755 index 0000000000000000000000000000000000000000..58b323e04937003709cf1cdedb95386408caa111 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/blocks.png differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/build.png b/AMDiS/lib/muparser_v134/docs/html/images/build.png new file mode 100755 index 0000000000000000000000000000000000000000..294b4e0f012ef733db77653a0897724e7992dcda Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/build.png differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/bytecode.png b/AMDiS/lib/muparser_v134/docs/html/images/bytecode.png new file mode 100644 index 0000000000000000000000000000000000000000..3faa404e6b27e97e430537ebcb2370f28e8967a4 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/bytecode.png differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/caption.png b/AMDiS/lib/muparser_v134/docs/html/images/caption.png new file mode 100755 index 0000000000000000000000000000000000000000..308abd7d321e99761dfe925d01c1bf7c74632084 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/caption.png differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/diff.png b/AMDiS/lib/muparser_v134/docs/html/images/diff.png new file mode 100644 index 0000000000000000000000000000000000000000..9b3aad8c16a4ec692ea37e5f2000cf68d9817e65 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/diff.png differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/download.gif b/AMDiS/lib/muparser_v134/docs/html/images/download.gif new file mode 100644 index 0000000000000000000000000000000000000000..b50dcc68bb0ce3e99bc4d8d2246574be6fecdcb8 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/download.gif differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/download.png b/AMDiS/lib/muparser_v134/docs/html/images/download.png new file mode 100755 index 0000000000000000000000000000000000000000..77a1b8778d4e20027d225cbf0e7b18ad7f4b4986 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/download.png differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/download_dark.png b/AMDiS/lib/muparser_v134/docs/html/images/download_dark.png new file mode 100755 index 0000000000000000000000000000000000000000..2dc6fa29a485d048bc4b4963c9fd7558e0225d61 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/download_dark.png differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/download_muparser.png b/AMDiS/lib/muparser_v134/docs/html/images/download_muparser.png new file mode 100644 index 0000000000000000000000000000000000000000..03638f6303c3a2f4639dfaa4701ffd9daba11f3d Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/download_muparser.png differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/download_muparser_.png b/AMDiS/lib/muparser_v134/docs/html/images/download_muparser_.png new file mode 100644 index 0000000000000000000000000000000000000000..7df6ee223517f0b918e266ca270a494406a76870 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/download_muparser_.png differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/grad1.jpg b/AMDiS/lib/muparser_v134/docs/html/images/grad1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..4b8fa756760126de03281064bb5ddcd5d3a38060 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/grad1.jpg differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/grad2.jpg b/AMDiS/lib/muparser_v134/docs/html/images/grad2.jpg new file mode 100644 index 0000000000000000000000000000000000000000..659a36ec5b39a6d85cf9cc9045cfde7f9afac3b8 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/grad2.jpg differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/grad2.xcf b/AMDiS/lib/muparser_v134/docs/html/images/grad2.xcf new file mode 100644 index 0000000000000000000000000000000000000000..bb64620987df64038da8d3a47967335610b38b86 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/grad2.xcf differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/grad3.jpg b/AMDiS/lib/muparser_v134/docs/html/images/grad3.jpg new file mode 100644 index 0000000000000000000000000000000000000000..a2209d910ce7b788e0be7b9a1b0e33cbb42e2eb8 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/grad3.jpg differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/help.gif b/AMDiS/lib/muparser_v134/docs/html/images/help.gif new file mode 100644 index 0000000000000000000000000000000000000000..c49667f01c125bee441a82e4bd092a6411b8f259 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/help.gif differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/help.png b/AMDiS/lib/muparser_v134/docs/html/images/help.png new file mode 100755 index 0000000000000000000000000000000000000000..4e84cd531451ad70d55abc48fca41b791586baec Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/help.png differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/home.png b/AMDiS/lib/muparser_v134/docs/html/images/home.png new file mode 100755 index 0000000000000000000000000000000000000000..78908a5669e33d0e4675efbb26bf890d2e70b8cc Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/home.png differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/home_dark.png b/AMDiS/lib/muparser_v134/docs/html/images/home_dark.png new file mode 100755 index 0000000000000000000000000000000000000000..820028a97955895db261d6bbda2b915b374c2233 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/home_dark.png differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/info.png b/AMDiS/lib/muparser_v134/docs/html/images/info.png new file mode 100755 index 0000000000000000000000000000000000000000..c4f73cb9cc513e81549fd0d91df0b51f32a82fa0 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/info.png differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/list.png b/AMDiS/lib/muparser_v134/docs/html/images/list.png new file mode 100755 index 0000000000000000000000000000000000000000..f301a07af9ec7cc0572c03748f23b7c5ee79b5cc Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/list.png differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/logo.xcf b/AMDiS/lib/muparser_v134/docs/html/images/logo.xcf new file mode 100644 index 0000000000000000000000000000000000000000..4db51e12057b7ab13da13fdc7f9072c40def58d3 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/logo.xcf differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/mathparser.jpg b/AMDiS/lib/muparser_v134/docs/html/images/mathparser.jpg new file mode 100644 index 0000000000000000000000000000000000000000..1c9e91c7c65ae94e880b48a263decdeb1920bf90 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/mathparser.jpg differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/mathparser_logo.gif b/AMDiS/lib/muparser_v134/docs/html/images/mathparser_logo.gif new file mode 100644 index 0000000000000000000000000000000000000000..7ce0dc8ead2ee7f11cb076fcc03daa088b3df91e Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/mathparser_logo.gif differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/mathparser_small.jpg b/AMDiS/lib/muparser_v134/docs/html/images/mathparser_small.jpg new file mode 100644 index 0000000000000000000000000000000000000000..66a866eb98dc1bba4b6e7701d569a69a18f0bfde Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/mathparser_small.jpg differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/muParser.png b/AMDiS/lib/muparser_v134/docs/html/images/muParser.png new file mode 100644 index 0000000000000000000000000000000000000000..af97a17281b0bff3ce9da43309674833ded72ace Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/muParser.png differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/muParserNET.png b/AMDiS/lib/muparser_v134/docs/html/images/muParserNET.png new file mode 100644 index 0000000000000000000000000000000000000000..fc87ee2f2781da4d918a00287cf9dcbe38a723a3 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/muParserNET.png differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/muParserNET.xcf b/AMDiS/lib/muparser_v134/docs/html/images/muParserNET.xcf new file mode 100644 index 0000000000000000000000000000000000000000..9c02188400bdf4f3b5ccff33ac47eb3ba5477a92 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/muParserNET.xcf differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/muParserNET_.png b/AMDiS/lib/muparser_v134/docs/html/images/muParserNET_.png new file mode 100644 index 0000000000000000000000000000000000000000..a353b02ed94331e92370870ae7bc83eef2e8354f Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/muParserNET_.png differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/muParserX.png b/AMDiS/lib/muparser_v134/docs/html/images/muParserX.png new file mode 100644 index 0000000000000000000000000000000000000000..a2e6b15d064bac3c9c92ad92e519da8440c870f9 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/muParserX.png differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/muParserX.xcf b/AMDiS/lib/muparser_v134/docs/html/images/muParserX.xcf new file mode 100644 index 0000000000000000000000000000000000000000..4f69880cd9da21202f8d5adb84ed6c36ab95ce7c Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/muParserX.xcf differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/muParserX_.png b/AMDiS/lib/muparser_v134/docs/html/images/muParserX_.png new file mode 100644 index 0000000000000000000000000000000000000000..5e12f9fc1852950627ecb3e42495b9a9ad11651d Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/muParserX_.png differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/osi.jpg b/AMDiS/lib/muparser_v134/docs/html/images/osi.jpg new file mode 100644 index 0000000000000000000000000000000000000000..f94bf9596ea41da3519592d2af6b632a94cbfae3 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/osi.jpg differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/question.png b/AMDiS/lib/muparser_v134/docs/html/images/question.png new file mode 100755 index 0000000000000000000000000000000000000000..abf35a71cd5ecb4ce92fbad6c9f77a4011a56033 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/question.png differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/related.png b/AMDiS/lib/muparser_v134/docs/html/images/related.png new file mode 100644 index 0000000000000000000000000000000000000000..11535afd0a2349fc7e7775e44f0a2b2431577257 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/related.png differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/run.png b/AMDiS/lib/muparser_v134/docs/html/images/run.png new file mode 100755 index 0000000000000000000000000000000000000000..985ecb4a3c04430c4f729c4e1a9c6f7647e4dba6 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/run.png differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/sflogo.png b/AMDiS/lib/muparser_v134/docs/html/images/sflogo.png new file mode 100644 index 0000000000000000000000000000000000000000..b65567f7357a0c38862ba703985ee6c692de532f Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/sflogo.png differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/thumb_geodes.jpg b/AMDiS/lib/muparser_v134/docs/html/images/thumb_geodes.jpg new file mode 100644 index 0000000000000000000000000000000000000000..5ef46b83931c0a8691db76d4cbffeaa4f9d1f5fd Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/thumb_geodes.jpg differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/thumb_kst.jpg b/AMDiS/lib/muparser_v134/docs/html/images/thumb_kst.jpg new file mode 100644 index 0000000000000000000000000000000000000000..95213ecca0e8ddab7db25fd8fb13b05b8d1f5ca5 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/thumb_kst.jpg differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/thumb_matrix.jpg b/AMDiS/lib/muparser_v134/docs/html/images/thumb_matrix.jpg new file mode 100644 index 0000000000000000000000000000000000000000..658aace45c7217e8ccec1402b0f0cbe4e066290a Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/thumb_matrix.jpg differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/thumb_meshlab.jpg b/AMDiS/lib/muparser_v134/docs/html/images/thumb_meshlab.jpg new file mode 100644 index 0000000000000000000000000000000000000000..0aca1d987f175f42e77df0bbb1f277dbde4fb774 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/thumb_meshlab.jpg differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/thumb_pasimodo.jpg b/AMDiS/lib/muparser_v134/docs/html/images/thumb_pasimodo.jpg new file mode 100644 index 0000000000000000000000000000000000000000..42d7e740b6cef5a0b07574398ff117fdd99b9f96 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/thumb_pasimodo.jpg differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/thumb_qtiplot.jpg b/AMDiS/lib/muparser_v134/docs/html/images/thumb_qtiplot.jpg new file mode 100644 index 0000000000000000000000000000000000000000..478da174e15dfb38411239512bd443b00c8ee9b5 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/thumb_qtiplot.jpg differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/thumb_tm2.jpg b/AMDiS/lib/muparser_v134/docs/html/images/thumb_tm2.jpg new file mode 100644 index 0000000000000000000000000000000000000000..97fbde4ca080e4963a6c1cf7a6a8d3ec67f08aa6 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/thumb_tm2.jpg differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/thumb_trini.jpg b/AMDiS/lib/muparser_v134/docs/html/images/thumb_trini.jpg new file mode 100644 index 0000000000000000000000000000000000000000..d6f7d22ffea84eecb160df57cd3e89acc687945f Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/thumb_trini.jpg differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/warning.gif b/AMDiS/lib/muparser_v134/docs/html/images/warning.gif new file mode 100644 index 0000000000000000000000000000000000000000..a58b7e7da5e358bc49344b5d55ddfd32202372fc Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/warning.gif differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/xxx .png b/AMDiS/lib/muparser_v134/docs/html/images/xxx .png new file mode 100644 index 0000000000000000000000000000000000000000..78efda623bdd0b6ac7804f11d0d5886b09c6f837 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/xxx .png differ diff --git a/AMDiS/lib/muparser_v134/docs/html/images/xxx.xcf b/AMDiS/lib/muparser_v134/docs/html/images/xxx.xcf new file mode 100644 index 0000000000000000000000000000000000000000..e7789b941f9ec2f9816e1504423e96cf038754e6 Binary files /dev/null and b/AMDiS/lib/muparser_v134/docs/html/images/xxx.xcf differ diff --git a/AMDiS/lib/muparser_v134/docs/html/index.html b/AMDiS/lib/muparser_v134/docs/html/index.html new file mode 100644 index 0000000000000000000000000000000000000000..bdc38475410bab95907c3f6a819d14122cd95a3d --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/index.html @@ -0,0 +1,302 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <link rel="stylesheet" type="text/css" href="style/formate.css"/> + <meta name="author" content="Ingo Berg"/> + <!-- $META --> + <meta name="keywords" content="math parser, math expression parser, muparser, muparserx, muparser.net, .net, c++, lib, dll, donation, function parser"/> + <meta name="description" content="muParser - a fast math parser library"/> + <title>muParser - a fast math parser library</title> + + <script src="script/functions.js" language="javascript" type="text/javascript"></script> + <script type="text/javascript"> + imgHome=new Image(); + imgHome.src="images/home.png"; + imgHomeDark=new Image(); + imgHomeDark.src="images/home_dark.png"; + + imgApi=new Image(); + imgApi.src="images/api.png"; + imgApiDark=new Image(); + imgApiDark.src="images/api_dark.png"; + + function ChangeButtonImage(num,obj) + { + window.document.images[num].src=obj.src; + } + </script> +</head> + +<body> + <div class="gradient" id="top"> + <div class="header"> + muParser - a fast math parser library + <br/> + <div style="font-size:14pt;">Version 1.32</div> + </div> + + <div style="position:absolute; width:250px; height:100px; top:20px; text-align:center"> + <a href="http://sourceforge.net/projects/muparser"> + <img src="http://sflogo.sourceforge.net/sflogo.php?group_id=137191&type=15" + width="150" + height="40" + border="0" + alt="Get muParser - A fast math parser library at SourceForge.net. Fast, secure and Free Open Source software downloads" /> + </a> + </div> + + <div style="position:absolute; width:100px; right:110px; text-align:center; line-height: 1em;"> + <a class="white" + href="http://www.beltoforion.de" + onmouseover="ChangeButtonImage(1,imgHome)" + onmouseout="ChangeButtonImage(1,imgHomeDark)"> + <img src="images/home_dark.png" border="0" height="40" alt="My home page"/> + <br/> + <span class="tiny_text">My home<br/>page</span> + </a> + </div> + + <div style="position:absolute; width:100px; right:10px; text-align:center; line-height: 1em;"> + <a class="white" + href="http://muparser.sourceforge.net/classdocu/index.html" + onmouseover="ChangeButtonImage(2,imgApi)" + onmouseout="ChangeButtonImage(2,imgApiDark)"> + <img src="images/api_dark.png" border="0" alt="class documentation" height="40"/> + <br/> + <span class="tiny_text">muParser<br/>API-doc</span> + </a> + </div> + <!-- + <div style="position:absolute; width:100px; right:10px; text-align:center; line-height: 1em;"> + <a class="white" + href="http://sourceforge.net/project/showfiles.php?group_id=137191" + onmouseover="ChangeButtonImage(3,imgDown)" + onmouseout="ChangeButtonImage(3,imgDownDark)"> + <img src="images/download_dark.png" height="40" border="0" alt="muParser download"/> + <br/> + <span class="tiny_text">muParser<br/>Download</span> + </a> + </div> +--> + </div> <!-- class="gradient" --> + + <!-- Tabelle mit Hauptinhalt der Seite --> + <table id="MainTable" border="0" cellpadding="5" cellspacing="0" style="width:100%; height:100%;"> + <tbody> + <tr> + <td style="vertical-align: top; text-align: center" width="230"> + <h3 class="navi_heading navi_info">Introduction</h3> + <div class="sidebarlink"> + <a href="index.html">About the parser</a><br/> + <a href="http://sourceforge.net/news/?group_id=137191">News</a><br/> + <a href="mup_links.html">Software using muParser</a><br/> + <a href="mup_licence.html">Licence</a><br/> + </div> + + <h3 class="navi_heading navi_blocks">Features</h3> + <div class="sidebarlink"> + <a href="mup_features.html">Features</a><br/> + <a href="mup_features.html#idFeatureOverview">Overview</a><br/> + <a href="mup_features.html#idDef2">Built in functions</a><br/> + <a href="mup_features.html#idDef3">Built in binary operators</a><br/> + </div> + + <h3 class="navi_heading navi_build">Build instructions</h3> + <div class="sidebarlink"> + <a href="mup_usage.html#idInstWin">Building on Win32</a><br/> + <a href="mup_usage.html#idInstLinux">Building on BSD/Linux</a><br/> + <a href="mup_usage.html#idInstMisc">Misc build instructions</a><br/> + <a href="mup_usage.html#idInstInc">Including the files</a><br/> + <a href="mup_usage.html#idInstInc">Where to ask for help</a><br/> + </div> + + <h3 class="navi_heading navi_list">Math parser interface</h3> + <div class="sidebarlink"> + <a href="mup_interface.html#idInit">Parser (de)initialization</a><br/> + <a href="mup_interface.html#idEval">Evaluating an expression</a><br/> + <a href="mup_interface.html#idSetExpr">Setting the expression</a><br/> + <a href="mup_interface.html#idDefCharset">Defining identifier charsets</a><br/> + <a href="mup_interface.html#idDefVar">Defining parser variables</a><br/> + <a href="mup_interface.html#idDefVarEx">Explicit variable definition</a><br/> + <a href="mup_interface.html#idDefVarIm">Implicit variable definition</a><br/> + <a href="mup_interface.html#idDefConst">Defining constants</a><br/> + <a href="mup_interface.html#idDefFun">Defining functions</a><br/> + <a href="mup_interface.html#idDefOprt">Defining operators</a><br/> + <a href="mup_interface.html#idUnOp">Unary operators</a><br/> + <a href="mup_interface.html#idBinOp">Binary operators</a><br/> + <a href="mup_interface.html#idQueryVar">Querying variables</a><br/> + <a href="mup_interface.html#idQueryConst">Querying constants</a><br/> + <a href="mup_interface.html#idDefConst2">Value recognition callbacks</a><br/> + <a href="mup_interface.html#idDefConst2">Removing variables/constants</a><br/> + <a href="mup_locale.html#idLoc">Localization</a><br/> + <a href="mup_interface.html#idErrors">Error handling</a><br/> + <a href="mup_version.html#idExample">Example code</a><br/> + </div> + + <h3 class="navi_heading navi_question">Current version</h3> + <div class="sidebarlink"> + <a href="mup_version.html#idRelNote">Release notes</a><br/> + <a href="mup_version.html#idBench">Benchmarks</a><br/> + </div> + + <br/> + <div align="center"> + <a href="http://www.opensource.org/"><img style="border:0;" src="images/osi.jpg" alt="Open source initiative logo"/></a> + <br/> + <br/> + <a href="http://validator.w3.org/check?uri=referer"> + <img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" style="border:0;width:88px;height:31px"/> + </a> + <br/> + <br/> + <a href="http://jigsaw.w3.org/css-validator/check/referer"> + <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="CSS ist valide!" /> + </a> + + </div> + </td> + + <td style="height: 100%; padding: 1em; vertical-align: top;"> + <!-- + This section contains the real page content. + pages are created automatically by using the script "build_page.sh" + which combines section templated with the navigation bar. + + This creates webpages that do not rely on php3 or Javascript for + serverside or client side html inclusion. + //--> + <!-- $PLACEHOLDER --> +<script type="text/javascript"> + imgParserNET=new Image(); + imgParserNET.src="images/muParserNET.png"; + imgParserNETDark=new Image(); + imgParserNETDark.src="images/muParserNET_.png"; + + imgParserX=new Image(); + imgParserX.src="images/muParserX.png"; + imgParserXDark=new Image(); + imgParserXDark.src="images/muParserX_.png"; + + imgDownload=new Image(); + imgDownload.src="images/download_muparser.png"; + imgDownloadDark=new Image(); + imgDownloadDark.src="images/download_muparser_.png"; +</script> + +<h2>About the parser</h2> + +<p> +Many applications require the parsing of <strong>mathematical expressions</strong>. +The main objective of this library is to provide a fast and easy way of +doing this. <strong>muParser</strong> is an extensible high performance +<strong>math parser</strong> library written in <a href="http://www.cplusplus.com/">C++</a>. It works +by transforming a mathematical expression into bytecode and precalculating constant +parts of the expression. +</p> + +<div style="/*position:float; */border: 1px solid #000000; width:420px; height:220px; text-align:left; float:left; margin-right:10px; background-color: #ffffff;"> +<img src="images/related.png" alt="math expression parser - related links" border="0" width="420"/> + <a href="http://www.codeproject.com/KB/recipes/muParser.aspx"> + <img src="images/muParserNET_.png" alt=".NET math parser" border="0" width="200" style="float:left;" onmouseover="ChangeButtonImage(7,imgParserNET)" onmouseout="ChangeButtonImage(7,imgParserNETDark)"/> + <br/> + <strong>muParser C# wrapper</strong> + <br/> + <span class="tiny_text">a math parser for .NET</span> + </a> + + <br clear="all"/><br/> + <a href="http://beltoforion.de/muparserx/math_expression_parser_en.html"> + <img src="images/muParserX_.png" + alt="math expression parser" + border="0" + width="200" + style="float:left;" + onmouseover="ChangeButtonImage(8,imgParserX)" + onmouseout="ChangeButtonImage(8,imgParserXDark)"/> + <strong>muParserX</strong> + <br/> + <span class="tiny_text">a math expression parser with support for multitype data types</span> + </a> +</div> +The library was designed with portability in mind and should compile on every +standard compliant C++ compiler. Wrapper for <strong>C</strong> and <strong>C#</strong> +exist. The parser archive contains ready to use project and makefiles files for a variety of +platforms. The code runs on both <strong>32 bit</strong> and +<strong>64 bit</strong> architechtures and has been tested using MS VC++ V8.0 +and GCC V4.4.1. Code samples are provided in order to help you understand its +usage. The library is <strong>open source</strong> and distributed under +the <a href="http://www.opensource.org/licenses/mit-license.php">MIT license</a>. + +<div style="text-align:center;"> +<a href="http://sourceforge.net/project/showfiles.php?group_id=137191"> + <img src="images/download_muparser_.png" + border="0" + alt="muParser download" + onmouseover="ChangeButtonImage(9,imgDownload)" + onmouseout="ChangeButtonImage(9,imgDownloadDark)"/> +</a> +</div> + +<p> +Before I go on, I'd like to thank <a href="http://sourceforge.net">SourceForge</a> for hosting this project. This +pages would not exist without the webspace provided by them and of course I'd like +to thank <a href="http://www.codeproject.com">CodeProject</a> for hosting the original +<a href="http://www.codeproject.com/cpp/FastMathParser.asp" target="_blank">math parser</a> +article. +</p> + + +<h2>Support this project</h2> +muParser is free software and anyone can use it free of charge for commercial and noncommercial purposes. If you wish you can support this project by <strong>making a small donation</strong>: +<br/> +<br/> +<div style="text-align:center;"> + <a href="http://sourceforge.net/donate/index.php?group_id=137191"> + <img src="http://images.sourceforge.net/images/project-support.jpg" + width="196" + height="64" + border="0" + alt="Support This Project"/> + </a> +</div> +<br/> +A project like muParser requires permanent maintanence in order to adopt to new platforms, new compiler version and for fixing bugs. So if you are using the library and find it useful i would like to encourage you to make a donation in order to help keeping the project up to date. I can officially guarantee that you <strong>make my day</strong> by donating even a small amount of money. In a way this is a "Wow the people actually really appreciate what i'm doing" kind of thing and that's whats driving me and ultimately this is what is keeping this project alive. + + + + <hr/> + <table border="0" style="width:100%"> + <tr> + <td>© 2005-2010 <a href="http://beltoforion.de">Ingo Berg</a> | + <a href="http://beltoforion.de/privacy_policy/privacy_policy_en.html">Privacy policy</a></td> + <td style="text-align:right; padding-right: 3em;"> + <a href="#top">^ TOP</a> + </td> + </tr> + </table> + <br/> + <br/> + + </td> + </tr> + </tbody> + </table> + +<!-- + <script type="text/javascript"> + var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); + document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); + </script> + <script type="text/javascript"> + try + { + var pageTracker = _gat._getTracker("UA-1019178-1"); + pageTracker._trackPageview(); + } + catch(err) {} + </script> +--> +</body> +</html> diff --git a/AMDiS/lib/muparser_v134/docs/html/misc/Main.txt b/AMDiS/lib/muparser_v134/docs/html/misc/Main.txt new file mode 100644 index 0000000000000000000000000000000000000000..6847344504a0f9ef270ffebed4d994be085c00da --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/misc/Main.txt @@ -0,0 +1,44 @@ +/** \mainpage +Welcome to the muParser API documentation. These pages contain the muParser API documentation. + +<table border="0" width="100%"> +<tr> + +<td> +<img src="../images/mathparser_small.jpg" width="200"/> +</td> + +<td> +<b>More muParser resources</b> +<ul> +<li><p>The <a href="http://muparser.sourceforge.net/">muParser homepage</a> +<br><small>More dokumentation; benchmarks ...</small> +</li> +<li><p>The official <a href="http://sourceforge.net/project/showfiles.php?group_id=137191">Project page</a> at Sourceforge<br> +<small>Downloadlinks for the current and older versions.</small> +</li> +<li><p>The <a href="http://www.codeproject.com/KB/recipes/FastMathParser.aspx">Project page</a> at CodeProject<br> +<small>This is how it started, provides an alternate package for VS2005.</small> +</li> +<li><p>A CodeProject article featuring a <a href="http://www.codeproject.com/KB/recipes/muParser.aspx">C# wrapper for muParser</a> +<br><small>Uses muParser with C# and the .NET framework.</small> +</li> +</ul> +<p> + +<b>Things i do when i'm not working on muParser.</b> +<ul> +<li> +<p><a href="http://www.codeproject.com/KB/openGL/Wator.aspx">Wator Screensaver</a> (for Windows; requires OpenGL) +<br><small>A simulation of predator prey dynamic C# wrapper for muParser</small> +</li> +<li><p><a href="http://www.codeproject.com/KB/recipes/MagneticPendulum.aspx">The magnetic pendulum fractal</a> (for Windows; requires OpenGL) +<br><small>Chaotic motion of a pendulum over three magnets</small> +</li> +</ul> +</td> + + +</tr> +</table> +*/ diff --git a/AMDiS/lib/muparser_v134/docs/html/misc/calc.cpp b/AMDiS/lib/muparser_v134/docs/html/misc/calc.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3b7adf1216dfbe8d47006358e8ca77dcc928b509 --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/misc/calc.cpp @@ -0,0 +1,59 @@ +//--------------------------------------------------------------------------- +value_type Mega(value_type a_fVal) +{ + return a_fVal * 1e6; +} + +//--------------------------------------------------------------------------- +value_type Not(value_type v) +{ + return v==0; +} + +//--------------------------------------------------------------------------- +value_type Ping() +{ + mu::console() << "ping\n"; + return 0; +} + +//--------------------------------------------------------------------------- +void Calc() +{ + mu::Parser parser; + + parser.SetArgSep(';'); + parser.SetDecSep(','); + parser.SetThousandsSep('.'); + + // Add some variables + value_type a = 10; + parser.DefineVar("a", &a); + parser.DefineStrConst("strBuf", "hello world"); + + // Add user defined unary operators + parser.DefinePostfixOprt("M", Mega); + parser.DefineInfixOprt("!", Not); + parser.DefineFun("ping", Ping, false); + + try + { + string_type sLine; + std::getline(mu::console_in(), sLine); + + parser.SetExpr(sLine); + mu::console() << std::setprecision(12); + mu::console() << parser.Eval() << "\n"; + } + catch(mu::Parser::exception_type &e) + { + mu::console() << "\nError:\n"; + mu::console() << "------\n"; + mu::console() << "Message: " << e.GetMsg() << "\n"; + mu::console() << "Expression: \"" << e.GetExpr() << "\"\n"; + mu::console() << "Token: \"" << e.GetToken() << "\"\n"; + mu::console() << "Position: " << (int)e.GetPos() << "\n"; + mu::console() << "Errc: " << std::dec << e.GetCode() << "\n"; + } +} + diff --git a/AMDiS/lib/muparser_v134/docs/html/misc/example.txt b/AMDiS/lib/muparser_v134/docs/html/misc/example.txt new file mode 100644 index 0000000000000000000000000000000000000000..cb6fb042ae384079db20bfdb2566e18c35d7571a --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/misc/example.txt @@ -0,0 +1,12 @@ +/** \example listvar.cpp + This example shows how to list parser variables. +*/ + +/** \example list_expr_var.cpp + This example shows how to list variables used in an expression. +*/ + +/** \example calc.cpp + This example shows a typical use case of muParser. +*/ + diff --git a/AMDiS/lib/muparser_v134/docs/html/misc/footer.html b/AMDiS/lib/muparser_v134/docs/html/misc/footer.html new file mode 100644 index 0000000000000000000000000000000000000000..25dd423ad01baa2954dc86ba688602a68e879a5d --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/misc/footer.html @@ -0,0 +1,19 @@ +<div style="position:absolute; width:100%; height:100%; text-align:center;"> +<p> +<hr/> +<strong>muParser</strong> API documentation - (C) 2009 <a href="http://beltoforion.de">Ingo Berg</a> +</p> +</div> + +<script type="text/javascript"> +var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); +document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); +</script> +<script type="text/javascript"> +try { +var pageTracker = _gat._getTracker("UA-1019178-3"); +pageTracker._trackPageview(); +} catch(err) {}</script> + +</body> +</html> \ No newline at end of file diff --git a/AMDiS/lib/muparser_v134/docs/html/misc/header.html b/AMDiS/lib/muparser_v134/docs/html/misc/header.html new file mode 100644 index 0000000000000000000000000000000000000000..921a2baaf58f6e5af0196ee331a908e148101935 --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/misc/header.html @@ -0,0 +1,8 @@ +<html> +<title>muParser - a fast math parser: Main Page</title> +<link href="doxygen.css" rel="stylesheet" type="text/css"> +<link href="tabs.css" rel="stylesheet" type="text/css"> + +<body> +<img src="../images/grad2.jpg"/> + diff --git a/AMDiS/lib/muparser_v134/docs/html/misc/list_expr_var.cpp b/AMDiS/lib/muparser_v134/docs/html/misc/list_expr_var.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b444c4ad82e307101d17bf72afc2c8d024bb671b --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/misc/list_expr_var.cpp @@ -0,0 +1,15 @@ +void ListExprVar(const mu::ParserBase &parser) +{ + varmap_type variables = parser.GetUsedVar(); + if (!variables.size()) + mu::console() << "Expression does not contain variables\n"; + else + { + mu::console() << "Number: " << (int)variables.size() << "\n"; + mu::varmap_type::const_iterator item = variables.begin(); + + for (; item!=variables.end(); ++item) + mu::console() << "Name: " << item->first << " Address: [0x" << item->second << "]\n"; + } +} + diff --git a/AMDiS/lib/muparser_v134/docs/html/misc/listvar.cpp b/AMDiS/lib/muparser_v134/docs/html/misc/listvar.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e7a106d4e093e3fbb39cf04cf75a92112ac80afe --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/misc/listvar.cpp @@ -0,0 +1,13 @@ +void ListVar(const mu::ParserBase &parser) +{ + mu::varmap_type variables = parser.GetVar(); + if (!variables.size()) + return; + + cout << "\nParser variables:\n"; + cout << "-----------------\n"; + cout << "Number: " << (int)variables.size() << "\n"; + varmap_type::const_iterator item = variables.begin(); + for (; item!=variables.end(); ++item) + mu::console() << _T("Name: ") << item->first << _T(" Address: [0x") << item->second << _T("]\n"); +} diff --git a/AMDiS/lib/muparser_v134/docs/html/mup_features.html b/AMDiS/lib/muparser_v134/docs/html/mup_features.html new file mode 100644 index 0000000000000000000000000000000000000000..f39fbf8187bd4fcd8b80d27dd65350a16d885e7a --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/mup_features.html @@ -0,0 +1,418 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <link rel="stylesheet" type="text/css" href="style/formate.css"/> + <meta name="author" content="Ingo Berg"/> + <!-- $META --> + <meta name="keywords" content="features, muparser, operator, function, math parser, C++"/> + <meta name="description" content="List of operators and functions supported by muparser"/> + <title>List of muparser features</title> + + <script src="script/functions.js" language="javascript" type="text/javascript"></script> + <script type="text/javascript"> + imgHome=new Image(); + imgHome.src="images/home.png"; + imgHomeDark=new Image(); + imgHomeDark.src="images/home_dark.png"; + + imgApi=new Image(); + imgApi.src="images/api.png"; + imgApiDark=new Image(); + imgApiDark.src="images/api_dark.png"; + + function ChangeButtonImage(num,obj) + { + window.document.images[num].src=obj.src; + } + </script> +</head> + +<body> + <div class="gradient" id="top"> + <div class="header"> + muParser - a fast math parser library + <br/> + <div style="font-size:14pt;">Version 1.32</div> + </div> + + <div style="position:absolute; width:250px; height:100px; top:20px; text-align:center"> + <a href="http://sourceforge.net/projects/muparser"> + <img src="http://sflogo.sourceforge.net/sflogo.php?group_id=137191&type=15" + width="150" + height="40" + border="0" + alt="Get muParser - A fast math parser library at SourceForge.net. Fast, secure and Free Open Source software downloads" /> + </a> + </div> + + <div style="position:absolute; width:100px; right:110px; text-align:center; line-height: 1em;"> + <a class="white" + href="http://www.beltoforion.de" + onmouseover="ChangeButtonImage(1,imgHome)" + onmouseout="ChangeButtonImage(1,imgHomeDark)"> + <img src="images/home_dark.png" border="0" height="40" alt="My home page"/> + <br/> + <span class="tiny_text">My home<br/>page</span> + </a> + </div> + + <div style="position:absolute; width:100px; right:10px; text-align:center; line-height: 1em;"> + <a class="white" + href="http://muparser.sourceforge.net/classdocu/index.html" + onmouseover="ChangeButtonImage(2,imgApi)" + onmouseout="ChangeButtonImage(2,imgApiDark)"> + <img src="images/api_dark.png" border="0" alt="class documentation" height="40"/> + <br/> + <span class="tiny_text">muParser<br/>API-doc</span> + </a> + </div> + <!-- + <div style="position:absolute; width:100px; right:10px; text-align:center; line-height: 1em;"> + <a class="white" + href="http://sourceforge.net/project/showfiles.php?group_id=137191" + onmouseover="ChangeButtonImage(3,imgDown)" + onmouseout="ChangeButtonImage(3,imgDownDark)"> + <img src="images/download_dark.png" height="40" border="0" alt="muParser download"/> + <br/> + <span class="tiny_text">muParser<br/>Download</span> + </a> + </div> +--> + </div> <!-- class="gradient" --> + + <!-- Tabelle mit Hauptinhalt der Seite --> + <table id="MainTable" border="0" cellpadding="5" cellspacing="0" style="width:100%; height:100%;"> + <tbody> + <tr> + <td style="vertical-align: top; text-align: center" width="230"> + <h3 class="navi_heading navi_info">Introduction</h3> + <div class="sidebarlink"> + <a href="index.html">About the parser</a><br/> + <a href="http://sourceforge.net/news/?group_id=137191">News</a><br/> + <a href="mup_links.html">Software using muParser</a><br/> + <a href="mup_licence.html">Licence</a><br/> + </div> + + <h3 class="navi_heading navi_blocks">Features</h3> + <div class="sidebarlink"> + <a href="mup_features.html">Features</a><br/> + <a href="mup_features.html#idFeatureOverview">Overview</a><br/> + <a href="mup_features.html#idDef2">Built in functions</a><br/> + <a href="mup_features.html#idDef3">Built in binary operators</a><br/> + </div> + + <h3 class="navi_heading navi_build">Build instructions</h3> + <div class="sidebarlink"> + <a href="mup_usage.html#idInstWin">Building on Win32</a><br/> + <a href="mup_usage.html#idInstLinux">Building on BSD/Linux</a><br/> + <a href="mup_usage.html#idInstMisc">Misc build instructions</a><br/> + <a href="mup_usage.html#idInstInc">Including the files</a><br/> + <a href="mup_usage.html#idInstInc">Where to ask for help</a><br/> + </div> + + <h3 class="navi_heading navi_list">Math parser interface</h3> + <div class="sidebarlink"> + <a href="mup_interface.html#idInit">Parser (de)initialization</a><br/> + <a href="mup_interface.html#idEval">Evaluating an expression</a><br/> + <a href="mup_interface.html#idSetExpr">Setting the expression</a><br/> + <a href="mup_interface.html#idDefCharset">Defining identifier charsets</a><br/> + <a href="mup_interface.html#idDefVar">Defining parser variables</a><br/> + <a href="mup_interface.html#idDefVarEx">Explicit variable definition</a><br/> + <a href="mup_interface.html#idDefVarIm">Implicit variable definition</a><br/> + <a href="mup_interface.html#idDefConst">Defining constants</a><br/> + <a href="mup_interface.html#idDefFun">Defining functions</a><br/> + <a href="mup_interface.html#idDefOprt">Defining operators</a><br/> + <a href="mup_interface.html#idUnOp">Unary operators</a><br/> + <a href="mup_interface.html#idBinOp">Binary operators</a><br/> + <a href="mup_interface.html#idQueryVar">Querying variables</a><br/> + <a href="mup_interface.html#idQueryConst">Querying constants</a><br/> + <a href="mup_interface.html#idDefConst2">Value recognition callbacks</a><br/> + <a href="mup_interface.html#idDefConst2">Removing variables/constants</a><br/> + <a href="mup_locale.html#idLoc">Localization</a><br/> + <a href="mup_interface.html#idErrors">Error handling</a><br/> + <a href="mup_version.html#idExample">Example code</a><br/> + </div> + + <h3 class="navi_heading navi_question">Current version</h3> + <div class="sidebarlink"> + <a href="mup_version.html#idRelNote">Release notes</a><br/> + <a href="mup_version.html#idBench">Benchmarks</a><br/> + </div> + + <br/> + <div align="center"> + <a href="http://www.opensource.org/"><img style="border:0;" src="images/osi.jpg" alt="Open source initiative logo"/></a> + <br/> + <br/> + <a href="http://validator.w3.org/check?uri=referer"> + <img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" style="border:0;width:88px;height:31px"/> + </a> + <br/> + <br/> + <a href="http://jigsaw.w3.org/css-validator/check/referer"> + <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="CSS ist valide!" /> + </a> + + </div> + </td> + + <td style="height: 100%; padding: 1em; vertical-align: top;"> + <!-- + This section contains the real page content. + pages are created automatically by using the script "build_page.sh" + which combines section templated with the navigation bar. + + This creates webpages that do not rely on php3 or Javascript for + serverside or client side html inclusion. + //--> + <!-- $PLACEHOLDER --> +<!-- +// +// +// +// Features +// +// +// +--> + +<br/> +<h2><a name="idFeature">Features</a></h2> + +<p> +The following is a list of the features currently supported by the parser library. +The primary objective is to keep it as extensible as possible whilst ensuring a maximum parsing speed. Extending the parser is mostly based on allowing a user to add custom callbacks which require only an absolute minimum of code. For instance you need exactly 2 lines of code to add a new function. +But extending the parser may not be necessary at all since it comes with a powerful default +implementation. Here is the (incomplete) list of features: +</p> + + +<!-- +// +// Features / Overview +// +--> + +<h3><a name="idFeatureOverview">Overview</a></h3> + + +<ul> + <li><b>Easy to use</b> + <ul> + <li>You need only a <a href="mup_version.html#idExample">few lines of code</a> to evaluate en expression</li> + </ul> + </li> + <li><b>Extremely fast</b> + <ul> + <li><a href="mup_version.html#idBench">faster than similar commercial parsers</a></li> + </ul> + </li> + + <li><b>User-defined operators</b> + <ul> + <li>binary operators</li> + <li>postfix operators</li> + <li>infix operators</li> + </ul> + </li> + + <li><b>User-defined functions</b> + <ul> + <li>with a fixed number of up to five arguments</li> + <li>with variable number of arguments</li> + <li>with a single string argument (for database queries)</li> + </ul> + </li> + + <li><b>User-defined constants.</b> + <ul> + <li>numeric constants</li> + <li>string constants</li> + </ul> + </li> + + <li><b>User-defined variables.</b> + <ul> + <li>unlimited in number</li> + <li>definable at parser runtime by the parser</li> + <li>assigning variables in terms of other variables is possible</li> + </ul> + </li> + + <li><b>Custom value recognition callbacks</b> + <ul> + <li>support for binary and hex values.</li> + <li>can be used to implement database queries</li> + </ul> + </li> + + <li><b>Default implementaion with many features</b> + <ul> + <li>26 <a href="#idDef1">predefined functions</a>.</li> + <li>15 <a href="#idDef2">predefined operators</a>.</li> + <li>Supports numerical differentiation with respect to a given variable.</li> + <li>Assignement operator is supported</li> + </ul> + </li> + + <li><b>Portability</b> + <ul> + <li>Project / makefiles for MSVC, mingw, autoconf, bcc</li> + <li>ISO 14882 compliant code</li> + <li>DLL version usable from every language able to use function exported in C-style</li> + </ul> + </li> + + <li><b>Unit support</b> + <ul> + <li>Use postfix operators as unit multipliers <code>(3m -> 0.003)</code></li> + </ul> + </li> + + <li><b>Localization</b> + <ul> + <li>Argument separator, decimal separator, thousands separator can be adjusted to your locale</code></li> + </ul> + </li> + +</ul> + + +<!-- +// +// +// +// Default implementation +// +// +// +--> + +<h3><a name="idDef1">The default implementation</a></h3> +<p> +This section gives an overview on the default features supported by the parser. The default +implementation is defined in the class <code>mu::Parser</code> located in the file +<i>muParser.cpp</i>. The DLL-version uses this class internally. +</p> + +<!-- +// +// Features / Built in functions +// +--> + + +<h4><a name="idDef2">Built-in functions</a></h4> +<p> +The following table gives an overview of the functions supported by the +default implementation. It lists the function names, the number of +arguments and a brief description. +</p> + +<table border="1"> +<thead> +<tr> + <td><b>Name</b></td> <td><b>Argc.</b></td> <td><b>Explanation</b></td> +</tr> +</thead> + +<tbody> +<tr><td><code>sin</code></td> <td align="center">1</td> <td>sine function</td></tr> +<tr><td><code>cos</code></td> <td align="center">1</td> <td>cosine function</td></tr> +<tr><td><code>tan</code></td> <td align="center">1</td> <td>tangens function</td></tr> +<tr><td><code>asin</code></td> <td align="center">1</td> <td>arcus sine function</td></tr> +<tr><td><code>acos</code></td> <td align="center">1</td> <td>arcus cosine function</td></tr> +<tr><td><code>atan</code></td> <td align="center">1</td> <td>arcus tangens function</td></tr> +<tr><td><code>sinh</code></td> <td align="center">1</td> <td>hyperbolic sine function</td></tr> +<tr><td><code>cosh</code></td> <td align="center">1</td> <td>hyperbolic cosine</td></tr> +<tr><td><code>tanh</code></td> <td align="center">1</td> <td>hyperbolic tangens function</td></tr> +<tr><td><code>asinh</code></td> <td align="center">1</td> <td>hyperbolic arcus sine function</td></tr> +<tr><td><code>acosh</code></td> <td align="center">1</td> <td>hyperbolic arcus tangens function</td></tr> +<tr><td><code>atanh</code></td> <td align="center">1</td> <td>hyperbolic arcur tangens function</td></tr> +<tr><td><code>log2</code></td> <td align="center">1</td> <td>logarithm to the base 2</td></tr> +<tr><td><code>log10</code></td> <td align="center">1</td> <td>logarithm to the base 10</td></tr> +<tr><td><code>log</code></td> <td align="center">1</td> <td>logarithm to the base 10</td></tr> +<tr><td><code>ln</code></td> <td align="center">1</td> <td>logarithm to base e (2.71828...)</td></tr> +<tr><td><code>exp</code></td> <td align="center">1</td> <td>e raised to the power of x</td></tr> +<tr><td><code>sqrt</code></td> <td align="center">1</td> <td>square root of a value</td></tr> +<tr><td><code>sign</code></td> <td align="center">1</td> <td>sign function -1 if x<0; 1 if x>0</td></tr> +<tr><td><code>rint</code></td> <td align="center">1</td> <td>round to nearest integer</td></tr> +<tr><td><code>abs</code></td> <td align="center">1</td> <td>absolute value</td></tr> +<tr><td><code>if</code></td> <td align="center">3</td> <td>if ... then ... else ...</td></tr> +<tr><td><code>min</code></td> <td align="center">var.</td> <td>min of all arguments</td></tr> +<tr><td><code>max</code></td> <td align="center">var.</td> <td>max of all arguments</td></tr> +<tr><td><code>sum</code></td> <td align="center">var.</td> <td>sum of all arguments</td></tr> +<tr><td><code>avg</code></td> <td align="center">var.</td> <td>mean value of all arguments</td></tr> +</tbody> + +</table> + + +<h4><a name="idDef3">Built-in binary operators</a></h4> +<p> +The following table lists the default binary operators supported by the parser. +</p> + +<table border="1"> + <thead> + <tr><td><b>Operator</b></td> <td><b>Meaning</b></td> <td><b>Priority</b></td></tr> + </thead> + + <tbody> + <tr><td><code>=</code></td> <td>assignement*</td> <td>-1</td></tr> + <tr><td><code>and</code></td> <td>logical and</td> <td>1</td></tr> + <tr><td><code>or</code></td> <td>logical or</td> <td>1</td></tr> + <tr><td><code>xor</code></td> <td>logical xor</td> <td>1</td></tr> + <tr><td><code><=</code></td> <td>less or equal</td> <td>2</td></tr> + <tr><td><code>>=</code></td> <td>greater or equal</td> <td>2</td></tr> + <tr><td><code>!=</code></td> <td>not equal</td> <td>2</td></tr> + <tr><td><code>==</code></td> <td>equal</td> <td>2</td></tr> + <tr><td><code>></code></td> <td>greater than</td> <td>2</td></tr> + <tr><td><code><</code></td> <td>less than</td> <td>2</td></tr> + <tr><td><code>+</code></td> <td>addition</td> <td>3</td></tr> + <tr><td><code>-</code></td> <td>subtraction</td> <td>3</td></tr> + <tr><td><code>*</code></td> <td>multiplication</td> <td>4</td></tr> + <tr><td><code>/</code></td> <td>division</td> <td>4</td></tr> + <tr><td><code>^</code></td> <td>raise x to the power of y</td> <td>5</td></tr> + </tbody> +</table> +<small>*The assignment operator is special since it changes one of its + arguments and can only by applied to variables.</small> + + + <hr/> + <table border="0" style="width:100%"> + <tr> + <td>© 2005-2010 <a href="http://beltoforion.de">Ingo Berg</a> | + <a href="http://beltoforion.de/privacy_policy/privacy_policy_en.html">Privacy policy</a></td> + <td style="text-align:right; padding-right: 3em;"> + <a href="#top">^ TOP</a> + </td> + </tr> + </table> + <br/> + <br/> + + </td> + </tr> + </tbody> + </table> + +<!-- + <script type="text/javascript"> + var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); + document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); + </script> + <script type="text/javascript"> + try + { + var pageTracker = _gat._getTracker("UA-1019178-1"); + pageTracker._trackPageview(); + } + catch(err) {} + </script> +--> +</body> +</html> diff --git a/AMDiS/lib/muparser_v134/docs/html/mup_interface.html b/AMDiS/lib/muparser_v134/docs/html/mup_interface.html new file mode 100644 index 0000000000000000000000000000000000000000..4ce581ab3418729a5250e8f7cf325a93771e5f94 --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/mup_interface.html @@ -0,0 +1,1190 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <link rel="stylesheet" type="text/css" href="style/formate.css"/> + <meta name="author" content="Ingo Berg"/> + <!-- $META --> + <meta name="keywords" content="muparser, api, interface, dll, C++"/> + <meta name="description" content="muparser programming interface"/> + <title>muParser programming interface</title> + + <script src="script/functions.js" language="javascript" type="text/javascript"></script> + <script type="text/javascript"> + imgHome=new Image(); + imgHome.src="images/home.png"; + imgHomeDark=new Image(); + imgHomeDark.src="images/home_dark.png"; + + imgApi=new Image(); + imgApi.src="images/api.png"; + imgApiDark=new Image(); + imgApiDark.src="images/api_dark.png"; + + function ChangeButtonImage(num,obj) + { + window.document.images[num].src=obj.src; + } + </script> +</head> + +<body> + <div class="gradient" id="top"> + <div class="header"> + muParser - a fast math parser library + <br/> + <div style="font-size:14pt;">Version 1.32</div> + </div> + + <div style="position:absolute; width:250px; height:100px; top:20px; text-align:center"> + <a href="http://sourceforge.net/projects/muparser"> + <img src="http://sflogo.sourceforge.net/sflogo.php?group_id=137191&type=15" + width="150" + height="40" + border="0" + alt="Get muParser - A fast math parser library at SourceForge.net. Fast, secure and Free Open Source software downloads" /> + </a> + </div> + + <div style="position:absolute; width:100px; right:110px; text-align:center; line-height: 1em;"> + <a class="white" + href="http://www.beltoforion.de" + onmouseover="ChangeButtonImage(1,imgHome)" + onmouseout="ChangeButtonImage(1,imgHomeDark)"> + <img src="images/home_dark.png" border="0" height="40" alt="My home page"/> + <br/> + <span class="tiny_text">My home<br/>page</span> + </a> + </div> + + <div style="position:absolute; width:100px; right:10px; text-align:center; line-height: 1em;"> + <a class="white" + href="http://muparser.sourceforge.net/classdocu/index.html" + onmouseover="ChangeButtonImage(2,imgApi)" + onmouseout="ChangeButtonImage(2,imgApiDark)"> + <img src="images/api_dark.png" border="0" alt="class documentation" height="40"/> + <br/> + <span class="tiny_text">muParser<br/>API-doc</span> + </a> + </div> + <!-- + <div style="position:absolute; width:100px; right:10px; text-align:center; line-height: 1em;"> + <a class="white" + href="http://sourceforge.net/project/showfiles.php?group_id=137191" + onmouseover="ChangeButtonImage(3,imgDown)" + onmouseout="ChangeButtonImage(3,imgDownDark)"> + <img src="images/download_dark.png" height="40" border="0" alt="muParser download"/> + <br/> + <span class="tiny_text">muParser<br/>Download</span> + </a> + </div> +--> + </div> <!-- class="gradient" --> + + <!-- Tabelle mit Hauptinhalt der Seite --> + <table id="MainTable" border="0" cellpadding="5" cellspacing="0" style="width:100%; height:100%;"> + <tbody> + <tr> + <td style="vertical-align: top; text-align: center" width="230"> + <h3 class="navi_heading navi_info">Introduction</h3> + <div class="sidebarlink"> + <a href="index.html">About the parser</a><br/> + <a href="http://sourceforge.net/news/?group_id=137191">News</a><br/> + <a href="mup_links.html">Software using muParser</a><br/> + <a href="mup_licence.html">Licence</a><br/> + </div> + + <h3 class="navi_heading navi_blocks">Features</h3> + <div class="sidebarlink"> + <a href="mup_features.html">Features</a><br/> + <a href="mup_features.html#idFeatureOverview">Overview</a><br/> + <a href="mup_features.html#idDef2">Built in functions</a><br/> + <a href="mup_features.html#idDef3">Built in binary operators</a><br/> + </div> + + <h3 class="navi_heading navi_build">Build instructions</h3> + <div class="sidebarlink"> + <a href="mup_usage.html#idInstWin">Building on Win32</a><br/> + <a href="mup_usage.html#idInstLinux">Building on BSD/Linux</a><br/> + <a href="mup_usage.html#idInstMisc">Misc build instructions</a><br/> + <a href="mup_usage.html#idInstInc">Including the files</a><br/> + <a href="mup_usage.html#idInstInc">Where to ask for help</a><br/> + </div> + + <h3 class="navi_heading navi_list">Math parser interface</h3> + <div class="sidebarlink"> + <a href="mup_interface.html#idInit">Parser (de)initialization</a><br/> + <a href="mup_interface.html#idEval">Evaluating an expression</a><br/> + <a href="mup_interface.html#idSetExpr">Setting the expression</a><br/> + <a href="mup_interface.html#idDefCharset">Defining identifier charsets</a><br/> + <a href="mup_interface.html#idDefVar">Defining parser variables</a><br/> + <a href="mup_interface.html#idDefVarEx">Explicit variable definition</a><br/> + <a href="mup_interface.html#idDefVarIm">Implicit variable definition</a><br/> + <a href="mup_interface.html#idDefConst">Defining constants</a><br/> + <a href="mup_interface.html#idDefFun">Defining functions</a><br/> + <a href="mup_interface.html#idDefOprt">Defining operators</a><br/> + <a href="mup_interface.html#idUnOp">Unary operators</a><br/> + <a href="mup_interface.html#idBinOp">Binary operators</a><br/> + <a href="mup_interface.html#idQueryVar">Querying variables</a><br/> + <a href="mup_interface.html#idQueryConst">Querying constants</a><br/> + <a href="mup_interface.html#idDefConst2">Value recognition callbacks</a><br/> + <a href="mup_interface.html#idDefConst2">Removing variables/constants</a><br/> + <a href="mup_locale.html#idLoc">Localization</a><br/> + <a href="mup_interface.html#idErrors">Error handling</a><br/> + <a href="mup_version.html#idExample">Example code</a><br/> + </div> + + <h3 class="navi_heading navi_question">Current version</h3> + <div class="sidebarlink"> + <a href="mup_version.html#idRelNote">Release notes</a><br/> + <a href="mup_version.html#idBench">Benchmarks</a><br/> + </div> + + <br/> + <div align="center"> + <a href="http://www.opensource.org/"><img style="border:0;" src="images/osi.jpg" alt="Open source initiative logo"/></a> + <br/> + <br/> + <a href="http://validator.w3.org/check?uri=referer"> + <img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" style="border:0;width:88px;height:31px"/> + </a> + <br/> + <br/> + <a href="http://jigsaw.w3.org/css-validator/check/referer"> + <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="CSS ist valide!" /> + </a> + + </div> + </td> + + <td style="height: 100%; padding: 1em; vertical-align: top;"> + <!-- + This section contains the real page content. + pages are created automatically by using the script "build_page.sh" + which combines section templated with the navigation bar. + + This creates webpages that do not rely on php3 or Javascript for + serverside or client side html inclusion. + //--> + <!-- $PLACEHOLDER --> + +<!-- +// +// +// +// The parser interface +// +// +// +--> + +<br/> +<h1><a id="idInterface"></a>The parser interface</h1> +The following section gives an overview of the public parser member functions as well as of the functions +exported by the DLL version of the parser. + + +<h2><a id="idInit"></a>Parser initialization / deinitialization</h2> +<h3>[DLL interface]</h3> +Create a new instance handle. You can create as many different instance handles as you like. Each will +internally reference a different parser object. When using the DLL it is necessary to manually release +any parser handle created by <code>mupInit()</code> by calling <code>mupRelease(hParser)</code>. + +<pre> +parser_handle hParser; +hParser = mupInit(); // Create a new handle + +// use the parser... + +mupRelease(hParser); // Release an existing parser handle +</pre> + +Internally a handle is nothing more than a pointer to a parser object casted to a void pointer. + + +<h3>[Parser class interface]</h3> +Code for creating a new parser object. (In case of dynamic allocation use <code>new</code> and <code>delete</code> +for initialization and deinitialization.) + +<pre> +mu::Parser parser; +</pre> + +<!-- +// +// The parser interface / Setting the expression +// +--> + +<h2><a id="idSetExpr"></a>Setting the expression</h2> +<h3>[DLL interface]</h3> +Setting the expression when using the DLL requires a valid parser handle and a pointer to +<code>const char</code> pointing to the expression. + +<pre> +mupSetExpr(hParser, szLine); +</pre> +<small>See also: <i>Example3/Example3.cpp</i>.</small> + +<h3>[Parser class interface]</h3> +Setting the expression using the parser class requires a <code>std::string</code> containing the expression as the +only parameter. +<pre> +parser.SetExpr(line); +</pre> +<small>See also: <i>Example1/Example1.cpp; Example2/WndMain.cpp; ParserLib/muParserTest.cpp</i>.</small> + +<!-- +// +// The parser interface / Evaluating the expression +// +--> + +<h2><a id="idEval"></a>Evaluating an expression</h2> +<p> +Expression evaluation is done by calling the <code>mupEval()</code> function in the DLL version or the +<code>Eval()</code> member function of a parser object. When evaluating an expression for the first time +the parser evaluates the expression string directly and creates a bytecode during +this first time evaluation. Every sucessive call to <code>Eval()</code> will evaluate the bytecode directly +unless you call a function that will silently reset the parser to string parse mode. Some functions +invalidate the bytecode due to possible changes in callback +function pointers or variable addresses. In this way they effectively cause a recreation of the +bytecode during the next call to <code>Eval()</code>. +</p> +<p> +Internally there are different evaluation functions. One for parsing from a string, the other for +parsing from bytecode (and a third one used only if the expression can be simplified to a constant). +Initially, <code>Eval()</code> will call the string parsing function which is slow due to all the +necessary syntax checking, variable lookup, and bytecode creation. Once this +function succeeds, <code>Eval()</code> will change its internal parse function pointer to either +the bytecode parsing function or the const result function which are significantly (approx. 1000 times) +faster. You don't have to worry about this, it's done automatically, just keep in mind that the +first time evaluation of a new formula is significantly slower than any successive call to +<code>Eval()</code>. +</p> + +<h3>[DLL interface]</h3> +<pre> +double fVal; +fVal = mupEval(hParser); +</pre> +<small>See also: <i>Example3/Example3.cpp</i>.</small> + +<h3>[Parser class interface]</h3> +<pre> +double fVal; +try +{ + fVal = parser.Eval(); +} +catch (Parser::exception_type &e) +{ + std::cout << e.GetMsg() << endl; +} +</pre> +<small>See also: <i>Example1/Example1.cpp; Example2/WndMain.cpp</i>.</small> + +<!-- +// +// The parser interface / Defining identifier character sets +// +--> + +<h2><a id="idDefCharset"></a>Defining identifier character sets</h2> +Sometimes it is necessary to change the character sets that are used for token identifiers in +order to avoid conflicts. The parser uses three different character sets. +<ul> + <li>The name character set, is used for: + <ul> + <li>function identifiers</li> + <li>variable identifiers</li> + <li>constant identifiers</li> + </ul> + </li> + <li>The operator character set is used for: + <ul> + <li>binary operator identifiers</li> + <li>postfix operator identifiers</li> + </ul></li> + + <li>The Infix operator charset is used for infix operator identifiers only</li> +</ul> + +When using the default implementation <code>mu::muParser</code> directly you can skip this +section. (The DLL version uses the default implementation internally.) + +<h3>[DLL interface]</h3> +<pre> +mupDefineNameChars(hParser, "0123456789_" + "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); +mupDefineOprtChars(hParser, "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "+-*^/?<>=#!$%&|~'_"); +mupDefineInfixOprtChars(hParser, "/+-*^?<>=#!$%&|~'_"); +</pre> + +<h3>[Parser class interface]</h3> +<pre> +parser.DefineNameChars("0123456789_" + "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); +parser.DefineOprtChars("abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "+-*^/?<>=#!$%&|~'_"); +parser.DefineInfixOprtChars("/+-*^?<>=#!$%&|~'_"); +</pre> +<small>See also: <i>ParserLib/muParser.cpp; ParserLib/muParserInt.cpp</i>.</small> + +<!-- +// +// The parser interface / Defining parser variables +// +--> + +<h2><a id="idDefVar"></a>Defining parser variables</h2> +Custom variables can be defined either explicit in the code by using the <code>DefineVar</code> function or implicit by the parser. Implicit declaration will call a variable factory function provided by the user. The parser is never the owner of its variables. So you must take care of their destruction in case of dynamic allocation. The general idea is to bind every parser variable to a C++ variable. For this reason, you have to make sure the C++ variable stays valid as long as you process a formula that needs it. Only variables of type <code>double</code> are supported. + + +<h2><a id="idDefVarEx"></a>Explicitely defining variables</h2> +Explicitely in this context means you have to do add the variables manually it in your application code. So you must know in advance which variables you intend to use. If this is not the case have a look at +the section on <a href="#idDefVarIm">Implicit creation of new variables</a>. + +<table> + <tr> + <td><img src="images/warning.gif" alt="warning"/></td> + <td>Defining new Variables will reset the parser bytecode. Do not use this function just for changing the values of variables! It would dramatically reduce the parser performance! Once the parser knows the address of the variable there is no need to explicitely call a function for changing the value. Since the parser knows the address it knows the value too so simply change the C++ variable in your code directly!</td> + </tr> +</table> + +<h3>[DLL interface]</h3> +The first parameter is a valid parser handle, the second the variable name and the third a pointer to +the associated C++ variable. + +<pre> +double fVal=0; +mupDefineVar(hParser, "a", &fVal); +</pre> +<small>See also: <i>Example3/Example3.cpp</i>.</small> + +<h3>[Parser class interface]</h3> + +The first parameter is the variable name and the second a pointer to the associated C++ variable. + +<pre> +double fVal=0; +parser.DefineVar("a", &fVal); +</pre> +<small>See also: <i>Example1/Example1.cpp; Example2/WndMain.cpp; ParserLib/muParserTest.cpp</i>.</small> + + +<h2><a id="idDefVarIm"></a>Implicit creation of new variables</h2> +Implicit declaration of new variables is only possible by setting a factory function. Implicit creation +means that everytime the parser finds an unknown token at a position where a variable could be located it +creates a new variable with that name automatically. The necessary factory function must be of type: +<pre>double* (*facfun_type)(const char*, void*)</pre> +The first argument to a factory function is the name of the variable found by the parser. The second is a pointer +to user defined data. This pointer can be used to provide a pointer to a class that implements the actual factory. +By doing this it is possible to use custom factory classes depending on the variable name. + +<table> +<tr><td><img src="images/warning.gif" alt="warning"/></td> <td>Be aware of name conflicts! Please notice that recognizing the name of an undefined variable is the last step during parser token detection. If the potential variable name starts with identifiers that could be interpreted as a function or operator it will be detected as such most likely resulting in an syntax error.</td> +</tr> +</table> + +The following code is an example of a factory function. The example does not use dynamic allocation for +the new variables although this would be possible too. But when using dynamic allocation you must keep +track of the variables allocated implicitely in order to free them later on. + +<pre> +double* AddVariable(const char *a_szName, void *pUserData) +{ + static double afValBuf[100]; + static int iVal = 0; + + std::cout << "Generating new variable \"" + << a_szName << "\" (slots left: " + << 99-iVal << ")" << endl; + + // you could also do: + // MyFactory *pFactory = (MyFactory*)pUserData; + // pFactory->CreateNewVariable(a_szName); + + afValBuf[iVal++] = 0; + if (iVal>=99) + throw mu::Parser::exception_type("Variable buffer overflow."); + + return &afValBuf[iVal]; +} +</pre> +<small>See also: <i>Example1/Example1.cpp</i>.</small> + +In order to add a variable factory use the <code>SetVarFactory</code> functions. The first parameter +is a pointer to the static factory function, the second parameter is optional and represents a pointer +to user defined data. Without a variable factory each undefined variable will cause an undefined token error. Factory +functions can be used to query the values of newly created variables directly from a +database. If you emit errors from a factory function be sure to throw an exception of +type <code>ParserBase::exception_type</code> all other exceptions will be caught internally +and result in an internal error. + +<h3>[DLL interface]</h3> +<pre> +mupSetVarFactory(hParser, AddVariable, pUserData); +</pre> +<small>See also: <i>Example3/Example3.cpp</i>.</small> + +<h3>[Parser class interface]</h3> +<pre> +parser.SetVarFactory(AddVariable, pUserData); +</pre> +<small>See also: <i>Example1/Example1.cpp</i>.</small> + + +<!-- +// +// The parser interface / Defining parser constants +// +--> + + +<h2><a id="idDefConst"></a>Defining parser constants</h2> +Parser constants can either be values of type <code>double</code> or <code>string</code>. Constness +refers to the bytecode. Constants will be stored by their value in the bytecode, not by a reference to +their address. Thus accessing them is faster. They may be optimized away if this is possible. +Defining new constants or changing old ones will reset the parser to string parsing mode thus resetting +the bytecode. +<br/> +The Names of user defined constants may contain only the following characters: <code>0-9, a-z, A-Z, _</code>, and they may not start with a number. Violating this rule will raise a parser error. + +<h3>[DLL interface]</h3> +<pre> +// Define value constants <code>_pi</code> +mupDefineConst(hParser, "_pi", (double)PARSER_CONST_PI); + +// Define a string constant named <code>strBuf</code> +mupDefineStrConst("strBuf", "hello world"); +</pre> +<small>See also: <i>Example3/Example3.cpp</i>.</small> + + +<h3>[Parser class interface]</h3> +<pre> +// Define value constant <code>_pi</code> +parser.DefineConst("_pi", (double)PARSER_CONST_PI); + +// Define a string constant named <code>strBuf</code> +parser.DefineStrConst("strBuf", "hello world"); +</pre> +<small>See also: <i>Example1/Example1.cpp; Example2/WndMain.cpp; ParserLib/muParserTest.cpp</i>.</small> + +<!-- +// +// The parser interface / Defining parser functions +// +--> + + +<h2><a id="idDefFun"></a>Defining parser functions</h2> +The parser allows the user to define a variety of different callback functions. +Functions with a fixed number of up to five numeric arguments, functions with +a variable number of numeric arguments and functions taking a sinlge string +argument plus up to two numeric values. +In order to define a parser function you need to specify its name, a pointer +to a static callback function and an optional flag indicating if the function +is volatile. Volatile functions are functions that can not be optimized. +<br/> +The static callback functions must have of either one of the <a id="FunTypes">following types</a>: + +<pre> +// For fixed number of arguments +double (*fun_type1)(double); +double (*fun_type2)(double, double); +double (*fun_type3)(double, double, double); +double (*fun_type4)(double, double, double, double); +double (*fun_type5)(double, double, double, double, double); + +// for a variable number of arguments +// first arg: pointer to the arguments +// second arg: number of arguments +double (*multfun_type)(const double*, int); + +// for functions taking a single string plus up to two numeric values +double (*strfun_type1)(const char *); +double (*strfun_type2)(const char *, double); +double (*strfun_type3)(const char *, double, double); +</pre> + + +<h3>[DLL interface]</h3> +When using the DLL version it is necessary to call a seperate function for +each type of callback. The following is a list of possible choices. + +<pre> +// Add functions taking string parameters that cant be optimized +mupDefineStrFun1(hParser, "StrFun1", pStrCallback1, false); +mupDefineStrFun2(hParser, "StrFun2", pStrCallback2, false); +mupDefineStrFun3(hParser, "StrFun3", pStrCallback3, false); + +// Add an function with a fixed number of arguments +mupDefineFun1(hParser, "fun1", pCallback1, false); +mupDefineFun2(hParser, "fun2", pCallback2, false); +mupDefineFun3(hParser, "fun3", pCallback3, false); +mupDefineFun4(hParser, "fun4", pCallback4, false); +mupDefineFun5(hParser, "fun5", pCallback5, false); + +// Define a function with variable number of arguments +mupDefineMultFun(hParser, "MultFun", pMultCallback); +</pre> +<small>See also: <i>Example3.cpp</i>.</small> + + +<h3>[Parser class interface]</h3> +Defining callback functions by using the parser class directly is easier since there is +only a single member function that is used for all kinds of callbacks. Since +this member function is defined as a template internally it automatically associates +the right code to any given type of callback. (As long as this type is listed +<a href="#FunTypes">above</a>) + +<pre> +parser.DefineFun("FunName", pCallback, false) +</pre> +<small>See also: <i>Example1/Example1.cpp; ParserLib/muParser.cpp; ParserLib/muParserInt.cpp</i>.</small> + +<!-- +// +// +// The parser interface / Defining parser operators +// +// +--> + +<h2><a id="idDefOprt"></a>Defining parser operators</h2> +The parser is extensible with different kinds of operators: prefix operators, infix operators +and binary operators. Operators can be applied to numerical values only (not to string constants). + +<ul> + <li>Postfix operators are operators that succeed values. For instance the factorial operator + (<code>a! = a*(a-1)...*2*1</code>). Another application for postfix operators is their use as multipliers + that can be used for implementing units.</li> + <li>Infix operators are operators like the unary minus which serves as a sign or the logical + not <code>"!(a<9)"</code>.</li> + <li>Binary operators can be defined in order to supplement or replace the built in binary operators + they require an additional parameter, the operator priority.</li> +</ul> + + +<!-- +// +// The parser interface / unary Operators +// +--> + + +<h3><a id="idUnOp"></a>Unary operators</h3> +Both postfix and infix operators take <a href="#FunTypes">callback functions of type</a> <code>fun_type1</code> like the following: + +<pre> +double MyCallback(double fVal) +{ + return fVal/1000.0; +} +</pre> + +For defining postfix operators and infix operators you need a valid parser instance, +an identifier string, and an optional third parameter marking the operator as volatile +(non optimizable). + +<h3>[DLL interface]</h3> +<pre> +// Define an infix operator +mupDefineInfixOprt(hParser, "!", MyCallback); + +// Define a postfix operators +mupDefinePostfixOprt(hParser, "M", MyCallback); +</pre> +<small>See also:<i>Example3/Example3.cpp</i>.</small> + +<h3>[Parser class interface]</h3> +<pre> +// Define an infix operator +parser.DefineInfixOprt("!", MyCallback); + +// Define a postfix operators +parser.DefinePostfixOprt("m", MyCallback); +</pre> +<small>See also:<i>Example1/Example1.cpp; Example2/WndMain.cpp; muParserTest.cpp</i>.</small> + + + +<!-- +// +// The parser interface / Binary Operators +// +--> + + +<h3><a id="idBinOp"></a>Binary operators</h3> +This parser has 15 <a href="mup_features.html#idDef3">Built in binary operators</a>. Sometimes it might be necessary to add additional custom binary operators. Examples are <code>shl</code> or <code>shr</code>, the "<b>shift left</b>" and "<b>shift right</b>" operators for integer numbers. +In order to add user defined operators you need to assign a name, a callback function of type <code><a href="#idDefFun">fun_type2</a></code> and a priority for each new binary operator. You are not allowed to overload built in operators, this would result in an error being raised! For instance lets consider the +following callback function which should be assigned to a binary operator: + +<pre> +double pMyAddFun(double v1, double v2) +{ + return v1+v2; +} +</pre> + +For the definintion of binary operators you need at least 4 parameters. The first is a valid parser handle, +the second is the identifier of the operator, the third is the operator callback function, the fourth is +the operator priority and the optional fifth parameter is a flag of type <code>bool</code> marking the operator +as volatile. (The examples below omit the last flag.) +Having defined a proper operator callback function you can add the binary operator with the following code: + +<h3>[DLL interface]</h3> +<pre> +mupDefineOprt(hParser, "add", pMyAddFun, 0); +</pre> +<small>See also:<i>Example3/Example3.cpp</i>.</small> + +<h3>[Parser class interface]</h3> +<pre> +parser.DefineOprt("add", pMyAddFun, 0); +</pre> +<small>See also:<i>Example1/Example1.cpp; Example2/WndMain.cpp; muParserTest.cpp</i>.</small> + +<a href="mup_features.html#idDef3">The priority</a> value must be greater or equal than zero (lowest possible priority). It controls the operator precedence in the formula. For instance if you want to calculate the formula <code>1+2*3^4</code> in a mathemetically correct sense you have to make sure that Addition has a lower priority than multiplication which in turn has a lower priority than the power operator. The most likely cases are that you assign an operator with a low priority of 0 (like <code>and</code>, <code>or</code>, <code>xor</code>) or a high priority that is larger than 6. (The priority of the power operator (<code>^</code>).) +By assigning Priority values already used by built in operators you might introduce unwanted side effects. To avoid this and make the order of calculation clear you must use brackets in these cases. Otherwise the order will be determined by the Formula parsing direction which is from left to right. +<br/> +<br/> +Example A: Priority of <code>shl</code> equals priority of an addition; The order of the execution is from left to right. +<pre> +1 + 2 shl 1 => (1 + 2) shl 1 +2 shl 1 + 1 => (s shl 1) + 1 +</pre> +Example B: Priority of <code>shl</code> is higher than the one of the addition; <code>shl</code> is executed first. +<pre> +1 + 2 shl 1 => 1 + (2 shl 1) +2 shl 1 + 1 => (2 shl 1) + 1 +</pre> + +If you encounter such conflicts or simply dont need the built in operators these can easily be deactivated using the <code>EnableBuiltInOprt(bool)</code> function. If you call this function you must add binary operators manually. After all without any operators you won't be able to parse anything useful. User defined operators come with approximately 10% decrease in parsing speed compared to built in operators. There is no way to avoid that. They cause an overhead when calling theeir callback functions. (This is the reason why there are built in operators) + +<pre> +// disable all built in operators +parser.EnableBuiltInOprt(false); +</pre> + + +<!-- +// +// The parser interface / Querying parser variables +// +--> + +<h2><a id="idQueryVar"></a>Querying parser variables</h2> +Keeping track of all variables can be a difficult task. For simplification the parser allows the user +to query the variables defined in the parser. There are two different sets of variables that can +be accessed: + +<ul> + <li>Varaiables defined in the parser</li> + <li>Variables used in the current expression</li> +</ul> + +Since the usage of the necessary commands is similar the following example shows +querying the parser variables only. + + +<h3>[DLL interface]</h3> +For querying the variables used in the expression exchange <code>mupGetVarNum(...)</code> with +<code>mupGetExprVarNum(...)</code> and <code>mupGetVar(...)</code> with <code>mupGetExprVar(...)</code> +in the following example. Due to the use of an temporary internal static buffer for storing the variable +name in the DLL version this DLL-function is not thread safe. + +<pre> +// Get the number of variables +int iNumVar = mupGetVarNum(a_hParser); + +// Query the variables +for (int i=0; i < iNumVar; ++i) +{ + const char *szName = 0; + double *pVar = 0; + mupGetVar(a_hParser, i, &szName, &pVar); + std::cout << "Name: " << szName << " Address: [0x" << pVar << "]\n"; +} +</pre> +<small>See also: <i>Example3/Example3.cpp</i>.</small> + +<h3>[Parser class interface]</h3> +For querying the expression variables exchange <code>parser.GetVar()</code> with +<code>parser.GetUsedVar()</code> in the following example. + +<pre> +// Get the map with the variables +mu::Parser::varmap_type variables = parser.GetVar(); +cout << "Number: " << (int)variables.size() << "\n"; + +// Get the number of variables +mu::Parser::varmap_type::const_iterator item = variables.begin(); + +// Query the variables +for (; item!=variables.end(); ++item) +{ + cout << "Name: " << item->first << " Address: [0x" << item->second << "]\n"; +} +</pre> + +<small> + See also: <i>Example1/Example1.cpp, Example2/WndMain.cpp</i>. +</small> + +<!-- +// +// The parser interface / Querying parser constants +// +--> + + +<h2><a id="idQueryConst"></a>Querying parser constants</h2> +Querying parser constants is similar to querying variables and expression variables. + +<h3>[DLL interface]</h3> +Due to the use of an temporary internal static buffer for storing the variable +name in the DLL version this DLL-function is not thread safe. + +<pre> +int iNumVar = mupGetConstNum(a_hParser); + +for (int i=0; i < iNumVar; ++i) +{ + const char *szName = 0; + double fVal = 0; + mupGetConst(a_hParser, i, &szName, fVal); + std::cout << " " << szName << " = " << fVal << "\n"; +} +</pre> + +<small> + See also: <i>Example3/Example3.cpp</i>. +</small> + + +<h3>[Parser class interface]</h3> +The parser class provides you with the <code>GetConst()</code> member function that returns a map structure +with all defined constants. The following code snippet shows how to use it: +<pre> +mu::Parser::valmap_type cmap = parser.GetConst(); +if (cmap.size()) +{ + mu::Parser::valmap_type::const_iterator item = cmap.begin(); + for (; item!=cmap.end(); ++item) + cout << " " << item->first << " = " << item->second << "\n"; +} +</pre> +<small>See also: <i>Example1/Example1.cpp, Example2/WndMain.cpp</i>.</small> + +<!-- +// +// The parser interface / Setting custom value recognition callbacks +// +--> + + +<h2><a id="idDefConst2"></a>Setting custom value recognition callbacks</h2> +The parser default implementation <i>(muParser.cpp)</i> scans expressions +only for floating point values. Custom value recognition callbacks can be used in order to +implement support for binary, hexadecimal or octal numbers. These functions are called +during the string parsing and allow the user to scan portions of the original expressions +for values. Their callback functions must be of the following type: + +<pre> +bool (*identfun_type)(const char_type*, int&, value_type&); +</pre> + +<p> +If the parser reaches an a position during string parsing that could host a value token it +tries to interpret it as such. If that fails the parser sucessively calls all +internal value recognition callbacks in order to give them a chance to make +sense out of what has been found. If all of them fail the parser continues to +check if it is a Variable or another kind of token. +</p> + +<p> +In order to perform the task of value recognition these functions take a <code>const char</code> +pointer, a reference to <code>int</code> and a reference +to <code>double</code> as their arguments. +The <code>const char</code> pointer points to the current formula position. The second +argument is the index of that position. This value must be increased by the length of the +value entry if one has been found. In that case the value must be written to the third +argument which is of type <code>double</code>. +</p> + +<p> +The next code snippet shows a sample implementation of a function that reads and +interprets binary values from the expression string. The code is taken from +<i>muParserInt.cpp</i> the implementation of a parser for integer numbers. Binary +numbers must be preceded with a <code>#</code> (i.e. <code>#1000101</code>). +</p> + +<pre> +bool ParserInt::IsBinVal(const char_type *a_szExpr, + int &a_iPos, value_type &a_fVal) +{ + if (a_szExpr[0]!='#') + return false; + + unsigned iVal = 0, iBits = sizeof(iVal)*8; + for (unsigned i=0; + (a_szExpr[i+1]=='0'||a_szExpr[i+1]=='1')&& i<iBits; + ++i) + { + iVal |= (int)(a_szExpr[i+1]=='1') << ((iBits-1)-i); + } + + if (i==0) + return false; + + if (i==iBits) + throw exception_type("Binary to integer conversion error (overflow)."); + + a_fVal = (unsigned)(iVal >> (iBits-i) ); + a_iPos += i+1; + + return true; +} +</pre> + +Once you have the callback you must add it to the parser. This can be done with: + +<h3>[DLL interface]</h3> +<pre> +mupAddValIdent(hParser, IsBinVal); +</pre> + +<small> +See also: <i>Example3/Example3.cpp</i>. +</small> + + +<h3>[Parser class interface]</h3> +<pre> +parser.AddValIdent(IsBinVal); +</pre> +<small> +See also: <i>ParserLib/muParserInt.cpp</i>. +</small> + +<!-- +// +// The parser interface / Removing variables or constants +// +--> + +<h2><a id="idRemoveVar"></a>Removing variables or constants</h2> +Removing variables and constants can be done all at once using <code>ClearVar</code> and +<code>ClearConst</code>. Additionally variables can be removed by name using +<code>RemoveVar</code>. Since the parser never owns the variables you must take care of +their release yourself <small>(if they were dynamically allocated)</small>. If you need to browse all +the variables have a look at the chapter explaining how to +<a href="#idQueryVar">query parser variables</a>. + + +<h3>[DLL interface]</h3> +<pre> +// Remove all constants +mupClearConst(hParser); + +// remove all variables +mupClearVar(hParser); + +// remove a single variable by name +mupRemoveVar(hParser, "a"); +</pre> + + +<h3>[Parser class interface]</h3> +<pre> +// Remove all constants +parser.ClearConst(); + +// remove all variables +parser.ClearVar(); + +// remove a single variable by name +parser.RemoveVar("a"); +</pre> + +<!-- +// +// The parser interface / Error handling +// +--> + + +<h2><a id="idErrors"></a>Error handling</h2> +In case of an error both parser class and the parser DLL provide +similar methods for querying the information associated with the +error. In the parser class they are member functions of the associated +exception class <code>mu::Parser::exception_type</code> and in the DLL +version they are normal functions. + +<p> +These functions are: +</p> + +<ul> + <li><code>exception.GetMsg() / mupGetErrorMsg()</code> - returns the error message.</li> + <li><code>exception.GetExpr() / mupGetExpr()</code> - returns the current formula (if a formula is set)</li> + <li><code>exception.GetToken() / mupGetErrorToken()</code> - returns the token associated with the error (if applicable)</li> + <li><code>exception.GetPos() / mupGetErrorPos()</code> - returns the current formula position (if applicable)</li> + <li><code>exception.GetCode() / mupGetErrorCode()</code> - returns the error code.</li> +</ul> + +<p> +The following table lists the parser error codes. +The first column contains the enumeration values as defined in the enumeration <code>mu::EErrorCodes</code> +located in the file <i>muParserError.h</i>. Since they are only accessible from C++ the second column lists +their numeric code and the third column contains the error description. +</p> + +<table border="0"> +<thead> + <tr> + <td> <small><b>Enumeration name</b></small></td> + <td align="center"><small><b>Value</b></small></td> + <td> <small><b>Description</b></small></td> + </tr> +</thead> + +<tbody> + <tr> + <td><small><code>ecUNEXPECTED_OPERATOR</code></small></td> + <td align="center"><small>0</small></td> + <td><small>Unexpected binary operator found</small></td> + </tr> + <tr> + <td><small><code>ecUNASSIGNABLE_TOKEN</code></small></td> + <td align="center"><small>1</small></td> + <td><small>Token cant be identified</small></td> + </tr> + <tr> + <td><small><code>ecUNEXPECTED_EOF</code></small></td> + <td align="center"><small>2</small></td> + <td><small>Unexpected end of formula. (Example: "2+sin(")</small></td> + </tr> + <tr> + <td><small><code>ecUNEXPECTED_COMMA</code></small></td> + <td align="center"><small>3</small></td> + <td><small>An unexpected comma has been found. (Example: "1,23")</small></td> + </tr> + <tr> + <td><small><code>ecUNEXPECTED_ARG</code></small></td> + <td align="center"><small>4</small></td> + <td><small>An unexpected argument has been found</small></td> + </tr> + <tr> + <td><small><code>ecUNEXPECTED_VAL</code></small></td> + <td align="center"><small>5</small></td> + <td><small>An unexpected value token has been found</small></td> + </tr> + <tr> + <td><small><code>ecUNEXPECTED_VAR</code></small></td> + <td align="center"><small>6</small></td> + <td><small>An unexpected variable token has been found</small></td> + </tr> + <tr> + <td><small><code>ecUNEXPECTED_PARENS</code></small></td> + <td align="center"><small>7</small></td> + <td><small>Unexpected parenthesis, opening or closing</small></td> + </tr> + <tr> + <td><small><code>ecUNEXPECTED_STR</code></small></td> + <td align="center"><small>8</small></td> + <td><small>A string has been found at an inapropriate position</small></td> + </tr> + <tr> + <td><small><code>ecSTRING_EXPECTED</code></small></td> + <td align="center"><small>9</small></td> + <td><small>A string function has been called with a different type of argument</small></td> + </tr> + <tr> + <td><small><code>ecVAL_EXPECTED</code></small></td> + <td align="center"><small>10</small></td> + <td><small>A numerical function has been called with a non value type of argument</small></td> + </tr> + <tr> + <td><small><code>ecMISSING_PARENS</code></small></td> + <td align="center"><small>11</small></td> <td><small>Missing parens. (Example: "3*sin(3")</small></td> + </tr> + <tr> + <td><small><code>ecUNEXPECTED_FUN</code></small></td> + <td align="center"><small>12</small></td> + <td><small>Unexpected function found. (Example: "sin(8)cos(9)")</small></td> + </tr> + <tr> + <td><small><code>ecUNTERMINATED_STRING</code></small></td> + <td align="center"><small>13</small></td> + <td><small>unterminated string constant. (Example: "3*valueof("hello)")</small></td> + </tr> + <tr> + <td><small><code>ecTOO_MANY_PARAMS</code></small></td> + <td align="center"><small>14</small></td> + <td><small>Too many function parameters</small></td> + </tr> + <tr> + <td><small><code>ecTOO_FEW_PARAMS</code></small></td> + <td align="center"><small>15</small></td> + <td><small>Too few function parameters. (Example: "ite(1<2,2)")</small></td> + </tr> + <tr> + <td><small><code>ecOPRT_TYPE_CONFLICT</code></small></td> + <td align="center"><small>16</small></td> + <td><small>binary operators may only be applied to value items of the same type</small></td> + </tr> + <tr> + <td><small><code>ecSTR_RESULT</code></small></td> + <td align="center"><small>17</small></td> + <td><small>result is a string</small></td> + </tr> + <tr> + <td><small><code>ecINVALID_NAME</code></small></td> + <td align="center"><small>18</small></td> + <td><small>Invalid function, variable or constant name.</small></td> + </tr> + <tr> + <td><small><code>ecBUILTIN_OVERLOAD</code></small></td> + <td align="center"><small>19</small></td> + <td><small>Trying to overload builtin operator</small></td> + </tr> + <tr> + <td><small><code>ecINVALID_FUN_PTR</code></small></td> + <td align="center"><small>20</small></td> + <td><small>Invalid callback function pointer</small></td> + </tr> + <tr> + <td><small><code>ecINVALID_VAR_PTR</code></small></td> + <td align="center"><small>21</small></td> + <td><small>Invalid variable pointer</small></td> + </tr> + <tr> + <td><small><code>ecNAME_CONFLICT</code></small></td> + <td align="center"><small>22</small></td> + <td><small>Name conflict</small></td> + </tr> + <tr> + <td><small><code>ecOPT_PRI</code></small></td> + <td align="center"><small>23</small></td> + <td><small>Invalid operator priority</small></td> + </tr> + <tr> + <td><small><code>ecDOMAIN_ERROR</code></small></td> + <td align="center"><small>24</small></td> + <td><small>catch division by zero, sqrt(-1), log(0) (currently unused)</small></td> + </tr> + <tr> + <td><small><code>ecDIV_BY_ZERO</code></small></td> + <td align="center"><small>25</small></td> + <td><small>Division by zero (currently unused)</small></td> + </tr> + <tr> + <td><small><code>ecGENERIC</code></small></td> + <td align="center"><small>26</small></td> + <td><small>Error that does not fit any other code but is not an internal error</small></td> + </tr> + <tr> + <td><small><code>ecINTERNAL_ERROR</code></small></td> + <td align="center"><small>27</small></td> + <td><small>Internal error of any kind.</small></td> + </tr> + </tbody> +</table> + +<h3>[DLL interface]</h3> +Since dynamic libraries with functions exported in C-style can't throw exceptions the DLL version +provides the user with a callback mechanism to raise errors. Simply add a callback function +that does the handling of errors. Additionally you can query the error flag with +<code>mupError()</code>. Please note that by calling this function you will automatically reset the error flag! +<pre> +// Callback function for errors +void OnError() +{ + cout << "Message: " << mupGetErrorMsg() << "\n"; + cout << "Token: " << mupGetErrorToken() << "\n"; + cout << "Position: " << mupGetErrorPos() << "\n"; + cout << "Errc: " << mupGetErrorCode() << "\n"; +} + +... + +// Set a callback for error handling +mupSetErrorHandler(OnError); + +// The next function could raise an error +fVal = mupEval(hParser); + +// Test for the error flag +if (!mupError()) cout << fVal << "\n"; +</pre> +<small>See also: Example3/Example3.cpp</small> + +<h3>[Parser class interface]</h3> +In case of an error the parser class raises an exception of type <code>Parser::exception_type</code>. This +class provides you with several member functions that allow querying the exact cause as well as +additional information for the error. +<pre> +try +{ + ... + parser.Eval(); + ... +} +catch(mu::Parser::exception_type &e) +{ + cout << "Message: " << e.GetMsg() << "\n"; + cout << "Formula: " << e.GetExpr() << "\n"; + cout << "Token: " << e.GetToken() << "\n"; + cout << "Position: " << e.GetPos() << "\n"; + cout << "Errc: " << e.GetCode() << "\n"; +} +</pre> +<small>See also: Example1/Example1.cpp</small> + + + + <hr/> + <table border="0" style="width:100%"> + <tr> + <td>© 2005-2010 <a href="http://beltoforion.de">Ingo Berg</a> | + <a href="http://beltoforion.de/privacy_policy/privacy_policy_en.html">Privacy policy</a></td> + <td style="text-align:right; padding-right: 3em;"> + <a href="#top">^ TOP</a> + </td> + </tr> + </table> + <br/> + <br/> + + </td> + </tr> + </tbody> + </table> + +<!-- + <script type="text/javascript"> + var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); + document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); + </script> + <script type="text/javascript"> + try + { + var pageTracker = _gat._getTracker("UA-1019178-1"); + pageTracker._trackPageview(); + } + catch(err) {} + </script> +--> +</body> +</html> diff --git a/AMDiS/lib/muparser_v134/docs/html/mup_intro.html b/AMDiS/lib/muparser_v134/docs/html/mup_intro.html new file mode 100644 index 0000000000000000000000000000000000000000..bdc38475410bab95907c3f6a819d14122cd95a3d --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/mup_intro.html @@ -0,0 +1,302 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <link rel="stylesheet" type="text/css" href="style/formate.css"/> + <meta name="author" content="Ingo Berg"/> + <!-- $META --> + <meta name="keywords" content="math parser, math expression parser, muparser, muparserx, muparser.net, .net, c++, lib, dll, donation, function parser"/> + <meta name="description" content="muParser - a fast math parser library"/> + <title>muParser - a fast math parser library</title> + + <script src="script/functions.js" language="javascript" type="text/javascript"></script> + <script type="text/javascript"> + imgHome=new Image(); + imgHome.src="images/home.png"; + imgHomeDark=new Image(); + imgHomeDark.src="images/home_dark.png"; + + imgApi=new Image(); + imgApi.src="images/api.png"; + imgApiDark=new Image(); + imgApiDark.src="images/api_dark.png"; + + function ChangeButtonImage(num,obj) + { + window.document.images[num].src=obj.src; + } + </script> +</head> + +<body> + <div class="gradient" id="top"> + <div class="header"> + muParser - a fast math parser library + <br/> + <div style="font-size:14pt;">Version 1.32</div> + </div> + + <div style="position:absolute; width:250px; height:100px; top:20px; text-align:center"> + <a href="http://sourceforge.net/projects/muparser"> + <img src="http://sflogo.sourceforge.net/sflogo.php?group_id=137191&type=15" + width="150" + height="40" + border="0" + alt="Get muParser - A fast math parser library at SourceForge.net. Fast, secure and Free Open Source software downloads" /> + </a> + </div> + + <div style="position:absolute; width:100px; right:110px; text-align:center; line-height: 1em;"> + <a class="white" + href="http://www.beltoforion.de" + onmouseover="ChangeButtonImage(1,imgHome)" + onmouseout="ChangeButtonImage(1,imgHomeDark)"> + <img src="images/home_dark.png" border="0" height="40" alt="My home page"/> + <br/> + <span class="tiny_text">My home<br/>page</span> + </a> + </div> + + <div style="position:absolute; width:100px; right:10px; text-align:center; line-height: 1em;"> + <a class="white" + href="http://muparser.sourceforge.net/classdocu/index.html" + onmouseover="ChangeButtonImage(2,imgApi)" + onmouseout="ChangeButtonImage(2,imgApiDark)"> + <img src="images/api_dark.png" border="0" alt="class documentation" height="40"/> + <br/> + <span class="tiny_text">muParser<br/>API-doc</span> + </a> + </div> + <!-- + <div style="position:absolute; width:100px; right:10px; text-align:center; line-height: 1em;"> + <a class="white" + href="http://sourceforge.net/project/showfiles.php?group_id=137191" + onmouseover="ChangeButtonImage(3,imgDown)" + onmouseout="ChangeButtonImage(3,imgDownDark)"> + <img src="images/download_dark.png" height="40" border="0" alt="muParser download"/> + <br/> + <span class="tiny_text">muParser<br/>Download</span> + </a> + </div> +--> + </div> <!-- class="gradient" --> + + <!-- Tabelle mit Hauptinhalt der Seite --> + <table id="MainTable" border="0" cellpadding="5" cellspacing="0" style="width:100%; height:100%;"> + <tbody> + <tr> + <td style="vertical-align: top; text-align: center" width="230"> + <h3 class="navi_heading navi_info">Introduction</h3> + <div class="sidebarlink"> + <a href="index.html">About the parser</a><br/> + <a href="http://sourceforge.net/news/?group_id=137191">News</a><br/> + <a href="mup_links.html">Software using muParser</a><br/> + <a href="mup_licence.html">Licence</a><br/> + </div> + + <h3 class="navi_heading navi_blocks">Features</h3> + <div class="sidebarlink"> + <a href="mup_features.html">Features</a><br/> + <a href="mup_features.html#idFeatureOverview">Overview</a><br/> + <a href="mup_features.html#idDef2">Built in functions</a><br/> + <a href="mup_features.html#idDef3">Built in binary operators</a><br/> + </div> + + <h3 class="navi_heading navi_build">Build instructions</h3> + <div class="sidebarlink"> + <a href="mup_usage.html#idInstWin">Building on Win32</a><br/> + <a href="mup_usage.html#idInstLinux">Building on BSD/Linux</a><br/> + <a href="mup_usage.html#idInstMisc">Misc build instructions</a><br/> + <a href="mup_usage.html#idInstInc">Including the files</a><br/> + <a href="mup_usage.html#idInstInc">Where to ask for help</a><br/> + </div> + + <h3 class="navi_heading navi_list">Math parser interface</h3> + <div class="sidebarlink"> + <a href="mup_interface.html#idInit">Parser (de)initialization</a><br/> + <a href="mup_interface.html#idEval">Evaluating an expression</a><br/> + <a href="mup_interface.html#idSetExpr">Setting the expression</a><br/> + <a href="mup_interface.html#idDefCharset">Defining identifier charsets</a><br/> + <a href="mup_interface.html#idDefVar">Defining parser variables</a><br/> + <a href="mup_interface.html#idDefVarEx">Explicit variable definition</a><br/> + <a href="mup_interface.html#idDefVarIm">Implicit variable definition</a><br/> + <a href="mup_interface.html#idDefConst">Defining constants</a><br/> + <a href="mup_interface.html#idDefFun">Defining functions</a><br/> + <a href="mup_interface.html#idDefOprt">Defining operators</a><br/> + <a href="mup_interface.html#idUnOp">Unary operators</a><br/> + <a href="mup_interface.html#idBinOp">Binary operators</a><br/> + <a href="mup_interface.html#idQueryVar">Querying variables</a><br/> + <a href="mup_interface.html#idQueryConst">Querying constants</a><br/> + <a href="mup_interface.html#idDefConst2">Value recognition callbacks</a><br/> + <a href="mup_interface.html#idDefConst2">Removing variables/constants</a><br/> + <a href="mup_locale.html#idLoc">Localization</a><br/> + <a href="mup_interface.html#idErrors">Error handling</a><br/> + <a href="mup_version.html#idExample">Example code</a><br/> + </div> + + <h3 class="navi_heading navi_question">Current version</h3> + <div class="sidebarlink"> + <a href="mup_version.html#idRelNote">Release notes</a><br/> + <a href="mup_version.html#idBench">Benchmarks</a><br/> + </div> + + <br/> + <div align="center"> + <a href="http://www.opensource.org/"><img style="border:0;" src="images/osi.jpg" alt="Open source initiative logo"/></a> + <br/> + <br/> + <a href="http://validator.w3.org/check?uri=referer"> + <img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" style="border:0;width:88px;height:31px"/> + </a> + <br/> + <br/> + <a href="http://jigsaw.w3.org/css-validator/check/referer"> + <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="CSS ist valide!" /> + </a> + + </div> + </td> + + <td style="height: 100%; padding: 1em; vertical-align: top;"> + <!-- + This section contains the real page content. + pages are created automatically by using the script "build_page.sh" + which combines section templated with the navigation bar. + + This creates webpages that do not rely on php3 or Javascript for + serverside or client side html inclusion. + //--> + <!-- $PLACEHOLDER --> +<script type="text/javascript"> + imgParserNET=new Image(); + imgParserNET.src="images/muParserNET.png"; + imgParserNETDark=new Image(); + imgParserNETDark.src="images/muParserNET_.png"; + + imgParserX=new Image(); + imgParserX.src="images/muParserX.png"; + imgParserXDark=new Image(); + imgParserXDark.src="images/muParserX_.png"; + + imgDownload=new Image(); + imgDownload.src="images/download_muparser.png"; + imgDownloadDark=new Image(); + imgDownloadDark.src="images/download_muparser_.png"; +</script> + +<h2>About the parser</h2> + +<p> +Many applications require the parsing of <strong>mathematical expressions</strong>. +The main objective of this library is to provide a fast and easy way of +doing this. <strong>muParser</strong> is an extensible high performance +<strong>math parser</strong> library written in <a href="http://www.cplusplus.com/">C++</a>. It works +by transforming a mathematical expression into bytecode and precalculating constant +parts of the expression. +</p> + +<div style="/*position:float; */border: 1px solid #000000; width:420px; height:220px; text-align:left; float:left; margin-right:10px; background-color: #ffffff;"> +<img src="images/related.png" alt="math expression parser - related links" border="0" width="420"/> + <a href="http://www.codeproject.com/KB/recipes/muParser.aspx"> + <img src="images/muParserNET_.png" alt=".NET math parser" border="0" width="200" style="float:left;" onmouseover="ChangeButtonImage(7,imgParserNET)" onmouseout="ChangeButtonImage(7,imgParserNETDark)"/> + <br/> + <strong>muParser C# wrapper</strong> + <br/> + <span class="tiny_text">a math parser for .NET</span> + </a> + + <br clear="all"/><br/> + <a href="http://beltoforion.de/muparserx/math_expression_parser_en.html"> + <img src="images/muParserX_.png" + alt="math expression parser" + border="0" + width="200" + style="float:left;" + onmouseover="ChangeButtonImage(8,imgParserX)" + onmouseout="ChangeButtonImage(8,imgParserXDark)"/> + <strong>muParserX</strong> + <br/> + <span class="tiny_text">a math expression parser with support for multitype data types</span> + </a> +</div> +The library was designed with portability in mind and should compile on every +standard compliant C++ compiler. Wrapper for <strong>C</strong> and <strong>C#</strong> +exist. The parser archive contains ready to use project and makefiles files for a variety of +platforms. The code runs on both <strong>32 bit</strong> and +<strong>64 bit</strong> architechtures and has been tested using MS VC++ V8.0 +and GCC V4.4.1. Code samples are provided in order to help you understand its +usage. The library is <strong>open source</strong> and distributed under +the <a href="http://www.opensource.org/licenses/mit-license.php">MIT license</a>. + +<div style="text-align:center;"> +<a href="http://sourceforge.net/project/showfiles.php?group_id=137191"> + <img src="images/download_muparser_.png" + border="0" + alt="muParser download" + onmouseover="ChangeButtonImage(9,imgDownload)" + onmouseout="ChangeButtonImage(9,imgDownloadDark)"/> +</a> +</div> + +<p> +Before I go on, I'd like to thank <a href="http://sourceforge.net">SourceForge</a> for hosting this project. This +pages would not exist without the webspace provided by them and of course I'd like +to thank <a href="http://www.codeproject.com">CodeProject</a> for hosting the original +<a href="http://www.codeproject.com/cpp/FastMathParser.asp" target="_blank">math parser</a> +article. +</p> + + +<h2>Support this project</h2> +muParser is free software and anyone can use it free of charge for commercial and noncommercial purposes. If you wish you can support this project by <strong>making a small donation</strong>: +<br/> +<br/> +<div style="text-align:center;"> + <a href="http://sourceforge.net/donate/index.php?group_id=137191"> + <img src="http://images.sourceforge.net/images/project-support.jpg" + width="196" + height="64" + border="0" + alt="Support This Project"/> + </a> +</div> +<br/> +A project like muParser requires permanent maintanence in order to adopt to new platforms, new compiler version and for fixing bugs. So if you are using the library and find it useful i would like to encourage you to make a donation in order to help keeping the project up to date. I can officially guarantee that you <strong>make my day</strong> by donating even a small amount of money. In a way this is a "Wow the people actually really appreciate what i'm doing" kind of thing and that's whats driving me and ultimately this is what is keeping this project alive. + + + + <hr/> + <table border="0" style="width:100%"> + <tr> + <td>© 2005-2010 <a href="http://beltoforion.de">Ingo Berg</a> | + <a href="http://beltoforion.de/privacy_policy/privacy_policy_en.html">Privacy policy</a></td> + <td style="text-align:right; padding-right: 3em;"> + <a href="#top">^ TOP</a> + </td> + </tr> + </table> + <br/> + <br/> + + </td> + </tr> + </tbody> + </table> + +<!-- + <script type="text/javascript"> + var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); + document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); + </script> + <script type="text/javascript"> + try + { + var pageTracker = _gat._getTracker("UA-1019178-1"); + pageTracker._trackPageview(); + } + catch(err) {} + </script> +--> +</body> +</html> diff --git a/AMDiS/lib/muparser_v134/docs/html/mup_licence.html b/AMDiS/lib/muparser_v134/docs/html/mup_licence.html new file mode 100644 index 0000000000000000000000000000000000000000..e78a646c3c31c75656d0ccd18e74ecb0361079bf --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/mup_licence.html @@ -0,0 +1,259 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <link rel="stylesheet" type="text/css" href="style/formate.css"/> + <meta name="author" content="Ingo Berg"/> + <!-- $META --> + <meta name="keywords" content="muparser, licence, licencing, terms and conditions, legal, mit, open source, c++"/> + <meta name="description" content="muparser licence"/> + <title>muparser Licence</title> + + <script src="script/functions.js" language="javascript" type="text/javascript"></script> + <script type="text/javascript"> + imgHome=new Image(); + imgHome.src="images/home.png"; + imgHomeDark=new Image(); + imgHomeDark.src="images/home_dark.png"; + + imgApi=new Image(); + imgApi.src="images/api.png"; + imgApiDark=new Image(); + imgApiDark.src="images/api_dark.png"; + + function ChangeButtonImage(num,obj) + { + window.document.images[num].src=obj.src; + } + </script> +</head> + +<body> + <div class="gradient" id="top"> + <div class="header"> + muParser - a fast math parser library + <br/> + <div style="font-size:14pt;">Version 1.32</div> + </div> + + <div style="position:absolute; width:250px; height:100px; top:20px; text-align:center"> + <a href="http://sourceforge.net/projects/muparser"> + <img src="http://sflogo.sourceforge.net/sflogo.php?group_id=137191&type=15" + width="150" + height="40" + border="0" + alt="Get muParser - A fast math parser library at SourceForge.net. Fast, secure and Free Open Source software downloads" /> + </a> + </div> + + <div style="position:absolute; width:100px; right:110px; text-align:center; line-height: 1em;"> + <a class="white" + href="http://www.beltoforion.de" + onmouseover="ChangeButtonImage(1,imgHome)" + onmouseout="ChangeButtonImage(1,imgHomeDark)"> + <img src="images/home_dark.png" border="0" height="40" alt="My home page"/> + <br/> + <span class="tiny_text">My home<br/>page</span> + </a> + </div> + + <div style="position:absolute; width:100px; right:10px; text-align:center; line-height: 1em;"> + <a class="white" + href="http://muparser.sourceforge.net/classdocu/index.html" + onmouseover="ChangeButtonImage(2,imgApi)" + onmouseout="ChangeButtonImage(2,imgApiDark)"> + <img src="images/api_dark.png" border="0" alt="class documentation" height="40"/> + <br/> + <span class="tiny_text">muParser<br/>API-doc</span> + </a> + </div> + <!-- + <div style="position:absolute; width:100px; right:10px; text-align:center; line-height: 1em;"> + <a class="white" + href="http://sourceforge.net/project/showfiles.php?group_id=137191" + onmouseover="ChangeButtonImage(3,imgDown)" + onmouseout="ChangeButtonImage(3,imgDownDark)"> + <img src="images/download_dark.png" height="40" border="0" alt="muParser download"/> + <br/> + <span class="tiny_text">muParser<br/>Download</span> + </a> + </div> +--> + </div> <!-- class="gradient" --> + + <!-- Tabelle mit Hauptinhalt der Seite --> + <table id="MainTable" border="0" cellpadding="5" cellspacing="0" style="width:100%; height:100%;"> + <tbody> + <tr> + <td style="vertical-align: top; text-align: center" width="230"> + <h3 class="navi_heading navi_info">Introduction</h3> + <div class="sidebarlink"> + <a href="index.html">About the parser</a><br/> + <a href="http://sourceforge.net/news/?group_id=137191">News</a><br/> + <a href="mup_links.html">Software using muParser</a><br/> + <a href="mup_licence.html">Licence</a><br/> + </div> + + <h3 class="navi_heading navi_blocks">Features</h3> + <div class="sidebarlink"> + <a href="mup_features.html">Features</a><br/> + <a href="mup_features.html#idFeatureOverview">Overview</a><br/> + <a href="mup_features.html#idDef2">Built in functions</a><br/> + <a href="mup_features.html#idDef3">Built in binary operators</a><br/> + </div> + + <h3 class="navi_heading navi_build">Build instructions</h3> + <div class="sidebarlink"> + <a href="mup_usage.html#idInstWin">Building on Win32</a><br/> + <a href="mup_usage.html#idInstLinux">Building on BSD/Linux</a><br/> + <a href="mup_usage.html#idInstMisc">Misc build instructions</a><br/> + <a href="mup_usage.html#idInstInc">Including the files</a><br/> + <a href="mup_usage.html#idInstInc">Where to ask for help</a><br/> + </div> + + <h3 class="navi_heading navi_list">Math parser interface</h3> + <div class="sidebarlink"> + <a href="mup_interface.html#idInit">Parser (de)initialization</a><br/> + <a href="mup_interface.html#idEval">Evaluating an expression</a><br/> + <a href="mup_interface.html#idSetExpr">Setting the expression</a><br/> + <a href="mup_interface.html#idDefCharset">Defining identifier charsets</a><br/> + <a href="mup_interface.html#idDefVar">Defining parser variables</a><br/> + <a href="mup_interface.html#idDefVarEx">Explicit variable definition</a><br/> + <a href="mup_interface.html#idDefVarIm">Implicit variable definition</a><br/> + <a href="mup_interface.html#idDefConst">Defining constants</a><br/> + <a href="mup_interface.html#idDefFun">Defining functions</a><br/> + <a href="mup_interface.html#idDefOprt">Defining operators</a><br/> + <a href="mup_interface.html#idUnOp">Unary operators</a><br/> + <a href="mup_interface.html#idBinOp">Binary operators</a><br/> + <a href="mup_interface.html#idQueryVar">Querying variables</a><br/> + <a href="mup_interface.html#idQueryConst">Querying constants</a><br/> + <a href="mup_interface.html#idDefConst2">Value recognition callbacks</a><br/> + <a href="mup_interface.html#idDefConst2">Removing variables/constants</a><br/> + <a href="mup_locale.html#idLoc">Localization</a><br/> + <a href="mup_interface.html#idErrors">Error handling</a><br/> + <a href="mup_version.html#idExample">Example code</a><br/> + </div> + + <h3 class="navi_heading navi_question">Current version</h3> + <div class="sidebarlink"> + <a href="mup_version.html#idRelNote">Release notes</a><br/> + <a href="mup_version.html#idBench">Benchmarks</a><br/> + </div> + + <br/> + <div align="center"> + <a href="http://www.opensource.org/"><img style="border:0;" src="images/osi.jpg" alt="Open source initiative logo"/></a> + <br/> + <br/> + <a href="http://validator.w3.org/check?uri=referer"> + <img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" style="border:0;width:88px;height:31px"/> + </a> + <br/> + <br/> + <a href="http://jigsaw.w3.org/css-validator/check/referer"> + <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="CSS ist valide!" /> + </a> + + </div> + </td> + + <td style="height: 100%; padding: 1em; vertical-align: top;"> + <!-- + This section contains the real page content. + pages are created automatically by using the script "build_page.sh" + which combines section templated with the navigation bar. + + This creates webpages that do not rely on php3 or Javascript for + serverside or client side html inclusion. + //--> + <!-- $PLACEHOLDER --> +<!-- +// +// +// +// License +// +// +// +--> + +<h1><a name="idLicense">muParser licence</a></h1> + +<p> +This library is distributed as freeware. The licence is the <a href="http://www.opensource.org/licenses/mit-license.php">MIT licence</a>: you are free to use it for both non-commercial and commercial use. In order to use it you have to agree to the licence text below. If you use the library I consider it appropriate to give me credit at some place. This can either be the about dialog of your application or the documentation of your software. +If you like this project I encourage you to support it by: +</p> +<ul> + <li>sending a brief description of how you use it in your project</li> + <li>sending <a href="http://sourceforge.net/tracker/?atid=737979&group_id=137191&func=browse">bug reports</a></li> + <li>voting for this project on <a href="http://www.codeproject.com/cpp/FastMathParser.asp">CodeProject</a></li> +</ul> + +<p> +<b>Copyright (c) 2010 Ingo Berg</b> +<br/> +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +</p> + +<p> +The above copyright notice and this permission notice +shall be included in all copies or substantial portions of +the Software.</p> +<p> + +<i> +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS +OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +</i> + +</p> + + + <hr/> + <table border="0" style="width:100%"> + <tr> + <td>© 2005-2010 <a href="http://beltoforion.de">Ingo Berg</a> | + <a href="http://beltoforion.de/privacy_policy/privacy_policy_en.html">Privacy policy</a></td> + <td style="text-align:right; padding-right: 3em;"> + <a href="#top">^ TOP</a> + </td> + </tr> + </table> + <br/> + <br/> + + </td> + </tr> + </tbody> + </table> + +<!-- + <script type="text/javascript"> + var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); + document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); + </script> + <script type="text/javascript"> + try + { + var pageTracker = _gat._getTracker("UA-1019178-1"); + pageTracker._trackPageview(); + } + catch(err) {} + </script> +--> +</body> +</html> diff --git a/AMDiS/lib/muparser_v134/docs/html/mup_links.html b/AMDiS/lib/muparser_v134/docs/html/mup_links.html new file mode 100644 index 0000000000000000000000000000000000000000..c3389018d2586258602744b97735fcb33e86601a --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/mup_links.html @@ -0,0 +1,276 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <link rel="stylesheet" type="text/css" href="style/formate.css"/> + <meta name="author" content="Ingo Berg"/> + <!-- $META --> + <meta name="keywords" content="muparser, related links, related"/> + <meta name="description" content="Software using muparser"/> + <title>Software using muparser</title> + + <script src="script/functions.js" language="javascript" type="text/javascript"></script> + <script type="text/javascript"> + imgHome=new Image(); + imgHome.src="images/home.png"; + imgHomeDark=new Image(); + imgHomeDark.src="images/home_dark.png"; + + imgApi=new Image(); + imgApi.src="images/api.png"; + imgApiDark=new Image(); + imgApiDark.src="images/api_dark.png"; + + function ChangeButtonImage(num,obj) + { + window.document.images[num].src=obj.src; + } + </script> +</head> + +<body> + <div class="gradient" id="top"> + <div class="header"> + muParser - a fast math parser library + <br/> + <div style="font-size:14pt;">Version 1.32</div> + </div> + + <div style="position:absolute; width:250px; height:100px; top:20px; text-align:center"> + <a href="http://sourceforge.net/projects/muparser"> + <img src="http://sflogo.sourceforge.net/sflogo.php?group_id=137191&type=15" + width="150" + height="40" + border="0" + alt="Get muParser - A fast math parser library at SourceForge.net. Fast, secure and Free Open Source software downloads" /> + </a> + </div> + + <div style="position:absolute; width:100px; right:110px; text-align:center; line-height: 1em;"> + <a class="white" + href="http://www.beltoforion.de" + onmouseover="ChangeButtonImage(1,imgHome)" + onmouseout="ChangeButtonImage(1,imgHomeDark)"> + <img src="images/home_dark.png" border="0" height="40" alt="My home page"/> + <br/> + <span class="tiny_text">My home<br/>page</span> + </a> + </div> + + <div style="position:absolute; width:100px; right:10px; text-align:center; line-height: 1em;"> + <a class="white" + href="http://muparser.sourceforge.net/classdocu/index.html" + onmouseover="ChangeButtonImage(2,imgApi)" + onmouseout="ChangeButtonImage(2,imgApiDark)"> + <img src="images/api_dark.png" border="0" alt="class documentation" height="40"/> + <br/> + <span class="tiny_text">muParser<br/>API-doc</span> + </a> + </div> + <!-- + <div style="position:absolute; width:100px; right:10px; text-align:center; line-height: 1em;"> + <a class="white" + href="http://sourceforge.net/project/showfiles.php?group_id=137191" + onmouseover="ChangeButtonImage(3,imgDown)" + onmouseout="ChangeButtonImage(3,imgDownDark)"> + <img src="images/download_dark.png" height="40" border="0" alt="muParser download"/> + <br/> + <span class="tiny_text">muParser<br/>Download</span> + </a> + </div> +--> + </div> <!-- class="gradient" --> + + <!-- Tabelle mit Hauptinhalt der Seite --> + <table id="MainTable" border="0" cellpadding="5" cellspacing="0" style="width:100%; height:100%;"> + <tbody> + <tr> + <td style="vertical-align: top; text-align: center" width="230"> + <h3 class="navi_heading navi_info">Introduction</h3> + <div class="sidebarlink"> + <a href="index.html">About the parser</a><br/> + <a href="http://sourceforge.net/news/?group_id=137191">News</a><br/> + <a href="mup_links.html">Software using muParser</a><br/> + <a href="mup_licence.html">Licence</a><br/> + </div> + + <h3 class="navi_heading navi_blocks">Features</h3> + <div class="sidebarlink"> + <a href="mup_features.html">Features</a><br/> + <a href="mup_features.html#idFeatureOverview">Overview</a><br/> + <a href="mup_features.html#idDef2">Built in functions</a><br/> + <a href="mup_features.html#idDef3">Built in binary operators</a><br/> + </div> + + <h3 class="navi_heading navi_build">Build instructions</h3> + <div class="sidebarlink"> + <a href="mup_usage.html#idInstWin">Building on Win32</a><br/> + <a href="mup_usage.html#idInstLinux">Building on BSD/Linux</a><br/> + <a href="mup_usage.html#idInstMisc">Misc build instructions</a><br/> + <a href="mup_usage.html#idInstInc">Including the files</a><br/> + <a href="mup_usage.html#idInstInc">Where to ask for help</a><br/> + </div> + + <h3 class="navi_heading navi_list">Math parser interface</h3> + <div class="sidebarlink"> + <a href="mup_interface.html#idInit">Parser (de)initialization</a><br/> + <a href="mup_interface.html#idEval">Evaluating an expression</a><br/> + <a href="mup_interface.html#idSetExpr">Setting the expression</a><br/> + <a href="mup_interface.html#idDefCharset">Defining identifier charsets</a><br/> + <a href="mup_interface.html#idDefVar">Defining parser variables</a><br/> + <a href="mup_interface.html#idDefVarEx">Explicit variable definition</a><br/> + <a href="mup_interface.html#idDefVarIm">Implicit variable definition</a><br/> + <a href="mup_interface.html#idDefConst">Defining constants</a><br/> + <a href="mup_interface.html#idDefFun">Defining functions</a><br/> + <a href="mup_interface.html#idDefOprt">Defining operators</a><br/> + <a href="mup_interface.html#idUnOp">Unary operators</a><br/> + <a href="mup_interface.html#idBinOp">Binary operators</a><br/> + <a href="mup_interface.html#idQueryVar">Querying variables</a><br/> + <a href="mup_interface.html#idQueryConst">Querying constants</a><br/> + <a href="mup_interface.html#idDefConst2">Value recognition callbacks</a><br/> + <a href="mup_interface.html#idDefConst2">Removing variables/constants</a><br/> + <a href="mup_locale.html#idLoc">Localization</a><br/> + <a href="mup_interface.html#idErrors">Error handling</a><br/> + <a href="mup_version.html#idExample">Example code</a><br/> + </div> + + <h3 class="navi_heading navi_question">Current version</h3> + <div class="sidebarlink"> + <a href="mup_version.html#idRelNote">Release notes</a><br/> + <a href="mup_version.html#idBench">Benchmarks</a><br/> + </div> + + <br/> + <div align="center"> + <a href="http://www.opensource.org/"><img style="border:0;" src="images/osi.jpg" alt="Open source initiative logo"/></a> + <br/> + <br/> + <a href="http://validator.w3.org/check?uri=referer"> + <img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" style="border:0;width:88px;height:31px"/> + </a> + <br/> + <br/> + <a href="http://jigsaw.w3.org/css-validator/check/referer"> + <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="CSS ist valide!" /> + </a> + + </div> + </td> + + <td style="height: 100%; padding: 1em; vertical-align: top;"> + <!-- + This section contains the real page content. + pages are created automatically by using the script "build_page.sh" + which combines section templated with the navigation bar. + + This creates webpages that do not rely on php3 or Javascript for + serverside or client side html inclusion. + //--> + <!-- $PLACEHOLDER --> +<br/> +<br/> +<h2>Software using the muParser library (alphabetically)</h2> +<table border="0"> + <colgroup> + <col width="120"/> + </colgroup> + + <tr> + <td><img src="images/thumb_geodes.jpg" border="0" width="120" alt="Geodes thumbnail"/></td> + <td align="center"><a href="http://geodes.sourceforge.net/" target="_top">Geodes</a></td> + <td>Geodes is a new dynamic geometry software for Mac OS X. The goal of this application is to make geometry become easy and funny.<br/> + (Platform: Mac OSX)</td> + </tr> + + <tr> + <td><img src="images/thumb_kst.jpg" width="120" border="0" alt="kst thumbnail"/></td> + <td align="center"><a href="http://extragear.kde.org/apps/kst/" target="_top">kst</a></td> + <td>A plotter for scientific data. (currently muParser is used by the Marquardt + Levenberg plugin)<br/> + (Platform: Linux / Operating systems that support KDE) + </td> + </tr> + + <tr> + <td><img src="images/thumb_matrix.jpg" border="0" width="120" alt="MatriX thumbnail"/></td> + <td align="center"><a href="http://www.ds4.it/" target="_top">MatriX</a></td> + <td>DS4 produces laser systems for industry applications like engraving, cutting, incision and welding. muParser is used + in their MatriX application, a software for for managing the laser systems.<br/> + (Platform: Linux)</td> + </tr> + + <tr> + <td><img src="images/thumb_meshlab.jpg" border="0" width="120" alt="tm2 thumbnail"/></td> + <td align="center"><a href="http://meshlab.sourceforge.net" target="_top">Meshlab </a></td> + <td>An open source, portable, and extensible system for the processing and editing of unstructured 3D triangular meshes. <br/> + (Platform: MS Windows, Linux, OSX)</td> + </tr> + + <tr> + <td><img src="images/thumb_pasimodo.jpg" border="0" width="120" alt="Pasimodo"/></td> + <td align="center"><a href="http://www.itm.uni-stuttgart.de/research/pasimodo/pasimodo_de.php" target="_top">Pasimodo</a></td> + <td>Pasimodo is a scientific software package for particle based simulations.<br/> + (Platform: Linux/BSD)</td> + </tr> + + <tr> + <td><img src="images/thumb_tm2.jpg" border="0" width="120" alt="tm2 thumbnail"/></td> + <td align="center"><a href="http://www.papajohn.org/tm2.html" target="_top">Transition Maker 2 </a></td> + <td>Creates transition sequences for video processing.<br/> + (Platform: MS Windows)</td> + </tr> + + <tr> + <td><img src="images/thumb_trini.jpg" border="0" width="120" alt="trininaut thumbnail"/></td> + <td align="center"><a href="http://trininaut.sourceforge.net/" target="_top">Trininaut</a></td> + <td>A Program launcher with extra features.<br/> + (Platform: WinXP, Win2K)</td> + </tr> + + <tr> + <td><img src="images/thumb_qtiplot.jpg" width="120" border="0" alt="qtiplot thumbnail"/></td> + <td align="center"><a href="http://soft.proindependent.com/qtiplot.html" target="_top">Qtiplot</a></td> + <td>A free platform independent clone of Origin<br/> + (Platform: MS Windows / Linux / Mac) + </td> + </tr> + + +</table> + + + <hr/> + <table border="0" style="width:100%"> + <tr> + <td>© 2005-2010 <a href="http://beltoforion.de">Ingo Berg</a> | + <a href="http://beltoforion.de/privacy_policy/privacy_policy_en.html">Privacy policy</a></td> + <td style="text-align:right; padding-right: 3em;"> + <a href="#top">^ TOP</a> + </td> + </tr> + </table> + <br/> + <br/> + + </td> + </tr> + </tbody> + </table> + +<!-- + <script type="text/javascript"> + var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); + document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); + </script> + <script type="text/javascript"> + try + { + var pageTracker = _gat._getTracker("UA-1019178-1"); + pageTracker._trackPageview(); + } + catch(err) {} + </script> +--> +</body> +</html> diff --git a/AMDiS/lib/muparser_v134/docs/html/mup_locale.html b/AMDiS/lib/muparser_v134/docs/html/mup_locale.html new file mode 100644 index 0000000000000000000000000000000000000000..fe58f37083b424081b9a425a7f1cf48ca6926ad7 --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/mup_locale.html @@ -0,0 +1,244 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <link rel="stylesheet" type="text/css" href="style/formate.css"/> + <meta name="author" content="Ingo Berg"/> + <!-- $META --> + <meta name="keywords" content="muparser, example, sample, benchmarks, benchmark, performance, comparison, release notes, changes, history"/> + <meta name="description" content="Sample code for using muParser"/> + <title>muParser - A basic axample and benchmarks</title> + + <script src="script/functions.js" language="javascript" type="text/javascript"></script> + <script type="text/javascript"> + imgHome=new Image(); + imgHome.src="images/home.png"; + imgHomeDark=new Image(); + imgHomeDark.src="images/home_dark.png"; + + imgApi=new Image(); + imgApi.src="images/api.png"; + imgApiDark=new Image(); + imgApiDark.src="images/api_dark.png"; + + function ChangeButtonImage(num,obj) + { + window.document.images[num].src=obj.src; + } + </script> +</head> + +<body> + <div class="gradient" id="top"> + <div class="header"> + muParser - a fast math parser library + <br/> + <div style="font-size:14pt;">Version 1.32</div> + </div> + + <div style="position:absolute; width:250px; height:100px; top:20px; text-align:center"> + <a href="http://sourceforge.net/projects/muparser"> + <img src="http://sflogo.sourceforge.net/sflogo.php?group_id=137191&type=15" + width="150" + height="40" + border="0" + alt="Get muParser - A fast math parser library at SourceForge.net. Fast, secure and Free Open Source software downloads" /> + </a> + </div> + + <div style="position:absolute; width:100px; right:110px; text-align:center; line-height: 1em;"> + <a class="white" + href="http://www.beltoforion.de" + onmouseover="ChangeButtonImage(1,imgHome)" + onmouseout="ChangeButtonImage(1,imgHomeDark)"> + <img src="images/home_dark.png" border="0" height="40" alt="My home page"/> + <br/> + <span class="tiny_text">My home<br/>page</span> + </a> + </div> + + <div style="position:absolute; width:100px; right:10px; text-align:center; line-height: 1em;"> + <a class="white" + href="http://muparser.sourceforge.net/classdocu/index.html" + onmouseover="ChangeButtonImage(2,imgApi)" + onmouseout="ChangeButtonImage(2,imgApiDark)"> + <img src="images/api_dark.png" border="0" alt="class documentation" height="40"/> + <br/> + <span class="tiny_text">muParser<br/>API-doc</span> + </a> + </div> + <!-- + <div style="position:absolute; width:100px; right:10px; text-align:center; line-height: 1em;"> + <a class="white" + href="http://sourceforge.net/project/showfiles.php?group_id=137191" + onmouseover="ChangeButtonImage(3,imgDown)" + onmouseout="ChangeButtonImage(3,imgDownDark)"> + <img src="images/download_dark.png" height="40" border="0" alt="muParser download"/> + <br/> + <span class="tiny_text">muParser<br/>Download</span> + </a> + </div> +--> + </div> <!-- class="gradient" --> + + <!-- Tabelle mit Hauptinhalt der Seite --> + <table id="MainTable" border="0" cellpadding="5" cellspacing="0" style="width:100%; height:100%;"> + <tbody> + <tr> + <td style="vertical-align: top; text-align: center" width="230"> + <h3 class="navi_heading navi_info">Introduction</h3> + <div class="sidebarlink"> + <a href="index.html">About the parser</a><br/> + <a href="http://sourceforge.net/news/?group_id=137191">News</a><br/> + <a href="mup_links.html">Software using muParser</a><br/> + <a href="mup_licence.html">Licence</a><br/> + </div> + + <h3 class="navi_heading navi_blocks">Features</h3> + <div class="sidebarlink"> + <a href="mup_features.html">Features</a><br/> + <a href="mup_features.html#idFeatureOverview">Overview</a><br/> + <a href="mup_features.html#idDef2">Built in functions</a><br/> + <a href="mup_features.html#idDef3">Built in binary operators</a><br/> + </div> + + <h3 class="navi_heading navi_build">Build instructions</h3> + <div class="sidebarlink"> + <a href="mup_usage.html#idInstWin">Building on Win32</a><br/> + <a href="mup_usage.html#idInstLinux">Building on BSD/Linux</a><br/> + <a href="mup_usage.html#idInstMisc">Misc build instructions</a><br/> + <a href="mup_usage.html#idInstInc">Including the files</a><br/> + <a href="mup_usage.html#idInstInc">Where to ask for help</a><br/> + </div> + + <h3 class="navi_heading navi_list">Math parser interface</h3> + <div class="sidebarlink"> + <a href="mup_interface.html#idInit">Parser (de)initialization</a><br/> + <a href="mup_interface.html#idEval">Evaluating an expression</a><br/> + <a href="mup_interface.html#idSetExpr">Setting the expression</a><br/> + <a href="mup_interface.html#idDefCharset">Defining identifier charsets</a><br/> + <a href="mup_interface.html#idDefVar">Defining parser variables</a><br/> + <a href="mup_interface.html#idDefVarEx">Explicit variable definition</a><br/> + <a href="mup_interface.html#idDefVarIm">Implicit variable definition</a><br/> + <a href="mup_interface.html#idDefConst">Defining constants</a><br/> + <a href="mup_interface.html#idDefFun">Defining functions</a><br/> + <a href="mup_interface.html#idDefOprt">Defining operators</a><br/> + <a href="mup_interface.html#idUnOp">Unary operators</a><br/> + <a href="mup_interface.html#idBinOp">Binary operators</a><br/> + <a href="mup_interface.html#idQueryVar">Querying variables</a><br/> + <a href="mup_interface.html#idQueryConst">Querying constants</a><br/> + <a href="mup_interface.html#idDefConst2">Value recognition callbacks</a><br/> + <a href="mup_interface.html#idDefConst2">Removing variables/constants</a><br/> + <a href="mup_locale.html#idLoc">Localization</a><br/> + <a href="mup_interface.html#idErrors">Error handling</a><br/> + <a href="mup_version.html#idExample">Example code</a><br/> + </div> + + <h3 class="navi_heading navi_question">Current version</h3> + <div class="sidebarlink"> + <a href="mup_version.html#idRelNote">Release notes</a><br/> + <a href="mup_version.html#idBench">Benchmarks</a><br/> + </div> + + <br/> + <div align="center"> + <a href="http://www.opensource.org/"><img style="border:0;" src="images/osi.jpg" alt="Open source initiative logo"/></a> + <br/> + <br/> + <a href="http://validator.w3.org/check?uri=referer"> + <img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" style="border:0;width:88px;height:31px"/> + </a> + <br/> + <br/> + <a href="http://jigsaw.w3.org/css-validator/check/referer"> + <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="CSS ist valide!" /> + </a> + + </div> + </td> + + <td style="height: 100%; padding: 1em; vertical-align: top;"> + <!-- + This section contains the real page content. + pages are created automatically by using the script "build_page.sh" + which combines section templated with the navigation bar. + + This creates webpages that do not rely on php3 or Javascript for + serverside or client side html inclusion. + //--> + <!-- $PLACEHOLDER --> +<!-- +// +// +// +// Localization +// +// +// +--> + +<h2><a id="idLoc"></a>Localization</h2> +<p> +Sometimes it is necessary to change decimal separator, argument separator or thousands separator +to match a certain locale. The following functions can be used for this purpose: +</p> + +<h3>[DLL interface]</h3> +<pre> +// german localization +mupSetArgSep(hParser, ';'); +mupSetDecSep(hParser, ','); +mupSetThousandsSep(hParser, '.'); + +// reset to defaults +mupResetLocale(); +</pre> +<small>See also: <i>example2/example2.c</i>.</small> + +<h3>[Parser class interface]</h3> +<pre> +// german localization +parser.SetArgSep(';'); +parser.SetDecSep(','); +parser.SetThousandsSep('.'); + +// reset to defaults +parser.ResetLocale(); +</pre> +<small>See also: <i>example1/example1.cpp</i>.</small> + + <hr/> + <table border="0" style="width:100%"> + <tr> + <td>© 2005-2010 <a href="http://beltoforion.de">Ingo Berg</a> | + <a href="http://beltoforion.de/privacy_policy/privacy_policy_en.html">Privacy policy</a></td> + <td style="text-align:right; padding-right: 3em;"> + <a href="#top">^ TOP</a> + </td> + </tr> + </table> + <br/> + <br/> + + </td> + </tr> + </tbody> + </table> + +<!-- + <script type="text/javascript"> + var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); + document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); + </script> + <script type="text/javascript"> + try + { + var pageTracker = _gat._getTracker("UA-1019178-1"); + pageTracker._trackPageview(); + } + catch(err) {} + </script> +--> +</body> +</html> diff --git a/AMDiS/lib/muparser_v134/docs/html/mup_usage.html b/AMDiS/lib/muparser_v134/docs/html/mup_usage.html new file mode 100644 index 0000000000000000000000000000000000000000..aa43e8fd7706eeaeb28c2ba4dc4afb0639f28516 --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/mup_usage.html @@ -0,0 +1,354 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <link rel="stylesheet" type="text/css" href="style/formate.css"/> + <meta name="author" content="Ingo Berg"/> + <!-- $META --> + <meta name="keywords" content="muparser, build instructions, makefile, configuration, built, project file, install"/> + <meta name="description" content="muparser build instructions"/> + <title>muParser build instructions</title> + + <script src="script/functions.js" language="javascript" type="text/javascript"></script> + <script type="text/javascript"> + imgHome=new Image(); + imgHome.src="images/home.png"; + imgHomeDark=new Image(); + imgHomeDark.src="images/home_dark.png"; + + imgApi=new Image(); + imgApi.src="images/api.png"; + imgApiDark=new Image(); + imgApiDark.src="images/api_dark.png"; + + function ChangeButtonImage(num,obj) + { + window.document.images[num].src=obj.src; + } + </script> +</head> + +<body> + <div class="gradient" id="top"> + <div class="header"> + muParser - a fast math parser library + <br/> + <div style="font-size:14pt;">Version 1.32</div> + </div> + + <div style="position:absolute; width:250px; height:100px; top:20px; text-align:center"> + <a href="http://sourceforge.net/projects/muparser"> + <img src="http://sflogo.sourceforge.net/sflogo.php?group_id=137191&type=15" + width="150" + height="40" + border="0" + alt="Get muParser - A fast math parser library at SourceForge.net. Fast, secure and Free Open Source software downloads" /> + </a> + </div> + + <div style="position:absolute; width:100px; right:110px; text-align:center; line-height: 1em;"> + <a class="white" + href="http://www.beltoforion.de" + onmouseover="ChangeButtonImage(1,imgHome)" + onmouseout="ChangeButtonImage(1,imgHomeDark)"> + <img src="images/home_dark.png" border="0" height="40" alt="My home page"/> + <br/> + <span class="tiny_text">My home<br/>page</span> + </a> + </div> + + <div style="position:absolute; width:100px; right:10px; text-align:center; line-height: 1em;"> + <a class="white" + href="http://muparser.sourceforge.net/classdocu/index.html" + onmouseover="ChangeButtonImage(2,imgApi)" + onmouseout="ChangeButtonImage(2,imgApiDark)"> + <img src="images/api_dark.png" border="0" alt="class documentation" height="40"/> + <br/> + <span class="tiny_text">muParser<br/>API-doc</span> + </a> + </div> + <!-- + <div style="position:absolute; width:100px; right:10px; text-align:center; line-height: 1em;"> + <a class="white" + href="http://sourceforge.net/project/showfiles.php?group_id=137191" + onmouseover="ChangeButtonImage(3,imgDown)" + onmouseout="ChangeButtonImage(3,imgDownDark)"> + <img src="images/download_dark.png" height="40" border="0" alt="muParser download"/> + <br/> + <span class="tiny_text">muParser<br/>Download</span> + </a> + </div> +--> + </div> <!-- class="gradient" --> + + <!-- Tabelle mit Hauptinhalt der Seite --> + <table id="MainTable" border="0" cellpadding="5" cellspacing="0" style="width:100%; height:100%;"> + <tbody> + <tr> + <td style="vertical-align: top; text-align: center" width="230"> + <h3 class="navi_heading navi_info">Introduction</h3> + <div class="sidebarlink"> + <a href="index.html">About the parser</a><br/> + <a href="http://sourceforge.net/news/?group_id=137191">News</a><br/> + <a href="mup_links.html">Software using muParser</a><br/> + <a href="mup_licence.html">Licence</a><br/> + </div> + + <h3 class="navi_heading navi_blocks">Features</h3> + <div class="sidebarlink"> + <a href="mup_features.html">Features</a><br/> + <a href="mup_features.html#idFeatureOverview">Overview</a><br/> + <a href="mup_features.html#idDef2">Built in functions</a><br/> + <a href="mup_features.html#idDef3">Built in binary operators</a><br/> + </div> + + <h3 class="navi_heading navi_build">Build instructions</h3> + <div class="sidebarlink"> + <a href="mup_usage.html#idInstWin">Building on Win32</a><br/> + <a href="mup_usage.html#idInstLinux">Building on BSD/Linux</a><br/> + <a href="mup_usage.html#idInstMisc">Misc build instructions</a><br/> + <a href="mup_usage.html#idInstInc">Including the files</a><br/> + <a href="mup_usage.html#idInstInc">Where to ask for help</a><br/> + </div> + + <h3 class="navi_heading navi_list">Math parser interface</h3> + <div class="sidebarlink"> + <a href="mup_interface.html#idInit">Parser (de)initialization</a><br/> + <a href="mup_interface.html#idEval">Evaluating an expression</a><br/> + <a href="mup_interface.html#idSetExpr">Setting the expression</a><br/> + <a href="mup_interface.html#idDefCharset">Defining identifier charsets</a><br/> + <a href="mup_interface.html#idDefVar">Defining parser variables</a><br/> + <a href="mup_interface.html#idDefVarEx">Explicit variable definition</a><br/> + <a href="mup_interface.html#idDefVarIm">Implicit variable definition</a><br/> + <a href="mup_interface.html#idDefConst">Defining constants</a><br/> + <a href="mup_interface.html#idDefFun">Defining functions</a><br/> + <a href="mup_interface.html#idDefOprt">Defining operators</a><br/> + <a href="mup_interface.html#idUnOp">Unary operators</a><br/> + <a href="mup_interface.html#idBinOp">Binary operators</a><br/> + <a href="mup_interface.html#idQueryVar">Querying variables</a><br/> + <a href="mup_interface.html#idQueryConst">Querying constants</a><br/> + <a href="mup_interface.html#idDefConst2">Value recognition callbacks</a><br/> + <a href="mup_interface.html#idDefConst2">Removing variables/constants</a><br/> + <a href="mup_locale.html#idLoc">Localization</a><br/> + <a href="mup_interface.html#idErrors">Error handling</a><br/> + <a href="mup_version.html#idExample">Example code</a><br/> + </div> + + <h3 class="navi_heading navi_question">Current version</h3> + <div class="sidebarlink"> + <a href="mup_version.html#idRelNote">Release notes</a><br/> + <a href="mup_version.html#idBench">Benchmarks</a><br/> + </div> + + <br/> + <div align="center"> + <a href="http://www.opensource.org/"><img style="border:0;" src="images/osi.jpg" alt="Open source initiative logo"/></a> + <br/> + <br/> + <a href="http://validator.w3.org/check?uri=referer"> + <img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" style="border:0;width:88px;height:31px"/> + </a> + <br/> + <br/> + <a href="http://jigsaw.w3.org/css-validator/check/referer"> + <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="CSS ist valide!" /> + </a> + + </div> + </td> + + <td style="height: 100%; padding: 1em; vertical-align: top;"> + <!-- + This section contains the real page content. + pages are created automatically by using the script "build_page.sh" + which combines section templated with the navigation bar. + + This creates webpages that do not rely on php3 or Javascript for + serverside or client side html inclusion. + //--> + <!-- $PLACEHOLDER --> +<!-- +// +// +// +// Adding the parser to your projects +// +// +// +--> + + +<br/> +<h1><a id="idBuild"></a>Build instructions</h1> +<h2><a id="idInstWin"></a>Building on win32</h2> +<b>muParser</b> supports various win32 command-line compilers: +<ul> + <li>Mingw</li> + <li>Borland C++</li> + <li>Watcom</li> + <li>Microsoft CL</li> +</ul> +In order to compile muParser from makefiles, open a command prompt then move to the muParser/build directory and +type: + +<ul> + <li>mingw32-make -fmakefile.gcc for mingw</li> + <li>nmake -fmakefile.vc for msvc</li> + <li>make -fmakefile.bcc for borland</li> + <li>wmake -fmakefile.wat for watcom</li> +</ul> + +All makefiles support the following options: +<pre> + # Set to 1 to build debug version [0,1] + # 0 - Release + # 1 - Debug + DEBUG = 0 + + # Set to 1 to build shared (DLL) version [0,1] + # 0 - Static + # 1 - DLL + SHARED = 0 + + # Set to 1 to compile samples [0,1] + SAMPLES = 1 +</pre> +The muParser library is created in the 'lib' folder and the sample +binaries are created in samples\example1 or samples\example2. (You may need to copy the dll +into the example2 directory in order to run it.) + +<table> +<tr> + <td><img src="images/warning.gif" alt="warning"/></td> + <td>samples\example1 can be compiled *only* when building muParser as a STATIC library (SHARED=0).<br/> + samples\example2 can be compiled *only* when building muParser as a SHARED library (SHARED=1). + </td> +</tr> +</table> + +<h2><a id="idInstLinux"></a>Building on BSD/Linux</h2> +muParser can be installed just extracting the sources somewhere and then, from a terminal, typing: + +<pre> + cd [path to muParser] + ./configure [--enable-shared=yes/no] [--enable-samples=yes/no] + [--enable-debug=yes/no] + make + [sudo*] make install +</pre> + <small>* = this command must be executed with root permissions and thus + you have to use 'sudo' or just 'su' to gain root access. + Note that installation is not strictly required.</small> +<p> +The "make" step will create the muParser library in 'lib' and the +sample binary in samples/example1. The samples/example2 is win32-specific and +thus won't be built. +</p> + +<h2><a id="idInstMisc"></a>Other miscellaneous info Unix-specific</h2> +If you don't like to have your muParser folder filled by temporary +files created by GCC, then you can do the following: + +<pre> + mkdir mybuild && cd mybuild && ../configure && make +</pre> + +to put all object files in the "mybuild" directory. If you want to use +muParser library in your programs, you can use the pkg-config program +(this works only if muParser was installed with 'make install' !). +The commands: +<ul> + <li>pkg-config muparser --cflags</li> + <li>pkg-config muparser --libs</li> +</ul> +will return all useful info you need to build your programs against +muParser ! + +<h2><a id="idInstInc"></a><a name="idUseSource"></a>Including the source code directly</h2> +Sometimes including the library sources directly into an application is the easiest +possibility to avoid linker conflicts originating from different versions of the +runtime libraries used by the parser and your project. + +In order to use the parser simply include the following files into your project: + +<p> +<i>muParser.cpp</i><br/> +<i>muParserBase.cpp</i><br/> +<i>muParserBytecode.cpp</i><br/> +<i>muParserCallback.cpp</i><br/> +<i>muParserError.cpp</i><br/> +<i>muParserTokenReader.cpp</i> +</p> + +And make sure the following files can be found in your projects include path: +<p> +<i>muParser.h</i><br/> +<i>muParserBase.h</i><br/> +<i>muParserBytecode.h</i><br/> +<i>muParserCallback.h</i><br/> +<i>muParserDef.h</i><br/> +<i>muParserError.h</i><br/> +<i>muParserFixes.h</i><br/> +<i>muParserStack.h</i><br/> +<i>muParserToken.h</i><br/> +<i>muParserTokenReader.h</i><br/> +</p> + +The parser class and all related classes reside in the namespace <code>mu</code> (MathUtils). So make sure to either +add a using + +<pre> +using namespace mu; +</pre> + +to your files or reference all classes with their complete name. + +<h2>Where to ask for help</h2> + +If you find problems with either compilation, installation or usage +of muParser, then you can ask in the muParser forum at:<br/> +<ul> +<li><a href="https://sourceforge.net/forum/forum.php?forum_id=462843">https://sourceforge.net/forum/forum.php?forum_id=462843</a></li> +</ul> + +For more info about muParser, visit: +<ul> +<li><a href="http://sourceforge.net/projects/muparser/">http://sourceforge.net/projects/muparser/</a><br/></li> +<li><a href="http://muparser.sourceforge.net">http://muparser.sourceforge.net</a></li> +</ul> + + <hr/> + <table border="0" style="width:100%"> + <tr> + <td>© 2005-2010 <a href="http://beltoforion.de">Ingo Berg</a> | + <a href="http://beltoforion.de/privacy_policy/privacy_policy_en.html">Privacy policy</a></td> + <td style="text-align:right; padding-right: 3em;"> + <a href="#top">^ TOP</a> + </td> + </tr> + </table> + <br/> + <br/> + + </td> + </tr> + </tbody> + </table> + +<!-- + <script type="text/javascript"> + var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); + document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); + </script> + <script type="text/javascript"> + try + { + var pageTracker = _gat._getTracker("UA-1019178-1"); + pageTracker._trackPageview(); + } + catch(err) {} + </script> +--> +</body> +</html> diff --git a/AMDiS/lib/muparser_v134/docs/html/mup_version.html b/AMDiS/lib/muparser_v134/docs/html/mup_version.html new file mode 100644 index 0000000000000000000000000000000000000000..cd979cef573ad6b30da6eec55ce8ab0be5def770 --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/mup_version.html @@ -0,0 +1,422 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <link rel="stylesheet" type="text/css" href="style/formate.css"/> + <meta name="author" content="Ingo Berg"/> + <!-- $META --> + <meta name="keywords" content="muparser, example, sample, benchmarks, benchmark, performance, comparison, release notes, changes, history"/> + <meta name="description" content="Sample code for using muParser"/> + <title>muParser - A basic axample and benchmarks</title> + + <script src="script/functions.js" language="javascript" type="text/javascript"></script> + <script type="text/javascript"> + imgHome=new Image(); + imgHome.src="images/home.png"; + imgHomeDark=new Image(); + imgHomeDark.src="images/home_dark.png"; + + imgApi=new Image(); + imgApi.src="images/api.png"; + imgApiDark=new Image(); + imgApiDark.src="images/api_dark.png"; + + function ChangeButtonImage(num,obj) + { + window.document.images[num].src=obj.src; + } + </script> +</head> + +<body> + <div class="gradient" id="top"> + <div class="header"> + muParser - a fast math parser library + <br/> + <div style="font-size:14pt;">Version 1.32</div> + </div> + + <div style="position:absolute; width:250px; height:100px; top:20px; text-align:center"> + <a href="http://sourceforge.net/projects/muparser"> + <img src="http://sflogo.sourceforge.net/sflogo.php?group_id=137191&type=15" + width="150" + height="40" + border="0" + alt="Get muParser - A fast math parser library at SourceForge.net. Fast, secure and Free Open Source software downloads" /> + </a> + </div> + + <div style="position:absolute; width:100px; right:110px; text-align:center; line-height: 1em;"> + <a class="white" + href="http://www.beltoforion.de" + onmouseover="ChangeButtonImage(1,imgHome)" + onmouseout="ChangeButtonImage(1,imgHomeDark)"> + <img src="images/home_dark.png" border="0" height="40" alt="My home page"/> + <br/> + <span class="tiny_text">My home<br/>page</span> + </a> + </div> + + <div style="position:absolute; width:100px; right:10px; text-align:center; line-height: 1em;"> + <a class="white" + href="http://muparser.sourceforge.net/classdocu/index.html" + onmouseover="ChangeButtonImage(2,imgApi)" + onmouseout="ChangeButtonImage(2,imgApiDark)"> + <img src="images/api_dark.png" border="0" alt="class documentation" height="40"/> + <br/> + <span class="tiny_text">muParser<br/>API-doc</span> + </a> + </div> + <!-- + <div style="position:absolute; width:100px; right:10px; text-align:center; line-height: 1em;"> + <a class="white" + href="http://sourceforge.net/project/showfiles.php?group_id=137191" + onmouseover="ChangeButtonImage(3,imgDown)" + onmouseout="ChangeButtonImage(3,imgDownDark)"> + <img src="images/download_dark.png" height="40" border="0" alt="muParser download"/> + <br/> + <span class="tiny_text">muParser<br/>Download</span> + </a> + </div> +--> + </div> <!-- class="gradient" --> + + <!-- Tabelle mit Hauptinhalt der Seite --> + <table id="MainTable" border="0" cellpadding="5" cellspacing="0" style="width:100%; height:100%;"> + <tbody> + <tr> + <td style="vertical-align: top; text-align: center" width="230"> + <h3 class="navi_heading navi_info">Introduction</h3> + <div class="sidebarlink"> + <a href="index.html">About the parser</a><br/> + <a href="http://sourceforge.net/news/?group_id=137191">News</a><br/> + <a href="mup_links.html">Software using muParser</a><br/> + <a href="mup_licence.html">Licence</a><br/> + </div> + + <h3 class="navi_heading navi_blocks">Features</h3> + <div class="sidebarlink"> + <a href="mup_features.html">Features</a><br/> + <a href="mup_features.html#idFeatureOverview">Overview</a><br/> + <a href="mup_features.html#idDef2">Built in functions</a><br/> + <a href="mup_features.html#idDef3">Built in binary operators</a><br/> + </div> + + <h3 class="navi_heading navi_build">Build instructions</h3> + <div class="sidebarlink"> + <a href="mup_usage.html#idInstWin">Building on Win32</a><br/> + <a href="mup_usage.html#idInstLinux">Building on BSD/Linux</a><br/> + <a href="mup_usage.html#idInstMisc">Misc build instructions</a><br/> + <a href="mup_usage.html#idInstInc">Including the files</a><br/> + <a href="mup_usage.html#idInstInc">Where to ask for help</a><br/> + </div> + + <h3 class="navi_heading navi_list">Math parser interface</h3> + <div class="sidebarlink"> + <a href="mup_interface.html#idInit">Parser (de)initialization</a><br/> + <a href="mup_interface.html#idEval">Evaluating an expression</a><br/> + <a href="mup_interface.html#idSetExpr">Setting the expression</a><br/> + <a href="mup_interface.html#idDefCharset">Defining identifier charsets</a><br/> + <a href="mup_interface.html#idDefVar">Defining parser variables</a><br/> + <a href="mup_interface.html#idDefVarEx">Explicit variable definition</a><br/> + <a href="mup_interface.html#idDefVarIm">Implicit variable definition</a><br/> + <a href="mup_interface.html#idDefConst">Defining constants</a><br/> + <a href="mup_interface.html#idDefFun">Defining functions</a><br/> + <a href="mup_interface.html#idDefOprt">Defining operators</a><br/> + <a href="mup_interface.html#idUnOp">Unary operators</a><br/> + <a href="mup_interface.html#idBinOp">Binary operators</a><br/> + <a href="mup_interface.html#idQueryVar">Querying variables</a><br/> + <a href="mup_interface.html#idQueryConst">Querying constants</a><br/> + <a href="mup_interface.html#idDefConst2">Value recognition callbacks</a><br/> + <a href="mup_interface.html#idDefConst2">Removing variables/constants</a><br/> + <a href="mup_locale.html#idLoc">Localization</a><br/> + <a href="mup_interface.html#idErrors">Error handling</a><br/> + <a href="mup_version.html#idExample">Example code</a><br/> + </div> + + <h3 class="navi_heading navi_question">Current version</h3> + <div class="sidebarlink"> + <a href="mup_version.html#idRelNote">Release notes</a><br/> + <a href="mup_version.html#idBench">Benchmarks</a><br/> + </div> + + <br/> + <div align="center"> + <a href="http://www.opensource.org/"><img style="border:0;" src="images/osi.jpg" alt="Open source initiative logo"/></a> + <br/> + <br/> + <a href="http://validator.w3.org/check?uri=referer"> + <img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" style="border:0;width:88px;height:31px"/> + </a> + <br/> + <br/> + <a href="http://jigsaw.w3.org/css-validator/check/referer"> + <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="CSS ist valide!" /> + </a> + + </div> + </td> + + <td style="height: 100%; padding: 1em; vertical-align: top;"> + <!-- + This section contains the real page content. + pages are created automatically by using the script "build_page.sh" + which combines section templated with the navigation bar. + + This creates webpages that do not rely on php3 or Javascript for + serverside or client side html inclusion. + //--> + <!-- $PLACEHOLDER --> +<!-- +// +// +// +// Example code +// +// +// +--> + +<h2><a id="idExample"></a>Example code</h2> + +<p> +If you put all this together, you get the source code for a small application. The application defines a parser variables ("<code>a</code>") and adds +a user defined functions named "<code>MyFunc</code>". When using the parser make sure that you don't forget to catch the <code>Parser::exception_type</code> in your application. It contains detailed information helping you to find syntax errors in your formula. +</p> + +<pre> +#include <iostream> +#include "muParser.h" + +// Function callback +double MyFunction(double a_fVal) +{ + return a_fVal*a_fVal; +} + +// main program +int main(int argc, char* argv[]) +{ + using namespace mu; + + try + { + double fVal = 1; + Parser p; + p.DefineVar("a", &fVal); + p.DefineFun("MyFunc", MyFunction); + p.SetExpr("MyFunc(a)*_pi+min(10,a)"); + std::cout << p.Eval() << std::endl; + } + catch (Parser::exception_type &e) + { + std::cout << e.GetMsg() << std::endl; + } + return 0; +} +</pre> + + +<!-- +// +// +// +// Benchmarks +// +// +// +--> + +<hr/> +<h2><a id="idBench"></a>Benchmarks</h2> + +<p> +Finally, I'd like to give you some benchmarks. The benchmarking was done on an Intel +Pentium P-4 with 2.6 GHz, with a version compiled by using MSVC++ 7.1 (Standard edition). +The diagram shows number of <b>evaluations per seconds vs. expression length</b>. +I compared both the static lib and the dll version with two other parsers that are freely available +on the net, very fast and have a similar set of features. One of them is a commercial product. +</p> + +<p> + <img src="images/bench2.jpg" alt="parser benchmarks" border="0" height="489" width="560"/> +</p> + +<p> +A higher curve means better performance. Expressions were created randomly. They used only <code>sin</code> and <code>cos</code> functions and contained +multiple variables and constants. In order to smoothen the curves each point represents the value of a +running average over 10 sample expressions. +</p> + + +<!-- +// +// +// +// History +// +// +// +--> + +<hr/> +<h2><a name="idRelNote"></a>Release Notes</h2> + +<h4>Rev 1.32: 30.01.2010</h4> +This is a service release to fix problems with modern compilers. +<ul> + <li><b>Changes</b> + <ul> + <li>Added a function for retrieving the Version number of muparser.</li> + <li>example3 renamed to example2</li> + <li>Project files for bcb and msvc6 removed (include the source directly into your projects)</li> + <li>Project files for msvc2003, msvc2005 and msvc2008 added</li> + </ul> + </li> + + <li><b>Bugfixes</b> + <ul> + <li>Deprecated feature warnings removed for gcc</li> + <li>example1 changed to get rid of memory leaks. Added code for memory leak detection (VisualStudio only)</li> + <li>Changes to allow compilation with msvc10 beta2</li> + <li>gcc versions >4.0 were not able to run with a customized locale (resulted in std::bad_cast exception)</li> + </ul> + </li> +</ul> +<hr/> +<h4>Rev 1.30: 09.06.2008</h4> +This is a service release with minor extensions and bugfixes. + +<ul> + <li><b>Changes</b> + <ul> + <li>Epsilon of the numerical differentiation algorithm changed to allow greater accuracy.</li> + </ul> + </li> + + <li><b>New features</b> + <ul> + <li>Setting thousands separator and decimal separator is now possible</li> + </ul> + </li> + + <li><b>Bugfixes</b> + <ul> + <li>The dll interface did not provide a callback for functions without any arguments.</li> + </ul> + </li> +</ul> +<hr/> +<h4>Rev 1.28: 02.07.2007</h4> + +<ul> + <li><b>Library changes</b> + <ul> + <li>Interface for the dynamic library changed and extended to create an interface using pure C functions only.</li> + <li>mupInit() removed</li> + </ul> + </li> + + <li><b>New features</b> + <ul> + <li>Functions without parameters added</li> + </ul> + </li> + + <li><b>Build system</b> + <ul> + <li>MSVC7 Project files removed in favor of MSVC8.</li> + </ul> + </li> + + <li><b>Bugfixes</b> + <ul> + <li>The dynamic library did not build on other systems than linux due to a misplaced + preprocessor definition. This is fixed now.</li> + </ul> + </li> + +</ul> + +<hr/> +<h4>Rev 1.2: 14.04.2005</h4> +First of all the interface has changed so this version is not backwards compatible. +After receiving a couple of questions about it, this version features support for user defined binary operators. Consequently the built in operators can now be turned off, thus you can deactivate them and write complete customized parser subclasses that only contain the functionality you want. Other new feature is the introduction of callback functions taking string arguments, implicit generation of +variables and the Assignement operator. + +<ul> + <li> <b>Functionality</b> + <ul> + <li><a href="mup_features.html#idDef3">New built in operator</a>: <code>xor</code>; Logical xor.</li> + <li>New built in operator: Assignement operator; Defining variables in terms of other variables/constants</li> + <li>New feature: <a href="mup_interface.html#idDefFun">Strings as arguments for callback functions</a></li> + <li>New feature: <a href="mup_interface.html#idDefOprt">User defined binary operators</a></li> + <li>New feature: <code>ParserInt</code> a class with a sample implementation for + integer numbers.</li> + <li>New feature: <a href="mup_interface.html#idDefConst2">Callbacks to value regognition functions.</a></li> + + <li>Removed: all predefined postfix operators have been removed.</li> + <li>New project file: Now comes with a ready to use windows DLL.</li> + <li>New project file: Makefile for cygwin now included.</li> + <li>New example: Example3 shows usage of the DLL.</li> + </ul> + </li> + + <li> <b>Interface changes</b> + <ul> + <li><a href="mup_interface.html#idBinOp">New member function</a>: <code>DefineOprt</code> For + adding user defined binary operators.</li> + <li>New member function: <code>EnableBuiltInOprt(bool)</code> Enables/Disables <a href="mup_features.html#idDef3"> + built in binary operators</a>.</li> + <li>New member function: <code>AddValIdent(...)</code> to add callbacks for custom value recognition functions.</li> + <li>Removed: <code>SetVar()</code>, <code>SetConst()</code>.</li> + <li>Renamed: Most interface functions have been renamed</li> + <li>Changed: The <a href="mup_interface.html#idDefFun">type for multiargument callbacks</a> <code>multfun_type</code> has changed. + It no longer takes a std::vector as input.</li> + </ul> + </li> + + <li> <b>Internal changes</b> + <ul> + <li>new class <i>muParserTokenReader.h</i> encapsulates the token identification and token assignement.</li> + <li>Internal handling of function callbacks unified as a result the performance of the bytecode evaluation + increased.</li> + </ul> + </li> +</ul> + + <hr/> + <table border="0" style="width:100%"> + <tr> + <td>© 2005-2010 <a href="http://beltoforion.de">Ingo Berg</a> | + <a href="http://beltoforion.de/privacy_policy/privacy_policy_en.html">Privacy policy</a></td> + <td style="text-align:right; padding-right: 3em;"> + <a href="#top">^ TOP</a> + </td> + </tr> + </table> + <br/> + <br/> + + </td> + </tr> + </tbody> + </table> + +<!-- + <script type="text/javascript"> + var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); + document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); + </script> + <script type="text/javascript"> + try + { + var pageTracker = _gat._getTracker("UA-1019178-1"); + pageTracker._trackPageview(); + } + catch(err) {} + </script> +--> +</body> +</html> diff --git a/AMDiS/lib/muparser_v134/docs/html/script/functions.js b/AMDiS/lib/muparser_v134/docs/html/script/functions.js new file mode 100644 index 0000000000000000000000000000000000000000..9d50650805c9a94da63117de8798b63f1b03115f --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/script/functions.js @@ -0,0 +1,32 @@ +//-------------------------------------------------- +// +// Bedingte darstellung des SourceForge logos +// +function SFLogo() +{ + document.write("<img src=\"http:\/\/sourceforge.net\/sflogo.php?group_id=137191&type=5\" width=\"210\" height=\"62\" border=\"0\" alt=\"SourceForge.net Logo\" \/>"); +} + +//-------------------------------------------------- +// +// Statcounter code erzeugen +// +function statCounter() +{ + // statcounter variablen + document.write("<script type=\"text\/javascript\" language=\"javascript\">"); + document.write("var sc_project=671117;"); + document.write("var sc_partition=5; "); + document.write("var sc_security=\"f3fad66c\";"); + document.write("<\/script>"); + + var sc_project=671117; + var sc_partition=5; + var sc_security="f3fad66c"; + + + // statcounter script + document.write("<script type=\"text\/javascript\" language=\"javascript\" src=\"http:\/\/www.statcounter.com\/counter\/counter.js\">"); + document.write("<\/script>"); +} + diff --git a/AMDiS/lib/muparser_v134/docs/html/sources/build_page.sh b/AMDiS/lib/muparser_v134/docs/html/sources/build_page.sh new file mode 100644 index 0000000000000000000000000000000000000000..dc673185d35db8c54f0841a989ca8bb1cb9a8f21 --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/sources/build_page.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +# +# This script is used for building the muParser html page from +# html templates. +# + +rm -rf ../mup_*.html +rm -rf ..index.html + +# +# add navigation bar to all html templates starting with mup_* +# +cat navigation.html | sed "/\$PLACEHOLDER/r mup_features.html" | sed "/\$META/r mup_features_meta.html" > ../mup_features.html +cat navigation.html | sed "/\$PLACEHOLDER/r mup_interface.html" | sed "/\$META/r mup_interface_meta.html" > ../mup_interface.html +cat navigation.html | sed "/\$PLACEHOLDER/r mup_intro.html" | sed "/\$META/r mup_intro_meta.html" > ../mup_intro.html +cat navigation.html | sed "/\$PLACEHOLDER/r mup_licence.html" | sed "/\$META/r mup_licence_meta.html" > ../mup_licence.html +cat navigation.html | sed "/\$PLACEHOLDER/r mup_links.html" | sed "/\$META/r mup_links_meta.html" > ../mup_links.html +cat navigation.html | sed "/\$PLACEHOLDER/r mup_usage.html" | sed "/\$META/r mup_usage_meta.html" > ../mup_usage.html +cat navigation.html | sed "/\$PLACEHOLDER/r mup_version.html" | sed "/\$META/r mup_version_meta.html" > ../mup_version.html +cat navigation.html | sed "/\$PLACEHOLDER/r mup_locale.html" | sed "/\$META/r mup_locale_meta.html" > ../mup_locale.html + + +#for file in mup_*.html +#do +# echo processing $file +# cat navigation.html | sed "/\$PLACEHOLDER/r $file" > ../$file +#done## +# +#for file in mup_*_header.html +#do +# echo processing $file +# cat navigation.html | sed "/\$META/r $file" > ../$file +#done + +# create index.html +cp ../mup_intro.html ../index.html +rm -rf ../*~ + diff --git a/AMDiS/lib/muparser_v134/docs/html/sources/mup_features.html b/AMDiS/lib/muparser_v134/docs/html/sources/mup_features.html new file mode 100644 index 0000000000000000000000000000000000000000..8fb6d3f4eb91932c5347c12a9bb131510d84c18c --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/sources/mup_features.html @@ -0,0 +1,213 @@ +<!-- +// +// +// +// Features +// +// +// +--> + +<br/> +<h2><a name="idFeature">Features</a></h2> + +<p> +The following is a list of the features currently supported by the parser library. +The primary objective is to keep it as extensible as possible whilst ensuring a maximum parsing speed. Extending the parser is mostly based on allowing a user to add custom callbacks which require only an absolute minimum of code. For instance you need exactly 2 lines of code to add a new function. +But extending the parser may not be necessary at all since it comes with a powerful default +implementation. Here is the (incomplete) list of features: +</p> + + +<!-- +// +// Features / Overview +// +--> + +<h3><a name="idFeatureOverview">Overview</a></h3> + + +<ul> + <li><b>Easy to use</b> + <ul> + <li>You need only a <a href="mup_version.html#idExample">few lines of code</a> to evaluate en expression</li> + </ul> + </li> + <li><b>Extremely fast</b> + <ul> + <li><a href="mup_version.html#idBench">faster than similar commercial parsers</a></li> + </ul> + </li> + + <li><b>User-defined operators</b> + <ul> + <li>binary operators</li> + <li>postfix operators</li> + <li>infix operators</li> + </ul> + </li> + + <li><b>User-defined functions</b> + <ul> + <li>with a fixed number of up to five arguments</li> + <li>with variable number of arguments</li> + <li>with a single string argument (for database queries)</li> + </ul> + </li> + + <li><b>User-defined constants.</b> + <ul> + <li>numeric constants</li> + <li>string constants</li> + </ul> + </li> + + <li><b>User-defined variables.</b> + <ul> + <li>unlimited in number</li> + <li>definable at parser runtime by the parser</li> + <li>assigning variables in terms of other variables is possible</li> + </ul> + </li> + + <li><b>Custom value recognition callbacks</b> + <ul> + <li>support for binary and hex values.</li> + <li>can be used to implement database queries</li> + </ul> + </li> + + <li><b>Default implementaion with many features</b> + <ul> + <li>26 <a href="#idDef1">predefined functions</a>.</li> + <li>15 <a href="#idDef2">predefined operators</a>.</li> + <li>Supports numerical differentiation with respect to a given variable.</li> + <li>Assignement operator is supported</li> + </ul> + </li> + + <li><b>Portability</b> + <ul> + <li>Project / makefiles for MSVC, mingw, autoconf, bcc</li> + <li>ISO 14882 compliant code</li> + <li>DLL version usable from every language able to use function exported in C-style</li> + </ul> + </li> + + <li><b>Unit support</b> + <ul> + <li>Use postfix operators as unit multipliers <code>(3m -> 0.003)</code></li> + </ul> + </li> + + <li><b>Localization</b> + <ul> + <li>Argument separator, decimal separator, thousands separator can be adjusted to your locale</code></li> + </ul> + </li> + +</ul> + + +<!-- +// +// +// +// Default implementation +// +// +// +--> + +<h3><a name="idDef1">The default implementation</a></h3> +<p> +This section gives an overview on the default features supported by the parser. The default +implementation is defined in the class <code>mu::Parser</code> located in the file +<i>muParser.cpp</i>. The DLL-version uses this class internally. +</p> + +<!-- +// +// Features / Built in functions +// +--> + + +<h4><a name="idDef2">Built-in functions</a></h4> +<p> +The following table gives an overview of the functions supported by the +default implementation. It lists the function names, the number of +arguments and a brief description. +</p> + +<table border="1"> +<thead> +<tr> + <td><b>Name</b></td> <td><b>Argc.</b></td> <td><b>Explanation</b></td> +</tr> +</thead> + +<tbody> +<tr><td><code>sin</code></td> <td align="center">1</td> <td>sine function</td></tr> +<tr><td><code>cos</code></td> <td align="center">1</td> <td>cosine function</td></tr> +<tr><td><code>tan</code></td> <td align="center">1</td> <td>tangens function</td></tr> +<tr><td><code>asin</code></td> <td align="center">1</td> <td>arcus sine function</td></tr> +<tr><td><code>acos</code></td> <td align="center">1</td> <td>arcus cosine function</td></tr> +<tr><td><code>atan</code></td> <td align="center">1</td> <td>arcus tangens function</td></tr> +<tr><td><code>sinh</code></td> <td align="center">1</td> <td>hyperbolic sine function</td></tr> +<tr><td><code>cosh</code></td> <td align="center">1</td> <td>hyperbolic cosine</td></tr> +<tr><td><code>tanh</code></td> <td align="center">1</td> <td>hyperbolic tangens function</td></tr> +<tr><td><code>asinh</code></td> <td align="center">1</td> <td>hyperbolic arcus sine function</td></tr> +<tr><td><code>acosh</code></td> <td align="center">1</td> <td>hyperbolic arcus tangens function</td></tr> +<tr><td><code>atanh</code></td> <td align="center">1</td> <td>hyperbolic arcur tangens function</td></tr> +<tr><td><code>log2</code></td> <td align="center">1</td> <td>logarithm to the base 2</td></tr> +<tr><td><code>log10</code></td> <td align="center">1</td> <td>logarithm to the base 10</td></tr> +<tr><td><code>log</code></td> <td align="center">1</td> <td>logarithm to the base 10</td></tr> +<tr><td><code>ln</code></td> <td align="center">1</td> <td>logarithm to base e (2.71828...)</td></tr> +<tr><td><code>exp</code></td> <td align="center">1</td> <td>e raised to the power of x</td></tr> +<tr><td><code>sqrt</code></td> <td align="center">1</td> <td>square root of a value</td></tr> +<tr><td><code>sign</code></td> <td align="center">1</td> <td>sign function -1 if x<0; 1 if x>0</td></tr> +<tr><td><code>rint</code></td> <td align="center">1</td> <td>round to nearest integer</td></tr> +<tr><td><code>abs</code></td> <td align="center">1</td> <td>absolute value</td></tr> +<tr><td><code>if</code></td> <td align="center">3</td> <td>if ... then ... else ...</td></tr> +<tr><td><code>min</code></td> <td align="center">var.</td> <td>min of all arguments</td></tr> +<tr><td><code>max</code></td> <td align="center">var.</td> <td>max of all arguments</td></tr> +<tr><td><code>sum</code></td> <td align="center">var.</td> <td>sum of all arguments</td></tr> +<tr><td><code>avg</code></td> <td align="center">var.</td> <td>mean value of all arguments</td></tr> +</tbody> + +</table> + + +<h4><a name="idDef3">Built-in binary operators</a></h4> +<p> +The following table lists the default binary operators supported by the parser. +</p> + +<table border="1"> + <thead> + <tr><td><b>Operator</b></td> <td><b>Meaning</b></td> <td><b>Priority</b></td></tr> + </thead> + + <tbody> + <tr><td><code>=</code></td> <td>assignement*</td> <td>-1</td></tr> + <tr><td><code>and</code></td> <td>logical and</td> <td>1</td></tr> + <tr><td><code>or</code></td> <td>logical or</td> <td>1</td></tr> + <tr><td><code>xor</code></td> <td>logical xor</td> <td>1</td></tr> + <tr><td><code><=</code></td> <td>less or equal</td> <td>2</td></tr> + <tr><td><code>>=</code></td> <td>greater or equal</td> <td>2</td></tr> + <tr><td><code>!=</code></td> <td>not equal</td> <td>2</td></tr> + <tr><td><code>==</code></td> <td>equal</td> <td>2</td></tr> + <tr><td><code>></code></td> <td>greater than</td> <td>2</td></tr> + <tr><td><code><</code></td> <td>less than</td> <td>2</td></tr> + <tr><td><code>+</code></td> <td>addition</td> <td>3</td></tr> + <tr><td><code>-</code></td> <td>subtraction</td> <td>3</td></tr> + <tr><td><code>*</code></td> <td>multiplication</td> <td>4</td></tr> + <tr><td><code>/</code></td> <td>division</td> <td>4</td></tr> + <tr><td><code>^</code></td> <td>raise x to the power of y</td> <td>5</td></tr> + </tbody> +</table> +<small>*The assignment operator is special since it changes one of its + arguments and can only by applied to variables.</small> + diff --git a/AMDiS/lib/muparser_v134/docs/html/sources/mup_features_meta.html b/AMDiS/lib/muparser_v134/docs/html/sources/mup_features_meta.html new file mode 100755 index 0000000000000000000000000000000000000000..66ac16a7e4909933b34aaab99da25cc3078070b4 --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/sources/mup_features_meta.html @@ -0,0 +1,3 @@ + <meta name="keywords" content="features, muparser, operator, function, math parser, C++"/> + <meta name="description" content="List of operators and functions supported by muparser"/> + <title>List of muparser features</title> diff --git a/AMDiS/lib/muparser_v134/docs/html/sources/mup_interface.html b/AMDiS/lib/muparser_v134/docs/html/sources/mup_interface.html new file mode 100644 index 0000000000000000000000000000000000000000..7cf9d9676dab11dbae585b3b0c48ce7d043eab93 --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/sources/mup_interface.html @@ -0,0 +1,985 @@ + +<!-- +// +// +// +// The parser interface +// +// +// +--> + +<br/> +<h1><a id="idInterface"></a>The parser interface</h1> +The following section gives an overview of the public parser member functions as well as of the functions +exported by the DLL version of the parser. + + +<h2><a id="idInit"></a>Parser initialization / deinitialization</h2> +<h3>[DLL interface]</h3> +Create a new instance handle. You can create as many different instance handles as you like. Each will +internally reference a different parser object. When using the DLL it is necessary to manually release +any parser handle created by <code>mupInit()</code> by calling <code>mupRelease(hParser)</code>. + +<pre> +parser_handle hParser; +hParser = mupInit(); // Create a new handle + +// use the parser... + +mupRelease(hParser); // Release an existing parser handle +</pre> + +Internally a handle is nothing more than a pointer to a parser object casted to a void pointer. + + +<h3>[Parser class interface]</h3> +Code for creating a new parser object. (In case of dynamic allocation use <code>new</code> and <code>delete</code> +for initialization and deinitialization.) + +<pre> +mu::Parser parser; +</pre> + +<!-- +// +// The parser interface / Setting the expression +// +--> + +<h2><a id="idSetExpr"></a>Setting the expression</h2> +<h3>[DLL interface]</h3> +Setting the expression when using the DLL requires a valid parser handle and a pointer to +<code>const char</code> pointing to the expression. + +<pre> +mupSetExpr(hParser, szLine); +</pre> +<small>See also: <i>Example3/Example3.cpp</i>.</small> + +<h3>[Parser class interface]</h3> +Setting the expression using the parser class requires a <code>std::string</code> containing the expression as the +only parameter. +<pre> +parser.SetExpr(line); +</pre> +<small>See also: <i>Example1/Example1.cpp; Example2/WndMain.cpp; ParserLib/muParserTest.cpp</i>.</small> + +<!-- +// +// The parser interface / Evaluating the expression +// +--> + +<h2><a id="idEval"></a>Evaluating an expression</h2> +<p> +Expression evaluation is done by calling the <code>mupEval()</code> function in the DLL version or the +<code>Eval()</code> member function of a parser object. When evaluating an expression for the first time +the parser evaluates the expression string directly and creates a bytecode during +this first time evaluation. Every sucessive call to <code>Eval()</code> will evaluate the bytecode directly +unless you call a function that will silently reset the parser to string parse mode. Some functions +invalidate the bytecode due to possible changes in callback +function pointers or variable addresses. In this way they effectively cause a recreation of the +bytecode during the next call to <code>Eval()</code>. +</p> +<p> +Internally there are different evaluation functions. One for parsing from a string, the other for +parsing from bytecode (and a third one used only if the expression can be simplified to a constant). +Initially, <code>Eval()</code> will call the string parsing function which is slow due to all the +necessary syntax checking, variable lookup, and bytecode creation. Once this +function succeeds, <code>Eval()</code> will change its internal parse function pointer to either +the bytecode parsing function or the const result function which are significantly (approx. 1000 times) +faster. You don't have to worry about this, it's done automatically, just keep in mind that the +first time evaluation of a new formula is significantly slower than any successive call to +<code>Eval()</code>. +</p> + +<h3>[DLL interface]</h3> +<pre> +double fVal; +fVal = mupEval(hParser); +</pre> +<small>See also: <i>Example3/Example3.cpp</i>.</small> + +<h3>[Parser class interface]</h3> +<pre> +double fVal; +try +{ + fVal = parser.Eval(); +} +catch (Parser::exception_type &e) +{ + std::cout << e.GetMsg() << endl; +} +</pre> +<small>See also: <i>Example1/Example1.cpp; Example2/WndMain.cpp</i>.</small> + +<!-- +// +// The parser interface / Defining identifier character sets +// +--> + +<h2><a id="idDefCharset"></a>Defining identifier character sets</h2> +Sometimes it is necessary to change the character sets that are used for token identifiers in +order to avoid conflicts. The parser uses three different character sets. +<ul> + <li>The name character set, is used for: + <ul> + <li>function identifiers</li> + <li>variable identifiers</li> + <li>constant identifiers</li> + </ul> + </li> + <li>The operator character set is used for: + <ul> + <li>binary operator identifiers</li> + <li>postfix operator identifiers</li> + </ul></li> + + <li>The Infix operator charset is used for infix operator identifiers only</li> +</ul> + +When using the default implementation <code>mu::muParser</code> directly you can skip this +section. (The DLL version uses the default implementation internally.) + +<h3>[DLL interface]</h3> +<pre> +mupDefineNameChars(hParser, "0123456789_" + "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); +mupDefineOprtChars(hParser, "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "+-*^/?<>=#!$%&|~'_"); +mupDefineInfixOprtChars(hParser, "/+-*^?<>=#!$%&|~'_"); +</pre> + +<h3>[Parser class interface]</h3> +<pre> +parser.DefineNameChars("0123456789_" + "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); +parser.DefineOprtChars("abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "+-*^/?<>=#!$%&|~'_"); +parser.DefineInfixOprtChars("/+-*^?<>=#!$%&|~'_"); +</pre> +<small>See also: <i>ParserLib/muParser.cpp; ParserLib/muParserInt.cpp</i>.</small> + +<!-- +// +// The parser interface / Defining parser variables +// +--> + +<h2><a id="idDefVar"></a>Defining parser variables</h2> +Custom variables can be defined either explicit in the code by using the <code>DefineVar</code> function or implicit by the parser. Implicit declaration will call a variable factory function provided by the user. The parser is never the owner of its variables. So you must take care of their destruction in case of dynamic allocation. The general idea is to bind every parser variable to a C++ variable. For this reason, you have to make sure the C++ variable stays valid as long as you process a formula that needs it. Only variables of type <code>double</code> are supported. + + +<h2><a id="idDefVarEx"></a>Explicitely defining variables</h2> +Explicitely in this context means you have to do add the variables manually it in your application code. So you must know in advance which variables you intend to use. If this is not the case have a look at +the section on <a href="#idDefVarIm">Implicit creation of new variables</a>. + +<table> + <tr> + <td><img src="images/warning.gif" alt="warning"/></td> + <td>Defining new Variables will reset the parser bytecode. Do not use this function just for changing the values of variables! It would dramatically reduce the parser performance! Once the parser knows the address of the variable there is no need to explicitely call a function for changing the value. Since the parser knows the address it knows the value too so simply change the C++ variable in your code directly!</td> + </tr> +</table> + +<h3>[DLL interface]</h3> +The first parameter is a valid parser handle, the second the variable name and the third a pointer to +the associated C++ variable. + +<pre> +double fVal=0; +mupDefineVar(hParser, "a", &fVal); +</pre> +<small>See also: <i>Example3/Example3.cpp</i>.</small> + +<h3>[Parser class interface]</h3> + +The first parameter is the variable name and the second a pointer to the associated C++ variable. + +<pre> +double fVal=0; +parser.DefineVar("a", &fVal); +</pre> +<small>See also: <i>Example1/Example1.cpp; Example2/WndMain.cpp; ParserLib/muParserTest.cpp</i>.</small> + + +<h2><a id="idDefVarIm"></a>Implicit creation of new variables</h2> +Implicit declaration of new variables is only possible by setting a factory function. Implicit creation +means that everytime the parser finds an unknown token at a position where a variable could be located it +creates a new variable with that name automatically. The necessary factory function must be of type: +<pre>double* (*facfun_type)(const char*, void*)</pre> +The first argument to a factory function is the name of the variable found by the parser. The second is a pointer +to user defined data. This pointer can be used to provide a pointer to a class that implements the actual factory. +By doing this it is possible to use custom factory classes depending on the variable name. + +<table> +<tr><td><img src="images/warning.gif" alt="warning"/></td> <td>Be aware of name conflicts! Please notice that recognizing the name of an undefined variable is the last step during parser token detection. If the potential variable name starts with identifiers that could be interpreted as a function or operator it will be detected as such most likely resulting in an syntax error.</td> +</tr> +</table> + +The following code is an example of a factory function. The example does not use dynamic allocation for +the new variables although this would be possible too. But when using dynamic allocation you must keep +track of the variables allocated implicitely in order to free them later on. + +<pre> +double* AddVariable(const char *a_szName, void *pUserData) +{ + static double afValBuf[100]; + static int iVal = 0; + + std::cout << "Generating new variable \"" + << a_szName << "\" (slots left: " + << 99-iVal << ")" << endl; + + // you could also do: + // MyFactory *pFactory = (MyFactory*)pUserData; + // pFactory->CreateNewVariable(a_szName); + + afValBuf[iVal++] = 0; + if (iVal>=99) + throw mu::Parser::exception_type("Variable buffer overflow."); + + return &afValBuf[iVal]; +} +</pre> +<small>See also: <i>Example1/Example1.cpp</i>.</small> + +In order to add a variable factory use the <code>SetVarFactory</code> functions. The first parameter +is a pointer to the static factory function, the second parameter is optional and represents a pointer +to user defined data. Without a variable factory each undefined variable will cause an undefined token error. Factory +functions can be used to query the values of newly created variables directly from a +database. If you emit errors from a factory function be sure to throw an exception of +type <code>ParserBase::exception_type</code> all other exceptions will be caught internally +and result in an internal error. + +<h3>[DLL interface]</h3> +<pre> +mupSetVarFactory(hParser, AddVariable, pUserData); +</pre> +<small>See also: <i>Example3/Example3.cpp</i>.</small> + +<h3>[Parser class interface]</h3> +<pre> +parser.SetVarFactory(AddVariable, pUserData); +</pre> +<small>See also: <i>Example1/Example1.cpp</i>.</small> + + +<!-- +// +// The parser interface / Defining parser constants +// +--> + + +<h2><a id="idDefConst"></a>Defining parser constants</h2> +Parser constants can either be values of type <code>double</code> or <code>string</code>. Constness +refers to the bytecode. Constants will be stored by their value in the bytecode, not by a reference to +their address. Thus accessing them is faster. They may be optimized away if this is possible. +Defining new constants or changing old ones will reset the parser to string parsing mode thus resetting +the bytecode. +<br/> +The Names of user defined constants may contain only the following characters: <code>0-9, a-z, A-Z, _</code>, and they may not start with a number. Violating this rule will raise a parser error. + +<h3>[DLL interface]</h3> +<pre> +// Define value constants <code>_pi</code> +mupDefineConst(hParser, "_pi", (double)PARSER_CONST_PI); + +// Define a string constant named <code>strBuf</code> +mupDefineStrConst("strBuf", "hello world"); +</pre> +<small>See also: <i>Example3/Example3.cpp</i>.</small> + + +<h3>[Parser class interface]</h3> +<pre> +// Define value constant <code>_pi</code> +parser.DefineConst("_pi", (double)PARSER_CONST_PI); + +// Define a string constant named <code>strBuf</code> +parser.DefineStrConst("strBuf", "hello world"); +</pre> +<small>See also: <i>Example1/Example1.cpp; Example2/WndMain.cpp; ParserLib/muParserTest.cpp</i>.</small> + +<!-- +// +// The parser interface / Defining parser functions +// +--> + + +<h2><a id="idDefFun"></a>Defining parser functions</h2> +The parser allows the user to define a variety of different callback functions. +Functions with a fixed number of up to five numeric arguments, functions with +a variable number of numeric arguments and functions taking a sinlge string +argument plus up to two numeric values. +In order to define a parser function you need to specify its name, a pointer +to a static callback function and an optional flag indicating if the function +is volatile. Volatile functions are functions that can not be optimized. +<br/> +The static callback functions must have of either one of the <a id="FunTypes">following types</a>: + +<pre> +// For fixed number of arguments +double (*fun_type1)(double); +double (*fun_type2)(double, double); +double (*fun_type3)(double, double, double); +double (*fun_type4)(double, double, double, double); +double (*fun_type5)(double, double, double, double, double); + +// for a variable number of arguments +// first arg: pointer to the arguments +// second arg: number of arguments +double (*multfun_type)(const double*, int); + +// for functions taking a single string plus up to two numeric values +double (*strfun_type1)(const char *); +double (*strfun_type2)(const char *, double); +double (*strfun_type3)(const char *, double, double); +</pre> + + +<h3>[DLL interface]</h3> +When using the DLL version it is necessary to call a seperate function for +each type of callback. The following is a list of possible choices. + +<pre> +// Add functions taking string parameters that cant be optimized +mupDefineStrFun1(hParser, "StrFun1", pStrCallback1, false); +mupDefineStrFun2(hParser, "StrFun2", pStrCallback2, false); +mupDefineStrFun3(hParser, "StrFun3", pStrCallback3, false); + +// Add an function with a fixed number of arguments +mupDefineFun1(hParser, "fun1", pCallback1, false); +mupDefineFun2(hParser, "fun2", pCallback2, false); +mupDefineFun3(hParser, "fun3", pCallback3, false); +mupDefineFun4(hParser, "fun4", pCallback4, false); +mupDefineFun5(hParser, "fun5", pCallback5, false); + +// Define a function with variable number of arguments +mupDefineMultFun(hParser, "MultFun", pMultCallback); +</pre> +<small>See also: <i>Example3.cpp</i>.</small> + + +<h3>[Parser class interface]</h3> +Defining callback functions by using the parser class directly is easier since there is +only a single member function that is used for all kinds of callbacks. Since +this member function is defined as a template internally it automatically associates +the right code to any given type of callback. (As long as this type is listed +<a href="#FunTypes">above</a>) + +<pre> +parser.DefineFun("FunName", pCallback, false) +</pre> +<small>See also: <i>Example1/Example1.cpp; ParserLib/muParser.cpp; ParserLib/muParserInt.cpp</i>.</small> + +<!-- +// +// +// The parser interface / Defining parser operators +// +// +--> + +<h2><a id="idDefOprt"></a>Defining parser operators</h2> +The parser is extensible with different kinds of operators: prefix operators, infix operators +and binary operators. Operators can be applied to numerical values only (not to string constants). + +<ul> + <li>Postfix operators are operators that succeed values. For instance the factorial operator + (<code>a! = a*(a-1)...*2*1</code>). Another application for postfix operators is their use as multipliers + that can be used for implementing units.</li> + <li>Infix operators are operators like the unary minus which serves as a sign or the logical + not <code>"!(a<9)"</code>.</li> + <li>Binary operators can be defined in order to supplement or replace the built in binary operators + they require an additional parameter, the operator priority.</li> +</ul> + + +<!-- +// +// The parser interface / unary Operators +// +--> + + +<h3><a id="idUnOp"></a>Unary operators</h3> +Both postfix and infix operators take <a href="#FunTypes">callback functions of type</a> <code>fun_type1</code> like the following: + +<pre> +double MyCallback(double fVal) +{ + return fVal/1000.0; +} +</pre> + +For defining postfix operators and infix operators you need a valid parser instance, +an identifier string, and an optional third parameter marking the operator as volatile +(non optimizable). + +<h3>[DLL interface]</h3> +<pre> +// Define an infix operator +mupDefineInfixOprt(hParser, "!", MyCallback); + +// Define a postfix operators +mupDefinePostfixOprt(hParser, "M", MyCallback); +</pre> +<small>See also:<i>Example3/Example3.cpp</i>.</small> + +<h3>[Parser class interface]</h3> +<pre> +// Define an infix operator +parser.DefineInfixOprt("!", MyCallback); + +// Define a postfix operators +parser.DefinePostfixOprt("m", MyCallback); +</pre> +<small>See also:<i>Example1/Example1.cpp; Example2/WndMain.cpp; muParserTest.cpp</i>.</small> + + + +<!-- +// +// The parser interface / Binary Operators +// +--> + + +<h3><a id="idBinOp"></a>Binary operators</h3> +This parser has 15 <a href="mup_features.html#idDef3">Built in binary operators</a>. Sometimes it might be necessary to add additional custom binary operators. Examples are <code>shl</code> or <code>shr</code>, the "<b>shift left</b>" and "<b>shift right</b>" operators for integer numbers. +In order to add user defined operators you need to assign a name, a callback function of type <code><a href="#idDefFun">fun_type2</a></code> and a priority for each new binary operator. You are not allowed to overload built in operators, this would result in an error being raised! For instance lets consider the +following callback function which should be assigned to a binary operator: + +<pre> +double pMyAddFun(double v1, double v2) +{ + return v1+v2; +} +</pre> + +For the definintion of binary operators you need at least 4 parameters. The first is a valid parser handle, +the second is the identifier of the operator, the third is the operator callback function, the fourth is +the operator priority and the optional fifth parameter is a flag of type <code>bool</code> marking the operator +as volatile. (The examples below omit the last flag.) +Having defined a proper operator callback function you can add the binary operator with the following code: + +<h3>[DLL interface]</h3> +<pre> +mupDefineOprt(hParser, "add", pMyAddFun, 0); +</pre> +<small>See also:<i>Example3/Example3.cpp</i>.</small> + +<h3>[Parser class interface]</h3> +<pre> +parser.DefineOprt("add", pMyAddFun, 0); +</pre> +<small>See also:<i>Example1/Example1.cpp; Example2/WndMain.cpp; muParserTest.cpp</i>.</small> + +<a href="mup_features.html#idDef3">The priority</a> value must be greater or equal than zero (lowest possible priority). It controls the operator precedence in the formula. For instance if you want to calculate the formula <code>1+2*3^4</code> in a mathemetically correct sense you have to make sure that Addition has a lower priority than multiplication which in turn has a lower priority than the power operator. The most likely cases are that you assign an operator with a low priority of 0 (like <code>and</code>, <code>or</code>, <code>xor</code>) or a high priority that is larger than 6. (The priority of the power operator (<code>^</code>).) +By assigning Priority values already used by built in operators you might introduce unwanted side effects. To avoid this and make the order of calculation clear you must use brackets in these cases. Otherwise the order will be determined by the Formula parsing direction which is from left to right. +<br/> +<br/> +Example A: Priority of <code>shl</code> equals priority of an addition; The order of the execution is from left to right. +<pre> +1 + 2 shl 1 => (1 + 2) shl 1 +2 shl 1 + 1 => (s shl 1) + 1 +</pre> +Example B: Priority of <code>shl</code> is higher than the one of the addition; <code>shl</code> is executed first. +<pre> +1 + 2 shl 1 => 1 + (2 shl 1) +2 shl 1 + 1 => (2 shl 1) + 1 +</pre> + +If you encounter such conflicts or simply dont need the built in operators these can easily be deactivated using the <code>EnableBuiltInOprt(bool)</code> function. If you call this function you must add binary operators manually. After all without any operators you won't be able to parse anything useful. User defined operators come with approximately 10% decrease in parsing speed compared to built in operators. There is no way to avoid that. They cause an overhead when calling theeir callback functions. (This is the reason why there are built in operators) + +<pre> +// disable all built in operators +parser.EnableBuiltInOprt(false); +</pre> + + +<!-- +// +// The parser interface / Querying parser variables +// +--> + +<h2><a id="idQueryVar"></a>Querying parser variables</h2> +Keeping track of all variables can be a difficult task. For simplification the parser allows the user +to query the variables defined in the parser. There are two different sets of variables that can +be accessed: + +<ul> + <li>Varaiables defined in the parser</li> + <li>Variables used in the current expression</li> +</ul> + +Since the usage of the necessary commands is similar the following example shows +querying the parser variables only. + + +<h3>[DLL interface]</h3> +For querying the variables used in the expression exchange <code>mupGetVarNum(...)</code> with +<code>mupGetExprVarNum(...)</code> and <code>mupGetVar(...)</code> with <code>mupGetExprVar(...)</code> +in the following example. Due to the use of an temporary internal static buffer for storing the variable +name in the DLL version this DLL-function is not thread safe. + +<pre> +// Get the number of variables +int iNumVar = mupGetVarNum(a_hParser); + +// Query the variables +for (int i=0; i < iNumVar; ++i) +{ + const char *szName = 0; + double *pVar = 0; + mupGetVar(a_hParser, i, &szName, &pVar); + std::cout << "Name: " << szName << " Address: [0x" << pVar << "]\n"; +} +</pre> +<small>See also: <i>Example3/Example3.cpp</i>.</small> + +<h3>[Parser class interface]</h3> +For querying the expression variables exchange <code>parser.GetVar()</code> with +<code>parser.GetUsedVar()</code> in the following example. + +<pre> +// Get the map with the variables +mu::Parser::varmap_type variables = parser.GetVar(); +cout << "Number: " << (int)variables.size() << "\n"; + +// Get the number of variables +mu::Parser::varmap_type::const_iterator item = variables.begin(); + +// Query the variables +for (; item!=variables.end(); ++item) +{ + cout << "Name: " << item->first << " Address: [0x" << item->second << "]\n"; +} +</pre> + +<small> + See also: <i>Example1/Example1.cpp, Example2/WndMain.cpp</i>. +</small> + +<!-- +// +// The parser interface / Querying parser constants +// +--> + + +<h2><a id="idQueryConst"></a>Querying parser constants</h2> +Querying parser constants is similar to querying variables and expression variables. + +<h3>[DLL interface]</h3> +Due to the use of an temporary internal static buffer for storing the variable +name in the DLL version this DLL-function is not thread safe. + +<pre> +int iNumVar = mupGetConstNum(a_hParser); + +for (int i=0; i < iNumVar; ++i) +{ + const char *szName = 0; + double fVal = 0; + mupGetConst(a_hParser, i, &szName, fVal); + std::cout << " " << szName << " = " << fVal << "\n"; +} +</pre> + +<small> + See also: <i>Example3/Example3.cpp</i>. +</small> + + +<h3>[Parser class interface]</h3> +The parser class provides you with the <code>GetConst()</code> member function that returns a map structure +with all defined constants. The following code snippet shows how to use it: +<pre> +mu::Parser::valmap_type cmap = parser.GetConst(); +if (cmap.size()) +{ + mu::Parser::valmap_type::const_iterator item = cmap.begin(); + for (; item!=cmap.end(); ++item) + cout << " " << item->first << " = " << item->second << "\n"; +} +</pre> +<small>See also: <i>Example1/Example1.cpp, Example2/WndMain.cpp</i>.</small> + +<!-- +// +// The parser interface / Setting custom value recognition callbacks +// +--> + + +<h2><a id="idDefConst2"></a>Setting custom value recognition callbacks</h2> +The parser default implementation <i>(muParser.cpp)</i> scans expressions +only for floating point values. Custom value recognition callbacks can be used in order to +implement support for binary, hexadecimal or octal numbers. These functions are called +during the string parsing and allow the user to scan portions of the original expressions +for values. Their callback functions must be of the following type: + +<pre> +bool (*identfun_type)(const char_type*, int&, value_type&); +</pre> + +<p> +If the parser reaches an a position during string parsing that could host a value token it +tries to interpret it as such. If that fails the parser sucessively calls all +internal value recognition callbacks in order to give them a chance to make +sense out of what has been found. If all of them fail the parser continues to +check if it is a Variable or another kind of token. +</p> + +<p> +In order to perform the task of value recognition these functions take a <code>const char</code> +pointer, a reference to <code>int</code> and a reference +to <code>double</code> as their arguments. +The <code>const char</code> pointer points to the current formula position. The second +argument is the index of that position. This value must be increased by the length of the +value entry if one has been found. In that case the value must be written to the third +argument which is of type <code>double</code>. +</p> + +<p> +The next code snippet shows a sample implementation of a function that reads and +interprets binary values from the expression string. The code is taken from +<i>muParserInt.cpp</i> the implementation of a parser for integer numbers. Binary +numbers must be preceded with a <code>#</code> (i.e. <code>#1000101</code>). +</p> + +<pre> +bool ParserInt::IsBinVal(const char_type *a_szExpr, + int &a_iPos, value_type &a_fVal) +{ + if (a_szExpr[0]!='#') + return false; + + unsigned iVal = 0, iBits = sizeof(iVal)*8; + for (unsigned i=0; + (a_szExpr[i+1]=='0'||a_szExpr[i+1]=='1')&& i<iBits; + ++i) + { + iVal |= (int)(a_szExpr[i+1]=='1') << ((iBits-1)-i); + } + + if (i==0) + return false; + + if (i==iBits) + throw exception_type("Binary to integer conversion error (overflow)."); + + a_fVal = (unsigned)(iVal >> (iBits-i) ); + a_iPos += i+1; + + return true; +} +</pre> + +Once you have the callback you must add it to the parser. This can be done with: + +<h3>[DLL interface]</h3> +<pre> +mupAddValIdent(hParser, IsBinVal); +</pre> + +<small> +See also: <i>Example3/Example3.cpp</i>. +</small> + + +<h3>[Parser class interface]</h3> +<pre> +parser.AddValIdent(IsBinVal); +</pre> +<small> +See also: <i>ParserLib/muParserInt.cpp</i>. +</small> + +<!-- +// +// The parser interface / Removing variables or constants +// +--> + +<h2><a id="idRemoveVar"></a>Removing variables or constants</h2> +Removing variables and constants can be done all at once using <code>ClearVar</code> and +<code>ClearConst</code>. Additionally variables can be removed by name using +<code>RemoveVar</code>. Since the parser never owns the variables you must take care of +their release yourself <small>(if they were dynamically allocated)</small>. If you need to browse all +the variables have a look at the chapter explaining how to +<a href="#idQueryVar">query parser variables</a>. + + +<h3>[DLL interface]</h3> +<pre> +// Remove all constants +mupClearConst(hParser); + +// remove all variables +mupClearVar(hParser); + +// remove a single variable by name +mupRemoveVar(hParser, "a"); +</pre> + + +<h3>[Parser class interface]</h3> +<pre> +// Remove all constants +parser.ClearConst(); + +// remove all variables +parser.ClearVar(); + +// remove a single variable by name +parser.RemoveVar("a"); +</pre> + +<!-- +// +// The parser interface / Error handling +// +--> + + +<h2><a id="idErrors"></a>Error handling</h2> +In case of an error both parser class and the parser DLL provide +similar methods for querying the information associated with the +error. In the parser class they are member functions of the associated +exception class <code>mu::Parser::exception_type</code> and in the DLL +version they are normal functions. + +<p> +These functions are: +</p> + +<ul> + <li><code>exception.GetMsg() / mupGetErrorMsg()</code> - returns the error message.</li> + <li><code>exception.GetExpr() / mupGetExpr()</code> - returns the current formula (if a formula is set)</li> + <li><code>exception.GetToken() / mupGetErrorToken()</code> - returns the token associated with the error (if applicable)</li> + <li><code>exception.GetPos() / mupGetErrorPos()</code> - returns the current formula position (if applicable)</li> + <li><code>exception.GetCode() / mupGetErrorCode()</code> - returns the error code.</li> +</ul> + +<p> +The following table lists the parser error codes. +The first column contains the enumeration values as defined in the enumeration <code>mu::EErrorCodes</code> +located in the file <i>muParserError.h</i>. Since they are only accessible from C++ the second column lists +their numeric code and the third column contains the error description. +</p> + +<table border="0"> +<thead> + <tr> + <td> <small><b>Enumeration name</b></small></td> + <td align="center"><small><b>Value</b></small></td> + <td> <small><b>Description</b></small></td> + </tr> +</thead> + +<tbody> + <tr> + <td><small><code>ecUNEXPECTED_OPERATOR</code></small></td> + <td align="center"><small>0</small></td> + <td><small>Unexpected binary operator found</small></td> + </tr> + <tr> + <td><small><code>ecUNASSIGNABLE_TOKEN</code></small></td> + <td align="center"><small>1</small></td> + <td><small>Token cant be identified</small></td> + </tr> + <tr> + <td><small><code>ecUNEXPECTED_EOF</code></small></td> + <td align="center"><small>2</small></td> + <td><small>Unexpected end of formula. (Example: "2+sin(")</small></td> + </tr> + <tr> + <td><small><code>ecUNEXPECTED_COMMA</code></small></td> + <td align="center"><small>3</small></td> + <td><small>An unexpected comma has been found. (Example: "1,23")</small></td> + </tr> + <tr> + <td><small><code>ecUNEXPECTED_ARG</code></small></td> + <td align="center"><small>4</small></td> + <td><small>An unexpected argument has been found</small></td> + </tr> + <tr> + <td><small><code>ecUNEXPECTED_VAL</code></small></td> + <td align="center"><small>5</small></td> + <td><small>An unexpected value token has been found</small></td> + </tr> + <tr> + <td><small><code>ecUNEXPECTED_VAR</code></small></td> + <td align="center"><small>6</small></td> + <td><small>An unexpected variable token has been found</small></td> + </tr> + <tr> + <td><small><code>ecUNEXPECTED_PARENS</code></small></td> + <td align="center"><small>7</small></td> + <td><small>Unexpected parenthesis, opening or closing</small></td> + </tr> + <tr> + <td><small><code>ecUNEXPECTED_STR</code></small></td> + <td align="center"><small>8</small></td> + <td><small>A string has been found at an inapropriate position</small></td> + </tr> + <tr> + <td><small><code>ecSTRING_EXPECTED</code></small></td> + <td align="center"><small>9</small></td> + <td><small>A string function has been called with a different type of argument</small></td> + </tr> + <tr> + <td><small><code>ecVAL_EXPECTED</code></small></td> + <td align="center"><small>10</small></td> + <td><small>A numerical function has been called with a non value type of argument</small></td> + </tr> + <tr> + <td><small><code>ecMISSING_PARENS</code></small></td> + <td align="center"><small>11</small></td> <td><small>Missing parens. (Example: "3*sin(3")</small></td> + </tr> + <tr> + <td><small><code>ecUNEXPECTED_FUN</code></small></td> + <td align="center"><small>12</small></td> + <td><small>Unexpected function found. (Example: "sin(8)cos(9)")</small></td> + </tr> + <tr> + <td><small><code>ecUNTERMINATED_STRING</code></small></td> + <td align="center"><small>13</small></td> + <td><small>unterminated string constant. (Example: "3*valueof("hello)")</small></td> + </tr> + <tr> + <td><small><code>ecTOO_MANY_PARAMS</code></small></td> + <td align="center"><small>14</small></td> + <td><small>Too many function parameters</small></td> + </tr> + <tr> + <td><small><code>ecTOO_FEW_PARAMS</code></small></td> + <td align="center"><small>15</small></td> + <td><small>Too few function parameters. (Example: "ite(1<2,2)")</small></td> + </tr> + <tr> + <td><small><code>ecOPRT_TYPE_CONFLICT</code></small></td> + <td align="center"><small>16</small></td> + <td><small>binary operators may only be applied to value items of the same type</small></td> + </tr> + <tr> + <td><small><code>ecSTR_RESULT</code></small></td> + <td align="center"><small>17</small></td> + <td><small>result is a string</small></td> + </tr> + <tr> + <td><small><code>ecINVALID_NAME</code></small></td> + <td align="center"><small>18</small></td> + <td><small>Invalid function, variable or constant name.</small></td> + </tr> + <tr> + <td><small><code>ecBUILTIN_OVERLOAD</code></small></td> + <td align="center"><small>19</small></td> + <td><small>Trying to overload builtin operator</small></td> + </tr> + <tr> + <td><small><code>ecINVALID_FUN_PTR</code></small></td> + <td align="center"><small>20</small></td> + <td><small>Invalid callback function pointer</small></td> + </tr> + <tr> + <td><small><code>ecINVALID_VAR_PTR</code></small></td> + <td align="center"><small>21</small></td> + <td><small>Invalid variable pointer</small></td> + </tr> + <tr> + <td><small><code>ecNAME_CONFLICT</code></small></td> + <td align="center"><small>22</small></td> + <td><small>Name conflict</small></td> + </tr> + <tr> + <td><small><code>ecOPT_PRI</code></small></td> + <td align="center"><small>23</small></td> + <td><small>Invalid operator priority</small></td> + </tr> + <tr> + <td><small><code>ecDOMAIN_ERROR</code></small></td> + <td align="center"><small>24</small></td> + <td><small>catch division by zero, sqrt(-1), log(0) (currently unused)</small></td> + </tr> + <tr> + <td><small><code>ecDIV_BY_ZERO</code></small></td> + <td align="center"><small>25</small></td> + <td><small>Division by zero (currently unused)</small></td> + </tr> + <tr> + <td><small><code>ecGENERIC</code></small></td> + <td align="center"><small>26</small></td> + <td><small>Error that does not fit any other code but is not an internal error</small></td> + </tr> + <tr> + <td><small><code>ecINTERNAL_ERROR</code></small></td> + <td align="center"><small>27</small></td> + <td><small>Internal error of any kind.</small></td> + </tr> + </tbody> +</table> + +<h3>[DLL interface]</h3> +Since dynamic libraries with functions exported in C-style can't throw exceptions the DLL version +provides the user with a callback mechanism to raise errors. Simply add a callback function +that does the handling of errors. Additionally you can query the error flag with +<code>mupError()</code>. Please note that by calling this function you will automatically reset the error flag! +<pre> +// Callback function for errors +void OnError() +{ + cout << "Message: " << mupGetErrorMsg() << "\n"; + cout << "Token: " << mupGetErrorToken() << "\n"; + cout << "Position: " << mupGetErrorPos() << "\n"; + cout << "Errc: " << mupGetErrorCode() << "\n"; +} + +... + +// Set a callback for error handling +mupSetErrorHandler(OnError); + +// The next function could raise an error +fVal = mupEval(hParser); + +// Test for the error flag +if (!mupError()) cout << fVal << "\n"; +</pre> +<small>See also: Example3/Example3.cpp</small> + +<h3>[Parser class interface]</h3> +In case of an error the parser class raises an exception of type <code>Parser::exception_type</code>. This +class provides you with several member functions that allow querying the exact cause as well as +additional information for the error. +<pre> +try +{ + ... + parser.Eval(); + ... +} +catch(mu::Parser::exception_type &e) +{ + cout << "Message: " << e.GetMsg() << "\n"; + cout << "Formula: " << e.GetExpr() << "\n"; + cout << "Token: " << e.GetToken() << "\n"; + cout << "Position: " << e.GetPos() << "\n"; + cout << "Errc: " << e.GetCode() << "\n"; +} +</pre> +<small>See also: Example1/Example1.cpp</small> + + diff --git a/AMDiS/lib/muparser_v134/docs/html/sources/mup_interface_meta.html b/AMDiS/lib/muparser_v134/docs/html/sources/mup_interface_meta.html new file mode 100644 index 0000000000000000000000000000000000000000..0c6e06dc2aa9e2407164e4ae30d9f51173e8bc16 --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/sources/mup_interface_meta.html @@ -0,0 +1,3 @@ + <meta name="keywords" content="muparser, api, interface, dll, C++"/> + <meta name="description" content="muparser programming interface"/> + <title>muParser programming interface</title> diff --git a/AMDiS/lib/muparser_v134/docs/html/sources/mup_intro.html b/AMDiS/lib/muparser_v134/docs/html/sources/mup_intro.html new file mode 100644 index 0000000000000000000000000000000000000000..cc4290c859c752c50a3d8961c55647086528ffe8 --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/sources/mup_intro.html @@ -0,0 +1,97 @@ +<script type="text/javascript"> + imgParserNET=new Image(); + imgParserNET.src="images/muParserNET.png"; + imgParserNETDark=new Image(); + imgParserNETDark.src="images/muParserNET_.png"; + + imgParserX=new Image(); + imgParserX.src="images/muParserX.png"; + imgParserXDark=new Image(); + imgParserXDark.src="images/muParserX_.png"; + + imgDownload=new Image(); + imgDownload.src="images/download_muparser.png"; + imgDownloadDark=new Image(); + imgDownloadDark.src="images/download_muparser_.png"; +</script> + +<h2>About the parser</h2> + +<p> +Many applications require the parsing of <strong>mathematical expressions</strong>. +The main objective of this library is to provide a fast and easy way of +doing this. <strong>muParser</strong> is an extensible high performance +<strong>math parser</strong> library written in <a href="http://www.cplusplus.com/">C++</a>. It works +by transforming a mathematical expression into bytecode and precalculating constant +parts of the expression. +</p> + +<div style="/*position:float; */border: 1px solid #000000; width:420px; height:220px; text-align:left; float:left; margin-right:10px; background-color: #ffffff;"> +<img src="images/related.png" alt="math expression parser - related links" border="0" width="420"/> + <a href="http://www.codeproject.com/KB/recipes/muParser.aspx"> + <img src="images/muParserNET_.png" alt=".NET math parser" border="0" width="200" style="float:left;" onmouseover="ChangeButtonImage(7,imgParserNET)" onmouseout="ChangeButtonImage(7,imgParserNETDark)"/> + <br/> + <strong>muParser C# wrapper</strong> + <br/> + <span class="tiny_text">a math parser for .NET</span> + </a> + + <br clear="all"/><br/> + <a href="http://beltoforion.de/muparserx/math_expression_parser_en.html"> + <img src="images/muParserX_.png" + alt="math expression parser" + border="0" + width="200" + style="float:left;" + onmouseover="ChangeButtonImage(8,imgParserX)" + onmouseout="ChangeButtonImage(8,imgParserXDark)"/> + <strong>muParserX</strong> + <br/> + <span class="tiny_text">a math expression parser with support for multitype data types</span> + </a> +</div> +The library was designed with portability in mind and should compile on every +standard compliant C++ compiler. Wrapper for <strong>C</strong> and <strong>C#</strong> +exist. The parser archive contains ready to use project and makefiles files for a variety of +platforms. The code runs on both <strong>32 bit</strong> and +<strong>64 bit</strong> architechtures and has been tested using MS VC++ V8.0 +and GCC V4.4.1. Code samples are provided in order to help you understand its +usage. The library is <strong>open source</strong> and distributed under +the <a href="http://www.opensource.org/licenses/mit-license.php">MIT license</a>. + +<div style="text-align:center;"> +<a href="http://sourceforge.net/project/showfiles.php?group_id=137191"> + <img src="images/download_muparser_.png" + border="0" + alt="muParser download" + onmouseover="ChangeButtonImage(9,imgDownload)" + onmouseout="ChangeButtonImage(9,imgDownloadDark)"/> +</a> +</div> + +<p> +Before I go on, I'd like to thank <a href="http://sourceforge.net">SourceForge</a> for hosting this project. This +pages would not exist without the webspace provided by them and of course I'd like +to thank <a href="http://www.codeproject.com">CodeProject</a> for hosting the original +<a href="http://www.codeproject.com/cpp/FastMathParser.asp" target="_blank">math parser</a> +article. +</p> + + +<h2>Support this project</h2> +muParser is free software and anyone can use it free of charge for commercial and noncommercial purposes. If you wish you can support this project by <strong>making a small donation</strong>: +<br/> +<br/> +<div style="text-align:center;"> + <a href="http://sourceforge.net/donate/index.php?group_id=137191"> + <img src="http://images.sourceforge.net/images/project-support.jpg" + width="196" + height="64" + border="0" + alt="Support This Project"/> + </a> +</div> +<br/> +A project like muParser requires permanent maintanence in order to adopt to new platforms, new compiler version and for fixing bugs. So if you are using the library and find it useful i would like to encourage you to make a donation in order to help keeping the project up to date. I can officially guarantee that you <strong>make my day</strong> by donating even a small amount of money. In a way this is a "Wow the people actually really appreciate what i'm doing" kind of thing and that's whats driving me and ultimately this is what is keeping this project alive. + + diff --git a/AMDiS/lib/muparser_v134/docs/html/sources/mup_intro_meta.html b/AMDiS/lib/muparser_v134/docs/html/sources/mup_intro_meta.html new file mode 100755 index 0000000000000000000000000000000000000000..36d285f96e4cc129f6d08cff778b345581a08630 --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/sources/mup_intro_meta.html @@ -0,0 +1,3 @@ + <meta name="keywords" content="math parser, math expression parser, muparser, muparserx, muparser.net, .net, c++, lib, dll, donation, function parser"/> + <meta name="description" content="muParser - a fast math parser library"/> + <title>muParser - a fast math parser library</title> diff --git a/AMDiS/lib/muparser_v134/docs/html/sources/mup_licence.html b/AMDiS/lib/muparser_v134/docs/html/sources/mup_licence.html new file mode 100644 index 0000000000000000000000000000000000000000..4a812e8db2a4e5b4b27f2803a4f6af0b6da2bea6 --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/sources/mup_licence.html @@ -0,0 +1,54 @@ +<!-- +// +// +// +// License +// +// +// +--> + +<h1><a name="idLicense">muParser licence</a></h1> + +<p> +This library is distributed as freeware. The licence is the <a href="http://www.opensource.org/licenses/mit-license.php">MIT licence</a>: you are free to use it for both non-commercial and commercial use. In order to use it you have to agree to the licence text below. If you use the library I consider it appropriate to give me credit at some place. This can either be the about dialog of your application or the documentation of your software. +If you like this project I encourage you to support it by: +</p> +<ul> + <li>sending a brief description of how you use it in your project</li> + <li>sending <a href="http://sourceforge.net/tracker/?atid=737979&group_id=137191&func=browse">bug reports</a></li> + <li>voting for this project on <a href="http://www.codeproject.com/cpp/FastMathParser.asp">CodeProject</a></li> +</ul> + +<p> +<b>Copyright (c) 2010 Ingo Berg</b> +<br/> +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +</p> + +<p> +The above copyright notice and this permission notice +shall be included in all copies or substantial portions of +the Software.</p> +<p> + +<i> +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS +OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +</i> + +</p> + diff --git a/AMDiS/lib/muparser_v134/docs/html/sources/mup_licence_meta.html b/AMDiS/lib/muparser_v134/docs/html/sources/mup_licence_meta.html new file mode 100755 index 0000000000000000000000000000000000000000..420a059714f49b9a26f7e2c45f0c6930583fe916 --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/sources/mup_licence_meta.html @@ -0,0 +1,3 @@ + <meta name="keywords" content="muparser, licence, licencing, terms and conditions, legal, mit, open source, c++"/> + <meta name="description" content="muparser licence"/> + <title>muparser Licence</title> diff --git a/AMDiS/lib/muparser_v134/docs/html/sources/mup_links.html b/AMDiS/lib/muparser_v134/docs/html/sources/mup_links.html new file mode 100644 index 0000000000000000000000000000000000000000..e1cf98ef25770122793d74cb4dadc46ef6965d3b --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/sources/mup_links.html @@ -0,0 +1,71 @@ +<br/> +<br/> +<h2>Software using the muParser library (alphabetically)</h2> +<table border="0"> + <colgroup> + <col width="120"/> + </colgroup> + + <tr> + <td><img src="images/thumb_geodes.jpg" border="0" width="120" alt="Geodes thumbnail"/></td> + <td align="center"><a href="http://geodes.sourceforge.net/" target="_top">Geodes</a></td> + <td>Geodes is a new dynamic geometry software for Mac OS X. The goal of this application is to make geometry become easy and funny.<br/> + (Platform: Mac OSX)</td> + </tr> + + <tr> + <td><img src="images/thumb_kst.jpg" width="120" border="0" alt="kst thumbnail"/></td> + <td align="center"><a href="http://extragear.kde.org/apps/kst/" target="_top">kst</a></td> + <td>A plotter for scientific data. (currently muParser is used by the Marquardt + Levenberg plugin)<br/> + (Platform: Linux / Operating systems that support KDE) + </td> + </tr> + + <tr> + <td><img src="images/thumb_matrix.jpg" border="0" width="120" alt="MatriX thumbnail"/></td> + <td align="center"><a href="http://www.ds4.it/" target="_top">MatriX</a></td> + <td>DS4 produces laser systems for industry applications like engraving, cutting, incision and welding. muParser is used + in their MatriX application, a software for for managing the laser systems.<br/> + (Platform: Linux)</td> + </tr> + + <tr> + <td><img src="images/thumb_meshlab.jpg" border="0" width="120" alt="tm2 thumbnail"/></td> + <td align="center"><a href="http://meshlab.sourceforge.net" target="_top">Meshlab </a></td> + <td>An open source, portable, and extensible system for the processing and editing of unstructured 3D triangular meshes. <br/> + (Platform: MS Windows, Linux, OSX)</td> + </tr> + + <tr> + <td><img src="images/thumb_pasimodo.jpg" border="0" width="120" alt="Pasimodo"/></td> + <td align="center"><a href="http://www.itm.uni-stuttgart.de/research/pasimodo/pasimodo_de.php" target="_top">Pasimodo</a></td> + <td>Pasimodo is a scientific software package for particle based simulations.<br/> + (Platform: Linux/BSD)</td> + </tr> + + <tr> + <td><img src="images/thumb_tm2.jpg" border="0" width="120" alt="tm2 thumbnail"/></td> + <td align="center"><a href="http://www.papajohn.org/tm2.html" target="_top">Transition Maker 2 </a></td> + <td>Creates transition sequences for video processing.<br/> + (Platform: MS Windows)</td> + </tr> + + <tr> + <td><img src="images/thumb_trini.jpg" border="0" width="120" alt="trininaut thumbnail"/></td> + <td align="center"><a href="http://trininaut.sourceforge.net/" target="_top">Trininaut</a></td> + <td>A Program launcher with extra features.<br/> + (Platform: WinXP, Win2K)</td> + </tr> + + <tr> + <td><img src="images/thumb_qtiplot.jpg" width="120" border="0" alt="qtiplot thumbnail"/></td> + <td align="center"><a href="http://soft.proindependent.com/qtiplot.html" target="_top">Qtiplot</a></td> + <td>A free platform independent clone of Origin<br/> + (Platform: MS Windows / Linux / Mac) + </td> + </tr> + + +</table> + diff --git a/AMDiS/lib/muparser_v134/docs/html/sources/mup_links_meta.html b/AMDiS/lib/muparser_v134/docs/html/sources/mup_links_meta.html new file mode 100755 index 0000000000000000000000000000000000000000..7d174655a56d524cb0451e62db8d63cdaf084a82 --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/sources/mup_links_meta.html @@ -0,0 +1,3 @@ + <meta name="keywords" content="muparser, related links, related"/> + <meta name="description" content="Software using muparser"/> + <title>Software using muparser</title> diff --git a/AMDiS/lib/muparser_v134/docs/html/sources/mup_locale.html b/AMDiS/lib/muparser_v134/docs/html/sources/mup_locale.html new file mode 100755 index 0000000000000000000000000000000000000000..1599742413e4e0ff1b36af1b99e4941efc3cdf3e --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/sources/mup_locale.html @@ -0,0 +1,39 @@ +<!-- +// +// +// +// Localization +// +// +// +--> + +<h2><a id="idLoc"></a>Localization</h2> +<p> +Sometimes it is necessary to change decimal separator, argument separator or thousands separator +to match a certain locale. The following functions can be used for this purpose: +</p> + +<h3>[DLL interface]</h3> +<pre> +// german localization +mupSetArgSep(hParser, ';'); +mupSetDecSep(hParser, ','); +mupSetThousandsSep(hParser, '.'); + +// reset to defaults +mupResetLocale(); +</pre> +<small>See also: <i>example2/example2.c</i>.</small> + +<h3>[Parser class interface]</h3> +<pre> +// german localization +parser.SetArgSep(';'); +parser.SetDecSep(','); +parser.SetThousandsSep('.'); + +// reset to defaults +parser.ResetLocale(); +</pre> +<small>See also: <i>example1/example1.cpp</i>.</small> diff --git a/AMDiS/lib/muparser_v134/docs/html/sources/mup_locale_meta.html b/AMDiS/lib/muparser_v134/docs/html/sources/mup_locale_meta.html new file mode 100755 index 0000000000000000000000000000000000000000..ec5d4b3b3d5614d72aa66e0645a716963071ebc6 --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/sources/mup_locale_meta.html @@ -0,0 +1,3 @@ + <meta name="keywords" content="muparser, example, sample, benchmarks, benchmark, performance, comparison, release notes, changes, history"/> + <meta name="description" content="Sample code for using muParser"/> + <title>muParser - A basic axample and benchmarks</title> diff --git a/AMDiS/lib/muparser_v134/docs/html/sources/mup_usage.html b/AMDiS/lib/muparser_v134/docs/html/sources/mup_usage.html new file mode 100644 index 0000000000000000000000000000000000000000..dfd8fcf4bd884ddd7a497b06251bc60fcbaf3529 --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/sources/mup_usage.html @@ -0,0 +1,149 @@ +<!-- +// +// +// +// Adding the parser to your projects +// +// +// +--> + + +<br/> +<h1><a id="idBuild"></a>Build instructions</h1> +<h2><a id="idInstWin"></a>Building on win32</h2> +<b>muParser</b> supports various win32 command-line compilers: +<ul> + <li>Mingw</li> + <li>Borland C++</li> + <li>Watcom</li> + <li>Microsoft CL</li> +</ul> +In order to compile muParser from makefiles, open a command prompt then move to the muParser/build directory and +type: + +<ul> + <li>mingw32-make -fmakefile.gcc for mingw</li> + <li>nmake -fmakefile.vc for msvc</li> + <li>make -fmakefile.bcc for borland</li> + <li>wmake -fmakefile.wat for watcom</li> +</ul> + +All makefiles support the following options: +<pre> + # Set to 1 to build debug version [0,1] + # 0 - Release + # 1 - Debug + DEBUG = 0 + + # Set to 1 to build shared (DLL) version [0,1] + # 0 - Static + # 1 - DLL + SHARED = 0 + + # Set to 1 to compile samples [0,1] + SAMPLES = 1 +</pre> +The muParser library is created in the 'lib' folder and the sample +binaries are created in samples\example1 or samples\example2. (You may need to copy the dll +into the example2 directory in order to run it.) + +<table> +<tr> + <td><img src="images/warning.gif" alt="warning"/></td> + <td>samples\example1 can be compiled *only* when building muParser as a STATIC library (SHARED=0).<br/> + samples\example2 can be compiled *only* when building muParser as a SHARED library (SHARED=1). + </td> +</tr> +</table> + +<h2><a id="idInstLinux"></a>Building on BSD/Linux</h2> +muParser can be installed just extracting the sources somewhere and then, from a terminal, typing: + +<pre> + cd [path to muParser] + ./configure [--enable-shared=yes/no] [--enable-samples=yes/no] + [--enable-debug=yes/no] + make + [sudo*] make install +</pre> + <small>* = this command must be executed with root permissions and thus + you have to use 'sudo' or just 'su' to gain root access. + Note that installation is not strictly required.</small> +<p> +The "make" step will create the muParser library in 'lib' and the +sample binary in samples/example1. The samples/example2 is win32-specific and +thus won't be built. +</p> + +<h2><a id="idInstMisc"></a>Other miscellaneous info Unix-specific</h2> +If you don't like to have your muParser folder filled by temporary +files created by GCC, then you can do the following: + +<pre> + mkdir mybuild && cd mybuild && ../configure && make +</pre> + +to put all object files in the "mybuild" directory. If you want to use +muParser library in your programs, you can use the pkg-config program +(this works only if muParser was installed with 'make install' !). +The commands: +<ul> + <li>pkg-config muparser --cflags</li> + <li>pkg-config muparser --libs</li> +</ul> +will return all useful info you need to build your programs against +muParser ! + +<h2><a id="idInstInc"></a><a name="idUseSource"></a>Including the source code directly</h2> +Sometimes including the library sources directly into an application is the easiest +possibility to avoid linker conflicts originating from different versions of the +runtime libraries used by the parser and your project. + +In order to use the parser simply include the following files into your project: + +<p> +<i>muParser.cpp</i><br/> +<i>muParserBase.cpp</i><br/> +<i>muParserBytecode.cpp</i><br/> +<i>muParserCallback.cpp</i><br/> +<i>muParserError.cpp</i><br/> +<i>muParserTokenReader.cpp</i> +</p> + +And make sure the following files can be found in your projects include path: +<p> +<i>muParser.h</i><br/> +<i>muParserBase.h</i><br/> +<i>muParserBytecode.h</i><br/> +<i>muParserCallback.h</i><br/> +<i>muParserDef.h</i><br/> +<i>muParserError.h</i><br/> +<i>muParserFixes.h</i><br/> +<i>muParserStack.h</i><br/> +<i>muParserToken.h</i><br/> +<i>muParserTokenReader.h</i><br/> +</p> + +The parser class and all related classes reside in the namespace <code>mu</code> (MathUtils). So make sure to either +add a using + +<pre> +using namespace mu; +</pre> + +to your files or reference all classes with their complete name. + +<h2>Where to ask for help</h2> + +If you find problems with either compilation, installation or usage +of muParser, then you can ask in the muParser forum at:<br/> +<ul> +<li><a href="https://sourceforge.net/forum/forum.php?forum_id=462843">https://sourceforge.net/forum/forum.php?forum_id=462843</a></li> +</ul> + +For more info about muParser, visit: +<ul> +<li><a href="http://sourceforge.net/projects/muparser/">http://sourceforge.net/projects/muparser/</a><br/></li> +<li><a href="http://muparser.sourceforge.net">http://muparser.sourceforge.net</a></li> +</ul> diff --git a/AMDiS/lib/muparser_v134/docs/html/sources/mup_usage_meta.html b/AMDiS/lib/muparser_v134/docs/html/sources/mup_usage_meta.html new file mode 100755 index 0000000000000000000000000000000000000000..1ca5af402b89e518e3651503d07fb5cacafee8ee --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/sources/mup_usage_meta.html @@ -0,0 +1,3 @@ + <meta name="keywords" content="muparser, build instructions, makefile, configuration, built, project file, install"/> + <meta name="description" content="muparser build instructions"/> + <title>muParser build instructions</title> diff --git a/AMDiS/lib/muparser_v134/docs/html/sources/mup_version.html b/AMDiS/lib/muparser_v134/docs/html/sources/mup_version.html new file mode 100644 index 0000000000000000000000000000000000000000..9179236857977f8897cc5da1670e07daa89c96ce --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/sources/mup_version.html @@ -0,0 +1,217 @@ +<!-- +// +// +// +// Example code +// +// +// +--> + +<h2><a id="idExample"></a>Example code</h2> + +<p> +If you put all this together, you get the source code for a small application. The application defines a parser variables ("<code>a</code>") and adds +a user defined functions named "<code>MyFunc</code>". When using the parser make sure that you don't forget to catch the <code>Parser::exception_type</code> in your application. It contains detailed information helping you to find syntax errors in your formula. +</p> + +<pre> +#include <iostream> +#include "muParser.h" + +// Function callback +double MyFunction(double a_fVal) +{ + return a_fVal*a_fVal; +} + +// main program +int main(int argc, char* argv[]) +{ + using namespace mu; + + try + { + double fVal = 1; + Parser p; + p.DefineVar("a", &fVal); + p.DefineFun("MyFunc", MyFunction); + p.SetExpr("MyFunc(a)*_pi+min(10,a)"); + std::cout << p.Eval() << std::endl; + } + catch (Parser::exception_type &e) + { + std::cout << e.GetMsg() << std::endl; + } + return 0; +} +</pre> + + +<!-- +// +// +// +// Benchmarks +// +// +// +--> + +<hr/> +<h2><a id="idBench"></a>Benchmarks</h2> + +<p> +Finally, I'd like to give you some benchmarks. The benchmarking was done on an Intel +Pentium P-4 with 2.6 GHz, with a version compiled by using MSVC++ 7.1 (Standard edition). +The diagram shows number of <b>evaluations per seconds vs. expression length</b>. +I compared both the static lib and the dll version with two other parsers that are freely available +on the net, very fast and have a similar set of features. One of them is a commercial product. +</p> + +<p> + <img src="images/bench2.jpg" alt="parser benchmarks" border="0" height="489" width="560"/> +</p> + +<p> +A higher curve means better performance. Expressions were created randomly. They used only <code>sin</code> and <code>cos</code> functions and contained +multiple variables and constants. In order to smoothen the curves each point represents the value of a +running average over 10 sample expressions. +</p> + + +<!-- +// +// +// +// History +// +// +// +--> + +<hr/> +<h2><a name="idRelNote"></a>Release Notes</h2> + +<h4>Rev 1.32: 30.01.2010</h4> +This is a service release to fix problems with modern compilers. +<ul> + <li><b>Changes</b> + <ul> + <li>Added a function for retrieving the Version number of muparser.</li> + <li>example3 renamed to example2</li> + <li>Project files for bcb and msvc6 removed (include the source directly into your projects)</li> + <li>Project files for msvc2003, msvc2005 and msvc2008 added</li> + </ul> + </li> + + <li><b>Bugfixes</b> + <ul> + <li>Deprecated feature warnings removed for gcc</li> + <li>example1 changed to get rid of memory leaks. Added code for memory leak detection (VisualStudio only)</li> + <li>Changes to allow compilation with msvc10 beta2</li> + <li>gcc versions >4.0 were not able to run with a customized locale (resulted in std::bad_cast exception)</li> + </ul> + </li> +</ul> +<hr/> +<h4>Rev 1.30: 09.06.2008</h4> +This is a service release with minor extensions and bugfixes. + +<ul> + <li><b>Changes</b> + <ul> + <li>Epsilon of the numerical differentiation algorithm changed to allow greater accuracy.</li> + </ul> + </li> + + <li><b>New features</b> + <ul> + <li>Setting thousands separator and decimal separator is now possible</li> + </ul> + </li> + + <li><b>Bugfixes</b> + <ul> + <li>The dll interface did not provide a callback for functions without any arguments.</li> + </ul> + </li> +</ul> +<hr/> +<h4>Rev 1.28: 02.07.2007</h4> + +<ul> + <li><b>Library changes</b> + <ul> + <li>Interface for the dynamic library changed and extended to create an interface using pure C functions only.</li> + <li>mupInit() removed</li> + </ul> + </li> + + <li><b>New features</b> + <ul> + <li>Functions without parameters added</li> + </ul> + </li> + + <li><b>Build system</b> + <ul> + <li>MSVC7 Project files removed in favor of MSVC8.</li> + </ul> + </li> + + <li><b>Bugfixes</b> + <ul> + <li>The dynamic library did not build on other systems than linux due to a misplaced + preprocessor definition. This is fixed now.</li> + </ul> + </li> + +</ul> + +<hr/> +<h4>Rev 1.2: 14.04.2005</h4> +First of all the interface has changed so this version is not backwards compatible. +After receiving a couple of questions about it, this version features support for user defined binary operators. Consequently the built in operators can now be turned off, thus you can deactivate them and write complete customized parser subclasses that only contain the functionality you want. Other new feature is the introduction of callback functions taking string arguments, implicit generation of +variables and the Assignement operator. + +<ul> + <li> <b>Functionality</b> + <ul> + <li><a href="mup_features.html#idDef3">New built in operator</a>: <code>xor</code>; Logical xor.</li> + <li>New built in operator: Assignement operator; Defining variables in terms of other variables/constants</li> + <li>New feature: <a href="mup_interface.html#idDefFun">Strings as arguments for callback functions</a></li> + <li>New feature: <a href="mup_interface.html#idDefOprt">User defined binary operators</a></li> + <li>New feature: <code>ParserInt</code> a class with a sample implementation for + integer numbers.</li> + <li>New feature: <a href="mup_interface.html#idDefConst2">Callbacks to value regognition functions.</a></li> + + <li>Removed: all predefined postfix operators have been removed.</li> + <li>New project file: Now comes with a ready to use windows DLL.</li> + <li>New project file: Makefile for cygwin now included.</li> + <li>New example: Example3 shows usage of the DLL.</li> + </ul> + </li> + + <li> <b>Interface changes</b> + <ul> + <li><a href="mup_interface.html#idBinOp">New member function</a>: <code>DefineOprt</code> For + adding user defined binary operators.</li> + <li>New member function: <code>EnableBuiltInOprt(bool)</code> Enables/Disables <a href="mup_features.html#idDef3"> + built in binary operators</a>.</li> + <li>New member function: <code>AddValIdent(...)</code> to add callbacks for custom value recognition functions.</li> + <li>Removed: <code>SetVar()</code>, <code>SetConst()</code>.</li> + <li>Renamed: Most interface functions have been renamed</li> + <li>Changed: The <a href="mup_interface.html#idDefFun">type for multiargument callbacks</a> <code>multfun_type</code> has changed. + It no longer takes a std::vector as input.</li> + </ul> + </li> + + <li> <b>Internal changes</b> + <ul> + <li>new class <i>muParserTokenReader.h</i> encapsulates the token identification and token assignement.</li> + <li>Internal handling of function callbacks unified as a result the performance of the bytecode evaluation + increased.</li> + </ul> + </li> +</ul> diff --git a/AMDiS/lib/muparser_v134/docs/html/sources/mup_version_meta.html b/AMDiS/lib/muparser_v134/docs/html/sources/mup_version_meta.html new file mode 100755 index 0000000000000000000000000000000000000000..ec5d4b3b3d5614d72aa66e0645a716963071ebc6 --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/sources/mup_version_meta.html @@ -0,0 +1,3 @@ + <meta name="keywords" content="muparser, example, sample, benchmarks, benchmark, performance, comparison, release notes, changes, history"/> + <meta name="description" content="Sample code for using muParser"/> + <title>muParser - A basic axample and benchmarks</title> diff --git a/AMDiS/lib/muparser_v134/docs/html/sources/navigation.html b/AMDiS/lib/muparser_v134/docs/html/sources/navigation.html new file mode 100644 index 0000000000000000000000000000000000000000..09f783f503b6e64df15454a9a3a741cf22af7c05 --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/sources/navigation.html @@ -0,0 +1,202 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <link rel="stylesheet" type="text/css" href="style/formate.css"/> + <meta name="author" content="Ingo Berg"/> + <!-- $META --> + + <script src="script/functions.js" language="javascript" type="text/javascript"></script> + <script type="text/javascript"> + imgHome=new Image(); + imgHome.src="images/home.png"; + imgHomeDark=new Image(); + imgHomeDark.src="images/home_dark.png"; + + imgApi=new Image(); + imgApi.src="images/api.png"; + imgApiDark=new Image(); + imgApiDark.src="images/api_dark.png"; + + function ChangeButtonImage(num,obj) + { + window.document.images[num].src=obj.src; + } + </script> +</head> + +<body> + <div class="gradient" id="top"> + <div class="header"> + muParser - a fast math parser library + <br/> + <div style="font-size:14pt;">Version 1.32</div> + </div> + + <div style="position:absolute; width:250px; height:100px; top:20px; text-align:center"> + <a href="http://sourceforge.net/projects/muparser"> + <img src="http://sflogo.sourceforge.net/sflogo.php?group_id=137191&type=15" + width="150" + height="40" + border="0" + alt="Get muParser - A fast math parser library at SourceForge.net. Fast, secure and Free Open Source software downloads" /> + </a> + </div> + + <div style="position:absolute; width:100px; right:110px; text-align:center; line-height: 1em;"> + <a class="white" + href="http://www.beltoforion.de" + onmouseover="ChangeButtonImage(1,imgHome)" + onmouseout="ChangeButtonImage(1,imgHomeDark)"> + <img src="images/home_dark.png" border="0" height="40" alt="My home page"/> + <br/> + <span class="tiny_text">My home<br/>page</span> + </a> + </div> + + <div style="position:absolute; width:100px; right:10px; text-align:center; line-height: 1em;"> + <a class="white" + href="http://muparser.sourceforge.net/classdocu/index.html" + onmouseover="ChangeButtonImage(2,imgApi)" + onmouseout="ChangeButtonImage(2,imgApiDark)"> + <img src="images/api_dark.png" border="0" alt="class documentation" height="40"/> + <br/> + <span class="tiny_text">muParser<br/>API-doc</span> + </a> + </div> + <!-- + <div style="position:absolute; width:100px; right:10px; text-align:center; line-height: 1em;"> + <a class="white" + href="http://sourceforge.net/project/showfiles.php?group_id=137191" + onmouseover="ChangeButtonImage(3,imgDown)" + onmouseout="ChangeButtonImage(3,imgDownDark)"> + <img src="images/download_dark.png" height="40" border="0" alt="muParser download"/> + <br/> + <span class="tiny_text">muParser<br/>Download</span> + </a> + </div> +--> + </div> <!-- class="gradient" --> + + <!-- Tabelle mit Hauptinhalt der Seite --> + <table id="MainTable" border="0" cellpadding="5" cellspacing="0" style="width:100%; height:100%;"> + <tbody> + <tr> + <td style="vertical-align: top; text-align: center" width="230"> + <h3 class="navi_heading navi_info">Introduction</h3> + <div class="sidebarlink"> + <a href="index.html">About the parser</a><br/> + <a href="http://sourceforge.net/news/?group_id=137191">News</a><br/> + <a href="mup_links.html">Software using muParser</a><br/> + <a href="mup_licence.html">Licence</a><br/> + </div> + + <h3 class="navi_heading navi_blocks">Features</h3> + <div class="sidebarlink"> + <a href="mup_features.html">Features</a><br/> + <a href="mup_features.html#idFeatureOverview">Overview</a><br/> + <a href="mup_features.html#idDef2">Built in functions</a><br/> + <a href="mup_features.html#idDef3">Built in binary operators</a><br/> + </div> + + <h3 class="navi_heading navi_build">Build instructions</h3> + <div class="sidebarlink"> + <a href="mup_usage.html#idInstWin">Building on Win32</a><br/> + <a href="mup_usage.html#idInstLinux">Building on BSD/Linux</a><br/> + <a href="mup_usage.html#idInstMisc">Misc build instructions</a><br/> + <a href="mup_usage.html#idInstInc">Including the files</a><br/> + <a href="mup_usage.html#idInstInc">Where to ask for help</a><br/> + </div> + + <h3 class="navi_heading navi_list">Math parser interface</h3> + <div class="sidebarlink"> + <a href="mup_interface.html#idInit">Parser (de)initialization</a><br/> + <a href="mup_interface.html#idEval">Evaluating an expression</a><br/> + <a href="mup_interface.html#idSetExpr">Setting the expression</a><br/> + <a href="mup_interface.html#idDefCharset">Defining identifier charsets</a><br/> + <a href="mup_interface.html#idDefVar">Defining parser variables</a><br/> + <a href="mup_interface.html#idDefVarEx">Explicit variable definition</a><br/> + <a href="mup_interface.html#idDefVarIm">Implicit variable definition</a><br/> + <a href="mup_interface.html#idDefConst">Defining constants</a><br/> + <a href="mup_interface.html#idDefFun">Defining functions</a><br/> + <a href="mup_interface.html#idDefOprt">Defining operators</a><br/> + <a href="mup_interface.html#idUnOp">Unary operators</a><br/> + <a href="mup_interface.html#idBinOp">Binary operators</a><br/> + <a href="mup_interface.html#idQueryVar">Querying variables</a><br/> + <a href="mup_interface.html#idQueryConst">Querying constants</a><br/> + <a href="mup_interface.html#idDefConst2">Value recognition callbacks</a><br/> + <a href="mup_interface.html#idDefConst2">Removing variables/constants</a><br/> + <a href="mup_locale.html#idLoc">Localization</a><br/> + <a href="mup_interface.html#idErrors">Error handling</a><br/> + <a href="mup_version.html#idExample">Example code</a><br/> + </div> + + <h3 class="navi_heading navi_question">Current version</h3> + <div class="sidebarlink"> + <a href="mup_version.html#idRelNote">Release notes</a><br/> + <a href="mup_version.html#idBench">Benchmarks</a><br/> + </div> + + <br/> + <div align="center"> + <a href="http://www.opensource.org/"><img style="border:0;" src="images/osi.jpg" alt="Open source initiative logo"/></a> + <br/> + <br/> + <a href="http://validator.w3.org/check?uri=referer"> + <img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" style="border:0;width:88px;height:31px"/> + </a> + <br/> + <br/> + <a href="http://jigsaw.w3.org/css-validator/check/referer"> + <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="CSS ist valide!" /> + </a> + + </div> + </td> + + <td style="height: 100%; padding: 1em; vertical-align: top;"> + <!-- + This section contains the real page content. + pages are created automatically by using the script "build_page.sh" + which combines section templated with the navigation bar. + + This creates webpages that do not rely on php3 or Javascript for + serverside or client side html inclusion. + //--> + <!-- $PLACEHOLDER --> + + <hr/> + <table border="0" style="width:100%"> + <tr> + <td>© 2005-2010 <a href="http://beltoforion.de">Ingo Berg</a> | + <a href="http://beltoforion.de/privacy_policy/privacy_policy_en.html">Privacy policy</a></td> + <td style="text-align:right; padding-right: 3em;"> + <a href="#top">^ TOP</a> + </td> + </tr> + </table> + <br/> + <br/> + + </td> + </tr> + </tbody> + </table> + +<!-- + <script type="text/javascript"> + var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); + document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); + </script> + <script type="text/javascript"> + try + { + var pageTracker = _gat._getTracker("UA-1019178-1"); + pageTracker._trackPageview(); + } + catch(err) {} + </script> +--> +</body> +</html> diff --git a/AMDiS/lib/muparser_v134/docs/html/style/formate.css b/AMDiS/lib/muparser_v134/docs/html/style/formate.css new file mode 100644 index 0000000000000000000000000000000000000000..e2630fc69d5036bbbfce460fdce0d10dc4abc202 --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/html/style/formate.css @@ -0,0 +1,169 @@ +/* Style Sheet Definition */ + +body { + background-color: #ffffff; + margin-top:0px; + background-repeat:repeat-y; + margin-left:0px; + margin-top:0px; + margin-right:0px; + margin-bottom:0px; + overflow:auto; +} + +div.header +{ + position:absolute; + left:20%; + width:600px; + height:80px; + z-index:2; + background-image:url("../images/caption.png"); + background-repeat: no-repeat; + background-position: top center; + text-align: center; + font-family: "Times New Roman",vserif; + font-size: 25pt; +} + +div.gradient +{ + background-image:url("../images/grad2.jpg"); + z-index:1; + width:100%; + height:80px; +} + +div.sidebarlink +{ + margin-top: -12px; + border: 1px solid #cfcfcf; + padding: 0.2em 0.1em 0.2em 0.2em; + background-color:#f4f4fF; + text-align: left; + line-height: 1.5em; +} + +.tiny_text { font-size: 80%; line-height: 0.8em;} + +/* Links */ +a { text-decoration: none; } + +a:link { color:#0000BB; } +a:visited { /*font-weight:bold;*/ color:#000080; } +a:hover { color:#00BB00; } +a:active { color:#E00000; } +a:focus { color:#BBBBBB; } + +a.white:link { color:#FFFFFF; } +a.white:visited { color:#FFFFFF; } +a.white:active { color:#000000; } +a.white:focus { color:#BBBBBB; } +a.white:hover { color:#FFFFFF; font-weight:bold;} + +/* Tables */ +table.main { background-color: #ffffff; } +td.Menu { background-color: #ffffff; color: #000000;} +td.MenuActive { background-color: #000000; color: #ffffff;} +td.main { color: #FFFFFF;} +td.Info { background-color: #ffffff;} + +/* Für <h> tags im Navigationsbereich */ +.navi_heading { text-align:left; + padding-left:50px; + line-height:30px; + color: #000000;} + +.navi_info { background-image:url("../images/info.png"); + background-repeat: no-repeat; + background-position:10px 0px; } + +.navi_build { background-image:url("../images/build.png"); + background-repeat: no-repeat; + background-position:10px 0px; } + + +.navi_list { background-image:url("../images/list.png"); + background-repeat: no-repeat; + background-position:10px 0px; } + +.navi_run { background-image:url("../images/run.png"); + background-repeat: no-repeat; + background-position:10px 0px; } + +.navi_question { background-image:url("../images/question.png"); + background-repeat: no-repeat; + background-position:10px 0px; } + +.navi_blocks { background-image:url("../images/blocks.png"); + background-repeat: no-repeat; + background-position:10px 0px; } + +/* Miscellaneous */ +body, P, H1, H2, H3, H4, H5, H6, LI, TD, TH, DD, DT +{ + font-family:Helvetica,Arial,sans-serif; + color: black; +} + +h1 +{ + font-size: 18pt; + border-bottom: 3px solid black; +} + +h2 +{ + font-size: 16pt; + font-weight: bold; + border-bottom: 1px solid #AAA; + color: #0099cc; +} + +h3 +{ + font-family: Arial, sans-serif; + font-size: 14pt; + font-weight: bold; + border-bottom: 1px solid #AAA; + color: #0099cc; +} + +h4 +{ + font-size: 12pt; + margin-bottom: 2px; +} + +h5 +{ + font-size: 12pt; + margin-bottom: 2px; + color: #0099cc; +} + +H6 +{ + color: #626262; + font-size: 65%; + font-weight: normal; +} + +code +{ + color: #990000; + font-family: "Courier New", Courier, mono; +} + +pre { + border: 1pt solid black; + background-color: #EFEFEF; + font: 12pt "Courier New", Courier, mono; + padding: 10pt; + width: 90%; +} + +p +{ + text-align: justify; +} diff --git a/AMDiS/lib/muparser_v134/docs/muParser.tdl b/AMDiS/lib/muparser_v134/docs/muParser.tdl new file mode 100644 index 0000000000000000000000000000000000000000..82198d29c0a3bcca5a080ea73397742d7a64eb49 --- /dev/null +++ b/AMDiS/lib/muparser_v134/docs/muParser.tdl @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="windows-1252" ?> +<TODOLIST FILEFORMAT="8" PROJECTNAME="muParser" NEXTUNIQUEID="8" FILEVERSION="5" LASTMODIFIED="2006-02-15" CUSTOMCOMMENTSTYPE="849cf988-79fe-418a-a40d-01fe3afcab2c"><TASK PRIORITYCOLOR="15388928" STARTDATESTRING="05.02.2006" TEXTWEBCOLOR="#000000" PRIORITY="3" LASTMOD="38753.75568287" TEXTCOLOR="0" CREATIONDATESTRING="05.02.2006" TITLE="Bytecodebase datatype should be set be template metaprogramming" CREATIONDATE="38753.00000000" COMMENTS="64 bit Alignment problems may require to adjust the bytecode to a different basetype on such machines. + +http://www.codeproject.com/cpp/FastMathParser.asp?df=100&forumid=79444&exp=0&select=1354345#xx1354345xx" PRIORITYWEBCOLOR="#00D1EA" ID="1" CUSTOMCOMMENTS="e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZGVmZjBcZGVmbGFuZzEwMzF7XGZvbnR0Ymx7XGYwXGZuaWxcZmNoYXJzZXQwIE1TIFNhbnMgU2VyaWY7fX0NClx2aWV3a2luZDRcdWMxXHBhcmRcdHg2NDBcdHgxMjgwXHR4MTkyMFx0eDI1NjBcdHgzMjAwXHR4Mzg0MFx0eDQ0ODBcdHg1MTIwXHR4NTc2MFx0eDY0MDBcdHg3MDQwXHR4NzY4MFx0eDgzMjBcdHg4OTYwXHR4OTYwMFx0eDEwMjQwXHR4MTA4ODBcdHgxMTUyMFx0eDEyMTYwXHR4MTI4MDBcdHgxMzQ0MFx0eDE0MDgwXHR4MTQ3MjBcdHgxNTM2MFx0eDE2MDAwXHR4MTY2NDBcdHgxNzI4MFx0eDE3OTIwXHR4MTg1NjBcdHgxOTIwMFx0eDE5ODQwXHR4MjA0ODBcZjBcZnMxOCA2NCBiaXQgQWxpZ25tZW50IHByb2JsZW1zIG1heSByZXF1aXJlIHRvIGFkanVzdCB0aGUgYnl0ZWNvZGUgdG8gYSBkaWZmZXJlbnQgYmFzZXR5cGUgb24gc3VjaCBtYWNoaW5lcy5ccGFyDQpccGFyDQpodHRwOi8vd3d3LmNvZGVwcm9qZWN0LmNvbS9jcHAvRmFzdE1hdGhQYXJzZXIuYXNwP2RmPTEwMCZmb3J1bWlkPTc5NDQ0JmV4cD0wJnNlbGVjdD0xMzU0MzQ1I3h4MTM1NDM0NXh4XHBhcg0KfQ0K" PERCENTDONE="0" STARTDATE="38753.00000000" POS="4"/><TASK PRIORITYCOLOR="4187136" STARTDATESTRING="05.02.2006" TEXTWEBCOLOR="#000000" PRIORITY="1" CALCPERCENTDONE="100" LASTMOD="38761.96054398" TEXTCOLOR="0" CREATIONDATESTRING="05.02.2006" TITLE="Remove unnecessary code" CREATIONDATE="38753.00000000" COMMENTS="http://www.codeproject.com/cpp/FastMathParser.asp?df=100&forumid=79444&exp=0&select=1354654#xx1354654xx" PRIORITYWEBCOLOR="#00E43F" ID="2" CUSTOMCOMMENTS="e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZGVmZjBcZGVmbGFuZzEwMzF7XGZvbnR0Ymx7XGYwXGZuaWxcZmNoYXJzZXQwIE1TIFNhbnMgU2VyaWY7fX0NClx2aWV3a2luZDRcdWMxXHBhcmRcdHg2NDBcdHgxMjgwXHR4MTkyMFx0eDI1NjBcdHgzMjAwXHR4Mzg0MFx0eDQ0ODBcdHg1MTIwXHR4NTc2MFx0eDY0MDBcdHg3MDQwXHR4NzY4MFx0eDgzMjBcdHg4OTYwXHR4OTYwMFx0eDEwMjQwXHR4MTA4ODBcdHgxMTUyMFx0eDEyMTYwXHR4MTI4MDBcdHgxMzQ0MFx0eDE0MDgwXHR4MTQ3MjBcdHgxNTM2MFx0eDE2MDAwXHR4MTY2NDBcdHgxNzI4MFx0eDE3OTIwXHR4MTg1NjBcdHgxOTIwMFx0eDE5ODQwXHR4MjA0ODBcZjBcZnMxOCBodHRwOi8vd3d3LmNvZGVwcm9qZWN0LmNvbS9jcHAvRmFzdE1hdGhQYXJzZXIuYXNwP2RmPTEwMCZmb3J1bWlkPTc5NDQ0JmV4cD0wJnNlbGVjdD0xMzU0NjU0I3h4MTM1NDY1NHh4XHBhcg0KfQ0K" PERCENTDONE="100" STARTDATE="38753.00000000" DONEDATESTRING="13.02.2006" DONEDATE="38761.00000000" POS="6"/><TASK PRIORITYCOLOR="15388928" STARTDATESTRING="05.02.2006" TEXTWEBCOLOR="#000000" PRIORITY="3" LASTMOD="38753.75146991" TEXTCOLOR="0" CREATIONDATESTRING="05.02.2006" TITLE="Compatibility" CREATIONDATE="38753.00000000" PRIORITYWEBCOLOR="#00D1EA" ID="3" PERCENTDONE="0" STARTDATE="38753.00000000" POS="3"><TASK PRIORITYCOLOR="4187136" STARTDATESTRING="05.02.2006" TEXTWEBCOLOR="#000000" PRIORITY="1" LASTMOD="38753.75134259" TEXTCOLOR="0" CREATIONDATESTRING="05.02.2006" TITLE="Fix stringstream for old gcc" CREATIONDATE="38753.00000000" COMMENTS="http://www.codeproject.com/cpp/FastMathParser.asp?df=100&forumid=79444&exp=0&select=1354598#xx1354598xx" PRIORITYWEBCOLOR="#00E43F" ID="4" CUSTOMCOMMENTS="e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZGVmZjBcZGVmbGFuZzEwMzF7XGZvbnR0Ymx7XGYwXGZuaWxcZmNoYXJzZXQwIE1TIFNhbnMgU2VyaWY7fX0NClx2aWV3a2luZDRcdWMxXHBhcmRcdHg2NDBcdHgxMjgwXHR4MTkyMFx0eDI1NjBcdHgzMjAwXHR4Mzg0MFx0eDQ0ODBcdHg1MTIwXHR4NTc2MFx0eDY0MDBcdHg3MDQwXHR4NzY4MFx0eDgzMjBcdHg4OTYwXHR4OTYwMFx0eDEwMjQwXHR4MTA4ODBcdHgxMTUyMFx0eDEyMTYwXHR4MTI4MDBcdHgxMzQ0MFx0eDE0MDgwXHR4MTQ3MjBcdHgxNTM2MFx0eDE2MDAwXHR4MTY2NDBcdHgxNzI4MFx0eDE3OTIwXHR4MTg1NjBcdHgxOTIwMFx0eDE5ODQwXHR4MjA0ODBcZjBcZnMxOCBodHRwOi8vd3d3LmNvZGVwcm9qZWN0LmNvbS9jcHAvRmFzdE1hdGhQYXJzZXIuYXNwP2RmPTEwMCZmb3J1bWlkPTc5NDQ0JmV4cD0wJnNlbGVjdD0xMzU0NTk4I3h4MTM1NDU5OHh4XHBhcg0KfQ0K" PERCENTDONE="0" STARTDATE="38753.00000000" POS="1"/></TASK><TASK PRIORITYCOLOR="10544896" STARTDATESTRING="05.02.2006" TEXTWEBCOLOR="#000000" PRIORITY="2" LASTMOD="38761.96232639" TEXTCOLOR="0" CREATIONDATESTRING="05.02.2006" TITLE="Add math functions: ceil, fmod, floor" CREATIONDATE="38753.00000000" COMMENTS="-(2+x)^2 should be evaluated as -((2+x)^2) currently - priority is too high for that" PRIORITYWEBCOLOR="#00E7A0" ID="5" CUSTOMCOMMENTS="e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZGVmZjBcZGVmbGFuZzEwMzF7XGZvbnR0Ymx7XGYwXGZuaWxcZmNoYXJzZXQwIE1TIFNhbnMgU2VyaWY7fX0NClx2aWV3a2luZDRcdWMxXHBhcmRcdHg2NDBcdHgxMjgwXHR4MTkyMFx0eDI1NjBcdHgzMjAwXHR4Mzg0MFx0eDQ0ODBcdHg1MTIwXHR4NTc2MFx0eDY0MDBcdHg3MDQwXHR4NzY4MFx0eDgzMjBcdHg4OTYwXHR4OTYwMFx0eDEwMjQwXHR4MTA4ODBcdHgxMTUyMFx0eDEyMTYwXHR4MTI4MDBcdHgxMzQ0MFx0eDE0MDgwXHR4MTQ3MjBcdHgxNTM2MFx0eDE2MDAwXHR4MTY2NDBcdHgxNzI4MFx0eDE3OTIwXHR4MTg1NjBcdHgxOTIwMFx0eDE5ODQwXHR4MjA0ODBcZjBcZnMxOCAtKDIreCleMiBzaG91bGQgYmUgZXZhbHVhdGVkIGFzIC0oKDIreCleMikgY3VycmVudGx5IC0gcHJpb3JpdHkgaXMgdG9vIGhpZ2ggZm9yIHRoYXRccGFyDQpccGFyDQp9DQoA" PERCENTDONE="0" STARTDATE="38753.00000000" POS="5"/><TASK PRIORITYCOLOR="15732480" STARTDATESTRING="13.02.2006" TEXTWEBCOLOR="#000000" PRIORITY="5" LASTMOD="38761.96026620" TEXTCOLOR="0" CREATIONDATESTRING="13.02.2006" TITLE="fix precedence issue with unary operators" CREATIONDATE="38761.00000000" PRIORITYWEBCOLOR="#000FF0" ID="6" PERCENTDONE="0" STARTDATE="38761.00000000" POS="1"/><TASK PRIORITYCOLOR="15732480" STARTDATESTRING="15.02.2006" TEXTWEBCOLOR="#000000" PRIORITY="5" LASTMOD="38763.94878472" TEXTCOLOR="0" CREATIONDATESTRING="15.02.2006" TITLE="Kommandocodes für postfix und infix operatoren" CREATIONDATE="38763.00000000" PRIORITYWEBCOLOR="#000FF0" ID="7" PERCENTDONE="0" STARTDATE="38763.00000000" POS="2"/></TODOLIST> diff --git a/AMDiS/lib/muparser_v134/include/muParser.h b/AMDiS/lib/muparser_v134/include/muParser.h new file mode 100644 index 0000000000000000000000000000000000000000..27b3e5dabc9b892c9fd7783540282f5d0a50865e --- /dev/null +++ b/AMDiS/lib/muparser_v134/include/muParser.h @@ -0,0 +1,156 @@ +/* + __________ + _____ __ __\______ \_____ _______ ______ ____ _______ + / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ + | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ + |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| + \/ \/ \/ \/ + Copyright (C) 2010 Ingo Berg + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +#ifndef MU_PARSER_H +#define MU_PARSER_H + +//--- Standard includes ------------------------------------------------------------------------ +#include <vector> +#include <locale> + +//--- Parser includes -------------------------------------------------------------------------- +#include "muParserBase.h" + + +/** \file + \brief Definition of the standard floating point parser. +*/ + +namespace mu +{ + /** \brief Mathematical expressions parser. + + Standard implementation of the mathematical expressions parser. + Can be used as a reference implementation for subclassing the parser. + + <small> + (C) 2010 Ingo Berg<br> + muparser(at)gmx.de + </small> + */ + class Parser : public ParserBase + { + public: + + Parser(); + + virtual void InitCharSets(); + virtual void InitFun(); + virtual void InitConst(); + virtual void InitOprt(); + virtual void OnDetectVar(string_type *pExpr, int &nStart, int &nEnd); + + void SetDecSep(char_type cDecSep); + void SetThousandsSep(char_type cThousandsSep = 0); + void ResetLocale(); + + value_type Diff(value_type *a_Var, + value_type a_fPos, + value_type a_fEpsilon = 0) const; + + private: + + /** \brief A facet class used to change decimal and thousands separator. */ + template<class TChar> + class change_dec_sep : public std::numpunct<TChar> + { + public: + + explicit change_dec_sep(char_type cDecSep, char_type cThousandsSep = 0, int nGroup = 3) + :std::numpunct<TChar>() + ,m_nGroup(nGroup) + ,m_cDecPoint(cDecSep) + ,m_cThousandsSep(cThousandsSep) + {} + + protected: + + virtual char_type do_decimal_point() const + { + return m_cDecPoint; + } + + virtual char_type do_thousands_sep() const + { + return m_cThousandsSep; + } + + virtual std::string do_grouping() const + { + return std::string(1, m_nGroup); + } + + private: + + int m_nGroup; + char_type m_cDecPoint; + char_type m_cThousandsSep; + }; + + // Trigonometric functions + static value_type Sin(value_type); + static value_type Cos(value_type); + static value_type Tan(value_type); + // arcus functions + static value_type ASin(value_type); + static value_type ACos(value_type); + static value_type ATan(value_type); + // hyperbolic functions + static value_type Sinh(value_type); + static value_type Cosh(value_type); + static value_type Tanh(value_type); + // arcus hyperbolic functions + static value_type ASinh(value_type); + static value_type ACosh(value_type); + static value_type ATanh(value_type); + // Logarithm functions + static value_type Log2(value_type); // Logarithm Base 2 + static value_type Log10(value_type); // Logarithm Base 10 + static value_type Ln(value_type); // Logarithm Base e (natural logarithm) + // misc + static value_type Exp(value_type); + static value_type Abs(value_type); + static value_type Sqrt(value_type); + static value_type Rint(value_type); + static value_type Sign(value_type); + static value_type Ite(value_type, value_type, value_type); + + // Prefix operators + // !!! Unary Minus is a MUST if you want to use negative signs !!! + static value_type UnaryMinus(value_type); + + // Functions with variable number of arguments + static value_type Sum(const value_type*, int); // sum + static value_type Avg(const value_type*, int); // mean value + static value_type Min(const value_type*, int); // minimum + static value_type Max(const value_type*, int); // maximum + + static int IsVal(const char_type* a_szExpr, int *a_iPos, value_type *a_fVal); + + static std::locale s_locale; ///< The locale used by the parser + }; +} // namespace mu + +#endif + diff --git a/AMDiS/lib/muparser_v134/include/muParserBase.h b/AMDiS/lib/muparser_v134/include/muParserBase.h new file mode 100644 index 0000000000000000000000000000000000000000..c26a6768801934da11b7a1bb1d106d0c6f6b08fc --- /dev/null +++ b/AMDiS/lib/muparser_v134/include/muParserBase.h @@ -0,0 +1,295 @@ +/* + __________ + _____ __ __\______ \_____ _______ ______ ____ _______ + / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ + | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ + |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| + \/ \/ \/ \/ + Copyright (C) 2010 Ingo Berg + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +#ifndef MU_PARSER_BASE_H +#define MU_PARSER_BASE_H + +//--- Standard includes ------------------------------------------------------------------------ +#include <cmath> +#include <string> +#include <iostream> +#include <map> +#include <memory> + +//--- Parser includes -------------------------------------------------------------------------- +#include "muParserDef.h" +#include "muParserStack.h" +#include "muParserTokenReader.h" +#include "muParserBytecode.h" +#include "muParserError.h" + + +namespace mu +{ +/** \file + \brief This file contains the class definition of the muparser engine. +*/ + +//-------------------------------------------------------------------------------------------------- +/** \brief Mathematical expressions parser (base parser engine). + \author (C) 2010 Ingo Berg + + This is the implementation of a bytecode based mathematical expressions parser. + The formula will be parsed from string and converted into a bytecode. + Future calculations will be done with the bytecode instead the formula string + resulting in a significant performance increase. + Complementary to a set of internally implemented functions the parser is able to handle + user defined functions and variables. +*/ +class ParserBase +{ +friend class ParserTokenReader; + +private: + + /** \brief Typedef for the parse functions. + + The parse function do the actual work. The parser exchanges + the function pointer to the parser function depending on + which state it is in. (i.e. bytecode parser vs. string parser) + */ + typedef value_type (ParserBase::*ParseFunction)() const; + + /** \brief Type used for storing an array of values. */ + typedef std::vector<value_type> valbuf_type; + + /** \brief Type for a vector of strings. */ + typedef std::vector<string_type> stringbuf_type; + + /** \brief Typedef for the token reader. */ + typedef ParserTokenReader token_reader_type; + + /** \brief Type used for parser tokens. */ + typedef ParserToken<value_type, string_type> token_type; + + public: + + /** \brief Type of the error class. + + Included for backwards compatibility. + */ + typedef ParserError exception_type; + + ParserBase(); + ParserBase(const ParserBase &a_Parser); + ParserBase& operator=(const ParserBase &a_Parser); + + virtual ~ParserBase(); + + //--------------------------------------------------------------------------- + /** \brief Calculate the result. + + A note on const correctness: + I consider it important that Calc is a const function. + Due to caching operations Calc changes only the state of internal variables with one exception + m_UsedVar this is reset during string parsing and accessible from the outside. Instead of making + Calc non const GetUsedVar is non const because it explicitely calls Eval() forcing this update. + + \pre A formula must be set. + \pre Variables must have been set (if needed) + + \sa #m_pParseFormula + \return The evaluation result + \throw ParseException if no Formula is set or in case of any other error related to the formula. + */ + inline value_type Eval() const + { + return (this->*m_pParseFormula)(); + } + + void SetExpr(const string_type &a_sExpr); + void SetVarFactory(facfun_type a_pFactory, void *pUserData = NULL); + + void EnableOptimizer(bool a_bIsOn=true); + void EnableByteCode(bool a_bIsOn=true); + void EnableBuiltInOprt(bool a_bIsOn=true); + + bool HasBuiltInOprt() const; + void AddValIdent(identfun_type a_pCallback); + +/** \fn void mu::ParserBase::DefineFun(const string_type &a_strName, fun_type0 a_pFun, bool a_bAllowOpt = true) + \brief Define a parser function without arguments. + \param a_strName Name of the function + \param a_pFun Pointer to the callback function + \param a_bAllowOpt A flag indicating this function may be optimized +*/ + +#define MUP_DEFINE_FUNC(TYPE) \ + inline void DefineFun(const string_type &a_strName, TYPE a_pFun, bool a_bAllowOpt = true) \ + { \ + AddCallback( a_strName, ParserCallback(a_pFun, a_bAllowOpt), \ + m_FunDef, ValidNameChars() ); \ + } + + MUP_DEFINE_FUNC(fun_type0) + MUP_DEFINE_FUNC(fun_type1) + MUP_DEFINE_FUNC(fun_type2) + MUP_DEFINE_FUNC(fun_type3) + MUP_DEFINE_FUNC(fun_type4) + MUP_DEFINE_FUNC(fun_type5) + MUP_DEFINE_FUNC(multfun_type) + MUP_DEFINE_FUNC(strfun_type1) + MUP_DEFINE_FUNC(strfun_type2) + MUP_DEFINE_FUNC(strfun_type3) +#undef MUP_DEFINE_FUNC + + void DefineOprt(const string_type &a_strName, + fun_type2 a_pFun, + unsigned a_iPri=0, + EOprtAssociativity a_eAssociativity = oaLEFT, + bool a_bAllowOpt = false); + void DefineConst(const string_type &a_sName, value_type a_fVal); + void DefineStrConst(const string_type &a_sName, const string_type &a_strVal); +// void DefineArrayVar(const string_type &a_sName, value_type *a_fVar, std::size_t sz); + void DefineVar(const string_type &a_sName, value_type *a_fVar); + void DefinePostfixOprt(const string_type &a_strFun, fun_type1 a_pOprt, bool a_bAllowOpt=true); + void DefineInfixOprt(const string_type &a_strName, fun_type1 a_pOprt, int a_iPrec=prINFIX, bool a_bAllowOpt=true); + + // Clear user defined variables, constants or functions + void ClearVar(); + void ClearFun(); + void ClearConst(); + void ClearInfixOprt(); + void ClearPostfixOprt(); + void ClearOprt(); + + void RemoveVar(const string_type &a_strVarName); + const varmap_type& GetUsedVar() const; + const varmap_type& GetVar() const; + const valmap_type& GetConst() const; + const string_type& GetExpr() const; + const funmap_type& GetFunDef() const; + string_type GetVersion() const; + + const char_type ** GetOprtDef() const; + void DefineNameChars(const char_type *a_szCharset); + void DefineOprtChars(const char_type *a_szCharset); + void DefineInfixOprtChars(const char_type *a_szCharset); + + const char_type* ValidNameChars() const; + const char_type* ValidOprtChars() const; + const char_type* ValidInfixOprtChars() const; + + void SetArgSep(char_type cArgSep); + char_type GetArgSep() const; + + void Error(EErrorCodes a_iErrc, + int a_iPos = (int)mu::string_type::npos, + const string_type &a_strTok = string_type() ) const; + + protected: + + void Init(); + + virtual void InitCharSets() = 0; + virtual void InitFun() = 0; + virtual void InitConst() = 0; + virtual void InitOprt() = 0; + + virtual void OnDetectVar(string_type *pExpr, int &nStart, int &nEnd); + static const char_type *c_DefaultOprt[]; + + private: + + void Assign(const ParserBase &a_Parser); + void InitTokenReader(); + void ReInit() const; + + void AddCallback( const string_type &a_strName, + const ParserCallback &a_Callback, + funmap_type &a_Storage, + const char_type *a_szCharSet ); + + void ApplyBinOprt(ParserStack<token_type> &a_stOpt, + ParserStack<token_type> &a_stVal) const; + + void ApplyFunc(ParserStack<token_type> &a_stOpt, + ParserStack<token_type> &a_stVal, + int iArgCount) const; + + token_type ApplyNumFunc(const token_type &a_FunTok, + const std::vector<token_type> &a_vArg) const; + + token_type ApplyStrFunc(const token_type &a_FunTok, + const std::vector<token_type> &a_vArg) const; + + int GetOprtPrecedence(const token_type &a_Tok) const; + EOprtAssociativity GetOprtAssociativity(const token_type &a_Tok) const; + + value_type ParseString() const; + value_type ParseCmdCode() const; + value_type ParseValue() const; + + void ClearFormula(); + void CheckName(const string_type &a_strName, const string_type &a_CharSet) const; + void CheckOprt(const string_type &a_sName, + const ParserCallback &a_Callback, + const string_type &a_szCharSet) const; + +#if defined(MUP_DUMP_STACK) | defined(MUP_DUMP_CMDCODE) + void StackDump(const ParserStack<token_type > &a_stVal, + const ParserStack<token_type > &a_stOprt) const; +#endif + + /** \brief Pointer to the parser function. + + Eval() calls the function whose address is stored there. + */ + mutable ParseFunction m_pParseFormula; + mutable const bytecode_type *m_pCmdCode; ///< Formula converted to bytecode, points to the data of the bytecode class. + mutable ParserByteCode m_vByteCode; ///< The Bytecode class. + mutable stringbuf_type m_vStringBuf; ///< String buffer, used for storing string function arguments + stringbuf_type m_vStringVarBuf; + +#if HAS_CXX11 + std::unique_ptr<token_reader_type> m_pTokenReader; ///< Managed pointer to the token reader object. +#else + std::auto_ptr<token_reader_type> m_pTokenReader; ///< Managed pointer to the token reader object. +#endif + + funmap_type m_FunDef; ///< Map of function names and pointers. + funmap_type m_PostOprtDef; ///< Postfix operator callbacks + funmap_type m_InfixOprtDef; ///< unary infix operator. + funmap_type m_OprtDef; ///< Binary operator callbacks + valmap_type m_ConstDef; ///< user constants. + strmap_type m_StrVarDef; ///< user defined string constants + varmap_type m_VarDef; ///< user defind variables. + + bool m_bOptimize; ///< Flag that indicates if the optimizer is on or off. + bool m_bUseByteCode; ///< Flag that indicates if bytecode parsing is on or off. + bool m_bBuiltInOp; ///< Flag that can be used for switching built in operators on and off + + string_type m_sNameChars; ///< Charset for names + string_type m_sOprtChars; ///< Charset for postfix/ binary operator tokens + string_type m_sInfixOprtChars; ///< Charset for infix operator tokens + + // items merely used for caching state information + mutable valbuf_type m_vStackBuffer; ///< This is merely a buffer used for the stack in the cmd parsing routine + mutable int m_nFinalResultIdx; +}; + +} // namespace mu + +#endif + diff --git a/AMDiS/lib/muparser_v134/include/muParserBytecode.h b/AMDiS/lib/muparser_v134/include/muParserBytecode.h new file mode 100644 index 0000000000000000000000000000000000000000..9800bf7384bfa6e089c2332ba7496b9a0719b0c1 --- /dev/null +++ b/AMDiS/lib/muparser_v134/include/muParserBytecode.h @@ -0,0 +1,149 @@ +/* + __________ + _____ __ __\______ \_____ _______ ______ ____ _______ + / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ + | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ + |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| + \/ \/ \/ \/ + Copyright (C) 2004-2009 Ingo Berg + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +#ifndef MU_PARSER_BYTECODE_H +#define MU_PARSER_BYTECODE_H + +#include <cassert> +#include <string> +#include <stack> +#include <vector> + +#include "muParserDef.h" +#include "muParserError.h" +#include "muParserToken.h" + +/** \file + \brief Definition of the parser bytecode class. +*/ + + +namespace mu +{ + + +/** \brief Bytecode implementation of the Math Parser. + + The bytecode contains the formula converted to revers polish notation stored in a continious + memory area. Associated with this data are operator codes, variable pointers, constant + values and function pointers. Those are necessary in order to calculate the result. + All those data items will be casted to the underlying datatype of the bytecode. + + \author (C) 2004-2010 Ingo Berg +*/ +class ParserByteCode +{ +private: + + /** \brief Token type for internal use only. */ + typedef ParserToken<value_type, string_type> token_type; + + /** \brief Core type of the bytecode. */ + typedef std::vector<bytecode_type> storage_type; + + /** \brief Position in the Calculation array. */ + unsigned m_iStackPos; + + /** \brief Maximum size needed for the stack. */ + std::size_t m_iMaxStackSize; + + /** \brief Core type of the bytecode. */ + storage_type m_vBase; + + /** \brief Size of a value entry in the bytecode, relative to TMapType size. */ + const int mc_iSizeVal; + + /** \brief Size of a pointer, relative to size of underlying TMapType. + + \attention The size is related to the size of TMapType not bytes! + */ + const int mc_iSizePtr; + + /** \brief A value entry requires that much entires in the bytecode. + + Value entry consists of: + <ul> + <li>One entry for Stack index</li> + <li>One entry for Token identifier</li> + <li>mc_iSizeVal entries for the value</li> + <ul> + + \sa AddVal(TBaseData a_fVal) + */ + const int mc_iSizeValEntry; + + void StorePtr(void *a_pAddr); + +public: + + ParserByteCode(); + ParserByteCode(const ParserByteCode &a_ByteCode); + ParserByteCode& operator=(const ParserByteCode &a_ByteCode); + void Assign(const ParserByteCode &a_ByteCode); + + void AddVar(value_type *a_pVar); + void AddVal(value_type a_fVal); + void AddOp(ECmdCode a_Oprt); + void AddAssignOp(value_type *a_pVar); + void AddFun(void *a_pFun, int a_iArgc); + void AddStrFun(void *a_pFun, int a_iArgc, int a_iIdx); + + void Finalize(); + void clear(); + std::size_t GetMaxStackSize() const; + std::size_t GetBufSize() const; + + const bytecode_type* GetRawData() const; + + /** \brief Return size of a value entry. + + That many bytecode entries are necessary to store a value. + + \sa mc_iSizeVal + */ + unsigned GetValSize() const + { + return mc_iSizeVal; + } + + /** \brief Return size of a pointer entry. + + That many bytecode entries are necessary to store a pointer. + + \sa mc_iSizePtr + */ + unsigned GetPtrSize() const + { + return mc_iSizePtr; + } + + void RemoveValEntries(unsigned a_iNumber); + void AsciiDump(); +}; + +} // namespace mu + +#endif + + diff --git a/AMDiS/lib/muparser_v134/include/muParserCallback.h b/AMDiS/lib/muparser_v134/include/muParserCallback.h new file mode 100644 index 0000000000000000000000000000000000000000..d0056c3665b766fc1ba450cfb52e7569712a128b --- /dev/null +++ b/AMDiS/lib/muparser_v134/include/muParserCallback.h @@ -0,0 +1,101 @@ +/* + __________ + _____ __ __\______ \_____ _______ ______ ____ _______ + / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ + | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ + |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| + \/ \/ \/ \/ + Copyright (C) 2004-2008 Ingo Berg + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef MU_PARSER_CALLBACK_H +#define MU_PARSER_CALLBACK_H + +#include "muParserDef.h" + +/** \file + \brief Definition of the parser callback class. +*/ + +namespace mu +{ + +/** \brief Encapsulation of prototypes for a numerical parser function. + + Encapsulates the prototyp for numerical parser functions. The class + stores the number of arguments for parser functions as well + as additional flags indication the function is non optimizeable. + The pointer to the callback function pointer is stored as void* + and needs to be casted according to the argument count. + Negative argument counts indicate a parser function with a variable number + of arguments. + This class is not used for string function prototyping. + + \author (C) 2004-2007 Ingo Berg +*/ +class ParserCallback +{ +public: + ParserCallback(fun_type0 a_pFun, bool a_bAllowOpti); + ParserCallback(fun_type1 a_pFun, bool a_bAllowOpti, int a_iPrec = -1, ECmdCode a_iCode=cmFUNC); + ParserCallback(fun_type2 a_pFun, bool a_bAllowOpti, int a_iPrec, EOprtAssociativity a_eAssociativity); + ParserCallback(fun_type2 a_pFun, bool a_bAllowOpti); + ParserCallback(fun_type3 a_pFun, bool a_bAllowOpti); + ParserCallback(fun_type4 a_pFun, bool a_bAllowOpti); + ParserCallback(fun_type5 a_pFun, bool a_bAllowOpti); + ParserCallback(multfun_type a_pFun, bool a_bAllowOpti); + ParserCallback(strfun_type1 a_pFun, bool a_bAllowOpti); + ParserCallback(strfun_type2 a_pFun, bool a_bAllowOpti); + ParserCallback(strfun_type3 a_pFun, bool a_bAllowOpti); + ParserCallback(); + ParserCallback(const ParserCallback &a_Fun); + + ParserCallback* Clone() const; + + bool IsOptimizable() const; + void* GetAddr() const; + ECmdCode GetCode() const; + ETypeCode GetType() const; + int GetPri() const; + EOprtAssociativity GetAssociativity() const; + int GetArgc() const; + +private: + void *m_pFun; ///< Pointer to the callback function, casted to void + + /** \brief Number of numeric function arguments + + This number is negative for functions with variable number of arguments. in this cases + they represent the actual number of arguments found. + */ + int m_iArgc; + int m_iPri; ///< Valid only for binary and infix operators; Operator precedence. + EOprtAssociativity m_eOprtAsct; ///< Operator associativity; Valid only for binary operators + ECmdCode m_iCode; + ETypeCode m_iType; + bool m_bAllowOpti; ///< Flag indication optimizeability +}; + +//------------------------------------------------------------------------------ +/** \brief Container for Callback objects. */ +typedef std::map<string_type, ParserCallback> funmap_type; + +} // namespace mu + +#endif + diff --git a/AMDiS/lib/muparser_v134/include/muParserComplex.h b/AMDiS/lib/muparser_v134/include/muParserComplex.h new file mode 100644 index 0000000000000000000000000000000000000000..2f34b3e68cc1b0c004974dcad5248cc569f62497 --- /dev/null +++ b/AMDiS/lib/muparser_v134/include/muParserComplex.h @@ -0,0 +1,83 @@ +/* + __________ + _____ __ __\______ \_____ _______ ______ ____ _______ + / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ + | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ + |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| + \/ \/ \/ \/ + Copyright (C) 2010 Ingo Berg + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef MU_PARSER_COMPLEX_H +#define MU_PARSER_COMPLEX_H + +#include "muParserBase.h" +#include <vector> +#include <complex> + +/** \file + \brief This file contains a definition of a parser using complex numbers. +*/ + + +namespace mu +{ + /** \brief Mathematical expressions parser. + + This version of the parser handles only complex numbers. It disables the built in operators + thus it is slower than muParser. + */ + class ParserComplex : private ParserBase + { + public: + + typedef std::complex<float> complex_type; + + ParserComplex(); + + using ParserBase::SetExpr; + + complex_type Eval(); + static complex_type UnpackToComplex(double val); + static double PackToDouble(const complex_type &val); + + private: + + // !! The unary Minus is a MUST, otherwise you cant use negative signs !! + static value_type UnaryMinus(value_type); + // binary operator callbacks + static value_type Add(value_type v1, value_type v2); + static value_type Sub(value_type v1, value_type v2); + static value_type Mul(value_type v1, value_type v2); + static value_type Div(value_type v1, value_type v2); + + static value_type Sin(value_type); + static value_type Cos(value_type); + static value_type Tan(value_type); + static value_type Sqrt(value_type); + + static int IsVal(const char_type* a_szExpr, int *a_iPos, value_type *a_iVal); + + virtual void InitOprt(); + virtual void InitCharSets(); + virtual void InitFun(); + virtual void InitConst(); + }; +} // namespace mu + +#endif diff --git a/AMDiS/lib/muparser_v134/include/muParserDLL.h b/AMDiS/lib/muparser_v134/include/muParserDLL.h new file mode 100644 index 0000000000000000000000000000000000000000..cf9d5a33bbd69cb7d09b279c705641d62048e32d --- /dev/null +++ b/AMDiS/lib/muparser_v134/include/muParserDLL.h @@ -0,0 +1,192 @@ +/* + __________ + _____ __ __\______ \_____ _______ ______ ____ _______ + / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ + | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ + |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| + \/ \/ \/ \/ + Copyright (C) 2010 Ingo Berg + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +#ifndef MU_PARSER_DLL_H +#define MU_PARSER_DLL_H + +#if defined(WIN32) || defined(_WIN32) + #ifdef MUPARSERLIB_EXPORTS + #define API_EXPORT(TYPE) __declspec(dllexport) TYPE __stdcall + #else + #define API_EXPORT(TYPE) __declspec(dllimport) TYPE __stdcall + #endif +#else + #define API_EXPORT(TYPE) TYPE +#endif + + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** \file + \brief This file contains the DLL interface of muparser. +*/ + +// Basic types +typedef void* muParserHandle_t; // parser handle +typedef char muChar_t; // character type +typedef int muBool_t; // boolean type +typedef int muInt_t; // integer type +typedef double muFloat_t; // floating point type + +// function types for calculation +typedef muFloat_t (*muFun0_t)(); +typedef muFloat_t (*muFun1_t)(muFloat_t); +typedef muFloat_t (*muFun2_t)(muFloat_t, muFloat_t); +typedef muFloat_t (*muFun3_t)(muFloat_t, muFloat_t, muFloat_t); +typedef muFloat_t (*muFun4_t)(muFloat_t, muFloat_t, muFloat_t, muFloat_t); +typedef muFloat_t (*muFun5_t)(muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t); +typedef muFloat_t (*muMultFun_t)(const muFloat_t*, muInt_t); +typedef muFloat_t (*muStrFun1_t)(const muChar_t*); +typedef muFloat_t (*muStrFun2_t)(const muChar_t*, muFloat_t); +typedef muFloat_t (*muStrFun3_t)(const muChar_t*, muFloat_t, muFloat_t); + +// Functions for parser management +typedef void (*muErrorHandler_t)(muParserHandle_t a_hParser); // [optional] callback to an error handler +typedef muFloat_t* (*muFacFun_t)(const muChar_t*, void*); // [optional] callback for creating new variables +typedef muInt_t (*muIdentFun_t)(const muChar_t*, muInt_t*, muFloat_t*); // [optional] value identification callbacks + +//----------------------------------------------------------------------------------------------------- +// Constants +#if defined(WIN32) || defined(_WIN32) +__declspec(dllimport) extern int muOPRT_ASCT_LEFT; +__declspec(dllimport) extern int muOPRT_ASCT_RIGHT; +#else + extern int muOPRT_ASCT_LEFT; + extern int muOPRT_ASCT_RIGHT; +#endif + +//----------------------------------------------------------------------------------------------------- +// +// +// muParser C compatible bindings +// +// +//----------------------------------------------------------------------------------------------------- + +// Basic operations / initialization +API_EXPORT(muParserHandle_t) mupCreate(); +API_EXPORT(void) mupRelease(muParserHandle_t a_hParser); +API_EXPORT(const muChar_t*) mupGetExpr(muParserHandle_t a_hParser); +API_EXPORT(void) mupSetExpr(muParserHandle_t a_hParser, const muChar_t *a_szExpr); +API_EXPORT(void) mupSetVarFactory(muParserHandle_t a_hParser, muFacFun_t a_pFactory, void* pUserData); +API_EXPORT(const muChar_t*) mupGetVersion(muParserHandle_t a_hParser); +API_EXPORT(muFloat_t) mupEval(muParserHandle_t a_hParser); + +// Defining callbacks / variables / constants +API_EXPORT(void) mupDefineFun0(muParserHandle_t a_hParser, const muChar_t *a_szName, muFun0_t a_pFun, muBool_t a_bOptimize); +API_EXPORT(void) mupDefineFun1(muParserHandle_t a_hParser, const muChar_t *a_szName, muFun1_t a_pFun, muBool_t a_bOptimize); +API_EXPORT(void) mupDefineFun2(muParserHandle_t a_hParser, const muChar_t *a_szName, muFun2_t a_pFun, muBool_t a_bOptimize); +API_EXPORT(void) mupDefineFun3(muParserHandle_t a_hParser, const muChar_t *a_szName, muFun3_t a_pFun, muBool_t a_bOptimize); +API_EXPORT(void) mupDefineFun4(muParserHandle_t a_hParser, const muChar_t *a_szName, muFun4_t a_pFun, muBool_t a_bOptimize); +API_EXPORT(void) mupDefineFun5(muParserHandle_t a_hParser, const muChar_t *a_szName, muFun5_t a_pFun, muBool_t a_bOptimize); +// string functions +API_EXPORT(void) mupDefineStrFun1(muParserHandle_t a_hParser, const muChar_t *a_szName, muStrFun1_t a_pFun); +API_EXPORT(void) mupDefineStrFun2(muParserHandle_t a_hParser, const muChar_t *a_szName, muStrFun2_t a_pFun); +API_EXPORT(void) mupDefineStrFun3(muParserHandle_t a_hParser, const muChar_t *a_szName, muStrFun3_t a_pFun); + +API_EXPORT(void) mupDefineMultFun( muParserHandle_t a_hParser, + const muChar_t* a_szName, + muMultFun_t a_pFun, + muBool_t a_bOptimize); + +API_EXPORT(void) mupDefineOprt( muParserHandle_t a_hParser, + const muChar_t* a_szName, + muFun2_t a_pFun, + muInt_t a_nPrec, + muInt_t a_nOprtAsct, + muBool_t a_bOptimize); + +API_EXPORT(void) mupDefineConst( muParserHandle_t a_hParser, + const muChar_t* a_szName, + muFloat_t a_fVal ); + +API_EXPORT(void) mupDefineStrConst( muParserHandle_t a_hParser, + const muChar_t* a_szName, + const muChar_t *a_sVal ); + +API_EXPORT(void) mupDefineVar( muParserHandle_t a_hParser, + const muChar_t* a_szName, + muFloat_t *a_fVar); + +API_EXPORT(void) mupDefinePostfixOprt( muParserHandle_t a_hParser, + const muChar_t* a_szName, + muFun1_t a_pOprt, + muBool_t a_bOptimize); + + +API_EXPORT(void) mupDefineInfixOprt( muParserHandle_t a_hParser, + const muChar_t* a_szName, + muFun1_t a_pOprt, + muBool_t a_bOptimize); + +// Define character sets for identifiers +API_EXPORT(void) mupDefineNameChars(muParserHandle_t a_hParser, const muChar_t* a_szCharset); +API_EXPORT(void) mupDefineOprtChars(muParserHandle_t a_hParser, const muChar_t* a_szCharset); +API_EXPORT(void) mupDefineInfixOprtChars(muParserHandle_t a_hParser, const muChar_t* a_szCharset); + +// Remove all / single variables +API_EXPORT(void) mupRemoveVar(muParserHandle_t a_hParser, const muChar_t* a_szName); +API_EXPORT(void) mupClearVar(muParserHandle_t a_hParser); +API_EXPORT(void) mupClearConst(muParserHandle_t a_hParser); +API_EXPORT(void) mupClearOprt(muParserHandle_t a_hParser); +API_EXPORT(void) mupClearFun(muParserHandle_t a_hParser); + +// Querying variables / expression variables / constants +API_EXPORT(int) mupGetExprVarNum(muParserHandle_t a_hParser); +API_EXPORT(int) mupGetVarNum(muParserHandle_t a_hParser); +API_EXPORT(int) mupGetConstNum(muParserHandle_t a_hParser); +API_EXPORT(void) mupGetExprVar(muParserHandle_t a_hParser, unsigned a_iVar, const muChar_t** a_pszName, muFloat_t** a_pVar); +API_EXPORT(void) mupGetVar(muParserHandle_t a_hParser, unsigned a_iVar, const muChar_t** a_pszName, muFloat_t** a_pVar); +API_EXPORT(void) mupGetConst(muParserHandle_t a_hParser, unsigned a_iVar, const muChar_t** a_pszName, muFloat_t* a_pVar); +API_EXPORT(void) mupSetArgSep(muParserHandle_t a_hParser, const muChar_t cArgSep); +API_EXPORT(void) mupSetDecSep(muParserHandle_t a_hParser, const muChar_t cArgSep); +API_EXPORT(void) mupSetThousandsSep(muParserHandle_t a_hParser, const muChar_t cArgSep); +API_EXPORT(void) mupResetLocale(muParserHandle_t a_hParser); + +// Add value recognition callbacks +API_EXPORT(void) mupAddValIdent(muParserHandle_t a_hParser, muIdentFun_t); + +// Error handling +API_EXPORT(muBool_t) mupError(muParserHandle_t a_hParser); +API_EXPORT(void) mupErrorReset(muParserHandle_t a_hParser); +API_EXPORT(void) mupSetErrorHandler(muParserHandle_t a_hParser, muErrorHandler_t a_pErrHandler); +API_EXPORT(const muChar_t*) mupGetErrorMsg(muParserHandle_t a_hParser); +API_EXPORT(muInt_t) mupGetErrorCode(muParserHandle_t a_hParser); +API_EXPORT(muInt_t) mupGetErrorPos(muParserHandle_t a_hParser); +API_EXPORT(const muChar_t*) mupGetErrorToken(muParserHandle_t a_hParser); +//API_EXPORT(const muChar_t*) mupGetErrorExpr(muParserHandle_t a_hParser); + +// This is used for .NET only. It creates a new variable allowing the dll to +// manage the variable rather than the .NET garbage collector. +API_EXPORT(muFloat_t*) mupCreateVar(); +API_EXPORT(void) mupReleaseVar(muFloat_t*); + +#ifdef __cplusplus +} +#endif + +#endif // include guard diff --git a/AMDiS/lib/muparser_v134/include/muParserDef.h b/AMDiS/lib/muparser_v134/include/muParserDef.h new file mode 100644 index 0000000000000000000000000000000000000000..65e56f7bdf6efa9fbad2c284cdb0bea763e5727d --- /dev/null +++ b/AMDiS/lib/muparser_v134/include/muParserDef.h @@ -0,0 +1,327 @@ +/* + __________ + _____ __ __\______ \_____ _______ ______ ____ _______ + / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ + | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ + |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| + \/ \/ \/ \/ + Copyright (C) 2010 Ingo Berg + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +#ifndef MUP_DEF_H +#define MUP_DEF_H + +#include <iostream> +#include <string> +#include <sstream> +#include <map> + +#include "muParserFixes.h" + +/** \file + \brief This file contains standard definitions used by the parser. +*/ + +#define MUP_VERSION _T("1.34") + +#define MUP_CHARS _T("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") + +/** \brief If this macro is defined mathematical exceptions (div by zero) will be thrown as exceptions. */ +//#define MUP_MATH_EXCEPTIONS + +/** \brief Define the base datatype for values. + + This datatype must be a built in value type. You can not use custom classes. + It has been tested with float, double and long double types, int should + work as well. +*/ +#define MUP_BASETYPE double + +/** \brief Definition of the basic bytecode datatype. + + This defines the smalles entity used in the bytecode. +*/ +#define MUP_BYTECODE_TYPE long + +#if defined(_UNICODE) + /** \brief Definition of the basic parser string type. */ + #define MUP_STRING_TYPE std::wstring + + #if !defined(_T) + #define _T(x) L##x + #endif // not defined _T +#else + #ifndef _T + #define _T(x) x + #endif + + /** \brief Definition of the basic parser string type. */ + #define MUP_STRING_TYPE std::string +#endif + +#if defined(_DEBUG) + /** \brief Debug macro to force an abortion of the programm with a certain message. + */ + #define MUP_FAIL(MSG) \ + bool MSG=false; \ + assert(MSG); + + /** \brief An assertion that does not kill the program. + + This macro is neutralised in UNICODE builds. It's + too difficult to translate. + */ + #define MUP_ASSERT(COND) \ + if (!(COND)) \ + { \ + stringstream_type ss; \ + ss << _T("Assertion \"") _T(#COND) _T("\" failed: ") \ + << __FILE__ << _T(" line ") \ + << __LINE__ << _T("."); \ + throw ParserError( ss.str() ); \ + } +#else + #define MUP_FAIL(MSG) + #define MUP_ASSERT(COND) +#endif + +//------------------------------------------------------------------------------ +// +// do not change anything beyond this point... +// +// !!! This section is devoted to macros that are used for debugging +// !!! or for features that are not fully implemented yet. +// +//#define MUP_DUMP_STACK +//#define MUP_DUMP_CMDCODE + + +namespace mu +{ +#if defined(_UNICODE) + + //------------------------------------------------------------------------------ + /** \brief Encapsulate wcout. */ + inline std::wostream& console() + { + return std::wcout; + } + + /** \brief Encapsulate cin. */ + inline std::wistream& console_in() + { + return std::wcin; + } + +#else + + /** \brief Encapsulate cout. + + Used for supporting UNICODE more easily. + */ + inline std::ostream& console() + { + return std::cout; + } + + /** \brief Encapsulate cin. + + Used for supporting UNICODE more easily. + */ + inline std::istream& console_in() + { + return std::cin; + } + +#endif + + //------------------------------------------------------------------------------ + /** \brief Bytecode values. + + \attention The order of the operator entries must match the order in ParserBase::c_DefaultOprt! + */ + enum ECmdCode + { + // The following are codes for built in binary operators + // apart from built in operators the user has the opportunity to + // add user defined operators. + cmLE = 0, ///< Operator item: less or equal + cmGE = 1, ///< Operator item: greater or equal + cmNEQ = 2, ///< Operator item: not equal + cmEQ = 3, ///< Operator item: equals + cmLT = 4, ///< Operator item: less than + cmGT = 5, ///< Operator item: greater than + cmADD = 6, ///< Operator item: add + cmSUB = 7, ///< Operator item: subtract + cmMUL = 8, ///< Operator item: multiply + cmDIV = 9, ///< Operator item: division + cmPOW = 10, ///< Operator item: y to the power of ... + cmAND = 11, ///< Operator item: logical and + cmOR = 12, ///< Operator item: logical or + cmXOR = 13, ///< Operator item: logical xor + cmASSIGN = 14, ///< Operator item: Assignment operator + cmBO = 15, ///< Operator item: opening bracket + cmBC = 16, ///< Operator item: closing bracket + cmARG_SEP, ///< function argument separator + cmVAR, ///< variable item + cmVAL, ///< value item + cmFUNC, ///< Code for a function item + cmFUNC_STR, ///< Code for a function with a string parameter + cmSTRING, ///< Code for a string token + cmOPRT_BIN, ///< user defined binary operator + cmOPRT_POSTFIX, ///< code for postfix operators + cmOPRT_INFIX, ///< code for infix operators + cmEND, ///< end of formula + cmUNKNOWN ///< uninitialized item + }; + + //------------------------------------------------------------------------------ + /** \brief Types internally used by the parser. + */ + enum ETypeCode + { + tpSTR = 0, ///< String type (Function arguments and constants only, no string variables) + tpDBL = 1, ///< Floating point variables + tpVOID = 2 ///< Undefined type. + }; + + //------------------------------------------------------------------------------ + /** \brief Parser operator precedence values. */ + enum EOprtAssociativity + { + oaLEFT = 0, + oaRIGHT = 1, + oaNONE = 2 + }; + + //------------------------------------------------------------------------------ + /** \brief Parser operator precedence values. */ + enum EOprtPrecedence + { + // binary operators + prLOGIC = 1, ///< logic operators + prCMP = 2, ///< comparsion operators + prADD_SUB = 3, ///< addition + prMUL_DIV = 4, ///< multiplication/division + prPOW = 5, ///< power operator priority (highest) + + // infix operators + prINFIX = 4, ///< Signs have a higher priority than ADD_SUB, but lower than power operator + prPOSTFIX = 4 ///< Postfix operator priority (currently unused) + }; + + //------------------------------------------------------------------------------ + // basic types + + /** \brief The numeric datatype used by the parser. + + Normally this is a floating point type either single or double precision. + */ + typedef MUP_BASETYPE value_type; + + /** \brief The stringtype used by the parser. + + Depends on wether UNICODE is used or not. + */ + typedef MUP_STRING_TYPE string_type; + + /** \brief The bytecode type used by the parser. + + The bytecode type depends on the value_type. + */ + typedef MUP_BYTECODE_TYPE bytecode_type; + + /** \brief The character type used by the parser. + + Depends on wether UNICODE is used or not. + */ + typedef string_type::value_type char_type; + + /** \brief Typedef for easily using stringstream that respect the parser stringtype. */ + typedef std::basic_stringstream<char_type, + std::char_traits<char_type>, + std::allocator<char_type> > stringstream_type; + + // Data container types + + /** \brief Type used for storing variables. */ + typedef std::map<string_type, value_type*> varmap_type; + + /** \brief Type used for storing constants. */ + typedef std::map<string_type, value_type> valmap_type; + + /** \brief Type for assigning a string name to an index in the internal string table. */ + typedef std::map<string_type, std::size_t> strmap_type; + + // Parser callbacks + + /** \brief Callback type used for functions without arguments. */ + typedef value_type (*fun_type0)(); + + /** \brief Callback type used for functions with a single arguments. */ + typedef value_type (*fun_type1)(value_type); + + /** \brief Callback type used for functions with two arguments. */ + typedef value_type (*fun_type2)(value_type, value_type); + + /** \brief Callback type used for functions with three arguments. */ + typedef value_type (*fun_type3)(value_type, value_type, value_type); + + /** \brief Callback type used for functions with four arguments. */ + typedef value_type (*fun_type4)(value_type, value_type, value_type, value_type); + + /** \brief Callback type used for functions with five arguments. */ + typedef value_type (*fun_type5)(value_type, value_type, value_type, value_type, value_type); + + /** \brief Callback type used for functions with a variable argument list. */ + typedef value_type (*multfun_type)(const value_type*, int); + + /** \brief Callback type used for functions taking a string as an argument. */ + typedef value_type (*strfun_type1)(const char_type*); + + /** \brief Callback type used for functions taking a string and a value as arguments. */ + typedef value_type (*strfun_type2)(const char_type*, value_type); + + /** \brief Callback type used for functions taking a string and two values as arguments. */ + typedef value_type (*strfun_type3)(const char_type*, value_type, value_type); + + /** \brief Callback used for functions that identify values in a string. */ + typedef int (*identfun_type)(const char_type *sExpr, int *nPos, value_type *fVal); + + /** \brief Callback used for variable creation factory functions. */ + typedef value_type* (*facfun_type)(const char_type*, void*); + + //------------------------------------------------------------------------------ + /** \brief Static type checks + + I took the static assert from boost, but did not want to + add boost as a dependency to this project. For the original go to: + + http://www.boost.org/doc/html/boost_staticassert.html + */ + template <bool> struct STATIC_ASSERTION_FAILURE; + template <> struct STATIC_ASSERTION_FAILURE<true> {}; + + /** \brief This is a static typecheck. + + If you get a compiler error here you tried to use an unsigned bytecode map type! + */ + typedef char MAP_TYPE_CANT_BE_UNSIGNED[ sizeof( STATIC_ASSERTION_FAILURE< bytecode_type(-1)<0 >) ]; +} // end fo namespace + +#endif + diff --git a/AMDiS/lib/muparser_v134/include/muParserError.h b/AMDiS/lib/muparser_v134/include/muParserError.h new file mode 100644 index 0000000000000000000000000000000000000000..88dd6c64c5c4e17576b5eaf6c7c2d698ad5eaf60 --- /dev/null +++ b/AMDiS/lib/muparser_v134/include/muParserError.h @@ -0,0 +1,170 @@ +/* + __________ + _____ __ __\______ \_____ _______ ______ ____ _______ + / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ + | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ + |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| + \/ \/ \/ \/ + Copyright (C) 2004-2010 Ingo Berg + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef MU_PARSER_ERROR_H +#define MU_PARSER_ERROR_H + +#include <cassert> +#include <stdexcept> +#include <string> +#include <sstream> +#include <vector> +#include <memory> + +#include "muParserDef.h" + +/** \file + \brief This file defines the error class used by the parser. +*/ + +namespace mu +{ + +/** \brief Error codes. */ +enum EErrorCodes +{ + // Formula syntax errors + ecUNEXPECTED_OPERATOR = 0, ///< Unexpected binary operator found + ecUNASSIGNABLE_TOKEN = 1, ///< Token cant be identified. + ecUNEXPECTED_EOF = 2, ///< Unexpected end of formula. (Example: "2+sin(") + ecUNEXPECTED_ARG_SEP = 3, ///< An unexpected comma has been found. (Example: "1,23") + ecUNEXPECTED_ARG = 4, ///< An unexpected argument has been found + ecUNEXPECTED_VAL = 5, ///< An unexpected value token has been found + ecUNEXPECTED_VAR = 6, ///< An unexpected variable token has been found + ecUNEXPECTED_PARENS = 7, ///< Unexpected Parenthesis, opening or closing + ecUNEXPECTED_STR = 8, ///< A string has been found at an inapropriate position + ecSTRING_EXPECTED = 9, ///< A string function has been called with a different type of argument + ecVAL_EXPECTED = 10, ///< A numerical function has been called with a non value type of argument + ecMISSING_PARENS = 11, ///< Missing parens. (Example: "3*sin(3") + ecUNEXPECTED_FUN = 12, ///< Unexpected function found. (Example: "sin(8)cos(9)") + ecUNTERMINATED_STRING = 13, ///< unterminated string constant. (Example: "3*valueof("hello)") + ecTOO_MANY_PARAMS = 14, ///< Too many function parameters + ecTOO_FEW_PARAMS = 15, ///< Too few function parameters. (Example: "ite(1<2,2)") + ecOPRT_TYPE_CONFLICT = 16, ///< binary operators may only be applied to value items of the same type + ecSTR_RESULT = 17, ///< result is a string + + // Invalid Parser input Parameters + ecINVALID_NAME = 18, ///< Invalid function, variable or constant name. + ecINVALID_BINOP_IDENT = 19, ///< Invalid binary operator identifier + ecINVALID_INFIX_IDENT = 20, ///< Invalid function, variable or constant name. + ecINVALID_POSTFIX_IDENT = 21, ///< Invalid function, variable or constant name. + + ecBUILTIN_OVERLOAD = 22, ///< Trying to overload builtin operator + ecINVALID_FUN_PTR = 23, ///< Invalid callback function pointer + ecINVALID_VAR_PTR = 24, ///< Invalid variable pointer + ecEMPTY_EXPRESSION = 25, ///< The Expression is empty + ecNAME_CONFLICT = 26, ///< Name conflict + ecOPT_PRI = 27, ///< Invalid operator priority + // + ecDOMAIN_ERROR = 28, ///< catch division by zero, sqrt(-1), log(0) (currently unused) + ecDIV_BY_ZERO = 29, ///< Division by zero (currently unused) + ecGENERIC = 30, ///< Generic error + ecLOCALE = 31, ///< Conflict with current locale + + // internal errors + ecINTERNAL_ERROR = 32, ///< Internal error of any kind. + + // The last two are special entries + ecCOUNT, ///< This is no error code, It just stores just the total number of error codes + ecUNDEFINED = -1 ///< Undefined message, placeholder to detect unassigned error messages +}; + +//--------------------------------------------------------------------------- +/** \brief A class that handles the error messages. +*/ +class ParserErrorMsg +{ +public: + typedef ParserErrorMsg self_type; + + ParserErrorMsg& operator=(const ParserErrorMsg &); + ParserErrorMsg(const ParserErrorMsg&); + ParserErrorMsg(); + + ~ParserErrorMsg(); + + static const ParserErrorMsg& Instance(); + string_type operator[](unsigned a_iIdx) const; + +private: + std::vector<string_type> m_vErrMsg; ///< A vector with the predefined error messages + static const self_type m_Instance; ///< The instance pointer +}; + +//--------------------------------------------------------------------------- +/** \brief Error class of the parser. + \author Ingo Berg + + Part of the math parser package. +*/ +class ParserError +{ +private: + + /** \brief Replace all ocuurences of a substring with another string. */ + void ReplaceSubString( string_type &strSource, + const string_type &strFind, + const string_type &strReplaceWith); + void Reset(); + +public: + + ParserError(); + explicit ParserError(EErrorCodes a_iErrc); + explicit ParserError(const string_type &sMsg); + ParserError( EErrorCodes a_iErrc, + const string_type &sTok, + const string_type &sFormula = string_type(_T("(formula is not available)")), + int a_iPos = -1); + ParserError( EErrorCodes a_iErrc, + int a_iPos, + const string_type &sTok); + ParserError( const char_type *a_szMsg, + int a_iPos = -1, + const string_type &sTok = string_type()); + ParserError(const ParserError &a_Obj); + ParserError& operator=(const ParserError &a_Obj); + ~ParserError(); + + void SetFormula(const string_type &a_strFormula); + const string_type& GetExpr() const; + const string_type& GetMsg() const; + std::size_t GetPos() const; + const string_type& GetToken() const; + EErrorCodes GetCode() const; + +private: + string_type m_strMsg; ///< The message string + string_type m_strFormula; ///< Formula string + string_type m_strTok; ///< Token related with the error + int m_iPos; ///< Formula position related to the error + EErrorCodes m_iErrc; ///< Error code + const ParserErrorMsg &m_ErrMsg; +}; + +} // namespace mu + +#endif + diff --git a/AMDiS/lib/muparser_v134/include/muParserFixes.h b/AMDiS/lib/muparser_v134/include/muParserFixes.h new file mode 100644 index 0000000000000000000000000000000000000000..f93aef7c701f40ed22b2179cfe0dc3f1d40c6612 --- /dev/null +++ b/AMDiS/lib/muparser_v134/include/muParserFixes.h @@ -0,0 +1,200 @@ +/* + __________ + _____ __ __\______ \_____ _______ ______ ____ _______ + / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ + | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ + |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| + \/ \/ \/ \/ + Copyright (C) 2010 Ingo Berg + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef MU_PARSER_FIXES_H +#define MU_PARSER_FIXES_H + +/** \file + \brief This file contains compatibility fixes for some platforms. +*/ + +// +// Compatibility fixes +// + +//--------------------------------------------------------------------------- +// +// Intel Compiler +// +//--------------------------------------------------------------------------- + +#ifdef __INTEL_COMPILER + +// remark #981: operands are evaluated in unspecified order +// disabled -> completely pointless if the functions do not have side effects +// +#pragma warning(disable:981) + +// remark #383: value copied to temporary, reference to temporary used +#pragma warning(disable:383) + +// remark #1572: floating-point equality and inequality comparisons are unreliable +// disabled -> everyone knows it, the parser passes this problem +// deliberately to the user +#pragma warning(disable:1572) + +#endif + + +//--------------------------------------------------------------------------- +// +// MSVC6 +// +//--------------------------------------------------------------------------- + + +#if defined(_MSC_VER) && _MSC_VER==1200 + +/** \brief Macro to replace the MSVC6 auto_ptr with the _my_auto_ptr class. + + Hijack auto_ptr and replace it with a version that actually does + what an auto_ptr normally does. If you use std::auto_ptr in your other code + might either explode or work much better. The original crap created + by Microsoft, called auto_ptr and bundled with MSVC6 is not standard compliant. +*/ +#define auto_ptr _my_auto_ptr + +// This is another stupidity that needs to be undone in order to de-pollute +// the global namespace! +#undef min +#undef max + + +namespace std +{ + typedef ::size_t size_t; + + //--------------------------------------------------------------------------- + /** \brief MSVC6 fix: Dummy function to put rand into namespace std. + + This is a hack for MSVC6 only. It's dirty, it's ugly and it works, provided + inlining is enabled. Necessary because I will not pollute or change my + code in order to adopt it to MSVC6 interpretation of how C++ should look like! + */ + inline int rand(void) + { + return ::rand(); + } + + //--------------------------------------------------------------------------- + /** \brief MSVC6 fix: Dummy function to put strlen into namespace std. + + This is a hack for MSVC6 only. It's dirty, it's ugly and it works, provided + inlining is enabled. Necessary because I will not pollute or change my + code in order to adopt it to MSVC6 interpretation of how C++ should look like! + */ + inline size_t strlen(const char *szMsg) + { + return ::strlen(szMsg); + } + + //--------------------------------------------------------------------------- + /** \brief MSVC6 fix: Dummy function to put strncmp into namespace std. + + This is a hack for MSVC6 only. It's dirty, it's ugly and it works, provided + inlining is enabled. Necessary because I will not pollute or change my + code in order to adopt it to MSVC6 interpretation of how C++ should look like! + */ + inline int strncmp(const char *a, const char *b, size_t len) + { + return ::strncmp(a,b,len); + } + + //--------------------------------------------------------------------------- + template<typename T> + T max(T a, T b) + { + return (a>b) ? a : b; + } + + //--------------------------------------------------------------------------- + template<typename T> + T min(T a, T b) + { + return (a<b) ? a : b; + } + + //--------------------------------------------------------------------------- + /** Standard compliant auto_ptr redefinition for MSVC6. + + The code is taken from VS.NET 2003, slightly modified to reduce + it's dependencies from other classes. + */ + template<class _Ty> + class _my_auto_ptr + { + public: + typedef _Ty element_type; + + explicit _my_auto_ptr(_Ty *_Ptr = 0) + :_Myptr(_Ptr) + {} + + _my_auto_ptr(_my_auto_ptr<_Ty>& _Right) + :_Myptr(_Right.release()) + {} + + template<class _Other> + operator _my_auto_ptr<_Other>() + { + return (_my_auto_ptr<_Other>(*this)); + } + + template<class _Other> + _my_auto_ptr<_Ty>& operator=(_my_auto_ptr<_Other>& _Right) + { + reset(_Right.release()); + return (*this); + } + + ~auto_ptr() { delete _Myptr; } + _Ty& operator*() const { return (*_Myptr); } + _Ty *operator->() const { return (&**this); } + _Ty *get() const { return (_Myptr); } + + _Ty *release() + { + _Ty *_Tmp = _Myptr; + _Myptr = 0; + return (_Tmp); + } + + void reset(_Ty* _Ptr = 0) + { + if (_Ptr != _Myptr) + delete _Myptr; + _Myptr = _Ptr; + } + + private: + _Ty *_Myptr; + }; // class _my_auto_ptr +} // namespace std + +#endif // Microsoft Visual Studio Version 6.0 + +#endif // include guard + + diff --git a/AMDiS/lib/muparser_v134/include/muParserInt.h b/AMDiS/lib/muparser_v134/include/muParserInt.h new file mode 100644 index 0000000000000000000000000000000000000000..cad2bdc4a9e523ca36458007b63461074d8bce7b --- /dev/null +++ b/AMDiS/lib/muparser_v134/include/muParserInt.h @@ -0,0 +1,97 @@ +/* + __________ + _____ __ __\______ \_____ _______ ______ ____ _______ + / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ + | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ + |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| + \/ \/ \/ \/ + Copyright (C) 2004-2008 Ingo Berg + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef MU_PARSER_INT_H +#define MU_PARSER_INT_H + +#include "muParserBase.h" +#include <vector> + +/** \file + \brief Definition of a parser using integer value. +*/ + + +namespace mu +{ + +/** \brief Mathematical expressions parser. + + This version of the parser handles only integer numbers. It disables the built in operators thus it is + slower than muParser. Integer values are stored in the double value_type and converted if needed. +*/ +class ParserInt : public ParserBase +{ +private: + static int Round(value_type v) { return (int)(v + ((v>=0) ? 0.5 : -0.5) ); }; + + static value_type Abs(value_type); + static value_type Sign(value_type); + static value_type Ite(value_type, value_type, value_type); + // !! The unary Minus is a MUST, otherwise you cant use negative signs !! + static value_type UnaryMinus(value_type); + // Functions with variable number of arguments + static value_type Sum(const value_type* a_afArg, int a_iArgc); // sum + static value_type Min(const value_type* a_afArg, int a_iArgc); // minimum + static value_type Max(const value_type* a_afArg, int a_iArgc); // maximum + // binary operator callbacks + static value_type Add(value_type v1, value_type v2); + static value_type Sub(value_type v1, value_type v2); + static value_type Mul(value_type v1, value_type v2); + static value_type Div(value_type v1, value_type v2); + static value_type Mod(value_type v1, value_type v2); + static value_type Pow(value_type v1, value_type v2); + static value_type Shr(value_type v1, value_type v2); + static value_type Shl(value_type v1, value_type v2); + static value_type LogAnd(value_type v1, value_type v2); + static value_type LogOr(value_type v1, value_type v2); + static value_type And(value_type v1, value_type v2); + static value_type Or(value_type v1, value_type v2); + static value_type Xor(value_type v1, value_type v2); + static value_type Less(value_type v1, value_type v2); + static value_type Greater(value_type v1, value_type v2); + static value_type LessEq(value_type v1, value_type v2); + static value_type GreaterEq(value_type v1, value_type v2); + static value_type Equal(value_type v1, value_type v2); + static value_type NotEqual(value_type v1, value_type v2); + static value_type Not(value_type v1); + + static int IsHexVal(const char_type* a_szExpr, int *a_iPos, value_type *a_iVal); + static int IsBinVal(const char_type* a_szExpr, int *a_iPos, value_type *a_iVal); + static int IsVal (const char_type* a_szExpr, int *a_iPos, value_type *a_iVal); + +public: + ParserInt(); + + virtual void InitFun(); + virtual void InitOprt(); + virtual void InitConst(); + virtual void InitCharSets(); +}; + +} // namespace mu + +#endif + diff --git a/AMDiS/lib/muparser_v134/include/muParserStack.h b/AMDiS/lib/muparser_v134/include/muParserStack.h new file mode 100644 index 0000000000000000000000000000000000000000..1d96570d890bab7c9cade32da9121b2c39bd4106 --- /dev/null +++ b/AMDiS/lib/muparser_v134/include/muParserStack.h @@ -0,0 +1,125 @@ +/* + __________ + _____ __ __\______ \_____ _______ ______ ____ _______ + / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ + | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ + |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| + \/ \/ \/ \/ + Copyright (C) 2004-2006 Ingo Berg + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef MU_PARSER_STACK_H +#define MU_PARSER_STACK_H + +#include <cassert> +#include <string> +#include <stack> +#include <vector> + +#include "muParserError.h" +#include "muParserToken.h" + +/** \file + \brief This file defines the stack used by muparser. +*/ + +namespace mu +{ + + /** \brief Parser stack implementation. + + Stack implementation based on a std::stack. The behaviour of pop() had been + slightly changed in order to get an error code if the stack is empty. + The stack is used within the Parser both as a value stack and as an operator stack. + + \author (C) 2004-2008 Ingo Berg + */ + template <typename TValueType> + class ParserStack + { + private: + + /** \brief Type of the underlying stack implementation. */ + typedef std::stack<TValueType, std::vector<TValueType> > impl_type; + + impl_type m_Stack; ///< This is the actual stack. + + public: + + //--------------------------------------------------------------------------- + ParserStack() + :m_Stack() + {} + + //--------------------------------------------------------------------------- + virtual ~ParserStack() + {} + + //--------------------------------------------------------------------------- + /** \brief Pop a value from the stack. + + Unlike the standard implementation this function will return the value that + is going to be taken from the stack. + + \throw ParserException in case the stack is empty. + \sa pop(int &a_iErrc) + */ + TValueType pop() + { + if (empty()) + throw ParserError( _T("stack is empty.") ); + + TValueType el = top(); + m_Stack.pop(); + return el; + } + + /** \brief Push an object into the stack. + + \param a_Val object to push into the stack. + \throw nothrow + */ + void push(const TValueType& a_Val) + { + m_Stack.push(a_Val); + } + + /** \brief Return the number of stored elements. */ + unsigned size() const + { + return (unsigned)m_Stack.size(); + } + + /** \brief Returns true if stack is empty false otherwise. */ + bool empty() const + { + return m_Stack.size()==0; + } + + /** \brief Return reference to the top object in the stack. + + The top object is the one pushed most recently. + */ + TValueType& top() + { + return m_Stack.top(); + } + }; +} // namespace MathUtils + +#endif diff --git a/AMDiS/lib/muparser_v134/include/muParserTest.h b/AMDiS/lib/muparser_v134/include/muParserTest.h new file mode 100644 index 0000000000000000000000000000000000000000..208a9bd71aed96f85431fc030390f129cbdc1579 --- /dev/null +++ b/AMDiS/lib/muparser_v134/include/muParserTest.h @@ -0,0 +1,203 @@ +/* + __________ + _____ __ __\______ \_____ _______ ______ ____ _______ + / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ + | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ + |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| + \/ \/ \/ \/ + Copyright (C) 2010 Ingo Berg + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef MU_PARSER_TEST_H +#define MU_PARSER_TEST_H + +#include <string> +#include <cstdlib> +#include <numeric> // for accumulate +#include "muParser.h" +#include "muParserInt.h" + +/** \file + \brief This file contains the parser test class. +*/ + +namespace mu +{ + /** \brief Namespace for test cases. */ + namespace Test + { + //------------------------------------------------------------------------------ + /** \brief Test cases for unit testing. + + (C) 2004-2006 Ingo Berg + */ + class ParserTester // final + { + private: + // Multiarg callbacks + static value_type f1of1(value_type v) { return v;}; + + static value_type f1of2(value_type v, value_type ) {return v;}; + static value_type f2of2(value_type , value_type v) {return v;}; + + static value_type f1of3(value_type v, value_type , value_type ) {return v;}; + static value_type f2of3(value_type , value_type v, value_type ) {return v;}; + static value_type f3of3(value_type , value_type , value_type v) {return v;}; + + static value_type f1of4(value_type v, value_type, value_type , value_type ) {return v;} + static value_type f2of4(value_type , value_type v, value_type , value_type ) {return v;} + static value_type f3of4(value_type , value_type, value_type v, value_type ) {return v;} + static value_type f4of4(value_type , value_type, value_type , value_type v) {return v;} + + static value_type f1of5(value_type v, value_type, value_type , value_type , value_type ) { return v; } + static value_type f2of5(value_type , value_type v, value_type , value_type , value_type ) { return v; } + static value_type f3of5(value_type , value_type, value_type v, value_type , value_type ) { return v; } + static value_type f4of5(value_type , value_type, value_type , value_type v, value_type ) { return v; } + static value_type f5of5(value_type , value_type, value_type , value_type , value_type v) { return v; } + + static value_type Min(value_type a_fVal1, value_type a_fVal2) { return (a_fVal1<a_fVal2) ? a_fVal1 : a_fVal2; } + static value_type Max(value_type a_fVal1, value_type a_fVal2) { return (a_fVal1>a_fVal2) ? a_fVal1 : a_fVal2; } + + static value_type plus2(value_type v1) { return v1+2; } + static value_type times3(value_type v1) { return v1*3; } + static value_type sqr(value_type v1) { return v1*v1; } + static value_type sign(value_type v) { return -v; } + static value_type add(value_type v1, value_type v2) { return v1+v2; } + + static value_type FirstArg(const value_type* a_afArg, int a_iArgc) + { + if (!a_iArgc) + throw mu::Parser::exception_type( _T("too few arguments for function FirstArg.") ); + + return a_afArg[0]; + } + + static value_type LastArg(const value_type* a_afArg, int a_iArgc) + { + if (!a_iArgc) + throw mu::Parser::exception_type( _T("too few arguments for function LastArg.") ); + + return a_afArg[a_iArgc-1]; + } + + static value_type Sum(const value_type* a_afArg, int a_iArgc) + { + if (!a_iArgc) + throw mu::Parser::exception_type( _T("too few arguments for function sum.") ); + + value_type fRes=0; + for (int i=0; i<a_iArgc; ++i) fRes += a_afArg[i]; + return fRes; + } + + static value_type Rnd(value_type v) + { + return (value_type)(1+(v*std::rand()/(RAND_MAX+1.0))); + } + + static value_type RndWithString(const char_type*) + { + return (value_type)( 1 + (1000.0f * std::rand() / (RAND_MAX + 1.0) ) ); + } + + static value_type Ping() + { + return 10; + } + + static value_type ValueOf(const char_type*) + { + return 123; + } + + static value_type StrFun1(const char_type* v1) + { + int val(0); + stringstream_type(v1) >> val; + return (value_type)val; + } + + static value_type StrFun2(const char_type* v1, value_type v2) + { + int val(0); + stringstream_type(v1) >> val; + return (value_type)(val + v2); + } + + static value_type StrFun3(const char_type* v1, value_type v2, value_type v3) + { + int val(0); + stringstream_type(v1) >> val; + return val + v2 + v3; + } + + static value_type StrToFloat(const char_type* a_szMsg) + { + value_type val(0); + stringstream_type(a_szMsg) >> val; + return val; + +// using namespace std; // atof is for some compilers in std for some not... +// return atof(a_szMsg); + } + + // postfix operator callback + static value_type Mega(value_type a_fVal) { return a_fVal * (value_type)1e6; } + static value_type Micro(value_type a_fVal) { return a_fVal * (value_type)1e-6; } + static value_type Milli(value_type a_fVal) { return a_fVal / (value_type)1e3; } + + static int c_iCount; + + int TestNames(); + int TestSyntax(); + int TestMultiArg(); + int TestVolatile(); + int TestPostFix(); + int TestExpression(); + int TestInfixOprt(); + int TestBinOprt(); + int TestVarConst(); + int TestInterface(); + int TestException(); + int TestStrArg(); + + void Abort() const; + + public: + typedef int (ParserTester::*testfun_type)(); + + ParserTester(); + void Run(); + + private: + std::vector<testfun_type> m_vTestFun; + void AddTest(testfun_type a_pFun); + + // Test Double Parser + int EqnTest(const string_type& a_str, double a_fRes, bool a_fPass); + int ThrowTest(const string_type& a_str, int a_iErrc, bool a_bFail = true); + + // Test Int Parser + int EqnTestInt(const string_type& a_str, double a_fRes, bool a_fPass); + }; + } // namespace Test +} // namespace mu + +#endif + + diff --git a/AMDiS/lib/muparser_v134/include/muParserToken.h b/AMDiS/lib/muparser_v134/include/muParserToken.h new file mode 100644 index 0000000000000000000000000000000000000000..c9aac4158a17780784a5f31d832fc17410789533 --- /dev/null +++ b/AMDiS/lib/muparser_v134/include/muParserToken.h @@ -0,0 +1,455 @@ +/* + __________ + _____ __ __\______ \_____ _______ ______ ____ _______ + / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ + | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ + |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| + \/ \/ \/ \/ + Copyright (C) 2004-2008 Ingo Berg + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef MU_PARSER_TOKEN_H +#define MU_PARSER_TOKEN_H + +#include <cassert> +#include <string> +#include <stack> +#include <vector> +#include <memory> + +#include "muParserError.h" +#include "muParserCallback.h" + +/** \file + \brief This file contains the parser token definition. +*/ + +namespace mu +{ + /** \brief Encapsulation of the data for a single formula token. + + Formula token implementation. Part of the Math Parser Package. + Formula tokens can be either one of the following: + <ul> + <li>value</li> + <li>variable</li> + <li>function with numerical arguments</li> + <li>functions with a string as argument</li> + <li>prefix operators</li> + <li>infix operators</li> + <li>binary operator</li> + </ul> + + \author (C) 2004 Ingo Berg + */ + template<typename TBase, typename TString> + class ParserToken + { + public: + + /** \brief Additional token flags. */ + enum ETokFlags + { + flVOLATILE = 1 ///< Mark a token that depends on a variable or a function that is not conservative + }; + + private: + + ECmdCode m_iCode; ///< Type of the token; The token type is a constant of type #ECmdCode. + ETypeCode m_iType; + void *m_pTok; ///< Stores Token pointer; not applicable for all tokens + int m_iFlags; ///< Additional flags for the token. + int m_iIdx; ///< An otional index to an external buffer storing the token data + TString m_strTok; ///< Token string + TString m_strVal; ///< Value for string variables + value_type m_fVal; +#if HAS_CXX11 + std::unique_ptr<ParserCallback> m_pCallback; +#else + std::auto_ptr<ParserCallback> m_pCallback; +#endif + + public: + + //--------------------------------------------------------------------------- + /** \brief Constructor (default). + + Sets token to an neutral state of type cmUNKNOWN. + \throw nothrow + \sa ECmdCode + */ + ParserToken() + :m_iCode(cmUNKNOWN) + ,m_iType(tpVOID) + ,m_pTok(0) + ,m_iFlags(0) + ,m_iIdx(-1) + ,m_strTok() + ,m_pCallback() + {} + + //------------------------------------------------------------------------------ + /** \brief Create token from another one. + + Implemented by calling Assign(...) + \throw nothrow + \post m_iType==cmUNKNOWN + \sa #Assign + */ + ParserToken(const ParserToken &a_Tok) + { + Assign(a_Tok); + } + + //------------------------------------------------------------------------------ + /** \brief Assignement operator. + + Copy token state from another token and return this. + Implemented by calling Assign(...). + \throw nothrow + */ + ParserToken& operator=(const ParserToken &a_Tok) + { + Assign(a_Tok); + return *this; + } + + //------------------------------------------------------------------------------ + /** \brief Copy token information from argument. + + \throw nothrow + */ + void Assign(const ParserToken &a_Tok) + { + m_iCode = a_Tok.m_iCode; + m_pTok = a_Tok.m_pTok; + m_iFlags = a_Tok.m_iFlags; + m_strTok = a_Tok.m_strTok; + m_iIdx = a_Tok.m_iIdx; + m_strVal = a_Tok.m_strVal; + m_iType = a_Tok.m_iType; + m_fVal = a_Tok.m_fVal; + // create new callback object if a_Tok has one + m_pCallback.reset(a_Tok.m_pCallback.get() ? a_Tok.m_pCallback->Clone() : 0); + } + + //------------------------------------------------------------------------------ + /** \brief Add additional flags to the token. + + Flags are currently used to mark volatile (non optimizeable) functions. + \sa m_iFlags, ETokFlags + */ + void AddFlags(int a_iFlags) + { + m_iFlags |= a_iFlags; + } + + //------------------------------------------------------------------------------ + /** \brief Check if a certain flag ist set. + + \throw nothrow + */ + bool IsFlagSet(int a_iFlags) const + { + #if defined(_MSC_VER) + #pragma warning( disable : 4800 ) + #endif + + return (bool)(m_iFlags & a_iFlags); + + #if defined(_MSC_VER) + #pragma warning( default : 4800 ) // int: Variable set to boolean value (may degrade performance) + #endif + } + + //------------------------------------------------------------------------------ + /** \brief Assign a token type. + + Token may not be of type value, variable or function. Those have seperate set functions. + + \pre [assert] a_iType!=cmVAR + \pre [assert] a_iType!=cmVAL + \pre [assert] a_iType!=cmFUNC + \post m_fVal = 0 + \post m_pTok = 0 + */ + ParserToken& Set(ECmdCode a_iType, const TString &a_strTok=TString()) + { + // The following types cant be set this way, they have special Set functions + assert(a_iType!=cmVAR); + assert(a_iType!=cmVAL); + assert(a_iType!=cmFUNC); + + m_iCode = a_iType; + m_iType = tpVOID; + m_pTok = 0; + m_iFlags = 0; + m_strTok = a_strTok; + m_iIdx = -1; + + return *this; + } + + //------------------------------------------------------------------------------ + /** \brief Set Callback type. */ + ParserToken& Set(const ParserCallback &a_pCallback, const TString &a_sTok) + { + assert(a_pCallback.GetAddr()); + + m_iCode = a_pCallback.GetCode(); + m_iType = tpVOID; + m_strTok = a_sTok; + m_pCallback.reset(new ParserCallback(a_pCallback)); + + m_pTok = 0; + m_iFlags = 0; + m_iIdx = -1; + + if (!m_pCallback->IsOptimizable()) + AddFlags(flVOLATILE); + + return *this; + } + + //------------------------------------------------------------------------------ + /** \brief Make this token a value token. + + Member variables not necessary for value tokens will be invalidated. + \throw nothrow + */ + ParserToken& SetVal(TBase a_fVal, const TString &a_strTok=TString()) + { + m_iCode = cmVAL; + m_iType = tpDBL; + m_fVal = a_fVal; + m_iFlags = 0; + m_strTok = a_strTok; + m_iIdx = -1; + + m_pTok = 0; + m_pCallback.reset(0); + + return *this; + } + + //------------------------------------------------------------------------------ + /** \brief make this token a variable token. + + Member variables not necessary for variable tokens will be invalidated. + \throw nothrow + */ + ParserToken& SetVar(TBase *a_pVar, const TString &a_strTok) + { + m_iCode = cmVAR; + m_iType = tpDBL; + m_iFlags = 0; + m_strTok = a_strTok; + m_iIdx = -1; + m_pTok = (void*)a_pVar; + m_pCallback.reset(0); + + AddFlags(ParserToken::flVOLATILE); + return *this; + } + + //------------------------------------------------------------------------------ + /** \brief Make this token a variable token. + + Member variables not necessary for variable tokens will be invalidated. + \throw nothrow + */ + ParserToken& SetString(const TString &a_strTok, std::size_t a_iSize) + { + m_iCode = cmSTRING; + m_iType = tpSTR; + m_iFlags = 0; + m_strTok = a_strTok; + m_iIdx = static_cast<int>(a_iSize); + + m_pTok = 0; + m_pCallback.reset(0); + + AddFlags(ParserToken::flVOLATILE); + return *this; + } + + //------------------------------------------------------------------------------ + /** \brief Set an index associated with the token related data. + + In cmSTRFUNC - This is the index to a string table in the main parser. + \param a_iIdx The index the string function result will take in the bytecode parser. + \throw exception_type if #a_iIdx<0 or #m_iType!=cmSTRING + */ + void SetIdx(int a_iIdx) + { + if (m_iCode!=cmSTRING || a_iIdx<0) + throw ParserError(ecINTERNAL_ERROR); + + m_iIdx = a_iIdx; + } + + //------------------------------------------------------------------------------ + /** \brief Return Index associated with the token related data. + + In cmSTRFUNC - This is the index to a string table in the main parser. + + \throw exception_type if #m_iIdx<0 or #m_iType!=cmSTRING + \return The index the result will take in the Bytecode calculatin array (#m_iIdx). + */ + int GetIdx() const + { + if (m_iIdx<0 || m_iCode!=cmSTRING ) + throw ParserError(ecINTERNAL_ERROR); + + return m_iIdx; + } + + //------------------------------------------------------------------------------ + /** \brief Return the token type. + + \return #m_iType + \throw nothrow + */ + ECmdCode GetCode() const + { + if (m_pCallback.get()) + { + return m_pCallback->GetCode(); + } + else + { + return m_iCode; + } + } + + //------------------------------------------------------------------------------ + ETypeCode GetType() const + { + if (m_pCallback.get()) + { + return m_pCallback->GetType(); + } + else + { + return m_iType; + } + } + + //------------------------------------------------------------------------------ + int GetPri() const + { + if ( !m_pCallback.get()) + throw ParserError(ecINTERNAL_ERROR); + + if ( m_pCallback->GetCode()!=cmOPRT_BIN && m_pCallback->GetCode()!=cmOPRT_INFIX) + throw ParserError(ecINTERNAL_ERROR); + + return m_pCallback->GetPri(); + } + + //------------------------------------------------------------------------------ + EOprtAssociativity GetAssociativity() const + { + if (m_pCallback.get()==NULL || m_pCallback->GetCode()!=cmOPRT_BIN) + throw ParserError(ecINTERNAL_ERROR); + + return m_pCallback->GetAssociativity(); + } + + //------------------------------------------------------------------------------ + /** \brief Return the address of the callback function assoziated with + function and operator tokens. + + \return The pointer stored in #m_pTok. + \throw exception_type if token type is non of: + <ul> + <li>cmFUNC</li> + <li>cmSTRFUNC</li> + <li>cmPOSTOP</li> + <li>cmINFIXOP</li> + <li>cmOPRT_BIN</li> + </ul> + \sa ECmdCode + */ + void* GetFuncAddr() const + { + return (m_pCallback.get()) ? m_pCallback->GetAddr() : 0; + } + + //------------------------------------------------------------------------------ + /** \biref Get value of the token. + + Only applicable to variable and value tokens. + \throw exception_type if token is no value/variable token. + */ + TBase GetVal() const + { + switch (m_iCode) + { + case cmVAL: return m_fVal; + case cmVAR: return *((TBase*)m_pTok); + default: throw ParserError(ecVAL_EXPECTED); + } + } + + //------------------------------------------------------------------------------ + /** \brief Get address of a variable token. + + Valid only if m_iType==CmdVar. + \throw exception_type if token is no variable token. + */ + TBase* GetVar() const + { + if (m_iCode!=cmVAR) + throw ParserError(ecINTERNAL_ERROR); + + return (TBase*)m_pTok; + } + + //------------------------------------------------------------------------------ + /** \brief Return the number of function arguments. + + Valid only if m_iType==CmdFUNC. + */ + int GetArgCount() const + { + assert(m_pCallback.get()); + + if (!m_pCallback->GetAddr()) + throw ParserError(ecINTERNAL_ERROR); + + return m_pCallback->GetArgc(); + } + + //------------------------------------------------------------------------------ + /** \brief Return the token identifier. + + If #m_iType is cmSTRING the token identifier is the value of the string argument + for a string function. + \return #m_strTok + \throw nothrow + \sa m_strTok + */ + const TString& GetAsString() const + { + return m_strTok; + } + }; +} // namespace mu + +#endif diff --git a/AMDiS/lib/muparser_v134/include/muParserTokenReader.h b/AMDiS/lib/muparser_v134/include/muParserTokenReader.h new file mode 100644 index 0000000000000000000000000000000000000000..cb6ffc3390c4385a4df0bee155c0f491490859e0 --- /dev/null +++ b/AMDiS/lib/muparser_v134/include/muParserTokenReader.h @@ -0,0 +1,157 @@ +/* + __________ + _____ __ __\______ \_____ _______ ______ ____ _______ + / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ + | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ + |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| + \/ \/ \/ \/ + Copyright (C) 2004-2010 Ingo Berg + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef MU_PARSER_TOKEN_READER_H +#define MU_PARSER_TOKEN_READER_H + +#include <cassert> +#include <cstdio> +#include <cstring> +#include <map> +#include <memory> +#include <stack> +#include <string> + +#include "muParserDef.h" +#include "muParserToken.h" + +/** \file + \brief This file contains the parser token reader definition. +*/ + + +namespace mu +{ + // Forward declaration + class ParserBase; + + /** \brief Token reader for the ParserBase class. + + */ + class ParserTokenReader + { + private: + + typedef ParserToken<value_type, string_type> token_type; + + public: + + ParserTokenReader(ParserBase *a_pParent); + ParserTokenReader* Clone(ParserBase *a_pParent) const; + + void AddValIdent(identfun_type a_pCallback); + void SetVarCreator(facfun_type a_pFactory, void *pUserData); + void SetFormula(const string_type &a_strFormula); + void SetArgSep(char_type cArgSep); + + int GetPos() const; + const string_type& GetExpr() const; + const varmap_type& GetUsedVar() const; + char_type GetArgSep() const; + + void IgnoreUndefVar(bool bIgnore); + void ReInit(); + token_type ReadNextToken(); + + private: + + /** \brief Syntax codes. + + The syntax codes control the syntax check done during the first time parsing of + the expression string. They are flags that indicate which tokens are allowed next + if certain tokens are identified. + */ + enum ESynCodes + { + noBO = 1 << 0, ///< to avoid i.e. "cos(7)(" + noBC = 1 << 1, ///< to avoid i.e. "sin)" or "()" + noVAL = 1 << 2, ///< to avoid i.e. "tan 2" or "sin(8)3.14" + noVAR = 1 << 3, ///< to avoid i.e. "sin a" or "sin(8)a" + noARG_SEP = 1 << 4, ///< to avoid i.e. ",," or "+," ... + noFUN = 1 << 5, ///< to avoid i.e. "sqrt cos" or "(1)sin" + noOPT = 1 << 6, ///< to avoid i.e. "(+)" + noPOSTOP = 1 << 7, ///< to avoid i.e. "(5!!)" "sin!" + noINFIXOP = 1 << 8, ///< to avoid i.e. "++4" "!!4" + noEND = 1 << 9, ///< to avoid unexpected end of formula + noSTR = 1 << 10, ///< to block numeric arguments on string functions + noASSIGN = 1 << 11, ///< to block assignement to constant i.e. "4=7" + noANY = ~0 ///< All of he above flags set + }; + + ParserTokenReader(const ParserTokenReader &a_Reader); + ParserTokenReader& operator=(const ParserTokenReader &a_Reader); + void Assign(const ParserTokenReader &a_Reader); + + void SetParent(ParserBase *a_pParent); + int ExtractToken(const char_type *a_szCharSet, + string_type &a_strTok, + int a_iPos) const; + int ExtractOperatorToken(string_type &a_sTok, int a_iPos) const; + + bool IsBuiltIn(token_type &a_Tok); + bool IsArgSep(token_type &a_Tok); + bool IsEOF(token_type &a_Tok); + bool IsInfixOpTok(token_type &a_Tok); + bool IsFunTok(token_type &a_Tok); + bool IsPostOpTok(token_type &a_Tok); + bool IsOprt(token_type &a_Tok); + bool IsValTok(token_type &a_Tok); + bool IsVarTok(token_type &a_Tok); + bool IsStrVarTok(token_type &a_Tok); + bool IsUndefVarTok(token_type &a_Tok); + bool IsString(token_type &a_Tok); + void Error(EErrorCodes a_iErrc, + int a_iPos = -1, + const string_type &a_sTok = string_type() ) const; + + token_type& SaveBeforeReturn(const token_type &tok); + + ParserBase *m_pParser; + string_type m_strFormula; + int m_iPos; + int m_iSynFlags; + bool m_bIgnoreUndefVar; + + const funmap_type *m_pFunDef; + const funmap_type *m_pPostOprtDef; + const funmap_type *m_pInfixOprtDef; + const funmap_type *m_pOprtDef; + const valmap_type *m_pConstDef; + const strmap_type *m_pStrVarDef; + varmap_type *m_pVarDef; ///< The only non const pointer to parser internals + facfun_type m_pFactory; + void *m_pFactoryData; + std::vector<identfun_type> m_vIdentFun; ///< Value token identification function + varmap_type m_UsedVar; + value_type m_fZero; ///< Dummy value of zero, referenced by undefined variables + int m_iBrackets; + token_type m_lastTok; + char_type m_cArgSep; ///< The character used for separating function arguments + }; +} // namespace mu + +#endif + + diff --git a/AMDiS/lib/muparser_v134/lib/Readme.txt b/AMDiS/lib/muparser_v134/lib/Readme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7240cc374f7a90316d2a393bb877f706bf6ea2c5 --- /dev/null +++ b/AMDiS/lib/muparser_v134/lib/Readme.txt @@ -0,0 +1 @@ +Here goes the libraries (both static and shared) for this component. \ No newline at end of file diff --git a/AMDiS/lib/muparser_v134/samples/example1/Example1.cpp b/AMDiS/lib/muparser_v134/samples/example1/Example1.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cefae8f267ae7dd94ea702c844dc29e9413278b7 --- /dev/null +++ b/AMDiS/lib/muparser_v134/samples/example1/Example1.cpp @@ -0,0 +1,467 @@ +//--------------------------------------------------------------------------- +// +// __________ +// _____ __ __\______ \_____ _______ ______ ____ _______ +// / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ +// | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ +// |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| +// \/ \/ \/ \/ +// (C) 2010 Ingo Berg +// +// example1.cpp - using the parser as a static library +// +//--------------------------------------------------------------------------- + +#include "muParserTest.h" + +#if defined(_WIN32) && defined(_DEBUG) + #define _CRTDBG_MAP_ALLOC + #include <stdlib.h> + #include <crtdbg.h> + #define CREATE_LEAKAGE_REPORT +#endif + +/** \brief This macro will enable mathematical constants like M_PI. */ +#define _USE_MATH_DEFINES + +#include <cstdlib> +#include <cstring> +#include <cmath> +#include <string> +#include <iostream> +#include <locale> +#include <limits> +#include <ios> +#include <iomanip> + +#include "muParser.h" +#include "muParserInt.h" +//#include "muParserComplex.h" + +#if defined( USINGDLL ) && defined( _WIN32 ) +#error This sample can be used only with STATIC builds of muParser (on win32) +#endif + +using namespace std; +using namespace mu; + + +#if defined(CREATE_LEAKAGE_REPORT) + +// Dumping memory leaks in the destructor of the static guard +// guarantees i won't get false positives from the ParserErrorMsg +// class wich is a singleton with a static instance. +struct DumpLeaks +{ + ~DumpLeaks() + { + _CrtDumpMemoryLeaks(); + } +} static LeakDumper; + +#endif + +// Operator callback functions +value_type Milli(value_type a_fVal) { return a_fVal * (value_type)1e-3; } +value_type Rnd(value_type v) { return v*std::rand()/(value_type)(RAND_MAX+1.0); } +value_type Not(value_type v) { return v==0; } +value_type Add(value_type v1, value_type v2) { return v1+v2; } +value_type Mul(value_type v1, value_type v2) { return v1*v2; } +value_type Noop(value_type) { return 0; } + +//--------------------------------------------------------------------------- +value_type Or(value_type v1, value_type v2) +{ + return v1!=1 || v2!=1; +} + +//--------------------------------------------------------------------------- +value_type StrFun2(const char_type *v1, value_type v2,value_type v3) +{ + mu::console() << v1 << std::endl; + return v2+v3; +} + +//--------------------------------------------------------------------------- +value_type Ping() +{ + mu::console() << "ping\n"; return 0; +} + +//--------------------------------------------------------------------------- +mu::value_type SampleQuery(const char_type *szMsg) +{ + if (szMsg) + mu::console() << szMsg << std::endl; + + return 999; +}; + +//--------------------------------------------------------------------------- +// Factory function for creating new parser variables +// This could as well be a function performing database queries. +value_type* AddVariable(const char_type *a_szName, void *a_pUserData) +{ + // I don't want dynamic allocation here, so i used this static buffer + // If you want dynamic allocation you must allocate all variables dynamically + // in order to delete them later on. Or you find other ways to keep track of + // variables that have been created implicitely. + static value_type afValBuf[100]; + static int iVal = 0; + + mu::console() << _T("Generating new variable \"") + << a_szName << _T("\" (slots left: ") + << 99-iVal << _T(")") + << _T(" User data pointer is:") + << std::hex << a_pUserData <<endl; + + afValBuf[iVal] = 0; + if (iVal>=99) + throw mu::ParserError( _T("Variable buffer overflow.") ); + + return &afValBuf[iVal++]; +} + +//--------------------------------------------------------------------------- +void Splash() +{ + mu::console() << _T(" __________ \n"); + mu::console() << _T(" _____ __ __\\______ \\_____ _______ ______ ____ _______\n"); + mu::console() << _T(" / \\ | | \\| ___/\\__ \\ \\_ __ \\/ ___/_/ __ \\\\_ __ \\ \n"); + mu::console() << _T(" | Y Y \\| | /| | / __ \\_| | \\/\\___ \\ \\ ___/ | | \\/ \n"); + mu::console() << _T(" |__|_| /|____/ |____| (____ /|__| /____ > \\___ >|__| \n"); + mu::console() << _T(" \\/ \\/ \\/ \\/ \n"); + mu::console() << _T(" Version ") << Parser().GetVersion() << _T("\n"); + mu::console() << _T(" (C) 2010 Ingo Berg\n"); +} + +//--------------------------------------------------------------------------- +void SelfTest() +{ + mu::console() << _T( "-----------------------------------------------------------\n"); + mu::console() << _T( "Configuration:\n\n"); + +#if defined(MUP_MATH_EXCEPTIONS) + mu::console() << _T( "- Math exceptions enabled\n"); +#else + mu::console() << _T( "- Math exceptions disabled\n"); +#endif +#if defined(_DEBUG) + mu::console() << _T( "- DEBUG build\n"); +#else + mu::console() << _T( "- RELEASE build\n"); +#endif + +#if defined(_UNICODE) + mu::console() << _T( "- UNICODE build\n"); +#else + mu::console() << _T( "- ASCII build\n"); +#endif + + mu::console() << _T( "-----------------------------------------------------------\n"); + mu::console() << _T( "Running test suite:\n\n"); + +#if !defined(MUP_DUMP_STACK) && !defined(MUP_DUMP_CMDCODE) + mu::Test::ParserTester pt; + pt.Run(); +#endif + + mu::console() << _T( "-----------------------------------------------------------\n"); + mu::console() << _T( "Commands:\n\n"); + mu::console() << _T( " list var - list parser variables\n"); + mu::console() << _T( " list exprvar - list expression variables\n"); + mu::console() << _T( " list const - list all numeric parser constants\n"); + mu::console() << _T( " locale de - switch to german locale\n"); + mu::console() << _T( " locale en - switch to english locale\n"); + mu::console() << _T( " locale reset - reset locale\n"); + mu::console() << _T( " quit - exits the parser\n"); + mu::console() << _T( "\nConstants:\n\n"); + mu::console() << _T( " \"_e\" 2.718281828459045235360287\n"); + mu::console() << _T( " \"_pi\" 3.141592653589793238462643\n"); + mu::console() << _T( "-----------------------------------------------------------\n"); +} + +////--------------------------------------------------------------------------- +//void CheckLocale() +//{ +// // Local names: +// // "C" - the classic C locale +// // "de_DE" - not for Windows? +// // "en_US" - not for Windows? +// // "German_germany" - For MSVC8 +// try +// { +// std::locale loc("German_germany"); +// console() << _T("Locale settings:\n"); +// console() << _T(" Decimal point: '") << std::use_facet<numpunct<char_type> >(loc).decimal_point() << "'\n"; +// console() << _T(" Thousands sep: '") << std::use_facet<numpunct<char_type> >(loc).thousands_sep() << "'\n"; +// console() << _T(" Grouping: \"") << std::use_facet<numpunct<char_type> >(loc).grouping() << "\"\n"; +// console() << _T(" True is named: \"") << std::use_facet<numpunct<char_type> >(loc).truename() << "\"\n"; +// console() << _T(" False is named: \"") << std::use_facet<numpunct<char_type> >(loc).falsename() << "\"\n"; +// console() << _T("-----------------------------------------------------------\n"); +// } +// catch(...) +// { +// console() << _T("Locale settings:\n"); +// console() << _T(" invalid locale name\n"); +// console() << _T("-----------------------------------------------------------\n"); +// } +//} + +//--------------------------------------------------------------------------- +void ListVar(const mu::ParserBase &parser) +{ + // Query the used variables (must be done after calc) + mu::varmap_type variables = parser.GetVar(); + if (!variables.size()) + return; + + cout << "\nParser variables:\n"; + cout << "-----------------\n"; + cout << "Number: " << (int)variables.size() << "\n"; + varmap_type::const_iterator item = variables.begin(); + for (; item!=variables.end(); ++item) + mu::console() << _T("Name: ") << item->first << _T(" Address: [0x") << item->second << _T("]\n"); +} + +//--------------------------------------------------------------------------- +void ListConst(const mu::ParserBase &parser) +{ + mu::console() << _T("\nParser constants:\n"); + mu::console() << _T("-----------------\n"); + + mu::valmap_type cmap = parser.GetConst(); + if (!cmap.size()) + { + mu::console() << _T("Expression does not contain constants\n"); + } + else + { + valmap_type::const_iterator item = cmap.begin(); + for (; item!=cmap.end(); ++item) + mu::console() << _T(" ") << item->first << _T(" = ") << item->second << _T("\n"); + } +} + +//--------------------------------------------------------------------------- +void ListExprVar(const mu::ParserBase &parser) +{ + string_type sExpr = parser.GetExpr(); + if (sExpr.length()==0) + { + cout << _T("Expression string is empty\n"); + return; + } + + // Query the used variables (must be done after calc) + mu::console() << _T("\nExpression variables:\n"); + mu::console() << _T("---------------------\n"); + mu::console() << _T("Expression: ") << parser.GetExpr() << _T("\n"); + + varmap_type variables = parser.GetUsedVar(); + if (!variables.size()) + { + mu::console() << _T("Expression does not contain variables\n"); + } + else + { + mu::console() << _T("Number: ") << (int)variables.size() << _T("\n"); + mu::varmap_type::const_iterator item = variables.begin(); + for (; item!=variables.end(); ++item) + mu::console() << _T("Name: ") << item->first << _T(" Address: [0x") << item->second << _T("]\n"); + } +} + +//--------------------------------------------------------------------------- +/** \brief Check for external keywords. +*/ +int CheckKeywords(const mu::char_type *a_szLine, mu::Parser &a_Parser) +{ + string_type sLine(a_szLine); + + if ( sLine == _T("quit") ) + { + return -1; + } + else if ( sLine == _T("list var") ) + { + ListVar(a_Parser); + return 1; + } + else if ( sLine == _T("list const") ) + { + ListConst(a_Parser); + return 1; + } + else if ( sLine == _T("list exprvar") ) + { + ListExprVar(a_Parser); + return 1; + } + else if ( sLine == _T("list const") ) + { + ListConst(a_Parser); + return 1; + } + else if ( sLine == _T("locale de") ) + { + mu::console() << _T("Setting german locale: ArgSep=';' DecSep=',' ThousandsSep='.'\n"); + a_Parser.SetArgSep(';'); + a_Parser.SetDecSep(','); + a_Parser.SetThousandsSep('.'); + return 1; + } + else if ( sLine == _T("locale en") ) + { + mu::console() << _T("Setting english locale: ArgSep=',' DecSep='.' ThousandsSep=''\n"); + a_Parser.SetArgSep(','); + a_Parser.SetDecSep('.'); + a_Parser.SetThousandsSep(); + return 1; + } + else if ( sLine == _T("locale reset") ) + { + mu::console() << _T("Resetting locale\n"); + a_Parser.ResetLocale(); + return 1; + } + + return 0; +} + +//--------------------------------------------------------------------------- +void Calc() +{ + mu::Parser parser; + mu::ParserInt int_parser; +// mu::ParserComplex cmplx_parser; + + // Change locale settings if necessary + // function argument separator: sum(2;3;4) vs. sum(2,3,4) + // decimal separator: 3,14 vs. 3.14 + // thousands separator: 1000000 vs 1.000.000 +//#define USE_GERMAN_LOCALE +#ifdef USE_GERMAN_LOCALE + parser.SetArgSep(';'); + parser.SetDecSep(','); + parser.SetThousandsSep('.'); +#else + // this is the default, so i it's commented: + //parser.SetArgSep(','); + //parser.SetDecSep('.'); + //parser.SetThousandsSep(''); +#endif + + // Add some variables + value_type vVarVal[] = { 1, 2 }; // Values of the parser variables +// parser.DefineArrayVar(_T("va"), vVarVal, 2); + parser.DefineVar(_T("a"), &vVarVal[0]); // Assign Variable names and bind them to the C++ variables + parser.DefineVar(_T("b"), &vVarVal[1]); + parser.DefineStrConst(_T("strBuf"), _T("hello world") ); + + // Add user defined unary operators + parser.DefinePostfixOprt(_T("{m}"), Milli); + parser.DefineInfixOprt(_T("!"), Not); + + parser.DefineFun(_T("query"), SampleQuery, false); + parser.DefineFun(_T("rnd"), Rnd, false); // Add an unoptimizeable function + parser.DefineFun(_T("strfun2"), StrFun2, false); // Add an unoptimizeable function + parser.DefineFun(_T("ping"), Ping, false); + + parser.DefineOprt(_T("add"), Add, 0); + parser.DefineOprt(_T("mul"), Mul, 1); + +#ifdef _DEBUG + parser.EnableOptimizer(false); +#endif + + // Define the variable factory + parser.SetVarFactory(AddVariable, &parser); + + for(;;) + { + try + { + string_type sLine; + std::getline(mu::console_in(), sLine); + + switch (CheckKeywords(sLine.c_str(), parser)) + { + case 0: break; + case 1: continue; + case -1: return; + } + +//#define MUP_EXAMPLE_INT_PARSER +//#define MUP_EXAMPLE_COMPLEX_PARSER +#ifdef MUP_EXAMPLE_INT_PARSER + int_parser.SetExpr(sLine); + mu::console() << int_parser.Eval() << "\n"; + mu::console() << int_parser.Eval() << "\n"; +#elif defined MUP_EXAMPLE_COMPLEX_PARSER + cmplx_parser.SetExpr(sLine); + mu::console() << cmplx_parser.Eval() << "\n"; +#else + + if (!sLine.length()) + continue; + + parser.SetExpr(sLine); + + mu::console() << std::setprecision(12); + + // The first call to eval implicitely creates the bytecode, and resets + // an internal pointer to the bytecode parsing function. Next time you call Eval + // the bytecode is used automatically! + mu::console() << "Parsing from string (slow): " << parser.Eval() << "\n"; + + // the second call automatically uses the bytecode for calculation, no interaction needed + mu::console() << "Parsing from bytecode (fast): " << parser.Eval() << "\n"; +// mu::console() << parser.GetExpr() << "\n"; +#endif + } + catch(mu::Parser::exception_type &e) + { + mu::console() << _T("\nError:\n"); + mu::console() << _T("------\n"); + mu::console() << _T("Message: ") << e.GetMsg() << _T("\n"); + mu::console() << _T("Expression: \"") << e.GetExpr() << _T("\"\n"); + mu::console() << _T("Token: \"") << e.GetToken() << _T("\"\n"); + mu::console() << _T("Position: ") << (int)e.GetPos() << _T("\n"); + mu::console() << _T("Errc: ") << std::dec << e.GetCode() << _T("\n"); + } + } // while running +} + +//--------------------------------------------------------------------------- +int main(int, char**) +{ + Splash(); + SelfTest(); +// CheckLocale(); +// CheckDiff(); + + mu::console() << _T("Enter an expression or a command:\n"); + + try + { + Calc(); + } + catch(Parser::exception_type &e) + { + // Only erros raised during the initialization will end up here + // formula related errors are treated in Calc() + console() << _T("Initialization error: ") << e.GetMsg() << endl; + console() << _T("aborting...") << endl; + string_type sBuf; + console_in() >> sBuf; + } + catch(std::exception & /*exc*/) + { + // there is no unicode compliant way to query exc.what() + // so i'll leave it for this example. + console() << _T("aborting...\n"); + } + + return 0; +} diff --git a/AMDiS/lib/muparser_v134/samples/example2/Readme.txt b/AMDiS/lib/muparser_v134/samples/example2/Readme.txt new file mode 100644 index 0000000000000000000000000000000000000000..98143429238cfd5e2859c50c1de5c354ecbebb2f --- /dev/null +++ b/AMDiS/lib/muparser_v134/samples/example2/Readme.txt @@ -0,0 +1,18 @@ + + __________ + _____ __ __\______ \_____ _______ ______ ____ _______ + / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ + | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ + |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| + \/ \/ \/ \/ + + Copyright (C) 2010 + Ingo Berg + + +This sample demonstrates using muParsers C-interface. The C-Interface +is usefull when interfacing muParser from different languages such +as C#. This sample is intended for use with the MS-Windows OS. + +You may need to copy the muparser.dll file from the ..\..\lib +folder in this directory in order to run this sample. diff --git a/AMDiS/lib/muparser_v134/samples/example2/example2.c b/AMDiS/lib/muparser_v134/samples/example2/example2.c new file mode 100644 index 0000000000000000000000000000000000000000..816cb3031415f9ef431cf20a18cf928ed5217a89 --- /dev/null +++ b/AMDiS/lib/muparser_v134/samples/example2/example2.c @@ -0,0 +1,355 @@ +#include <string.h> +#include <stdio.h> +#include <stdlib.h> + +#include "muParserDLL.h" + +#define PARSER_CONST_PI 3.141592653589793238462643 +#define PARSER_CONST_E 2.718281828459045235360287 +#define PARSER_MAXVARS 10 + + +//--------------------------------------------------------------------------- +// Callbacks for postfix operators +double Mega(double a_fVal) +{ + return a_fVal * 1.0e6; +} + +double Milli(double a_fVal) +{ + return a_fVal / 1.0e3; +} + +double ZeroArg() +{ + printf("i'm a function without arguments.\n"); + return 123; +} + +//--------------------------------------------------------------------------- +// Callbacks for infix operators +double Not(double v) { return v==0; } + +//--------------------------------------------------------------------------- +// Function callbacks +double Rnd(double v) { return v * rand() / (double)(RAND_MAX+1.0); } + +double SampleQuery(const char *szMsg) +{ + if (szMsg) + printf("%s\n", szMsg); + + return 999; +} + +double Sum(const double *a_afArg, int a_iArgc) +{ + double fRes=0; + int i=0; + + for (i=0; i<a_iArgc; ++i) + fRes += a_afArg[i]; + + return fRes; +} + +//--------------------------------------------------------------------------- +// Binarty operator callbacks +muFloat_t Add(muFloat_t v1, muFloat_t v2) +{ + return v1+v2; +} + +muFloat_t Mul(muFloat_t v1, muFloat_t v2) +{ + return v1*v2; +} + +//--------------------------------------------------------------------------- +// Factory function for creating new parser variables +// This could as well be a function performing database queries. +muFloat_t* AddVariable(const muChar_t* a_szName, void *pUserData) +{ + static double afValBuf[PARSER_MAXVARS]; // I don't want dynamic allocation here + static int iVal = 0; // so i used this buffer + + printf("Generating new variable \"%s\" (slots left: %d)\n", a_szName, PARSER_MAXVARS-iVal); + + afValBuf[iVal] = 0; + if (iVal>=PARSER_MAXVARS-1) + { + printf("Variable buffer overflow."); + return NULL; + } + + return &afValBuf[iVal++]; +} + +//--------------------------------------------------------------------------- +void Intro(muParserHandle_t hParser) +{ + printf(" __________ \n"); + printf(" _____ __ __\\______ \\_____ _______ ______ ____ _______\n"); + printf(" / \\ | | \\| ___/\\__ \\ \\_ __ \\/ ___/_/ __ \\\\_ __ \\ \n"); + printf(" | Y Y \\| | /| | / __ \\_| | \\/\\___ \\ \\ ___/ | | \\/ \n"); + printf(" |__|_| /|____/ |____| (____ /|__| /____ > \\___ >|__| \n"); + printf(" \\/ \\/ \\/ \\/ \n"); + printf(" Version %s (DLL)\n", mupGetVersion(hParser)); + printf(" (C) 2010 Ingo Berg\n"); + printf("---------------------------------------\n"); + printf("Commands:\n"); + printf(" list var - list parser variables\n"); + printf(" list exprvar - list expression variables\n"); + printf(" list const - list all numeric parser constants\n"); + printf(" locale de - switch to german locale\n"); + printf(" locale en - switch to english locale\n"); + printf(" locale reset - reset locale\n"); + printf(" quit - exits the parser\n\n"); + printf("Constants:\n"); + printf(" \"_e\" 2.718281828459045235360287\n"); + printf(" \"_pi\" 3.141592653589793238462643\n"); + printf("---------------------------------------\n"); + printf("Please enter a formula:\n"); +} + +//--------------------------------------------------------------------------- +// Callback function for parser errors +void OnError(muParserHandle_t hParser) +{ + printf("\nError:\n"); + printf("------\n"); + printf("Message: \"%s\"\n", mupGetErrorMsg(hParser)); + printf("Token: \"%s\"\n", mupGetErrorToken(hParser)); + printf("Position: %d\n", mupGetErrorPos(hParser)); + printf("Errc: %d\n", mupGetErrorCode(hParser)); +} + +//--------------------------------------------------------------------------- +void ListVar(muParserHandle_t a_hParser) +{ + int iNumVar = mupGetVarNum(a_hParser); + int i = 0; + + if (iNumVar==0) + { + printf("No variables defined\n"); + return; + } + + printf("\nExpression variables:\n"); + printf("---------------------\n"); + printf("Number: %d\n", iNumVar); + + for (i=0; i<iNumVar; ++i) + { + const muChar_t* szName = 0; + muFloat_t* pVar = 0; + + mupGetVar(a_hParser, i, &szName, &pVar); + printf("Name: %s Address: [0x%x]\n", szName, (long long)pVar); + } +} + +//--------------------------------------------------------------------------- +void ListExprVar(muParserHandle_t a_hParser) +{ + muInt_t iNumVar = mupGetExprVarNum(a_hParser), + i = 0; + + if (iNumVar==0) + { + printf("Expression dos not contain variables\n"); + return; + } + + printf("\nExpression variables:\n"); + printf("---------------------\n"); + printf("Expression: %s\n", mupGetExpr(a_hParser) ); + printf("Number: %d\n", iNumVar); + + for (i=0; i<iNumVar; ++i) + { + const muChar_t* szName = 0; + muFloat_t* pVar = 0; + + mupGetExprVar(a_hParser, i, &szName, &pVar); + printf("Name: %s Address: [0x%x]\n", szName, (long long)pVar); + } +} + +//--------------------------------------------------------------------------- +void ListConst(muParserHandle_t a_hParser) +{ + muInt_t iNumVar = mupGetConstNum(a_hParser), + i = 0; + + if (iNumVar==0) + { + printf("No constants defined\n"); + return; + } + + printf("\nParser constants:\n"); + printf("---------------------\n"); + printf("Number: %d", iNumVar); + + for (i=0; i<iNumVar; ++i) + { + const muChar_t* szName = 0; + muFloat_t fVal = 0; + + mupGetConst(a_hParser, i, &szName, &fVal); + printf(" %s = %f\n", szName, fVal); + } +} + +//--------------------------------------------------------------------------- +/** \brief Check for external keywords. +*/ +int CheckKeywords(const char *a_szLine, muParserHandle_t a_hParser) +{ + if (!strcmp(a_szLine, "quit")) + { + return -1; + } + else if (!strcmp(a_szLine,"list var")) + { + ListVar(a_hParser); + return 1; + } + else if (!strcmp(a_szLine, "list exprvar")) + { + ListExprVar(a_hParser); + return 1; + } + else if (!strcmp(a_szLine, "list const")) + { + ListConst(a_hParser); + return 1; + } + else if (!strcmp(a_szLine, "locale de")) + { + printf("Setting german locale: ArgSep=';' DecSep=',' ThousandsSep='.'\n"); + mupSetArgSep(a_hParser, ';'); + mupSetDecSep(a_hParser, ','); + mupSetThousandsSep(a_hParser, '.'); + return 1; + } + else if (!strcmp(a_szLine, "locale en")) + { + printf("Setting english locale: ArgSep=',' DecSep='.' ThousandsSep=''\n"); + mupSetArgSep(a_hParser, ','); + mupSetDecSep(a_hParser, '.'); + mupSetThousandsSep(a_hParser, 0); + return 1; + } + else if (!strcmp(a_szLine, "locale reset")) + { + printf("Resetting locale\n"); + mupResetLocale(a_hParser); + return 1; + } + + return 0; +} + +//--------------------------------------------------------------------------- +void Calc() +{ + muChar_t szLine[100]; + muFloat_t fVal = 0, + afVarVal[] = { 1, 2 }; // Values of the parser variables + muParserHandle_t hParser; + + hParser = mupCreate(); // initialize the parser + Intro(hParser); + + // Set an error handler [optional] + // the only function that does not take a parser instance handle + mupSetErrorHandler(hParser, OnError); + +//#define GERMAN_LOCALS +#ifdef GERMAN_LOCALS + mupSetArgSep(hParser, ';'); + mupSetDecSep(hParser, ','); + mupSetThousandsSep(hParser, '.'); +#else + mupSetArgSep(hParser, ','); + mupSetDecSep(hParser, '.'); +#endif + + // Set a variable factory + mupSetVarFactory(hParser, AddVariable, NULL); + + // Define parser variables and bind them to C++ variables [optional] + mupDefineConst(hParser, "const1", 1); + mupDefineConst(hParser, "const2", 2); + mupDefineStrConst(hParser, "strBuf", "Hallo welt"); + + // Define parser variables and bind them to C++ variables [optional] + mupDefineVar(hParser, "a", &afVarVal[0]); + mupDefineVar(hParser, "b", &afVarVal[1]); + + // Define postfix operators [optional] + mupDefinePostfixOprt(hParser, "M", Mega, 0); + mupDefinePostfixOprt(hParser, "m", Milli, 0); + + // Define infix operator [optional] + mupDefineInfixOprt(hParser, "!", Not, 0); + + // Define functions [optional] +// mupDefineStrFun(hParser, "query", SampleQuery, 0); // Add an unoptimizeable function + mupDefineFun0(hParser, "zero", ZeroArg, 0); + mupDefineFun1(hParser, "rnd", Rnd, 0); // Add an unoptimizeable function + mupDefineFun1(hParser, "rnd2", Rnd, 1); + mupDefineMultFun(hParser, "_sum", Sum, 0); // "sum" is already a default function + + // Define binary operators [optional] + mupDefineOprt(hParser, "add", Add, 0, muOPRT_ASCT_LEFT, 0); + mupDefineOprt(hParser, "mul", Mul, 1, muOPRT_ASCT_LEFT, 0); + + while ( fgets(szLine, 99, stdin) ) + { + szLine[strlen(szLine)-1] = 0; // overwrite the newline + + switch(CheckKeywords(szLine, hParser)) + { + case 0: break; // no keyword found; parse the line + case 1: continue; // A Keyword was found do not parse the line + case -1: return; // abort the application + } + + mupSetExpr(hParser, szLine); + + fVal = mupEval(hParser); + + + // Without an Error handler function + // you must use this for error treatment: + //if (mupError(hParser)) + //{ + // printf("\nError:\n"); + // printf("------\n"); + // printf("Message: %s\n", mupGetErrorMsg(hParser) ); + // printf("Token: %s\n", mupGetErrorToken(hParser) ); + // printf("Position: %s\n", mupGetErrorPos(hParser) ); + // printf("Errc: %s\n", mupGetErrorCode(hParser) ); + // continue; + //} + + if (!mupError(hParser)) + printf("%f\n", fVal); + + } // while + + // finalle free the parser ressources + mupRelease(hParser); +} + +//--------------------------------------------------------------------------- +int main(int argc, char *argv[]) +{ + Calc(); + printf("done..."); +} diff --git a/AMDiS/lib/muparser_v134/src/muParser.cpp b/AMDiS/lib/muparser_v134/src/muParser.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9ee27d00a94c4eb433581789a2bee6f7866322ca --- /dev/null +++ b/AMDiS/lib/muparser_v134/src/muParser.cpp @@ -0,0 +1,394 @@ +/* + __________ + _____ __ __\______ \_____ _______ ______ ____ _______ + / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ + | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ + |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| + \/ \/ \/ \/ + + Copyright (C) 2010 Ingo Berg + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +#include "muParser.h" + +//--- Standard includes ------------------------------------------------------------------------ +#include <cmath> +#include <algorithm> +#include <numeric> + +/** \brief Pi (what else?). */ +#define PARSER_CONST_PI 3.141592653589793238462643 + +/** \brief The eulerian number. */ +#define PARSER_CONST_E 2.718281828459045235360287 + +using namespace std; + +/** \file + \brief Implementation of the standard floating point parser. +*/ + + +/** \brief Namespace for mathematical applications. */ +namespace mu +{ + std::locale Parser::s_locale; + + //--------------------------------------------------------------------------- + // Trigonometric function + value_type Parser::Sin(value_type v) { return sin(v); } + value_type Parser::Cos(value_type v) { return cos(v); } + value_type Parser::Tan(value_type v) { return tan(v); } + value_type Parser::ASin(value_type v) { return asin(v); } + value_type Parser::ACos(value_type v) { return acos(v); } + value_type Parser::ATan(value_type v) { return atan(v); } + value_type Parser::Sinh(value_type v) { return sinh(v); } + value_type Parser::Cosh(value_type v) { return cosh(v); } + value_type Parser::Tanh(value_type v) { return tanh(v); } + value_type Parser::ASinh(value_type v) { return log(v + sqrt(v * v + 1)); } + value_type Parser::ACosh(value_type v) { return log(v + sqrt(v * v - 1)); } + value_type Parser::ATanh(value_type v) { return ((value_type)0.5 * log((1 + v) / (1 - v))); } + + //--------------------------------------------------------------------------- + // Logarithm functions + value_type Parser::Log2(value_type v) { return log(v)/log((value_type)2); } // Logarithm base 2 + value_type Parser::Log10(value_type v) { return log10(v); } // Logarithm base 10 + value_type Parser::Ln(value_type v) { return log(v); } // Logarithm base e (natural logarithm) + + //--------------------------------------------------------------------------- + // misc + value_type Parser::Exp(value_type v) { return exp(v); } + value_type Parser::Abs(value_type v) { return fabs(v); } + value_type Parser::Sqrt(value_type v) { return sqrt(v); } + value_type Parser::Rint(value_type v) { return floor(v + (value_type)0.5); } + value_type Parser::Sign(value_type v) { return (value_type)((v<0) ? -1 : (v>0) ? 1 : 0); } + + //--------------------------------------------------------------------------- + /** \brief Conditional (if then else). + \param v1 Condition + \param v2 First value + \param v3 Second value + \return v2 if v1!=0 v3 otherwise. + */ + value_type Parser::Ite(value_type v1, value_type v2, value_type v3) + { + return (v1) ? v2 : v3; + } + + //--------------------------------------------------------------------------- + /** \brief Callback for the unary minus operator. + \param v The value to negate + \return -v + */ + value_type Parser::UnaryMinus(value_type v) + { + return -v; + } + + //--------------------------------------------------------------------------- + /** \brief Callback for adding multiple values. + \param [in] a_afArg Vector with the function arguments + \param [in] a_iArgc The size of a_afArg + */ + value_type Parser::Sum(const value_type *a_afArg, int a_iArgc) + { + if (!a_iArgc) + throw exception_type(_T("too few arguments for function sum.")); + + value_type fRes=0; + for (int i=0; i<a_iArgc; ++i) fRes += a_afArg[i]; + return fRes; + } + + //--------------------------------------------------------------------------- + /** \brief Callback for averaging multiple values. + \param [in] a_afArg Vector with the function arguments + \param [in] a_iArgc The size of a_afArg + */ + value_type Parser::Avg(const value_type *a_afArg, int a_iArgc) + { + if (!a_iArgc) + throw exception_type(_T("too few arguments for function sum.")); + + value_type fRes=0; + for (int i=0; i<a_iArgc; ++i) fRes += a_afArg[i]; + return fRes/(value_type)a_iArgc; + } + + + //--------------------------------------------------------------------------- + /** \brief Callback for determining the minimum value out of a vector. + \param [in] a_afArg Vector with the function arguments + \param [in] a_iArgc The size of a_afArg + */ + value_type Parser::Min(const value_type *a_afArg, int a_iArgc) + { + if (!a_iArgc) + throw exception_type(_T("too few arguments for function min.")); + + value_type fRes=a_afArg[0]; + for (int i=0; i<a_iArgc; ++i) fRes = std::min(fRes, a_afArg[i]); + + return fRes; + } + + + //--------------------------------------------------------------------------- + /** \brief Callback for determining the maximum value out of a vector. + \param [in] a_afArg Vector with the function arguments + \param [in] a_iArgc The size of a_afArg + */ + value_type Parser::Max(const value_type *a_afArg, int a_iArgc) + { + if (!a_iArgc) + throw exception_type(_T("too few arguments for function min.")); + + value_type fRes=a_afArg[0]; + for (int i=0; i<a_iArgc; ++i) fRes = std::max(fRes, a_afArg[i]); + + return fRes; + } + + + //--------------------------------------------------------------------------- + /** \brief Default value recognition callback. + \param [in] a_szExpr Pointer to the expression + \param [in, out] a_iPos Pointer to an index storing the current position within the expression + \param [out] a_fVal Pointer where the value should be stored in case one is found. + \return 1 if a value was found 0 otherwise. + */ + int Parser::IsVal(const char_type* a_szExpr, int *a_iPos, value_type *a_fVal) + { + value_type fVal(0); + + stringstream_type stream(a_szExpr); + stream.seekg(0); // todo: check if this really is necessary + stream.imbue(Parser::s_locale); + stream >> fVal; + stringstream_type::pos_type iEnd = stream.tellg(); // Position after reading + + if (iEnd==(stringstream_type::pos_type)-1) + return 0; + + *a_iPos += (int)iEnd; + *a_fVal = fVal; + return 1; + } + + + //--------------------------------------------------------------------------- + /** \brief Constructor. + + Call ParserBase class constructor and trigger Function, Operator and Constant initialization. + */ + Parser::Parser() + :ParserBase() + { + // For some reason locale initialization in the dll fails when done in the static + // constructor. I have to do it here + static bool bInitLocale = true; + if (bInitLocale) + { + Parser::s_locale = std::locale(std::locale::classic(), new change_dec_sep<char_type>('.')); + bInitLocale = false; + } + + AddValIdent(IsVal); + + InitCharSets(); + InitFun(); + InitConst(); + InitOprt(); + } + + //--------------------------------------------------------------------------- + /** \brief Define the character sets. + \sa DefineNameChars, DefineOprtChars, DefineInfixOprtChars + + This function is used for initializing the default character sets that define + the characters to be useable in function and variable names and operators. + */ + void Parser::InitCharSets() + { + DefineNameChars( _T("0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") ); + DefineOprtChars( _T("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+-*^/?<>=#!$%&|~'_{}") ); + DefineInfixOprtChars( _T("/+-*^?<>=#!$%&|~'_") ); + } + + //--------------------------------------------------------------------------- + /** \brief Initialize the default functions. */ + void Parser::InitFun() + { + // trigonometric functions + DefineFun(_T("sin"), Sin); + DefineFun(_T("cos"), Cos); + DefineFun(_T("tan"), Tan); + // arcus functions + DefineFun(_T("asin"), ASin); + DefineFun(_T("acos"), ACos); + DefineFun(_T("atan"), ATan); + // hyperbolic functions + DefineFun(_T("sinh"), Sinh); + DefineFun(_T("cosh"), Cosh); + DefineFun(_T("tanh"), Tanh); + // arcus hyperbolic functions + DefineFun(_T("asinh"), ASinh); + DefineFun(_T("acosh"), ACosh); + DefineFun(_T("atanh"), ATanh); + // Logarithm functions + DefineFun(_T("log2"), Log2); + DefineFun(_T("log10"), Log10); + DefineFun(_T("log"), Log10); + DefineFun(_T("ln"), Ln); + // misc + DefineFun(_T("exp"), Exp); + DefineFun(_T("sqrt"), Sqrt); + DefineFun(_T("sign"), Sign); + DefineFun(_T("rint"), Rint); + DefineFun(_T("abs"), Abs); + DefineFun(_T("if"), Ite); + // Functions with variable number of arguments + DefineFun(_T("sum"), Sum); + DefineFun(_T("avg"), Avg); + DefineFun(_T("min"), Min); + DefineFun(_T("max"), Max); + } + + //--------------------------------------------------------------------------- + /** \brief Initialize constants. + + By default the parser recognizes two constants. Pi ("pi") and the eulerian + number ("_e"). + */ + void Parser::InitConst() + { + DefineConst(_T("_pi"), (value_type)PARSER_CONST_PI); + DefineConst(_T("_e"), (value_type)PARSER_CONST_E); + } + + //--------------------------------------------------------------------------- + /** \brief Set the decimal separator. + \param cDecSep Decimal separator as a character value. + \sa SetThousandsSep + + By default muparser uses the "C" locale. The decimal separator of this + locale is overwritten by the one provided here. + */ + void Parser::SetDecSep(char_type cDecSep) + { + char_type cThousandsSep = std::use_facet< change_dec_sep<char_type> >(s_locale).thousands_sep(); + s_locale = std::locale(std::locale("C"), new change_dec_sep<char_type>(cDecSep, cThousandsSep)); + } + + //--------------------------------------------------------------------------- + /** \brief Sets the thousands operator. + \param cThousandsSep The thousands separator as a character + \sa SetDecSep + + By default muparser uses the "C" locale. The thousands separator of this + locale is overwritten by the one provided here. + */ + void Parser::SetThousandsSep(char_type cThousandsSep) + { + char_type cDecSep = std::use_facet< change_dec_sep<char_type> >(s_locale).decimal_point(); + s_locale = std::locale(std::locale("C"), new change_dec_sep<char_type>(cDecSep, cThousandsSep)); + } + + //--------------------------------------------------------------------------- + /** \brief Resets the locale. + + The default locale used "." as decimal separator, no thousands separator and + "," as function argument separator. + */ + void Parser::ResetLocale() + { + s_locale = std::locale(std::locale("C"), new change_dec_sep<char_type>('.')); + SetArgSep(','); + } + + //--------------------------------------------------------------------------- + /** \brief Initialize operators. + + By default only the unary minus operator is added. + */ + void Parser::InitOprt() + { + DefineInfixOprt(_T("-"), UnaryMinus); + } + + //--------------------------------------------------------------------------- + void Parser::OnDetectVar(string_type * /*pExpr*/, int & /*nStart*/, int & /*nEnd*/) + { + // this is just sample code to illustrate modifying variable names on the fly. + // I'm not sure anyone really needs such a feature... + /* + + + string sVar(pExpr->begin()+nStart, pExpr->begin()+nEnd); + string sRepl = std::string("_") + sVar + "_"; + + int nOrigVarEnd = nEnd; + cout << "variable detected!\n"; + cout << " Expr: " << *pExpr << "\n"; + cout << " Start: " << nStart << "\n"; + cout << " End: " << nEnd << "\n"; + cout << " Var: \"" << sVar << "\"\n"; + cout << " Repl: \"" << sRepl << "\"\n"; + nEnd = nStart + sRepl.length(); + cout << " End: " << nEnd << "\n"; + pExpr->replace(pExpr->begin()+nStart, pExpr->begin()+nOrigVarEnd, sRepl); + cout << " New expr: " << *pExpr << "\n"; + */ + } + + //--------------------------------------------------------------------------- + /** \brief Numerically differentiate with regard to a variable. + \param [in] a_Var Pointer to the differentiation variable. + \param [in] a_fPos Position at which the differentiation should take place. + \param [in] a_fEpsilon Epsilon used for the numerical differentiation. + + Numerical differentiation uses a 5 point operator yielding a 4th order + formula. The default value for epsilon is 0.00074 which is + numerical_limits<double>::epsilon() ^ (1/5) as suggested in the muparser + forum: + + http://sourceforge.net/forum/forum.php?thread_id=1994611&forum_id=462843 + */ + value_type Parser::Diff(value_type *a_Var, + value_type a_fPos, + value_type a_fEpsilon) const + { + value_type fRes(0), + fBuf(*a_Var), + f[4] = {0,0,0,0}, + fEpsilon(a_fEpsilon); + + // Backwards compatible calculation of epsilon inc case the user doesnt provide + // his own epsilon + if (fEpsilon==0) + fEpsilon = (a_fPos==0) ? (value_type)1e-10 : (value_type)1e-7 * a_fPos; + + *a_Var = a_fPos+2 * fEpsilon; f[0] = Eval(); + *a_Var = a_fPos+1 * fEpsilon; f[1] = Eval(); + *a_Var = a_fPos-1 * fEpsilon; f[2] = Eval(); + *a_Var = a_fPos-2 * fEpsilon; f[3] = Eval(); + *a_Var = fBuf; // restore variable + + fRes = (-f[0] + 8*f[1] - 8*f[2] + f[3]) / (12*fEpsilon); + return fRes; + } +} // namespace mu diff --git a/AMDiS/lib/muparser_v134/src/muParserBase.cpp b/AMDiS/lib/muparser_v134/src/muParserBase.cpp new file mode 100644 index 0000000000000000000000000000000000000000..396761ccdf5ca1d7171cd688c07d1aa99b5a0043 --- /dev/null +++ b/AMDiS/lib/muparser_v134/src/muParserBase.cpp @@ -0,0 +1,1632 @@ +/* + __________ + _____ __ __\______ \_____ _______ ______ ____ _______ + / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ + | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ + |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| + \/ \/ \/ \/ + Copyright (C) 2010 Ingo Berg + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include "muParserBase.h" + +//--- Standard includes ------------------------------------------------------------------------ +#include <cassert> +#include <cmath> +#include <memory> +#include <vector> +#include <deque> +#include <sstream> +#include <locale> + +using namespace std; + +/** \file + \brief This file contains the basic implementation of the muparser engine. +*/ + +namespace mu +{ + //------------------------------------------------------------------------------ + /** \brief Identifiers for built in binary operators. + + When defining custom binary operators with #AddOprt(...) make sure not to choose + names conflicting with these definitions. + */ + const char_type* ParserBase::c_DefaultOprt[] = + { + _T("<="), _T(">="), _T("!="), + _T("=="), _T("<"), _T(">"), + _T("+"), _T("-"), _T("*"), + _T("/"), _T("^"), _T("and"), + _T("or"), _T("xor"), _T("="), + _T("("), _T(")"), 0 + }; + + //------------------------------------------------------------------------------ + /** \brief Constructor. + \param a_szFormula the formula to interpret. + \throw ParserException if a_szFormula is null. + */ + ParserBase::ParserBase() + :m_pParseFormula(&ParserBase::ParseString) + ,m_pCmdCode(0) + ,m_vByteCode() + ,m_vStringBuf() + ,m_pTokenReader() + ,m_FunDef() + ,m_PostOprtDef() + ,m_InfixOprtDef() + ,m_OprtDef() + ,m_ConstDef() + ,m_StrVarDef() + ,m_VarDef() + ,m_bOptimize(true) + ,m_bUseByteCode(true) + ,m_bBuiltInOp(true) + ,m_sNameChars() + ,m_sOprtChars() + ,m_sInfixOprtChars() + ,m_vStackBuffer() + ,m_nFinalResultIdx(0) + { + InitTokenReader(); + } + + //--------------------------------------------------------------------------- + /** \brief Copy constructor. + + Tha parser can be safely copy constructed but the bytecode is reset during + copy construction. + */ + ParserBase::ParserBase(const ParserBase &a_Parser) + :m_pParseFormula(&ParserBase::ParseString) + ,m_pCmdCode(0) + ,m_vByteCode() + ,m_vStringBuf() + ,m_pTokenReader() + ,m_FunDef() + ,m_PostOprtDef() + ,m_InfixOprtDef() + ,m_OprtDef() + ,m_ConstDef() + ,m_StrVarDef() + ,m_VarDef() + ,m_bOptimize(true) + ,m_bUseByteCode(true) + ,m_bBuiltInOp(true) + { + m_pTokenReader.reset(new token_reader_type(this)); + Assign(a_Parser); + } + + //--------------------------------------------------------------------------- + ParserBase::~ParserBase() + {} + + //--------------------------------------------------------------------------- + /** \brief Assignement operator. + + Implemented by calling Assign(a_Parser). Self assignement is suppressed. + \param a_Parser Object to copy to this. + \return *this + \throw nothrow + */ + ParserBase& ParserBase::operator=(const ParserBase &a_Parser) + { + Assign(a_Parser); + return *this; + } + + //--------------------------------------------------------------------------- + /** \brief Copy state of a parser object to this. + + Clears Variables and Functions of this parser. + Copies the states of all internal variables. + Resets parse function to string parse mode. + + \param a_Parser the source object. + */ + void ParserBase::Assign(const ParserBase &a_Parser) + { + if (&a_Parser==this) + return; + + // Don't copy bytecode instead cause the parser to create new bytecode + // by resetting the parse function. + ReInit(); + + m_ConstDef = a_Parser.m_ConstDef; // Copy user define constants + m_VarDef = a_Parser.m_VarDef; // Copy user defined variables + m_bOptimize = a_Parser.m_bOptimize; + m_bUseByteCode = a_Parser.m_bUseByteCode; + m_bBuiltInOp = a_Parser.m_bBuiltInOp; + m_vStringBuf = a_Parser.m_vStringBuf; + m_vStackBuffer = a_Parser.m_vStackBuffer; + m_nFinalResultIdx = a_Parser.m_nFinalResultIdx; + m_StrVarDef = a_Parser.m_StrVarDef; + m_vStringVarBuf = a_Parser.m_vStringVarBuf; + m_pTokenReader.reset(a_Parser.m_pTokenReader->Clone(this)); + + // Copy function and operator callbacks + m_FunDef = a_Parser.m_FunDef; // Copy function definitions + m_PostOprtDef = a_Parser.m_PostOprtDef; // post value unary operators + m_InfixOprtDef = a_Parser.m_InfixOprtDef; // unary operators for infix notation + m_OprtDef = a_Parser.m_OprtDef; // binary operators + + m_sNameChars = a_Parser.m_sNameChars; + m_sOprtChars = a_Parser.m_sOprtChars; + m_sInfixOprtChars = a_Parser.m_sInfixOprtChars; + } + + //--------------------------------------------------------------------------- + /** \brief Initialize the token reader. + + Create new token reader object and submit pointers to function, operator, + constant and variable definitions. + + \post m_pTokenReader.get()!=0 + \throw nothrow + */ + void ParserBase::InitTokenReader() + { + m_pTokenReader.reset(new token_reader_type(this)); + } + + //--------------------------------------------------------------------------- + /** \brief Reset parser to string parsing mode and clear internal buffers. + + Clear bytecode, reset the token reader. + \throw nothrow + */ + void ParserBase::ReInit() const + { + m_pParseFormula = &ParserBase::ParseString; + m_vStringBuf.clear(); + m_vByteCode.clear(); + m_pTokenReader->ReInit(); + } + + //--------------------------------------------------------------------------- + void ParserBase::OnDetectVar(string_type * /*pExpr*/, int & /*nStart*/, int & /*nEnd*/) + {} + + //--------------------------------------------------------------------------- + /** \brief Returns the version of muparser. + + Format is as follows: "MAJOR.MINOR (OPTIONAL TEXT)" + */ + string_type ParserBase::GetVersion() const + { + return MUP_VERSION; + } + + //--------------------------------------------------------------------------- + /** \brief Add a value parsing function. + + When parsing an expression muParser tries to detect values in the expression + string using different valident callbacks. Thuis it's possible to parse + for hex values, binary values and floating point values. + */ + void ParserBase::AddValIdent(identfun_type a_pCallback) + { + m_pTokenReader->AddValIdent(a_pCallback); + } + + //--------------------------------------------------------------------------- + /** \brief Set a function that can create variable pointer for unknown expression variables. + \param a_pFactory A pointer to the variable factory. + \param pUserData A user defined context pointer. + */ + void ParserBase::SetVarFactory(facfun_type a_pFactory, void *pUserData) + { + m_pTokenReader->SetVarCreator(a_pFactory, pUserData); + } + + //--------------------------------------------------------------------------- + /** \brief Add a function or operator callback to the parser. */ + void ParserBase::AddCallback( const string_type &a_strName, + const ParserCallback &a_Callback, + funmap_type &a_Storage, + const char_type *a_szCharSet ) + { + if (a_Callback.GetAddr()==0) + Error(ecINVALID_FUN_PTR); + + const funmap_type *pFunMap = &a_Storage; + + // Check for conflicting operator or function names + if ( pFunMap!=&m_FunDef && m_FunDef.find(a_strName)!=m_FunDef.end() ) + Error(ecNAME_CONFLICT); + + if ( pFunMap!=&m_PostOprtDef && m_PostOprtDef.find(a_strName)!=m_PostOprtDef.end() ) + Error(ecNAME_CONFLICT); + + if ( pFunMap!=&m_InfixOprtDef && pFunMap!=&m_OprtDef && m_InfixOprtDef.find(a_strName)!=m_InfixOprtDef.end() ) + Error(ecNAME_CONFLICT); + + if ( pFunMap!=&m_InfixOprtDef && pFunMap!=&m_OprtDef && m_OprtDef.find(a_strName)!=m_OprtDef.end() ) + Error(ecNAME_CONFLICT); + + CheckOprt(a_strName, a_Callback, a_szCharSet); + a_Storage[a_strName] = a_Callback; + ReInit(); + } + + //--------------------------------------------------------------------------- + /** \brief Check if a name contains invalid characters. + + \throw ParserException if the name contains invalid charakters. + */ + void ParserBase::CheckOprt(const string_type &a_sName, + const ParserCallback &a_Callback, + const string_type &a_szCharSet) const + { + if ( !a_sName.length() || + (a_sName.find_first_not_of(a_szCharSet)!=string_type::npos) || + (a_sName[0]>='0' && a_sName[0]<='9')) + { + switch(a_Callback.GetCode()) + { + case cmOPRT_POSTFIX: Error(ecINVALID_POSTFIX_IDENT, -1, a_sName); + case cmOPRT_INFIX: Error(ecINVALID_INFIX_IDENT, -1, a_sName); + default: Error(ecINVALID_NAME, -1, a_sName); + } + } + } + + //--------------------------------------------------------------------------- + /** \brief Check if a name contains invalid characters. + + \throw ParserException if the name contains invalid charakters. + */ + void ParserBase::CheckName(const string_type &a_sName, + const string_type &a_szCharSet) const + { + if ( !a_sName.length() || + (a_sName.find_first_not_of(a_szCharSet)!=string_type::npos) || + (a_sName[0]>='0' && a_sName[0]<='9')) + { + Error(ecINVALID_NAME); + } + } + + //--------------------------------------------------------------------------- + /** \brief Set the formula. + \param a_strFormula Formula as string_type + \throw ParserException in case of syntax errors. + + Triggers first time calculation thus the creation of the bytecode and + scanning of used variables. + */ + void ParserBase::SetExpr(const string_type &a_sExpr) + { + // Check locale compatibility + std::locale loc; + if (m_pTokenReader->GetArgSep()==std::use_facet<numpunct<char_type> >(loc).decimal_point()) + Error(ecLOCALE); + + // <ibg> 20060222: Bugfix for Borland-Kylix: + // adding a space to the expression will keep Borlands KYLIX from going wild + // when calling tellg on a stringstream created from the expression after + // reading a value at the end of an expression. (mu::Parser::IsVal function) + // (tellg returns -1 otherwise causing the parser to ignore the value) + string_type sBuf(a_sExpr + _T(" ") ); + m_pTokenReader->SetFormula(sBuf); + ReInit(); + } + + //--------------------------------------------------------------------------- + /** \brief Get the default symbols used for the built in operators. + \sa c_DefaultOprt + */ + const char_type** ParserBase::GetOprtDef() const + { + return (const char_type **)(&c_DefaultOprt[0]); + } + + //--------------------------------------------------------------------------- + /** \brief Define the set of valid characters to be used in names of + functions, variables, constants. + */ + void ParserBase::DefineNameChars(const char_type *a_szCharset) + { + m_sNameChars = a_szCharset; + } + + //--------------------------------------------------------------------------- + /** \brief Define the set of valid characters to be used in names of + binary operators and postfix operators. + */ + void ParserBase::DefineOprtChars(const char_type *a_szCharset) + { + m_sOprtChars = a_szCharset; + } + + //--------------------------------------------------------------------------- + /** \brief Define the set of valid characters to be used in names of + infix operators. + */ + void ParserBase::DefineInfixOprtChars(const char_type *a_szCharset) + { + m_sInfixOprtChars = a_szCharset; + } + + //--------------------------------------------------------------------------- + /** \brief Virtual function that defines the characters allowed in name identifiers. + \sa #ValidOprtChars, #ValidPrefixOprtChars + */ + const char_type* ParserBase::ValidNameChars() const + { + assert(m_sNameChars.size()); + return m_sNameChars.c_str(); + } + + //--------------------------------------------------------------------------- + /** \brief Virtual function that defines the characters allowed in operator definitions. + \sa #ValidNameChars, #ValidPrefixOprtChars + */ + const char_type* ParserBase::ValidOprtChars() const + { + assert(m_sOprtChars.size()); + return m_sOprtChars.c_str(); + } + + //--------------------------------------------------------------------------- + /** \brief Virtual function that defines the characters allowed in infix operator definitions. + \sa #ValidNameChars, #ValidOprtChars + */ + const char_type* ParserBase::ValidInfixOprtChars() const + { + assert(m_sInfixOprtChars.size()); + return m_sInfixOprtChars.c_str(); + } + + //--------------------------------------------------------------------------- + /** \brief Add a user defined operator. + \post Will reset the Parser to string parsing mode. + */ + void ParserBase::DefinePostfixOprt(const string_type &a_sName, + fun_type1 a_pFun, + bool a_bAllowOpt) + { + AddCallback(a_sName, + ParserCallback(a_pFun, a_bAllowOpt, prPOSTFIX, cmOPRT_POSTFIX), + m_PostOprtDef, + ValidOprtChars() ); + } + + //--------------------------------------------------------------------------- + /** \brief Initialize user defined functions. + + Calls the virtual functions InitFun(), InitConst() and InitOprt(). + */ + void ParserBase::Init() + { + InitCharSets(); + InitFun(); + InitConst(); + InitOprt(); + } + + //--------------------------------------------------------------------------- + /** \brief Add a user defined operator. + \post Will reset the Parser to string parsing mode. + \param [in] a_sName operator Identifier + \param [in] a_pFun Operator callback function + \param [in] a_iPrec Operator Precedence (default=prSIGN) + \param [in] a_bAllowOpt True if operator is volatile (default=false) + \sa EPrec + */ + void ParserBase::DefineInfixOprt(const string_type &a_sName, + fun_type1 a_pFun, + int a_iPrec, + bool a_bAllowOpt) + { + AddCallback(a_sName, + ParserCallback(a_pFun, a_bAllowOpt, a_iPrec, cmOPRT_INFIX), + m_InfixOprtDef, + ValidInfixOprtChars() ); + } + + + //--------------------------------------------------------------------------- + /** \brief Define a binary operator. + \param [in] a_pFun Pointer to the callback function. + \param [in] a_iPrec Precedence of the operator. + \param [in] a_bAllowOpt If this is true the operator may be optimized away. + */ + void ParserBase::DefineOprt( const string_type &a_sName, + fun_type2 a_pFun, + unsigned a_iPrec, + EOprtAssociativity a_eAssociativity, + bool a_bAllowOpt ) + { + // Check for conflicts with built in operator names + for (int i=0; m_bBuiltInOp && i<cmARG_SEP; ++i) + if (a_sName == string_type(c_DefaultOprt[i])) + Error(ecBUILTIN_OVERLOAD, -1, a_sName); + + AddCallback(a_sName, + ParserCallback(a_pFun, a_bAllowOpt, a_iPrec, a_eAssociativity), + m_OprtDef, + ValidOprtChars() ); + } + + //--------------------------------------------------------------------------- + /** \brief Define a new string constant. + \param [in] a_strName The name of the constant. + \param [in] a_strVal the value of the constant. + */ + void ParserBase::DefineStrConst(const string_type &a_strName, const string_type &a_strVal) + { + // Test if a constant with that names already exists + if (m_StrVarDef.find(a_strName)!=m_StrVarDef.end()) + Error(ecNAME_CONFLICT); + + CheckName(a_strName, ValidNameChars()); + + m_vStringVarBuf.push_back(a_strVal); // Store variable string in internal buffer + m_StrVarDef[a_strName] = m_vStringBuf.size(); // bind buffer index to variable name + + ReInit(); + } + + //--------------------------------------------------------------------------- + /** \brief Add a user defined variable. + \param [in] a_sName the variable name + \param [in] a_pVar A pointer to the variable vaule. + \post Will reset the Parser to string parsing mode. + \pre [assert] a_fVar!=0 + \throw ParserException in case the name contains invalid signs. + */ + void ParserBase::DefineVar(const string_type &a_sName, value_type *a_pVar) + { + if (a_pVar==0) + Error(ecINVALID_VAR_PTR); + + // Test if a constant with that names already exists + if (m_ConstDef.find(a_sName)!=m_ConstDef.end()) + Error(ecNAME_CONFLICT); + + CheckName(a_sName, ValidNameChars()); + m_VarDef[a_sName] = a_pVar; + ReInit(); + } + + //--------------------------------------------------------------------------- + /** \brief Add a user defined constant. + \param [in] a_sName The name of the constant. + \param [in] a_fVal the value of the constant. + \post Will reset the Parser to string parsing mode. + \throw ParserException in case the name contains invalid signs. + */ + void ParserBase::DefineConst(const string_type &a_sName, value_type a_fVal) + { + CheckName(a_sName, ValidNameChars()); + m_ConstDef[a_sName] = a_fVal; + ReInit(); + } + + //--------------------------------------------------------------------------- + /** \brief Get operator priority. + \throw ParserException if a_Oprt is no operator code + */ + int ParserBase::GetOprtPrecedence(const token_type &a_Tok) const + { + switch (a_Tok.GetCode()) + { + // built in operators + case cmEND: return -5; + case cmARG_SEP: return -4; + case cmBO : + case cmBC : return -2; + case cmASSIGN: return -1; + case cmAND: + case cmXOR: + case cmOR: return prLOGIC; + case cmLT: + case cmGT: + case cmLE: + case cmGE: + case cmNEQ: + case cmEQ: return prCMP; + case cmADD: + case cmSUB: return prADD_SUB; + case cmMUL: + case cmDIV: return prMUL_DIV; + case cmPOW: return prPOW; + + // user defined binary operators + case cmOPRT_INFIX: + case cmOPRT_BIN: return a_Tok.GetPri(); + default: Error(ecINTERNAL_ERROR, 5); + return 999; + } + } + + //--------------------------------------------------------------------------- + /** \brief Get operator priority. + \throw ParserException if a_Oprt is no operator code + */ + EOprtAssociativity ParserBase::GetOprtAssociativity(const token_type &a_Tok) const + { + switch (a_Tok.GetCode()) + { + case cmASSIGN: + case cmAND: + case cmXOR: + case cmOR: + case cmLT: + case cmGT: + case cmLE: + case cmGE: + case cmNEQ: + case cmEQ: + case cmADD: + case cmSUB: + case cmMUL: + case cmDIV: return oaLEFT; + case cmPOW: return oaRIGHT; + case cmOPRT_BIN: return a_Tok.GetAssociativity(); + default: return oaNONE; + } + } + + //--------------------------------------------------------------------------- + /** \brief Return a map containing the used variables only. */ + const varmap_type& ParserBase::GetUsedVar() const + { + try + { + m_pTokenReader->IgnoreUndefVar(true); + ParseString(); // implicitely create or update the map with the + // used variables stored in the token reader if not already done + m_pTokenReader->IgnoreUndefVar(false); + } + catch(exception_type &e) + { + m_pTokenReader->IgnoreUndefVar(false); + throw e; + } + + // Make sure to stay in string parse mode, dont call ReInit() + // because it deletes the array with the used variables + m_pParseFormula = &ParserBase::ParseString; + + return m_pTokenReader->GetUsedVar(); + } + + //--------------------------------------------------------------------------- + /** \brief Return a map containing the used variables only. */ + const varmap_type& ParserBase::GetVar() const + { + return m_VarDef; + } + + //--------------------------------------------------------------------------- + /** \brief Return a map containing all parser constants. */ + const valmap_type& ParserBase::GetConst() const + { + return m_ConstDef; + } + + //--------------------------------------------------------------------------- + /** \brief Return prototypes of all parser functions. + \return #m_FunDef + \sa FunProt + \throw nothrow + + The return type is a map of the public type #funmap_type containing the prototype + definitions for all numerical parser functions. String functions are not part of + this map. The Prototype definition is encapsulated in objects of the class FunProt + one per parser function each associated with function names via a map construct. + */ + const funmap_type& ParserBase::GetFunDef() const + { + return m_FunDef; + } + + //--------------------------------------------------------------------------- + /** \brief Retrieve the formula. */ + const string_type& ParserBase::GetExpr() const + { + return m_pTokenReader->GetExpr(); + } + + //--------------------------------------------------------------------------- + ParserBase::token_type ParserBase::ApplyNumFunc(const token_type &a_FunTok, + const std::vector<token_type> &a_vArg) const + { + token_type valTok; + int iArgCount = (unsigned)a_vArg.size(); + void *pFunc = a_FunTok.GetFuncAddr(); + assert(pFunc); + + // Collect the function arguments from the value stack + switch(a_FunTok.GetArgCount()) + { + case -1: + // Function with variable argument count + // copy arguments into a vector<value_type> + { + if (iArgCount==0) + Error(ecTOO_FEW_PARAMS, m_pTokenReader->GetPos(), a_FunTok.GetAsString()); + + std::vector<value_type> vArg(iArgCount); + for (int i=0; i<iArgCount; ++i) + vArg[iArgCount-(i+1)] = a_vArg[i].GetVal(); + + valTok.SetVal( ((multfun_type)a_FunTok.GetFuncAddr())(&vArg[0], (int)vArg.size()) ); + } + break; + + case 0: valTok.SetVal( ((fun_type0)pFunc)() ); break; + case 1: valTok.SetVal( ((fun_type1)pFunc)(a_vArg[0].GetVal()) ); break; + case 2: valTok.SetVal( ((fun_type2)pFunc)(a_vArg[1].GetVal(), + a_vArg[0].GetVal()) ); break; + case 3: valTok.SetVal( ((fun_type3)pFunc)(a_vArg[2].GetVal(), + a_vArg[1].GetVal(), + a_vArg[0].GetVal()) ); break; + case 4: valTok.SetVal( ((fun_type4)pFunc)(a_vArg[3].GetVal(), + a_vArg[2].GetVal(), + a_vArg[1].GetVal(), + a_vArg[0].GetVal()) ); break; + case 5: valTok.SetVal( ((fun_type5)pFunc)(a_vArg[4].GetVal(), + a_vArg[3].GetVal(), + a_vArg[2].GetVal(), + a_vArg[1].GetVal(), + a_vArg[0].GetVal()) ); break; + default: Error(ecINTERNAL_ERROR, 6); + } + + // Find out if the result will depend on a variable + /** \todo remove this loop, put content in the loop that takes the argument values. + + (Attention: SetVal will reset Flags.) + */ + bool bVolatile = a_FunTok.IsFlagSet(token_type::flVOLATILE); + for (int i=0; (bVolatile==false) && (i<iArgCount); ++i) + bVolatile |= a_vArg[i].IsFlagSet(token_type::flVOLATILE); + + if (bVolatile) + valTok.AddFlags(token_type::flVOLATILE); + + #if defined(_MSC_VER) + #pragma warning( disable : 4311 ) + #endif + + // Formula optimization + if ( m_bOptimize && + !valTok.IsFlagSet(token_type::flVOLATILE) && + !a_FunTok.IsFlagSet(token_type::flVOLATILE) ) + { + m_vByteCode.RemoveValEntries(iArgCount); + m_vByteCode.AddVal( valTok.GetVal() ); + } + else + { + // operation dosnt depends on a variable or the function is flagged unoptimizeable + // we cant optimize here... + m_vByteCode.AddFun(pFunc, (a_FunTok.GetArgCount()==-1) ? -iArgCount : iArgCount); + } + + return valTok; + + #if defined(_MSC_VER) + #pragma warning( default : 4311 ) + #endif + } + + //--------------------------------------------------------------------------- + /** \brief Execute a function that takes a single string argument. + \param a_FunTok Function token. + \throw exception_type If the function token is not a string function + */ + ParserBase::token_type ParserBase::ApplyStrFunc(const token_type &a_FunTok, + const std::vector<token_type> &a_vArg) const + { + if (a_vArg.back().GetCode()!=cmSTRING) + Error(ecSTRING_EXPECTED, m_pTokenReader->GetPos(), a_FunTok.GetAsString()); + + token_type valTok; + int iArgCount = (unsigned)a_vArg.size(); + void *pFunc = a_FunTok.GetFuncAddr(); + assert(pFunc); + + try + { + // Collect the function arguments from the value stack + switch(a_FunTok.GetArgCount()) + { + case 0: valTok.SetVal( ((strfun_type1)pFunc)(a_vArg[0].GetAsString().c_str()) ); break; + case 1: valTok.SetVal( ((strfun_type2)pFunc)(a_vArg[1].GetAsString().c_str(), + a_vArg[0].GetVal()) ); break; + case 2: valTok.SetVal( ((strfun_type3)pFunc)(a_vArg[2].GetAsString().c_str(), + a_vArg[1].GetVal(), + a_vArg[0].GetVal()) ); break; + default: Error(ecINTERNAL_ERROR); + } + } + catch(ParserError& /*e*/) + { + Error(ecVAL_EXPECTED, m_pTokenReader->GetPos(), a_FunTok.GetAsString()); + } + + // Find out if the result will depend on a variable + /** \todo remove this loop, put content in the loop that takes the argument values. + + (Attention: SetVal will reset Flags.) + */ + bool bVolatile = a_FunTok.IsFlagSet(token_type::flVOLATILE); + for (int i=0; (bVolatile==false) && (i<iArgCount); ++i) + bVolatile |= a_vArg[i].IsFlagSet(token_type::flVOLATILE); + + if (bVolatile) + valTok.AddFlags(token_type::flVOLATILE); + + // string functions won't be optimized + m_vByteCode.AddStrFun((void*)pFunc, a_FunTok.GetArgCount(), a_vArg.back().GetIdx()); + + return valTok; + } + + //--------------------------------------------------------------------------- + /** \brief Apply a function token. + \param iArgCount Number of Arguments actually gathered used only for multiarg functions. + \post The result is pushed to the value stack + \post The function token is removed from the stack + \throw exception_type if Argument count does not mach function requirements. + */ + void ParserBase::ApplyFunc( ParserStack<token_type> &a_stOpt, + ParserStack<token_type> &a_stVal, + int a_iArgCount) const + { + assert(m_pTokenReader.get()); + + // Operator stack empty or does not contain tokens with callback functions + if (a_stOpt.empty() || a_stOpt.top().GetFuncAddr()==0 ) + return; + + token_type funTok = a_stOpt.pop(); + assert(funTok.GetFuncAddr()); + + // Binary operators must rely on their internal operator number + // since counting of operators relies on commas for function arguments + // binary operators do not have commas in their expression + int iArgCount = (funTok.GetCode()==cmOPRT_BIN) ? funTok.GetArgCount() : a_iArgCount; + + // determine how many parameters the function needs. To remember iArgCount includes the + // string parameter whilst GetArgCount() counts only numeric parameters. + int iArgRequired = funTok.GetArgCount() + ((funTok.GetType()==tpSTR) ? 1 : 0); + + // Thats the number of numerical parameters + int iArgNumerical = iArgCount - ((funTok.GetType()==tpSTR) ? 1 : 0); + + if (funTok.GetCode()==cmFUNC_STR && iArgCount-iArgNumerical>1) + Error(ecINTERNAL_ERROR); + + if (funTok.GetArgCount()>=0 && iArgCount>iArgRequired) + Error(ecTOO_MANY_PARAMS, m_pTokenReader->GetPos()-1, funTok.GetAsString()); + + if (funTok.GetCode()!=cmOPRT_BIN && iArgCount<iArgRequired ) + Error(ecTOO_FEW_PARAMS, m_pTokenReader->GetPos()-1, funTok.GetAsString()); + + if (funTok.GetCode()==cmFUNC_STR && iArgCount>iArgRequired ) + Error(ecTOO_MANY_PARAMS, m_pTokenReader->GetPos()-1, funTok.GetAsString()); + + // Collect the numeric function arguments from the value stack and store them + // in a vector + std::vector<token_type> stArg; + for (int i=0; i<iArgNumerical; ++i) + { + stArg.push_back( a_stVal.pop() ); + if ( stArg.back().GetType()==tpSTR && funTok.GetType()!=tpSTR ) + Error(ecVAL_EXPECTED, m_pTokenReader->GetPos(), funTok.GetAsString()); + } + + // for string functions add the string argument + if (funTok.GetCode()==cmFUNC_STR) + { + stArg.push_back( a_stVal.pop() ); + if ( stArg.back().GetType()==tpSTR && funTok.GetType()!=tpSTR ) + Error(ecVAL_EXPECTED, m_pTokenReader->GetPos(), funTok.GetAsString()); + } + + // String functions accept only one parameter + if (funTok.GetType()==tpSTR) + { + token_type token( ApplyStrFunc(funTok, stArg) ); + a_stVal.push( token ); + } + else + { + token_type token( ApplyNumFunc(funTok, stArg) ); + a_stVal.push( token ); + } + } + + //--------------------------------------------------------------------------- + /** \brief Apply a binary operator. + \param a_stOpt The operator stack + \param a_stVal The value stack + */ + void ParserBase::ApplyBinOprt( ParserStack<token_type> &a_stOpt, + ParserStack<token_type> &a_stVal) const + { + assert(a_stOpt.size()); + + // user defined binary operator + if (a_stOpt.top().GetCode()==cmOPRT_BIN) + { + ApplyFunc(a_stOpt, a_stVal, 2); + } + else + { + // internal binary operator + MUP_ASSERT(a_stVal.size()>=2); + + token_type valTok1 = a_stVal.pop(), + valTok2 = a_stVal.pop(), + optTok = a_stOpt.pop(), + resTok; + + if ( valTok1.GetType()!=valTok2.GetType() || + (valTok1.GetType()==tpSTR && valTok2.GetType()==tpSTR) ) + Error(ecOPRT_TYPE_CONFLICT, m_pTokenReader->GetPos(), optTok.GetAsString()); + + value_type x = valTok2.GetVal(), + y = valTok1.GetVal(); + + switch (optTok.GetCode()) + { + // built in binary operators + case cmAND: resTok.SetVal( (int)x & (int)y ); break; + case cmOR: resTok.SetVal( (int)x | (int)y ); break; + case cmXOR: resTok.SetVal( (int)x ^ (int)y ); break; + case cmLT: resTok.SetVal( x < y ); break; + case cmGT: resTok.SetVal( x > y ); break; + case cmLE: resTok.SetVal( x <= y ); break; + case cmGE: resTok.SetVal( x >= y ); break; + case cmNEQ: resTok.SetVal( x != y ); break; + case cmEQ: resTok.SetVal( x == y ); break; + case cmADD: resTok.SetVal( x + y ); break; + case cmSUB: resTok.SetVal( x - y ); break; + case cmMUL: resTok.SetVal( x * y ); break; + case cmDIV: +#if defined(MUP_MATH_EXCEPTIONS) + if (y==0) + { + Error(ecDIV_BY_ZERO); + } +#endif + resTok.SetVal( x / y ); + break; + case cmPOW: resTok.SetVal(pow(x, y)); break; + + case cmASSIGN: + // The assignement operator needs special treatment + // it uses a different format when stored in the bytecode! + { + if (valTok2.GetCode()!=cmVAR) + Error(ecUNEXPECTED_OPERATOR, -1 /* m_pTokenReader->GetPos() */, _T("=")); + + value_type *pVar = valTok2.GetVar(); + resTok.SetVal( *pVar = y ); + resTok.AddFlags(token_type::flVOLATILE); + a_stVal.push( resTok ); + + m_vByteCode.AddAssignOp(pVar); + return; // we must return since the following + // stuff does not apply + } + + default: Error(ecINTERNAL_ERROR, 8); + } + + // Create the bytecode entries + if (!m_bOptimize) + { + // Optimization flag is not set + m_vByteCode.AddOp(optTok.GetCode()); + } + else if ( valTok1.IsFlagSet(token_type::flVOLATILE) || + valTok2.IsFlagSet(token_type::flVOLATILE) ) + { + // Optimization flag is not set, but one of the value + // depends on a variable + m_vByteCode.AddOp(optTok.GetCode()); + resTok.AddFlags(token_type::flVOLATILE); + } + else + { + // operator call can be optimized; If optimization is possible + // the two previous tokens must be value tokens / they will be removed + // and replaced with the result of the pending operation. + m_vByteCode.RemoveValEntries(2); + m_vByteCode.AddVal(resTok.GetVal()); + } + + a_stVal.push( resTok ); + } + } + + //--------------------------------------------------------------------------- + /** \brief Parse the command code. + \sa ParseString(), ParseValue() + + Command code contains precalculated stack positions of the values and the + associated operators. The Stack is filled beginning from index one the + value at index zero is not used at all. + */ + value_type ParserBase::ParseCmdCode() const + { + #if defined(_MSC_VER) + #pragma warning( disable : 4312 ) + #endif + + value_type *Stack = &m_vStackBuffer[0]; + ECmdCode iCode; + bytecode_type idx(0); + int i(0); + + __start: + + idx = m_pCmdCode[i]; + iCode = (ECmdCode)m_pCmdCode[i+1]; + i += 2; + +#ifdef _DEBUG + // Die Formelendkennung ist Wert 26 dreimal hintereinander geschrieben + // Ich muss für den Test das Formelende filtern. + if (idx>=(int)m_vStackBuffer.size() && iCode!=cmEND) + throw exception_type(ecGENERIC, _T(""), m_pTokenReader->GetExpr(), -1); +#endif + + switch (iCode) + { + // built in binary operators + case cmAND: Stack[idx] = (int)Stack[idx] & (int)Stack[idx+1]; goto __start; + case cmOR: Stack[idx] = (int)Stack[idx] | (int)Stack[idx+1]; goto __start; + case cmXOR: Stack[idx] = (int)Stack[idx] ^ (int)Stack[idx+1]; goto __start; + case cmLE: Stack[idx] = Stack[idx] <= Stack[idx+1]; goto __start; + case cmGE: Stack[idx] = Stack[idx] >= Stack[idx+1]; goto __start; + case cmNEQ: Stack[idx] = Stack[idx] != Stack[idx+1]; goto __start; + case cmEQ: Stack[idx] = Stack[idx] == Stack[idx+1]; goto __start; + case cmLT: Stack[idx] = Stack[idx] < Stack[idx+1]; goto __start; + case cmGT: Stack[idx] = Stack[idx] > Stack[idx+1]; goto __start; + case cmADD: Stack[idx] += Stack[1+idx]; goto __start; + case cmSUB: Stack[idx] -= Stack[1+idx]; goto __start; + case cmMUL: Stack[idx] *= Stack[1+idx]; goto __start; + case cmDIV: + +#if defined(MUP_MATH_EXCEPTIONS) + if (Stack[1+idx]==0) + Error(ecDIV_BY_ZERO); +#endif + Stack[idx] /= Stack[1+idx]; + goto __start; + case cmPOW: + { + // The int overload of pow is significantly faster + // use it if applicable + value_type p = Stack[1+idx]; + if ((value_type)(int)p==p) + Stack[idx] = pow(Stack[idx], (int)p); + else + Stack[idx] = pow(Stack[idx], p); + } + goto __start; + + // Assignement needs special treatment + case cmASSIGN: + { + // next is a pointer to the target + value_type **pDest = (value_type**)(&m_pCmdCode[i]); + + // advance index according to pointer size + i += m_vByteCode.GetPtrSize(); + // assign the value + Stack[idx] = **pDest = Stack[idx+1]; + } + goto __start; + + // user defined binary operators + case cmOPRT_BIN: + Stack[idx] = (**(fun_type2**)(&m_pCmdCode[i]))(Stack[idx], Stack[idx+1]); + ++i; + goto __start; + + // variable tokens + case cmVAR: + Stack[idx] = **(value_type**)(&m_pCmdCode[i]); + i += m_vByteCode.GetValSize(); + goto __start; + + // value tokens + case cmVAL: + Stack[idx] = *(value_type*)(&m_pCmdCode[i]); + i += m_vByteCode.GetValSize(); + goto __start; + + // Next is treatment of string functions + case cmFUNC_STR: + { + // The function argument count + int iArgCount = (int)m_pCmdCode[ i++ ]; + + // The index of the string argument in the string table + int iIdxStack = (int)m_pCmdCode[ i++ ]; + MUP_ASSERT( iIdxStack>=0 && iIdxStack<(int)m_vStringBuf.size() ); + + switch(iArgCount) // switch according to argument count + { + case 0: Stack[idx] = (*(strfun_type1*)(&m_pCmdCode[i]))(m_vStringBuf[iIdxStack].c_str()); break; + case 1: Stack[idx] = (*(strfun_type2*)(&m_pCmdCode[i]))(m_vStringBuf[iIdxStack].c_str(), Stack[idx]); break; + case 2: Stack[idx] = (*(strfun_type3*)(&m_pCmdCode[i]))(m_vStringBuf[iIdxStack].c_str(), Stack[idx], Stack[idx+1]); break; + } + i += m_vByteCode.GetPtrSize(); + } + goto __start; + + // Next is treatment of numeric functions + case cmFUNC: + { + int iArgCount = (int)m_pCmdCode[i++]; + + // switch according to argument count + switch(iArgCount) + { + case 0: Stack[idx] = (*(fun_type0*)(&m_pCmdCode[i]))(); break; + case 1: Stack[idx] = (*(fun_type1*)(&m_pCmdCode[i]))(Stack[idx]); break; + case 2: Stack[idx] = (*(fun_type2*)(&m_pCmdCode[i]))(Stack[idx], Stack[idx+1]); break; + case 3: Stack[idx] = (*(fun_type3*)(&m_pCmdCode[i]))(Stack[idx], Stack[idx+1], Stack[idx+2]); break; + case 4: Stack[idx] = (*(fun_type4*)(&m_pCmdCode[i]))(Stack[idx], Stack[idx+1], Stack[idx+2], Stack[idx+3]); break; + case 5: Stack[idx] = (*(fun_type5*)(&m_pCmdCode[i]))(Stack[idx], Stack[idx+1], Stack[idx+2], Stack[idx+3], Stack[idx+4]); break; + default: + if (iArgCount>0) // function with variable arguments store the number as a negative value + Error(ecINTERNAL_ERROR, 1); + + Stack[idx] =(*(multfun_type*)(&m_pCmdCode[i]))(&Stack[idx], -iArgCount); + break; + } + i += m_vByteCode.GetPtrSize(); + } + goto __start; + + case cmEND: + return Stack[m_nFinalResultIdx]; + + default: + Error(ecINTERNAL_ERROR, 2); + return 0; + } + + #if defined(_MSC_VER) + #pragma warning( default : 4312 ) + #endif + } + + //--------------------------------------------------------------------------- + /** \brief Return result for constant functions. + + Seems pointless, but for parser functions that are made up of only a value, which occur + in real world applications, this speeds up things by removing the parser overhead almost + completely. + */ + value_type ParserBase::ParseValue() const + { + return *(value_type*)(&m_pCmdCode[2]); + } + + //--------------------------------------------------------------------------- + /** \brief One of the two main parse functions. + + Parse expression from input string. Perform syntax checking and create bytecode. + After parsing the string and creating the bytecode the function pointer + #m_pParseFormula will be changed to the second parse routine the uses bytecode instead of string parsing. + + \sa ParseCmdCode(), ParseValue() + */ + value_type ParserBase::ParseString() const + { + #if defined(_MSC_VER) + #pragma warning( disable : 4311 ) + #endif + if (!m_pTokenReader->GetExpr().length()) + Error(ecUNEXPECTED_EOF, 0); + + ParserStack<token_type> stOpt, stVal; + ParserStack<int> stArgCount; + token_type opta, opt; // for storing operators + token_type val, tval; // for storing value + string_type strBuf; // buffer for string function arguments + + ReInit(); + + // The outermost counter counts the number of seperated items + // such as in "a=10,b=20,c=c+a" + stArgCount.push(1); + + for(;;) + { + opt = m_pTokenReader->ReadNextToken(); + + switch (opt.GetCode()) + { + // + // Next three are different kind of value entries + // + case cmSTRING: + opt.SetIdx((int)m_vStringBuf.size()); // Assign buffer index to token + stVal.push(opt); + m_vStringBuf.push_back(opt.GetAsString()); // Store string in internal buffer + break; + + case cmVAR: + stVal.push(opt); + m_vByteCode.AddVar( static_cast<value_type*>(opt.GetVar()) ); + break; + + case cmVAL: + stVal.push(opt); + m_vByteCode.AddVal( opt.GetVal() ); + break; + + case cmARG_SEP: + if (stArgCount.empty()) + Error(ecUNEXPECTED_ARG_SEP, m_pTokenReader->GetPos()); + + ++stArgCount.top(); + // fall through... + + case cmEND: + case cmBC: + { + // The argument count for parameterless functions is zero + // by default an opening bracket sets parameter count to 1 + // in preparation of arguments to come. If the last token + // was an opening bracket we know better... + if (opta.GetCode()==cmBO) + --stArgCount.top(); + + while ( stOpt.size() && stOpt.top().GetCode() != cmBO) + { + if (stOpt.top().GetCode()==cmOPRT_INFIX) + ApplyFunc(stOpt, stVal, 1); // infix operator + else + ApplyBinOprt(stOpt, stVal); + } + + // <ibg> 20060218 infix operator treatment moved here + if (stOpt.size() && stOpt.top().GetCode()==cmOPRT_INFIX) + ApplyFunc(stOpt, stVal, 1); // infix operator + + if ( opt.GetCode()!=cmBC || stOpt.size()==0 || stOpt.top().GetCode()!=cmBO ) + break; + + // if opt is ")" and opta is "(" the bracket has been evaluated, now its time to check + // if there is either a function or a sign pending + // neither the opening nor the closing bracket will be pushed back to + // the operator stack + // Check if a function is standing in front of the opening bracket, + // if yes evaluate it afterwards check for infix operators + assert(stArgCount.size()); + int iArgCount = stArgCount.pop(); + + stOpt.pop(); // Take opening bracket from stack + + if (iArgCount>1 && ( stOpt.size()==0 || + (stOpt.top().GetCode()!=cmFUNC && + stOpt.top().GetCode()!=cmFUNC_STR) ) ) + Error(ecUNEXPECTED_ARG, m_pTokenReader->GetPos()); + + // The openin bracket was popped from the stack now check if there + // was a function before this bracket + if (stOpt.size() && + stOpt.top().GetCode()!=cmOPRT_INFIX && + stOpt.top().GetCode()!=cmOPRT_BIN && + stOpt.top().GetFuncAddr()!=0) + { + ApplyFunc(stOpt, stVal, iArgCount); + } + } // if bracket content is evaluated + break; + + // + // Next are the binary operator entries + // + case cmAND: // built in binary operators + case cmOR: + case cmXOR: + case cmLT: + case cmGT: + case cmLE: + case cmGE: + case cmNEQ: + case cmEQ: + case cmADD: + case cmSUB: + case cmMUL: + case cmDIV: + case cmPOW: + case cmASSIGN: + case cmOPRT_BIN: + // A binary operator (user defined or built in) has been found. + while ( stOpt.size() && stOpt.top().GetCode() != cmBO) + { + int nPrec1 = GetOprtPrecedence(stOpt.top()), + nPrec2 = GetOprtPrecedence(opt); + + if (stOpt.top().GetCode()==opt.GetCode()) + { + + // Deal with operator associativity + EOprtAssociativity eOprtAsct = GetOprtAssociativity(opt); + if ( (eOprtAsct==oaRIGHT && (nPrec1 <= nPrec2)) || + (eOprtAsct==oaLEFT && (nPrec1 < nPrec2)) ) + { + break; + } + } + else if (nPrec1 < nPrec2) + { + // In case the operators are not equal the precedence decides alone... + break; + } + + + if (stOpt.top().GetCode()==cmOPRT_INFIX) + ApplyFunc(stOpt, stVal, 1); // infix operator + else + ApplyBinOprt(stOpt, stVal); + } // while ( ... ) + + // The operator can't be evaluated right now, push back to the operator stack + stOpt.push(opt); + break; + + // + // Last section contains functions and operators implicitely mapped to functions + // + case cmBO: + stArgCount.push(1); + stOpt.push(opt); + break; + + case cmFUNC: + case cmOPRT_INFIX: + case cmFUNC_STR: + stOpt.push(opt); + break; + + case cmOPRT_POSTFIX: + stOpt.push(opt); + ApplyFunc(stOpt, stVal, 1); // this is the postfix operator + break; + + default: Error(ecINTERNAL_ERROR, 3); + } // end of switch operator-token + + opta = opt; + + if ( opt.GetCode() == cmEND ) + { + m_vByteCode.Finalize(); + break; + } + + //if (stArgCount.size()) + // cout << "Arguments: " << stArgCount.top() << "\n"; + + #if defined(MUP_DUMP_STACK) + + StackDump(stVal, stOpt); + m_vByteCode.AsciiDump(); + #endif + } // while (true) + + // Store pointer to start of bytecode + m_pCmdCode = m_vByteCode.GetRawData(); + + #if defined(MUP_DUMP_CMDCODE) + m_vByteCode.AsciiDump(); + #endif + + // get the last value (= final result) from the stack + MUP_ASSERT(stArgCount.size()==1); + m_nFinalResultIdx = stArgCount.top(); + + if (stVal.size()==0) + Error(ecEMPTY_EXPRESSION); + + if (stVal.top().GetType()!=tpDBL) + Error(ecSTR_RESULT); + + // no error, so change the function pointer for the main parse routine + value_type fVal = stVal.top().GetVal(); // Result from String parsing + + if (m_bUseByteCode) + { + // (n is a double requires if it is stored in the bytecode) + // pos 0: stack index must be 0 for the final result + // pos 1: code signaling the next entry is a value (cmVal==20) + // pos 2..2+n: the final result + // pos 2+n+1: the bytecode end marker + // + // Check if the bytecode contains only a single constant, if so parsing is no longer necessary. + std::size_t checkEnd = 2 + m_vByteCode.GetValSize(); // + m_pParseFormula = (m_pCmdCode[1]==cmVAL && checkEnd<m_vByteCode.GetBufSize() && m_pCmdCode[checkEnd]==cmEND) ? + &ParserBase::ParseValue : + &ParserBase::ParseCmdCode; + m_vStackBuffer.resize(m_vByteCode.GetMaxStackSize()); + } + + return fVal; + + #if defined(_MSC_VER) + #pragma warning( default : 4311 ) + #endif + } + + //--------------------------------------------------------------------------- + /** \brief Create an error containing the parse error position. + + This function will create an Parser Exception object containing the error text and + its position. + + \param a_iErrc [in] The error code of type #EErrorCodes. + \param a_iPos [in] The position where the error was detected. + \param a_strTok [in] The token string representation associated with the error. + \throw ParserException always throws thats the only purpose of this function. + */ + void ParserBase::Error(EErrorCodes a_iErrc, int a_iPos, const string_type &a_sTok) const + { + throw exception_type(a_iErrc, a_sTok, m_pTokenReader->GetExpr(), a_iPos); + } + + //------------------------------------------------------------------------------ + /** \brief Clear all user defined variables. + \throw nothrow + + Resets the parser to string parsing mode by calling #ReInit. + */ + void ParserBase::ClearVar() + { + m_VarDef.clear(); + ReInit(); + } + + //------------------------------------------------------------------------------ + /** \brief Remove a variable from internal storage. + \throw nothrow + + Removes a variable if it exists. If the Variable does not exist nothing will be done. + */ + void ParserBase::RemoveVar(const string_type &a_strVarName) + { + varmap_type::iterator item = m_VarDef.find(a_strVarName); + if (item!=m_VarDef.end()) + { + m_VarDef.erase(item); + ReInit(); + } + } + + //------------------------------------------------------------------------------ + /** \brief Clear the formula. + \post Resets the parser to string parsing mode. + \throw nothrow + + Clear the formula and existing bytecode. + */ + void ParserBase::ClearFormula() + { + m_vByteCode.clear(); + m_pCmdCode = 0; + m_pTokenReader->SetFormula(_T("")); + ReInit(); + } + + //------------------------------------------------------------------------------ + /** \brief Clear all functions. + \post Resets the parser to string parsing mode. + \throw nothrow + */ + void ParserBase::ClearFun() + { + m_FunDef.clear(); + ReInit(); + } + + //------------------------------------------------------------------------------ + /** \brief Clear all user defined constants. + + Both numeric and string constants will be removed from the internal storage. + \post Resets the parser to string parsing mode. + \throw nothrow + */ + void ParserBase::ClearConst() + { + m_ConstDef.clear(); + m_StrVarDef.clear(); + ReInit(); + } + + //------------------------------------------------------------------------------ + /** \brief Clear all user defined postfix operators. + \post Resets the parser to string parsing mode. + \throw nothrow + */ + void ParserBase::ClearPostfixOprt() + { + m_PostOprtDef.clear(); + ReInit(); + } + + //------------------------------------------------------------------------------ + /** \brief Clear all user defined binary operators. + \post Resets the parser to string parsing mode. + \throw nothrow + */ + void ParserBase::ClearOprt() + { + m_OprtDef.clear(); + ReInit(); + } + + //------------------------------------------------------------------------------ + /** \brief Clear the user defined Prefix operators. + \post Resets the parser to string parser mode. + \throw nothrow + */ + void ParserBase::ClearInfixOprt() + { + m_InfixOprtDef.clear(); + ReInit(); + } + + //------------------------------------------------------------------------------ + /** \brief Enable or disable the formula optimization feature. + \post Resets the parser to string parser mode. + \throw nothrow + */ + void ParserBase::EnableOptimizer(bool a_bIsOn) + { + m_bOptimize = a_bIsOn; + ReInit(); + } + + //------------------------------------------------------------------------------ + /** \brief Enable or disable parsing from Bytecode. + + \attention There is no reason to disable bytecode. It will + drastically decrease parsing speed. + */ + void ParserBase::EnableByteCode(bool a_bIsOn) + { + m_bUseByteCode = a_bIsOn; + if (!a_bIsOn) + ReInit(); + } + + //------------------------------------------------------------------------------ + /** \brief Enable or disable the built in binary operators. + \throw nothrow + \sa m_bBuiltInOp, ReInit() + + If you disable the built in binary operators there will be no binary operators + defined. Thus you must add them manually one by one. It is not possible to + disable built in operators selectively. This function will Reinitialize the + parser by calling ReInit(). + */ + void ParserBase::EnableBuiltInOprt(bool a_bIsOn) + { + m_bBuiltInOp = a_bIsOn; + ReInit(); + } + + //------------------------------------------------------------------------------ + /** \brief Query status of built in variables. + \return #m_bBuiltInOp; true if built in operators are enabled. + \throw nothrow + */ + bool ParserBase::HasBuiltInOprt() const + { + return m_bBuiltInOp; + } + + //------------------------------------------------------------------------------ + /** \brief Get the argument separator character. + */ + char_type ParserBase::GetArgSep() const + { + return m_pTokenReader->GetArgSep(); + } + + //------------------------------------------------------------------------------ + /** \brief Set argument separator. + \param cArgSep the argument separator character. + */ + void ParserBase::SetArgSep(char_type cArgSep) + { + m_pTokenReader->SetArgSep(cArgSep); + } + +#if defined(MUP_DUMP_STACK) | defined(MUP_DUMP_CMDCODE) + //------------------------------------------------------------------------------ + /** \brief Dump stack content. + + This function is used for debugging only. + */ + void ParserBase::StackDump(const ParserStack<token_type> &a_stVal, + const ParserStack<token_type> &a_stOprt) const + { + ParserStack<token_type> stOprt(a_stOprt), + stVal(a_stVal); + + mu::console() << _T("\nValue stack:\n"); + while ( !stVal.empty() ) + { + token_type val = stVal.pop(); + if (val.GetType()==tpSTR) + mu::console() << _T(" \"") << val.GetAsString() << _T("\" "); + else + mu::console() << _T(" ") << val.GetVal() << _T(" "); + } + mu::console() << "\nOperator stack:\n"; + + while ( !stOprt.empty() ) + { + if (stOprt.top().GetCode()<=cmASSIGN) + { + mu::console() << _T("OPRT_INTRNL \"") + << ParserBase::c_DefaultOprt[stOprt.top().GetCode()] + << _T("\" \n"); + } + else + { + switch(stOprt.top().GetCode()) + { + case cmVAR: mu::console() << _T("VAR\n"); break; + case cmVAL: mu::console() << _T("VAL\n"); break; + case cmFUNC: mu::console() << _T("FUNC_NUM \"") + << stOprt.top().GetAsString() + << _T("\"\n"); break; + case cmOPRT_INFIX: mu::console() << _T("OPRT_INFIX \"") + << stOprt.top().GetAsString() + << _T("\"\n"); break; + case cmOPRT_BIN: mu::console() << _T("OPRT_BIN \"") + << stOprt.top().GetAsString() + << _T("\"\n"); break; + case cmFUNC_STR: mu::console() << _T("FUNC_STR\n"); break; + case cmEND: mu::console() << _T("END\n"); break; + case cmUNKNOWN: mu::console() << _T("UNKNOWN\n"); break; + case cmBO: mu::console() << _T("BRACKET \"(\"\n"); break; + case cmBC: mu::console() << _T("BRACKET \")\"\n"); break; + default: mu::console() << stOprt.top().GetType() << _T(" "); break; + } + } + stOprt.pop(); + } + + mu::console() << dec << endl; + } + +#endif // defined(MUP_DUMP_STACK) | defined(MUP_DUMP_CMDCODE) +} // namespace mu diff --git a/AMDiS/lib/muparser_v134/src/muParserBytecode.cpp b/AMDiS/lib/muparser_v134/src/muParserBytecode.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b5ea33f09eb7bce3f7daaf841064f07c8f694b75 --- /dev/null +++ b/AMDiS/lib/muparser_v134/src/muParserBytecode.cpp @@ -0,0 +1,408 @@ +/* + __________ + _____ __ __\______ \_____ _______ ______ ____ _______ + / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ + | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ + |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| + \/ \/ \/ \/ + Copyright (C) 2010 Ingo Berg + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include "muParserBytecode.h" + +#include <cassert> +#include <string> +#include <stack> +#include <vector> +#include <iostream> +#include <algorithm> + +#include "muParserDef.h" +#include "muParserError.h" +#include "muParserToken.h" + +/** \file + \brief Implementation of the parser bytecode class. +*/ + + +namespace mu +{ + //--------------------------------------------------------------------------- + /** Bytecode default constructor. */ + ParserByteCode::ParserByteCode() + :m_iStackPos(0) + ,m_iMaxStackSize(0) + ,m_vBase() + ,mc_iSizeVal( std::max( (int)sizeof(value_type) / (int)sizeof(bytecode_type), 1 ) ) + ,mc_iSizePtr( std::max( (int)sizeof(value_type*) / (int)sizeof(bytecode_type), 1 ) ) + ,mc_iSizeValEntry( 2 + mc_iSizeVal) + { + m_vBase.reserve(1000); + } + + //--------------------------------------------------------------------------- + /** \brief Copy constructor. + + Implemented in Terms of Assign(const ParserByteCode &a_ByteCode) + */ + ParserByteCode::ParserByteCode(const ParserByteCode &a_ByteCode) + :mc_iSizeVal( sizeof(value_type)/sizeof(bytecode_type) ) + ,mc_iSizePtr( sizeof(value_type*)/sizeof(bytecode_type) ) + ,mc_iSizeValEntry( 2 + mc_iSizeVal) + { + Assign(a_ByteCode); + } + + //--------------------------------------------------------------------------- + /** \brief Assignment operator. + + Implemented in Terms of Assign(const ParserByteCode &a_ByteCode) + */ + ParserByteCode& ParserByteCode::operator=(const ParserByteCode &a_ByteCode) + { + Assign(a_ByteCode); + return *this; + } + + //--------------------------------------------------------------------------- + /** \brief Store an address in bytecode. + + \param a_pAddr Address to be stored. + \throw nothrow + */ + void ParserByteCode::StorePtr(void *a_pAddr) + { +#if defined(_MSC_VER) + #pragma warning( disable : 4311 ) +#endif + + // demo code for packing / unpacking pointers into bytecode +// void *ptr(NULL); +// double **pVal; +// double fVal; +// map_type dbg[2]; +// dbg[0] = *( reinterpret_cast<map_type*>(&a_pAddr) ), +// dbg[1] = *( reinterpret_cast<map_type*>(&a_pAddr) + 1 ); +// Version 1: +// *( (map_type*)&ptr+0) = dbg[0]; +// *( (map_type*)&ptr+1) = dbg[1]; +// Version 2: +// memcpy(&ptr, dbg, sizeof(dbg)); +// Version 3: +// pVal = (double**)dbg; +// fVal = **(double**)dbg; + + for (int i=0; i<mc_iSizePtr; ++i) + m_vBase.push_back( *( reinterpret_cast<bytecode_type*>(&a_pAddr) + i ) ); + +#if defined(_MSC_VER) + #pragma warning( default : 4311 ) +#endif + } + + //--------------------------------------------------------------------------- + /** \brief Copy state of another object to this. + + \throw nowthrow + */ + void ParserByteCode::Assign(const ParserByteCode &a_ByteCode) + { + if (this==&a_ByteCode) + return; + + m_iStackPos = a_ByteCode.m_iStackPos; + m_vBase = a_ByteCode.m_vBase; + m_iMaxStackSize = a_ByteCode.m_iMaxStackSize; + } + + //--------------------------------------------------------------------------- + /** \brief Add a Variable pointer to bytecode. + \param a_pVar Pointer to be added. + \throw nothrow + */ + void ParserByteCode::AddVar(value_type *a_pVar) + { + m_vBase.push_back( ++m_iStackPos ); + m_vBase.push_back( cmVAR ); + + m_iMaxStackSize = std::max(m_iMaxStackSize, (size_t)m_iStackPos); + + StorePtr(a_pVar); + + const int iSize = mc_iSizeVal - mc_iSizePtr; + assert(iSize>=0); + + // Make sure variable entries have the same size as value entries. + // (necessary for optimization; fill with zeros) + for (int i=0; i<iSize; ++i) + m_vBase.push_back(0); + } + + //--------------------------------------------------------------------------- + /** \brief Add a Variable pointer to bytecode. + + Value entries in byte code consist of: + <ul> + <li>value array position of the value</li> + <li>the operator code according to ParserToken::cmVAL</li> + <li>the value stored in #mc_iSizeVal number of bytecode entries.</li> + </ul> + + \param a_pVal Value to be added. + \throw nothrow + */ + void ParserByteCode::AddVal(value_type a_fVal) + { + m_vBase.push_back( ++m_iStackPos ); + m_vBase.push_back( cmVAL ); + m_iMaxStackSize = std::max(m_iMaxStackSize, (size_t)m_iStackPos); + + for (int i=0; i<mc_iSizeVal; ++i) + m_vBase.push_back( *(reinterpret_cast<bytecode_type*>(&a_fVal) + i) ); + } + + //--------------------------------------------------------------------------- + /** \brief Add an operator identifier to bytecode. + + Operator entries in byte code consist of: + <ul> + <li>value array position of the result</li> + <li>the operator code according to ParserToken::ECmdCode</li> + </ul> + + \sa ParserToken::ECmdCode + */ + void ParserByteCode::AddOp(ECmdCode a_Oprt) + { + m_vBase.push_back(--m_iStackPos); + m_vBase.push_back(a_Oprt); + } + + //--------------------------------------------------------------------------- + /** \brief Add an assignement operator + + Operator entries in byte code consist of: + <ul> + <li>cmASSIGN code</li> + <li>the pointer of the destination variable</li> + </ul> + + \sa ParserToken::ECmdCode + */ + void ParserByteCode::AddAssignOp(value_type *a_pVar) + { + m_vBase.push_back(--m_iStackPos); + m_vBase.push_back(cmASSIGN); + StorePtr(a_pVar); + } + + //--------------------------------------------------------------------------- + /** \brief Add function to bytecode. + + \param a_iArgc Number of arguments, negative numbers indicate multiarg functions. + \param a_pFun Pointer to function callback. + */ + void ParserByteCode::AddFun(void *a_pFun, int a_iArgc) + { + if (a_iArgc>=0) + { + m_iStackPos = m_iStackPos - a_iArgc + 1; + } + else + { + m_iStackPos = m_iStackPos + a_iArgc + 1; + } + m_iMaxStackSize = std::max(m_iMaxStackSize, (size_t)m_iStackPos); + + m_vBase.push_back(m_iStackPos); + m_vBase.push_back(cmFUNC); + m_vBase.push_back(a_iArgc); + + StorePtr(a_pFun); + } + + //--------------------------------------------------------------------------- + /** \brief Add Strung function entry to the parser bytecode. + \throw nothrow + + A string function entry consists of the stack position of the return value, + followed by a cmSTRFUNC code, the function pointer and an index into the + string buffer maintained by the parser. + */ + void ParserByteCode::AddStrFun(void *a_pFun, int a_iArgc, int a_iIdx) + { + m_iStackPos = m_iStackPos - a_iArgc + 1; + m_vBase.push_back(m_iStackPos); + m_vBase.push_back(cmFUNC_STR); + m_vBase.push_back(a_iArgc); + m_vBase.push_back(a_iIdx); + + m_iMaxStackSize = std::max(m_iMaxStackSize, (size_t)m_iStackPos); + + StorePtr(a_pFun); + } + + //--------------------------------------------------------------------------- + /** \brief Add end marker to bytecode. + + \throw nothrow + */ + void ParserByteCode::Finalize() + { + m_vBase.push_back(cmEND); + m_vBase.push_back(cmEND); +// m_vBase.push_back(cmEND); + + // shrink bytecode vector to fit + storage_type(m_vBase).swap(m_vBase); + } + + //--------------------------------------------------------------------------- + /** \brief Get Pointer to bytecode data storage. */ + const bytecode_type* ParserByteCode::GetRawData() const + { + assert(m_vBase.size()); + return &m_vBase[0]; + } + + + //--------------------------------------------------------------------------- + std::size_t ParserByteCode::GetMaxStackSize() const + { + return m_iMaxStackSize+1; + } + + //--------------------------------------------------------------------------- + std::size_t ParserByteCode::GetBufSize() const + { + return m_vBase.size(); + } + + //--------------------------------------------------------------------------- + /** \brief Delete the bytecode. + + \throw nothrow + + The name of this function is a violation of my own coding guidelines + but this way it's more in line with the STL functions thus more + intuitive. + */ + void ParserByteCode::clear() + { + m_vBase.clear(); + m_iStackPos = 0; + m_iMaxStackSize = 0; + } + + //--------------------------------------------------------------------------- + /** \brief Remove a value number of entries from the bytecode. + + \attention Currently I don't test if the entries are really value entries. + */ + void ParserByteCode::RemoveValEntries(unsigned a_iNumber) + { + unsigned iSize = a_iNumber * mc_iSizeValEntry; + assert( m_vBase.size() >= iSize ); + m_vBase.resize(m_vBase.size()-iSize); + + assert(m_iStackPos >= a_iNumber); + m_iStackPos -= (a_iNumber); + } + + //--------------------------------------------------------------------------- + /** \brief Dump bytecode (for debugging only!). */ + void ParserByteCode::AsciiDump() + { + if (!m_vBase.size()) + { + std::cout << "No bytecode available\n"; + return; + } + + std::cout << "Entries:" << (int)m_vBase.size() + << " (ValSize:" << mc_iSizeVal + << " entries, PtrSize:" << mc_iSizePtr + << " entries, MapSize:" << sizeof(bytecode_type) + << " byte)\n"; + int i = 0; + + while ( i<(int)m_vBase.size() && m_vBase[i] != cmEND) + { + std::cout << "IDX[" << (int)m_vBase[i++] << "]\t"; + switch (m_vBase[i]) + { + case cmVAL: std::cout << "VAL "; ++i; + std::cout << "[" << *( reinterpret_cast<double*>(&m_vBase[i]) ) << "]\n"; + i += mc_iSizeVal; + break; + + case cmVAR: std::cout << "VAR "; ++i; + std::cout << "[ADDR: 0x" << std::hex << *(value_type**)&m_vBase[i] << "]\n"; + i += mc_iSizePtr; + + // Variable entries have the same size like value entries + // the remaining spave must be skipped + i+= std::max(mc_iSizeVal - mc_iSizePtr, 0); + break; + + case cmFUNC: + std::cout << "CALL\t"; ++i; + std::cout << "[ARG:" << std::dec << (int)m_vBase[i] << "]"; ++i; + std::cout << "[ADDR: 0x" << std::hex << *(value_type**)&m_vBase[i] << "]\n"; + i += mc_iSizePtr; + break; + + case cmFUNC_STR: + std::cout << "CALL STRFUNC\t"; ++i; + std::cout << "[ARG:" << std::dec << (int)m_vBase[i] << "]"; ++i; + std::cout << "[IDX:" << std::dec << (int)m_vBase[i] << "]"; ++i; + std::cout << "[ADDR: 0x" << *(value_type**)&m_vBase[i] << "]\n"; + i += mc_iSizePtr; + break; + + case cmLT: std::cout << "LT\n"; ++i; break; + case cmGT: std::cout << "GT\n"; ++i; break; + case cmLE: std::cout << "LE\n"; ++i; break; + case cmGE: std::cout << "GE\n"; ++i; break; + case cmEQ: std::cout << "EQ\n"; ++i; break; + case cmNEQ: std::cout << "NEQ\n"; ++i; break; + case cmADD: std::cout << "ADD\n"; ++i; break; + case cmAND: std::cout << "AND\n"; ++i; break; + case cmOR: std::cout << "OR\n"; ++i; break; + case cmXOR: std::cout << "XOR\n"; ++i; break; + case cmSUB: std::cout << "SUB\n"; ++i; break; + case cmMUL: std::cout << "MUL\n"; ++i; break; + case cmDIV: std::cout << "DIV\n"; ++i; break; + case cmPOW: std::cout << "POW\n"; ++i; break; + + case cmASSIGN: + std::cout << "ASSIGN\t"; ++i; + std::cout << "[ADDR: 0x" << *(value_type**)&m_vBase[i] << "]\n"; + i += mc_iSizePtr; + break; + + default: std::cout << "(unknown code: " << (int)m_vBase[i] << ")\n"; + ++i; + break; + } // switch cmdCode + } // while bytecode + + std::cout << "END" << std::endl; + } +} // namespace mu diff --git a/AMDiS/lib/muparser_v134/src/muParserCallback.cpp b/AMDiS/lib/muparser_v134/src/muParserCallback.cpp new file mode 100644 index 0000000000000000000000000000000000000000..190dcd9eb0b6a43af7a960a8b6fc1f40994a5b8e --- /dev/null +++ b/AMDiS/lib/muparser_v134/src/muParserCallback.cpp @@ -0,0 +1,281 @@ +/* + __________ + _____ __ __\______ \_____ _______ ______ ____ _______ + / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ + | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ + |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| + \/ \/ \/ \/ + Copyright (C) 2004-2008 Ingo Berg + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include "muParserCallback.h" + +/** \file + \brief Implementation of the parser callback class. +*/ + + +namespace mu +{ + //--------------------------------------------------------------------------- + ParserCallback::ParserCallback(fun_type0 a_pFun, bool a_bAllowOpti) + :m_pFun((void*)a_pFun) + ,m_iArgc(0) + ,m_iPri(-1) + ,m_eOprtAsct(oaNONE) + ,m_iCode(cmFUNC) + ,m_iType(tpDBL) + ,m_bAllowOpti(a_bAllowOpti) + {} + + //--------------------------------------------------------------------------- + ParserCallback::ParserCallback(fun_type1 a_pFun, bool a_bAllowOpti, int a_iPrec, ECmdCode a_iCode) + :m_pFun((void*)a_pFun) + ,m_iArgc(1) + ,m_iPri(a_iPrec) + ,m_eOprtAsct(oaNONE) + ,m_iCode(a_iCode) + ,m_iType(tpDBL) + ,m_bAllowOpti(a_bAllowOpti) + {} + + + //--------------------------------------------------------------------------- + /** \brief Constructor for constructing funcstion callbacks taking two arguments. + \throw nothrow + */ + ParserCallback::ParserCallback(fun_type2 a_pFun, bool a_bAllowOpti) + :m_pFun((void*)a_pFun) + ,m_iArgc(2) + ,m_iPri(-1) + ,m_eOprtAsct(oaNONE) + ,m_iCode(cmFUNC) + ,m_iType(tpDBL) + ,m_bAllowOpti(a_bAllowOpti) + {} + + //--------------------------------------------------------------------------- + /** \brief Constructor for constructing binary operator callbacks. + \param a_pFun Pointer to a static function taking two arguments + \param a_bAllowOpti A flag indicating this funcation can be optimized + \param a_iPrec The operator precedence + \param a_eOprtAsct The operators associativity + \throw nothrow + */ + ParserCallback::ParserCallback(fun_type2 a_pFun, + bool a_bAllowOpti, + int a_iPrec, + EOprtAssociativity a_eOprtAsct) + :m_pFun((void*)a_pFun) + ,m_iArgc(2) + ,m_iPri(a_iPrec) + ,m_eOprtAsct(a_eOprtAsct) + ,m_iCode(cmOPRT_BIN) + ,m_iType(tpDBL) + ,m_bAllowOpti(a_bAllowOpti) + {} + + //--------------------------------------------------------------------------- + ParserCallback::ParserCallback(fun_type3 a_pFun, bool a_bAllowOpti) + :m_pFun((void*)a_pFun) + ,m_iArgc(3) + ,m_iPri(-1) + ,m_eOprtAsct(oaNONE) + ,m_iCode(cmFUNC) + ,m_iType(tpDBL) + ,m_bAllowOpti(a_bAllowOpti) + {} + + + //--------------------------------------------------------------------------- + ParserCallback::ParserCallback(fun_type4 a_pFun, bool a_bAllowOpti) + :m_pFun((void*)a_pFun) + ,m_iArgc(4) + ,m_iPri(-1) + ,m_eOprtAsct(oaNONE) + ,m_iCode(cmFUNC) + ,m_iType(tpDBL) + ,m_bAllowOpti(a_bAllowOpti) + {} + + + //--------------------------------------------------------------------------- + ParserCallback::ParserCallback(fun_type5 a_pFun, bool a_bAllowOpti) + :m_pFun((void*)a_pFun) + ,m_iArgc(5) + ,m_iPri(-1) + ,m_eOprtAsct(oaNONE) + ,m_iCode(cmFUNC) + ,m_iType(tpDBL) + ,m_bAllowOpti(a_bAllowOpti) + {} + + + //--------------------------------------------------------------------------- + ParserCallback::ParserCallback(multfun_type a_pFun, bool a_bAllowOpti) + :m_pFun((void*)a_pFun) + ,m_iArgc(-1) + ,m_iPri(-1) + ,m_eOprtAsct(oaNONE) + ,m_iCode(cmFUNC) + ,m_iType(tpDBL) + ,m_bAllowOpti(a_bAllowOpti) + {} + + + //--------------------------------------------------------------------------- + ParserCallback::ParserCallback(strfun_type1 a_pFun, bool a_bAllowOpti) + :m_pFun((void*)a_pFun) + ,m_iArgc(0) + ,m_iPri(-1) + ,m_eOprtAsct(oaNONE) + ,m_iCode(cmFUNC_STR) + ,m_iType(tpSTR) + ,m_bAllowOpti(a_bAllowOpti) + {} + + + //--------------------------------------------------------------------------- + ParserCallback::ParserCallback(strfun_type2 a_pFun, bool a_bAllowOpti) + :m_pFun((void*)a_pFun) + ,m_iArgc(1) + ,m_iPri(-1) + ,m_eOprtAsct(oaNONE) + ,m_iCode(cmFUNC_STR) + ,m_iType(tpSTR) + ,m_bAllowOpti(a_bAllowOpti) + {} + + + //--------------------------------------------------------------------------- + ParserCallback::ParserCallback(strfun_type3 a_pFun, bool a_bAllowOpti) + :m_pFun((void*)a_pFun) + ,m_iArgc(2) + ,m_iPri(-1) + ,m_eOprtAsct(oaNONE) + ,m_iCode(cmFUNC_STR) + ,m_iType(tpSTR) + ,m_bAllowOpti(a_bAllowOpti) + {} + + + //--------------------------------------------------------------------------- + /** \brief Default constructor. + \throw nothrow + */ + ParserCallback::ParserCallback() + :m_pFun(0) + ,m_iArgc(0) + ,m_iPri(-1) + ,m_eOprtAsct(oaNONE) + ,m_iCode(cmUNKNOWN) + ,m_iType(tpVOID) + ,m_bAllowOpti(0) + {} + + + //--------------------------------------------------------------------------- + /** \brief Copy constructor. + \throw nothrow + */ + ParserCallback::ParserCallback(const ParserCallback &ref) + { + m_pFun = ref.m_pFun; + m_iArgc = ref.m_iArgc; + m_bAllowOpti = ref.m_bAllowOpti; + m_iCode = ref.m_iCode; + m_iType = ref.m_iType; + m_iPri = ref.m_iPri; + m_eOprtAsct = ref.m_eOprtAsct; + } + + //--------------------------------------------------------------------------- + /** \brief Clone this instance and return a pointer to the new instance. */ + ParserCallback* ParserCallback::Clone() const + { + return new ParserCallback(*this); + } + + //--------------------------------------------------------------------------- + /** \brief Return tru if the function is conservative. + + Conservative functions return always the same result for the same argument. + \throw nothrow + */ + bool ParserCallback::IsOptimizable() const + { + return m_bAllowOpti; + } + + //--------------------------------------------------------------------------- + /** \brief Get the callback address for the parser function. + + The type of the address is void. It needs to be recasted according to the + argument number to the right type. + + \throw nothrow + \return #pFun + */ + void* ParserCallback::GetAddr() const + { + return m_pFun; + } + + //--------------------------------------------------------------------------- + /** \brief Return the callback code. */ + ECmdCode ParserCallback::GetCode() const + { + return m_iCode; + } + + //--------------------------------------------------------------------------- + ETypeCode ParserCallback::GetType() const + { + return m_iType; + } + + + //--------------------------------------------------------------------------- + /** \brief Return the operator precedence. + \throw nothrown + + Only valid if the callback token is an operator token (binary or infix). + */ + int ParserCallback::GetPri() const + { + return m_iPri; + } + + //--------------------------------------------------------------------------- + /** \brief Return the operators associativity. + \throw nothrown + + Only valid if the callback token is a binary operator token. + */ + EOprtAssociativity ParserCallback::GetAssociativity() const + { + return m_eOprtAsct; + } + + //--------------------------------------------------------------------------- + /** \brief Returns the number of function Arguments. */ + int ParserCallback::GetArgc() const + { + return m_iArgc; + } +} // namespace mu diff --git a/AMDiS/lib/muparser_v134/src/muParserComplex.cpp b/AMDiS/lib/muparser_v134/src/muParserComplex.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a770213b92ec0b982b2139a600cb9a0c926bdc2e --- /dev/null +++ b/AMDiS/lib/muparser_v134/src/muParserComplex.cpp @@ -0,0 +1,218 @@ +/* + __________ + _____ __ __\______ \_____ _______ ______ ____ _______ + / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ + | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ + |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| + \/ \/ \/ \/ + Copyright (C) 2010 Ingo Berg + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include "muParserComplex.h" +#include "muParserFixes.h" + +#include <cmath> +#include <complex> +#include <algorithm> +#include <numeric> + +using namespace std; + +/** \file + \brief This file contains the implementation of a parser using complex numbers. +*/ + + +/** \brief Namespace for mathematical applications. */ +namespace mu +{ + //--------------------------------------------------------------------------- + value_type ParserComplex::Sin(value_type v) + { + complex_type c = UnpackToComplex(v); + return (value_type)PackToDouble(sin(c)); + } + + //--------------------------------------------------------------------------- + value_type ParserComplex::Cos(value_type v) + { + complex_type c = UnpackToComplex(v); + return (value_type)PackToDouble(cos(c)); + } + + //--------------------------------------------------------------------------- + value_type ParserComplex::Tan(value_type v) + { + complex_type c = UnpackToComplex(v); + return (value_type)PackToDouble(tan(c)); + } + + //--------------------------------------------------------------------------- + value_type ParserComplex::Sqrt(value_type v) + { + complex_type c = UnpackToComplex(v); + return (value_type)PackToDouble(sqrt(c)); + } + + //--------------------------------------------------------------------------- + value_type ParserComplex::Add(value_type v1, value_type v2) + { + complex_type c1 = UnpackToComplex(v1), + c2 = UnpackToComplex(v2); + return (value_type)PackToDouble(c1+c2); + } + + //--------------------------------------------------------------------------- + value_type ParserComplex::Sub(value_type v1, value_type v2) + { + complex_type c1 = UnpackToComplex(v1), + c2 = UnpackToComplex(v2); + return (value_type)PackToDouble(c1-c2); + } + + //--------------------------------------------------------------------------- + value_type ParserComplex::Mul(value_type v1, value_type v2) + { + complex_type c1 = UnpackToComplex(v1), + c2 = UnpackToComplex(v2); + return (value_type)PackToDouble(c1*c2); + } + + //--------------------------------------------------------------------------- + value_type ParserComplex::Div(value_type v1, value_type v2) + { + complex_type c1 = UnpackToComplex(v1), + c2 = UnpackToComplex(v2); + return (value_type)PackToDouble(c1/c2); + } + + //--------------------------------------------------------------------------- + // Unary operator Callbacks: Infix operators + value_type ParserComplex::UnaryMinus(value_type v) + { + return -v; + } + + //--------------------------------------------------------------------------- + // Default value recognition callback + int ParserComplex::IsVal(const char_type *a_szExpr, int *a_iPos, value_type *a_fVal) + { + string_type buf(a_szExpr); + + float real, imag; + int stat, len; + +#if defined (_UNICODE) + stat = swscanf(buf.c_str(), _T("{%f,%f}%n"), &real, &imag, &len); +#else + stat = sscanf(buf.c_str(), "{%f,%f}%n", &real, &imag, &len); +#endif + + if (stat!=2) + return 0; + + *a_iPos += len; + *a_fVal = (value_type)PackToDouble(complex_type(real, imag)); + return 1; + } + + //--------------------------------------------------------------------------- + /** \brief Constructor. + + Call ParserBase class constructor and trigger Function, Operator and Constant initialization. + */ + ParserComplex::ParserComplex() + :ParserBase() + { + AddValIdent(IsVal); + + InitCharSets(); + InitFun(); + InitOprt(); + } + + //--------------------------------------------------------------------------- + void ParserComplex::InitCharSets() + { + DefineNameChars( _T("0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") ); + DefineOprtChars( _T("+-*^/?<>=!%&|~'_") ); + DefineInfixOprtChars( _T("/+-*^?<>=!%&|~'_") ); + } + + //--------------------------------------------------------------------------- + /** \brief Initialize operators. */ + void ParserComplex::InitOprt() + { + // disable all built in operators, not all of them usefull for integer numbers + // (they don't do rounding of values) + EnableBuiltInOprt(false); + + // Disable all built in operators, they wont work with integer numbers + // since they are designed for floating point numbers + DefineInfixOprt( _T("-"), UnaryMinus); + + DefineOprt( _T("+"), Add, prADD_SUB); + DefineOprt( _T("-"), Sub, prADD_SUB); + DefineOprt( _T("*"), Mul, prMUL_DIV); + DefineOprt( _T("/"), Div, prMUL_DIV); + } + + //--------------------------------------------------------------------------- + void ParserComplex::InitFun() + { + DefineFun( _T("sin"), Sin); + DefineFun( _T("cos"), Cos); + DefineFun( _T("tan"), Tan); + DefineFun( _T("sqrt"), Sqrt); + } + + //--------------------------------------------------------------------------- + void ParserComplex::InitConst() + {} + + //--------------------------------------------------------------------------- + ParserComplex::complex_type ParserComplex::UnpackToComplex(double val) + { + float imag(0), real(0); + + real = *((float*)(&val)); + imag = *((float*)(&val)+1); + + return complex_type(real, imag); + } + + //--------------------------------------------------------------------------- + double ParserComplex::PackToDouble(const complex_type &val) + { + double packed = 0; + float *real = (float*)(&packed), + *imag = (float*)(&packed)+1; + + *real = val.real(); + *imag = val.imag(); + + return packed; + } + + //--------------------------------------------------------------------------- + ParserComplex::complex_type ParserComplex::Eval() + { + return UnpackToComplex(ParserBase::Eval()); + } + +} // namespace mu diff --git a/AMDiS/lib/muparser_v134/src/muParserDLL.cpp b/AMDiS/lib/muparser_v134/src/muParserDLL.cpp new file mode 100644 index 0000000000000000000000000000000000000000..86adca425eaaed91f8ce0498357f0b2171fc20ff --- /dev/null +++ b/AMDiS/lib/muparser_v134/src/muParserDLL.cpp @@ -0,0 +1,831 @@ +/* + __________ + _____ __ __\______ \_____ _______ ______ ____ _______ + / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ + | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ + |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| + \/ \/ \/ \/ + Copyright (C) 2004-2010 Ingo Berg + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +#if defined(MUPARSER_DLL) + +#if defined(_WIN32) + #define WIN32_LEAN_AND_MEAN + #include <windows.h> +#endif + +#include "muParserDLL.h" +#include "muParser.h" +#include "muParserError.h" + + +#define MU_TRY \ + try \ + { + +#define MU_CATCH \ + } \ + catch(muError_t &e) \ + { \ + ParserTag *pTag = static_cast<ParserTag*>(a_hParser); \ + pTag->exc = e; \ + pTag->bError = true; \ + if (pTag->errHandler) \ + (pTag->errHandler)(a_hParser); \ + } \ + catch(...) \ + { \ + ParserTag *pTag = static_cast<ParserTag*>(a_hParser); \ + pTag->exc = muError_t(mu::ecINTERNAL_ERROR); \ + pTag->bError = true; \ + if (pTag->errHandler) \ + (pTag->errHandler)(a_hParser); \ + } + +/** \file + \brief This file contains the implementation of the DLL interface of muparser. +*/ + +//--------------------------------------------------------------------------- +class ParserTag +{ +public: + ParserTag() + :pParser(new mu::Parser()) + ,exc() + ,errHandler(NULL) + ,bError(false) + {} + + ~ParserTag() + { + delete pParser; + } + + mu::Parser *pParser; + mu::ParserBase::exception_type exc; + muErrorHandler_t errHandler; + bool bError; + +private: + ParserTag(const ParserTag &ref); + ParserTag& operator=(const ParserTag &ref); +}; + +static muChar_t s_tmpOutBuf[2048]; + +//--------------------------------------------------------------------------- +// private types +typedef mu::ParserBase::exception_type muError_t; +typedef mu::Parser muParser_t; + +//--------------------------------------------------------------------------- +// constants +int muOPRT_ASCT_LEFT = 0; +int muOPRT_ASCT_RIGHT = 1; + +//--------------------------------------------------------------------------- +// +// +// unexported functions +// +// +//--------------------------------------------------------------------------- + +muParser_t* AsParser(muParserHandle_t a_hParser) +{ + return static_cast<ParserTag*>(a_hParser)->pParser; +} + +//--------------------------------------------------------------------------- +ParserTag* AsParserTag(muParserHandle_t a_hParser) +{ + return static_cast<ParserTag*>(a_hParser); +} + +//--------------------------------------------------------------------------- +#if defined(_WIN32) + #define _CRT_SECURE_NO_DEPRECATE + + BOOL APIENTRY DllMain( HANDLE /*hModule*/, + DWORD ul_reason_for_call, + LPVOID /*lpReserved*/ ) + { + switch (ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + break; + + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + + return TRUE; + } + +#endif + +//--------------------------------------------------------------------------- +// +// +// exported functions +// +// +//--------------------------------------------------------------------------- + +API_EXPORT(void) mupSetVarFactory(muParserHandle_t a_hParser, muFacFun_t a_pFactory, void *pUserData) +{ + MU_TRY + muParser_t* p(AsParser(a_hParser)); + p->SetVarFactory(a_pFactory, pUserData); + MU_CATCH +} + +//--------------------------------------------------------------------------- +/** \brief Create a new Parser instance and return its handle. +*/ +API_EXPORT(muParserHandle_t) mupCreate() +{ + return (void*)(new ParserTag()); +} + +//--------------------------------------------------------------------------- +/** \brief Release the parser instance related with a parser handle. +*/ +API_EXPORT(void) mupRelease(muParserHandle_t a_hParser) +{ + MU_TRY + ParserTag* p = static_cast<ParserTag*>(a_hParser); + delete p; + MU_CATCH +} + +//--------------------------------------------------------------------------- +API_EXPORT(const muChar_t*) mupGetVersion(muParserHandle_t a_hParser) +{ + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + sprintf(s_tmpOutBuf, "%s", p->GetVersion().c_str()); + return s_tmpOutBuf; + MU_CATCH + + return ""; +} + +//--------------------------------------------------------------------------- +/** \brief Evaluate the expression. +*/ +API_EXPORT(double) mupEval(muParserHandle_t a_hParser) +{ + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + return p->Eval(); + MU_CATCH + + return 0; +} + +//--------------------------------------------------------------------------- +API_EXPORT(void) mupSetExpr(muParserHandle_t a_hParser, const muChar_t* a_szExpr) +{ + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + p->SetExpr(a_szExpr); + MU_CATCH +} + +//--------------------------------------------------------------------------- +API_EXPORT(void) mupRemoveVar(muParserHandle_t a_hParser, const muChar_t* a_szName) +{ + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + p->RemoveVar( a_szName ); + MU_CATCH +} + +//--------------------------------------------------------------------------- +/** \brief Release all parser variables. + \param a_hParser Handle to the parser instance. +*/ +API_EXPORT(void) mupClearVar(muParserHandle_t a_hParser) +{ + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + p->ClearVar(); + MU_CATCH +} + +//--------------------------------------------------------------------------- +/** \brief Release all parser variables. + \param a_hParser Handle to the parser instance. +*/ +API_EXPORT(void) mupClearConst(muParserHandle_t a_hParser) +{ + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + p->ClearConst(); + MU_CATCH +} + +//--------------------------------------------------------------------------- +/** \brief Clear all user defined operators. + \param a_hParser Handle to the parser instance. +*/ +API_EXPORT(void) mupClearOprt(muParserHandle_t a_hParser) +{ + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + p->ClearOprt(); + MU_CATCH +} + +//--------------------------------------------------------------------------- +API_EXPORT(void) mupClearFun(muParserHandle_t a_hParser) +{ + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + p->ClearFun(); + MU_CATCH +} + +//--------------------------------------------------------------------------- +API_EXPORT(void) mupDefineFun0( muParserHandle_t a_hParser, + const muChar_t* a_szName, + muFun0_t a_pFun, + muBool_t a_bAllowOpt ) +{ + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + p->DefineFun(a_szName, a_pFun, a_bAllowOpt!=0); + MU_CATCH +} + +//--------------------------------------------------------------------------- +API_EXPORT(void) mupDefineFun1( muParserHandle_t a_hParser, + const muChar_t* a_szName, + muFun1_t a_pFun, + muBool_t a_bAllowOpt ) +{ + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + p->DefineFun(a_szName, a_pFun, a_bAllowOpt!=0); + MU_CATCH +} + +//--------------------------------------------------------------------------- +API_EXPORT(void) mupDefineFun2( muParserHandle_t a_hParser, + const muChar_t* a_szName, + muFun2_t a_pFun, + muBool_t a_bAllowOpt ) +{ + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + p->DefineFun(a_szName, a_pFun, a_bAllowOpt!=0); + MU_CATCH +} + +//--------------------------------------------------------------------------- +API_EXPORT(void) mupDefineFun3( muParserHandle_t a_hParser, + const muChar_t *a_szName, + muFun3_t a_pFun, + muBool_t a_bAllowOpt ) +{ + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + p->DefineFun(a_szName, a_pFun, a_bAllowOpt!=0); + MU_CATCH +} + +//--------------------------------------------------------------------------- +API_EXPORT(void) mupDefineFun4( muParserHandle_t a_hParser, + const muChar_t *a_szName, + muFun4_t a_pFun, + muBool_t a_bAllowOpt ) +{ + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + p->DefineFun(a_szName, a_pFun, a_bAllowOpt!=0); + MU_CATCH +} + +//--------------------------------------------------------------------------- +API_EXPORT(void) mupDefineFun5( muParserHandle_t a_hParser, + const muChar_t *a_szName, + muFun5_t a_pFun, + muBool_t a_bAllowOpt ) +{ + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + p->DefineFun(a_szName, a_pFun, a_bAllowOpt!=0); + MU_CATCH +} + +//--------------------------------------------------------------------------- +API_EXPORT(void) mupDefineStrFun1( muParserHandle_t a_hParser, + const muChar_t *a_szName, + muStrFun1_t a_pFun ) +{ + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + p->DefineFun(a_szName, a_pFun, false); + MU_CATCH +} + +//--------------------------------------------------------------------------- +API_EXPORT(void) mupDefineStrFun2( muParserHandle_t a_hParser, + const muChar_t* a_szName, + muStrFun2_t a_pFun ) +{ + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + p->DefineFun(a_szName, a_pFun, false); + MU_CATCH +} + +//--------------------------------------------------------------------------- +API_EXPORT(void) mupDefineStrFun3( muParserHandle_t a_hParser, + const muChar_t* a_szName, + muStrFun3_t a_pFun ) +{ + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + p->DefineFun(a_szName, a_pFun, false); + MU_CATCH +} + +//--------------------------------------------------------------------------- +API_EXPORT(void) mupDefineMultFun( muParserHandle_t a_hParser, + const muChar_t *a_szName, + muMultFun_t a_pFun, + muBool_t a_bAllowOpt ) +{ + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + p->DefineFun(a_szName, a_pFun, a_bAllowOpt!=0); + MU_CATCH +} + +//--------------------------------------------------------------------------- +API_EXPORT(void) mupDefineOprt( muParserHandle_t a_hParser, + const muChar_t* a_szName, + muFun2_t a_pFun, + muInt_t a_nPrec, + muInt_t a_nOprtAsct, + muBool_t a_bAllowOpt) +{ + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + p->DefineOprt(a_szName, + a_pFun, + a_nPrec, + (mu::EOprtAssociativity)a_nOprtAsct, + a_bAllowOpt!=0); + MU_CATCH +} + +//--------------------------------------------------------------------------- +API_EXPORT(void) mupDefineVar(muParserHandle_t a_hParser, + const char *a_szName, + double *a_pVar) +{ + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + p->DefineVar(a_szName, a_pVar); + MU_CATCH +} + +//--------------------------------------------------------------------------- +API_EXPORT(void) mupDefineConst(muParserHandle_t a_hParser, const char *a_szName, double a_fVal) +{ + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + p->DefineConst(a_szName, a_fVal); + MU_CATCH +} + +//--------------------------------------------------------------------------- +API_EXPORT(void) mupDefineStrConst(muParserHandle_t a_hParser, const char *a_szName, const char *a_szVal) +{ + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + p->DefineStrConst(a_szName, a_szVal); + MU_CATCH +} + +//--------------------------------------------------------------------------- +API_EXPORT(const muChar_t*) mupGetExpr(muParserHandle_t a_hParser) +{ + MU_TRY + muParser_t* const p(AsParser(a_hParser)); +// return p->GetExpr().c_str(); + + // C# explodes when pMsg is returned directly. For some reason it can't access + // the memory where the message lies directly. +// static char szBuf[1024]; + sprintf(s_tmpOutBuf, "%s", p->GetExpr().c_str()); + return s_tmpOutBuf; + + MU_CATCH + + return ""; +} + +//--------------------------------------------------------------------------- +API_EXPORT(void) mupDefinePostfixOprt( muParserHandle_t a_hParser, + const muChar_t* a_szName, + muFun1_t a_pOprt, + muBool_t a_bAllowOpt ) +{ + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + p->DefinePostfixOprt(a_szName, a_pOprt, a_bAllowOpt!=0); + MU_CATCH +} + +//--------------------------------------------------------------------------- +API_EXPORT(void) mupDefineInfixOprt( muParserHandle_t a_hParser, + const muChar_t* a_szName, + muFun1_t a_pOprt, + muBool_t a_bAllowOpt ) +{ + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + p->DefineInfixOprt(a_szName, a_pOprt, a_bAllowOpt!=0); + MU_CATCH +} + +// Define character sets for identifiers +//--------------------------------------------------------------------------- +API_EXPORT(void) mupDefineNameChars( muParserHandle_t a_hParser, + const muChar_t* a_szCharset ) +{ + muParser_t* const p(AsParser(a_hParser)); + p->DefineNameChars(a_szCharset); +} + +//--------------------------------------------------------------------------- +API_EXPORT(void) mupDefineOprtChars( muParserHandle_t a_hParser, + const muChar_t* a_szCharset ) +{ + muParser_t* const p(AsParser(a_hParser)); + p->DefineOprtChars(a_szCharset); +} + +//--------------------------------------------------------------------------- +API_EXPORT(void) mupDefineInfixOprtChars(muParserHandle_t a_hParser, const char *a_szCharset) +{ + muParser_t* const p(AsParser(a_hParser)); + p->DefineInfixOprtChars(a_szCharset); +} + +//--------------------------------------------------------------------------- +/** \brief Get the number of variables defined in the parser. + \param a_hParser [in] Must be a valid parser handle. + \return The number of used variables. + \sa mupGetExprVar +*/ +API_EXPORT(int) mupGetVarNum(muParserHandle_t a_hParser) +{ + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + const mu::varmap_type VarMap = p->GetVar(); + return (int)VarMap.size(); + MU_CATCH + + return 0; // never reached +} + +//--------------------------------------------------------------------------- +/** \brief Return a variable that is used in an expression. + \param a_hParser [in] A valid parser handle. + \param a_iVar [in] The index of the variable to return. + \param a_szName [out] Pointer to the variable name. + \param a_pVar [out] Pointer to the variable. + \throw nothrow + + Prior to calling this function call mupGetExprVarNum in order to get the + number of variables in the expression. If the parameter a_iVar is greater + than the number of variables both a_szName and a_pVar will be set to zero. + As a side effect this function will trigger an internal calculation of the + expression undefined variables will be set to zero during this calculation. + During the calculation user defined callback functions present in the expression + will be called, this is unavoidable. +*/ +API_EXPORT(void) mupGetVar(muParserHandle_t a_hParser, unsigned a_iVar, const char **a_szName, double **a_pVar) +{ + // A static buffer is needed for the name since i cant return the + // pointer from the map. + static char szName[1024]; + + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + const mu::varmap_type VarMap = p->GetVar(); + + if (a_iVar>=VarMap.size()) + { + *a_szName = 0; + *a_pVar = 0; + return; + } + mu::varmap_type::const_iterator item; + + item = VarMap.begin(); + for (unsigned i=0; i<a_iVar; ++i) + item++; + + strncpy(szName, item->first.c_str(), sizeof(szName)); + szName[sizeof(szName)-1] = 0; + + *a_szName = &szName[0]; + *a_pVar = item->second; + return; + + MU_CATCH + + *a_szName = 0; + *a_pVar = 0; +} + +//--------------------------------------------------------------------------- +/** \brief Get the number of variables used in the expression currently set in the parser. + \param a_hParser [in] Must be a valid parser handle. + \return The number of used variables. + \sa mupGetExprVar +*/ +API_EXPORT(int) mupGetExprVarNum(muParserHandle_t a_hParser) +{ + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + const mu::varmap_type VarMap = p->GetUsedVar(); + return (int)VarMap.size(); + MU_CATCH + + return 0; // never reached +} + +//--------------------------------------------------------------------------- +/** \brief Return a variable that is used in an expression. + + Prior to calling this function call mupGetExprVarNum in order to get the + number of variables in the expression. If the parameter a_iVar is greater + than the number of variables both a_szName and a_pVar will be set to zero. + As a side effect this function will trigger an internal calculation of the + expression undefined variables will be set to zero during this calculation. + During the calculation user defined callback functions present in the expression + will be called, this is unavoidable. + + \param a_hParser [in] A valid parser handle. + \param a_iVar [in] The index of the variable to return. + \param a_szName [out] Pointer to the variable name. + \param a_pVar [out] Pointer to the variable. + \throw nothrow +*/ +API_EXPORT(void) mupGetExprVar(muParserHandle_t a_hParser, unsigned a_iVar, const char **a_szName, double **a_pVar) +{ + // A static buffer is needed for the name since i cant return the + // pointer from the map. + static char szName[1024]; + + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + const mu::varmap_type VarMap = p->GetUsedVar(); + + if (a_iVar>=VarMap.size()) + { + *a_szName = 0; + *a_pVar = 0; + return; + } + mu::varmap_type::const_iterator item; + + item = VarMap.begin(); + for (unsigned i=0; i<a_iVar; ++i) + item++; + + strncpy(szName, item->first.c_str(), sizeof(szName)); + szName[sizeof(szName)-1] = 0; + + *a_szName = &szName[0]; + *a_pVar = item->second; + return; + + MU_CATCH + + *a_szName = 0; + *a_pVar = 0; +} + +//--------------------------------------------------------------------------- +/** \brief Return the number of constants defined in a parser. */ +API_EXPORT(int) mupGetConstNum(muParserHandle_t a_hParser) +{ + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + const mu::valmap_type ValMap = p->GetConst(); + return (int)ValMap.size(); + MU_CATCH + + return 0; // never reached +} + +//----------------------------------------------------------------------------------------------------- +API_EXPORT(void) mupSetArgSep(muParserHandle_t a_hParser, const muChar_t cArgSep) +{ + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + p->SetArgSep(cArgSep); + MU_CATCH +} + +//----------------------------------------------------------------------------------------------------- +API_EXPORT(void) mupResetLocale(muParserHandle_t a_hParser) +{ + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + p->ResetLocale(); + MU_CATCH +} + +//----------------------------------------------------------------------------------------------------- +API_EXPORT(void) mupSetDecSep(muParserHandle_t a_hParser, const muChar_t cDecSep) +{ + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + p->SetDecSep(cDecSep); + MU_CATCH +} + +//----------------------------------------------------------------------------------------------------- +API_EXPORT(void) mupSetThousandsSep(muParserHandle_t a_hParser, const muChar_t cThousandsSep) +{ + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + p->SetThousandsSep(cThousandsSep); + MU_CATCH +} + +//--------------------------------------------------------------------------- +/** \brief Retrieve name and value of a single parser constant. + \param a_hParser [in] a valid parser handle + \param a_iVar [in] Index of the constant to query + \param a_pszName [out] pointer to a null terminated string with the constant name + \param [out] The constant value +*/ +API_EXPORT(void) mupGetConst( muParserHandle_t a_hParser, + unsigned a_iVar, + const muChar_t **a_pszName, + muFloat_t *a_fVal) +{ + // A static buffer is needed for the name since i cant return the + // pointer from the map. + static char szName[1024]; + + MU_TRY + muParser_t* const p(AsParser(a_hParser)); + const mu::valmap_type ValMap = p->GetConst(); + + if (a_iVar>=ValMap.size()) + { + *a_pszName = 0; + *a_fVal = 0; + return; + } + + mu::valmap_type::const_iterator item; + item = ValMap.begin(); + for (unsigned i=0; i<a_iVar; ++i) + item++; + + strncpy(szName, item->first.c_str(), sizeof(szName)); + szName[sizeof(szName)-1] = 0; + + *a_pszName = &szName[0]; + *a_fVal = item->second; + return; + + MU_CATCH + + *a_pszName = 0; + *a_fVal = 0; +} + +//--------------------------------------------------------------------------- +/** \brief Add a custom value regognition function. +*/ +API_EXPORT(void) mupAddValIdent(muParserHandle_t a_hParser, + muIdentFun_t a_pFun) +{ + MU_TRY + muParser_t* p(AsParser(a_hParser)); + p->AddValIdent(a_pFun); + MU_CATCH +} + +//--------------------------------------------------------------------------- +/** \brief Query if an error occured. + + After querying the internal error bit will be reset. So a consecutive call + will return false. +*/ +API_EXPORT(muBool_t) mupError(muParserHandle_t a_hParser) +{ + bool bError( AsParserTag(a_hParser)->bError ); + AsParserTag(a_hParser)->bError = false; + return bError; +} + +//--------------------------------------------------------------------------- +/** \brief Reset the internal error flag. +*/ +API_EXPORT(void) mupErrorReset(muParserHandle_t a_hParser) +{ + AsParserTag(a_hParser)->bError = false; +} + +//--------------------------------------------------------------------------- +API_EXPORT(void) mupSetErrorHandler(muParserHandle_t a_hParser, muErrorHandler_t a_pHandler) +{ + AsParserTag(a_hParser)->errHandler = a_pHandler; +} + +//--------------------------------------------------------------------------- +/** \brief Return the message associated with the last error. +*/ +API_EXPORT(const muChar_t*) mupGetErrorMsg(muParserHandle_t a_hParser) +{ + ParserTag* const p(AsParserTag(a_hParser)); + const char *pMsg = p->exc.GetMsg().c_str(); + + // C# explodes when pMsg is returned directly. For some reason it can't access + // the memory where the message lies directly. +// static char szBuf[1024]; + sprintf(s_tmpOutBuf, "%s", pMsg); + return s_tmpOutBuf; +} + +//--------------------------------------------------------------------------- +/** \brief Return the message associated with the last error. +*/ +API_EXPORT(const muChar_t*) mupGetErrorToken(muParserHandle_t a_hParser) +{ + ParserTag* const p(AsParserTag(a_hParser)); + const char *pToken = p->exc.GetToken().c_str(); + + // C# explodes when pMsg is returned directly. For some reason it can't access + // the memory where the message lies directly. +// static char szBuf[1024]; + sprintf(s_tmpOutBuf, "%s", pToken); + return s_tmpOutBuf; +} + +//--------------------------------------------------------------------------- +/** \brief Return the code associated with the last error. +*/ +API_EXPORT(int) mupGetErrorCode(muParserHandle_t a_hParser) +{ + return AsParserTag(a_hParser)->exc.GetCode(); +} + +//--------------------------------------------------------------------------- +/** \brief Return the postion associated with the last error. */ +API_EXPORT(int) mupGetErrorPos(muParserHandle_t a_hParser) +{ + return (int)AsParserTag(a_hParser)->exc.GetPos(); +} + +////----------------------------------------------------------------------------------------------------- +//API_EXPORT(const muChar_t*) mupGetErrorExpr(muParserHandle_t a_hParser) +//{ +// return AsParserTag(a_hParser)->exc.GetExpr().c_str(); +//} + +//----------------------------------------------------------------------------------------------------- +API_EXPORT(muFloat_t*) mupCreateVar() +{ + return new muFloat_t(0); +} + +//----------------------------------------------------------------------------------------------------- +API_EXPORT(void) mupReleaseVar(muFloat_t *ptr) +{ + delete ptr; +} + +#endif // MUPARSER_DLL diff --git a/AMDiS/lib/muparser_v134/src/muParserError.cpp b/AMDiS/lib/muparser_v134/src/muParserError.cpp new file mode 100644 index 0000000000000000000000000000000000000000..43b8a2a93193ac02907128a0a9883eba3d9b27b0 --- /dev/null +++ b/AMDiS/lib/muparser_v134/src/muParserError.cpp @@ -0,0 +1,325 @@ +/* + __________ + _____ __ __\______ \_____ _______ ______ ____ _______ + / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ + | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ + |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| + \/ \/ \/ \/ + Copyright (C) 2010 Ingo Berg + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +#include "muParserError.h" + + +namespace mu +{ + const ParserErrorMsg ParserErrorMsg::m_Instance; + + //------------------------------------------------------------------------------ + const ParserErrorMsg& ParserErrorMsg::Instance() + { + return m_Instance; + } + + //------------------------------------------------------------------------------ + string_type ParserErrorMsg::operator[](unsigned a_iIdx) const + { + return (a_iIdx<m_vErrMsg.size()) ? m_vErrMsg[a_iIdx] : string_type(); + } + + //--------------------------------------------------------------------------- + ParserErrorMsg::~ParserErrorMsg() + {} + + //--------------------------------------------------------------------------- + /** \brief Assignement operator is deactivated. + */ + ParserErrorMsg& ParserErrorMsg::operator=(const ParserErrorMsg& ) + { + assert(false); + return *this; + } + + //--------------------------------------------------------------------------- + ParserErrorMsg::ParserErrorMsg(const ParserErrorMsg&) + {} + + //--------------------------------------------------------------------------- + ParserErrorMsg::ParserErrorMsg() + :m_vErrMsg(0) + { + m_vErrMsg.resize(ecCOUNT); + + m_vErrMsg[ecUNASSIGNABLE_TOKEN] = _T("Undefined token \"$TOK$\" found at position $POS$."); + m_vErrMsg[ecINTERNAL_ERROR] = _T("Internal error"); + m_vErrMsg[ecINVALID_NAME] = _T("Invalid function-, variable- or constant name: \"$TOK$\"."); + m_vErrMsg[ecINVALID_BINOP_IDENT] = _T("Invalid binary operator identifier: \"$TOK$\"."); + m_vErrMsg[ecINVALID_INFIX_IDENT] = _T("Invalid infix operator identifier: \"$TOK$\"."); + m_vErrMsg[ecINVALID_POSTFIX_IDENT] = _T("Invalid postfix operator identifier: \"$TOK$\"."); + m_vErrMsg[ecINVALID_FUN_PTR] = _T("Invalid pointer to callback function."); + m_vErrMsg[ecEMPTY_EXPRESSION] = _T("Expression is empty."); + m_vErrMsg[ecINVALID_VAR_PTR] = _T("Invalid pointer to variable."); + m_vErrMsg[ecUNEXPECTED_OPERATOR] = _T("Unexpected operator \"$TOK$\" found at position $POS$"); + m_vErrMsg[ecUNEXPECTED_EOF] = _T("Unexpected end of expression at position $POS$"); + m_vErrMsg[ecUNEXPECTED_ARG_SEP] = _T("Unexpected argument separator at position $POS$"); + m_vErrMsg[ecUNEXPECTED_PARENS] = _T("Unexpected parenthesis \"$TOK$\" at position $POS$"); + m_vErrMsg[ecUNEXPECTED_FUN] = _T("Unexpected function \"$TOK$\" at position $POS$"); + m_vErrMsg[ecUNEXPECTED_VAL] = _T("Unexpected value \"$TOK$\" found at position $POS$"); + m_vErrMsg[ecUNEXPECTED_VAR] = _T("Unexpected variable \"$TOK$\" found at position $POS$"); + m_vErrMsg[ecUNEXPECTED_ARG] = _T("Function arguments used without a function (position: $POS$)"); + m_vErrMsg[ecMISSING_PARENS] = _T("Missing parenthesis"); + m_vErrMsg[ecTOO_MANY_PARAMS] = _T("Too many parameters for function \"$TOK$\" at expression position $POS$"); + m_vErrMsg[ecTOO_FEW_PARAMS] = _T("Too few parameters for function \"$TOK$\" at expression position $POS$"); + m_vErrMsg[ecDIV_BY_ZERO] = _T("Divide by zero"); + m_vErrMsg[ecDOMAIN_ERROR] = _T("Domain error"); + m_vErrMsg[ecNAME_CONFLICT] = _T("Name conflict"); + m_vErrMsg[ecOPT_PRI] = _T("Invalid value for operator priority (must be greater or equal to zero)."); + m_vErrMsg[ecBUILTIN_OVERLOAD] = _T("user defined binary operator \"$TOK$\" conflicts with a built in operator."); + m_vErrMsg[ecUNEXPECTED_STR] = _T("Unexpected string token found at position $POS$."); + m_vErrMsg[ecUNTERMINATED_STRING] = _T("Unterminated string starting at position $POS$."); + m_vErrMsg[ecSTRING_EXPECTED] = _T("String function called with a non string type of argument."); + m_vErrMsg[ecVAL_EXPECTED] = _T("String value used where a numerical argument is expected."); + m_vErrMsg[ecOPRT_TYPE_CONFLICT] = _T("No suitable overload for operator \"$TOK$\" at position $POS$."); + m_vErrMsg[ecGENERIC] = _T("Parser error."); + m_vErrMsg[ecLOCALE] = _T("Decimal separator is identic to function argument separator."); + m_vErrMsg[ecSTR_RESULT] = _T("Function result is a string."); + + #if defined(_DEBUG) + for (int i=0; i<ecCOUNT; ++i) + if (!m_vErrMsg[i].length()) + assert(false); + #endif + } + + //--------------------------------------------------------------------------- + // + // ParserError class + // + //--------------------------------------------------------------------------- + + /** \brief Default constructor. */ + ParserError::ParserError() + :m_strMsg() + ,m_strFormula() + ,m_strTok() + ,m_iPos(-1) + ,m_iErrc(ecUNDEFINED) + ,m_ErrMsg(ParserErrorMsg::Instance()) + { + } + + //------------------------------------------------------------------------------ + /** \brief This Constructor is used for internal exceptions only. + + It does not contain any information but the error code. + */ + ParserError::ParserError(EErrorCodes /*a_iErrc*/) + :m_ErrMsg(ParserErrorMsg::Instance()) + { + Reset(); + m_strMsg = _T("parser error"); + } + + //------------------------------------------------------------------------------ + /** \brief Construct an error from a message text. */ + ParserError::ParserError(const string_type &sMsg) + :m_ErrMsg(ParserErrorMsg::Instance()) + { + Reset(); + m_strMsg = sMsg; + } + + //------------------------------------------------------------------------------ + /** \brief Construct an error object. + \param [in] a_iErrc the error code. + \param [in] sTok The token string related to this error. + \param [in] sExpr The expression related to the error. + \param [in] a_iPos the position in the expression where the error occured. + */ + ParserError::ParserError( EErrorCodes iErrc, + const string_type &sTok, + const string_type &sExpr, + int iPos ) + :m_strMsg() + ,m_strFormula(sExpr) + ,m_strTok(sTok) + ,m_iPos(iPos) + ,m_iErrc(iErrc) + ,m_ErrMsg(ParserErrorMsg::Instance()) + { + m_strMsg = m_ErrMsg[m_iErrc]; + stringstream_type stream; + stream << (int)m_iPos; + ReplaceSubString(m_strMsg, _T("$POS$"), stream.str()); + ReplaceSubString(m_strMsg, _T("$TOK$"), m_strTok); + } + + //------------------------------------------------------------------------------ + /** \brief Construct an error object. + \param [in] iErrc the error code. + \param [in] iPos the position in the expression where the error occured. + \param [in] sTok The token string related to this error. + */ + ParserError::ParserError(EErrorCodes iErrc, int iPos, const string_type &sTok) + :m_strMsg() + ,m_strFormula() + ,m_strTok(sTok) + ,m_iPos(iPos) + ,m_iErrc(iErrc) + ,m_ErrMsg(ParserErrorMsg::Instance()) + { + m_strMsg = m_ErrMsg[m_iErrc]; + stringstream_type stream; + stream << (int)m_iPos; + ReplaceSubString(m_strMsg, _T("$POS$"), stream.str()); + ReplaceSubString(m_strMsg, _T("$TOK$"), m_strTok); + } + + //------------------------------------------------------------------------------ + /** \brief Construct an error object. + \param [in] szMsg The error message text. + \param [in] iPos the position related to the error. + \param [in] sTok The token string related to this error. + */ + ParserError::ParserError(const char_type *szMsg, int iPos, const string_type &sTok) + :m_strMsg(szMsg) + ,m_strFormula() + ,m_strTok(sTok) + ,m_iPos(iPos) + ,m_iErrc(ecGENERIC) + ,m_ErrMsg(ParserErrorMsg::Instance()) + { + stringstream_type stream; + stream << (int)m_iPos; + ReplaceSubString(m_strMsg, _T("$POS$"), stream.str()); + ReplaceSubString(m_strMsg, _T("$TOK$"), m_strTok); + } + + //------------------------------------------------------------------------------ + /** \brief Copy constructor. */ + ParserError::ParserError(const ParserError &a_Obj) + :m_strMsg(a_Obj.m_strMsg) + ,m_strFormula(a_Obj.m_strFormula) + ,m_strTok(a_Obj.m_strTok) + ,m_iPos(a_Obj.m_iPos) + ,m_iErrc(a_Obj.m_iErrc) + ,m_ErrMsg(ParserErrorMsg::Instance()) + { + } + + //------------------------------------------------------------------------------ + /** \brief Assignment operator. */ + ParserError& ParserError::operator=(const ParserError &a_Obj) + { + if (this==&a_Obj) + return *this; + + m_strMsg = a_Obj.m_strMsg; + m_strFormula = a_Obj.m_strFormula; + m_strTok = a_Obj.m_strTok; + m_iPos = a_Obj.m_iPos; + m_iErrc = a_Obj.m_iErrc; + return *this; + } + + //------------------------------------------------------------------------------ + ParserError::~ParserError() + {} + + //------------------------------------------------------------------------------ + /** \brief Replace all ocuurences of a substring with another string. + \param strFind The string that shall be replaced. + \param strReplaceWith The string that should be inserted instead of strFind + */ + void ParserError::ReplaceSubString( string_type &strSource, + const string_type &strFind, + const string_type &strReplaceWith) + { + string_type strResult; + string_type::size_type iPos(0), iNext(0); + + for(;;) + { + iNext = strSource.find(strFind, iPos); + strResult.append(strSource, iPos, iNext-iPos); + + if( iNext==string_type::npos ) + break; + + strResult.append(strReplaceWith); + iPos = iNext + strFind.length(); + } + + strSource.swap(strResult); + } + + //------------------------------------------------------------------------------ + /** \brief Reset the erro object. */ + void ParserError::Reset() + { + m_strMsg = _T(""); + m_strFormula = _T(""); + m_strTok = _T(""); + m_iPos = -1; + m_iErrc = ecUNDEFINED; + } + + //------------------------------------------------------------------------------ + /** \brief Set the expression related to this error. */ + void ParserError::SetFormula(const string_type &a_strFormula) + { + m_strFormula = a_strFormula; + } + + //------------------------------------------------------------------------------ + /** \brief gets the expression related tp this error.*/ + const string_type& ParserError::GetExpr() const + { + return m_strFormula; + } + + //------------------------------------------------------------------------------ + /** \brief Returns the message string for this error. */ + const string_type& ParserError::GetMsg() const + { + return m_strMsg; + } + + //------------------------------------------------------------------------------ + /** \brief Return the formula position related to the error. + + If the error is not related to a distinct position this will return -1 + */ + std::size_t ParserError::GetPos() const + { + return m_iPos; + } + + //------------------------------------------------------------------------------ + /** \brief Return string related with this token (if available). */ + const string_type& ParserError::GetToken() const + { + return m_strTok; + } + + //------------------------------------------------------------------------------ + /** \brief Return the error code. */ + EErrorCodes ParserError::GetCode() const + { + return m_iErrc; + } +} // namespace mu diff --git a/AMDiS/lib/muparser_v134/src/muParserInt.cpp b/AMDiS/lib/muparser_v134/src/muParserInt.cpp new file mode 100644 index 0000000000000000000000000000000000000000..25792be80aacea0ba008538eb1d4f51e0b9af999 --- /dev/null +++ b/AMDiS/lib/muparser_v134/src/muParserInt.cpp @@ -0,0 +1,271 @@ +/* + __________ + _____ __ __\______ \_____ _______ ______ ____ _______ + / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ + | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ + |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| + \/ \/ \/ \/ + Copyright (C) 2010 Ingo Berg + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include "muParserInt.h" + +#include <cmath> +#include <algorithm> +#include <numeric> + +using namespace std; + +/** \file + \brief Implementation of a parser using integer value. +*/ + +/** \brief Namespace for mathematical applications. */ +namespace mu +{ + +value_type ParserInt::Abs(value_type v) { return (value_type)Round(fabs(v)); } +value_type ParserInt::Sign(value_type v) { return (Round(v)<0) ? -1 : (Round(v)>0) ? 1 : 0; } +value_type ParserInt::Ite(value_type v1, + value_type v2, + value_type v3) { return (Round(v1)==1) ? Round(v2) : Round(v3); } +value_type ParserInt::Add(value_type v1, value_type v2) { return Round(v1) + Round(v2); } +value_type ParserInt::Sub(value_type v1, value_type v2) { return Round(v1) - Round(v2); } +value_type ParserInt::Mul(value_type v1, value_type v2) { return Round(v1) * Round(v2); } +value_type ParserInt::Div(value_type v1, value_type v2) { return Round(v1) / Round(v2); } +value_type ParserInt::Mod(value_type v1, value_type v2) { return Round(v1) % Round(v2); } +value_type ParserInt::Shr(value_type v1, value_type v2) { return Round(v1) >> Round(v2); } +value_type ParserInt::Shl(value_type v1, value_type v2) { return Round(v1) << Round(v2); } +value_type ParserInt::LogAnd(value_type v1, value_type v2) { return Round(v1) & Round(v2); } +value_type ParserInt::LogOr(value_type v1, value_type v2) { return Round(v1) | Round(v2); } +value_type ParserInt::And(value_type v1, value_type v2) { return Round(v1) && Round(v2); } +value_type ParserInt::Or(value_type v1, value_type v2) { return Round(v1) || Round(v2); } +value_type ParserInt::Less(value_type v1, value_type v2) { return Round(v1) < Round(v2); } +value_type ParserInt::Greater(value_type v1, value_type v2) { return Round(v1) > Round(v2); } +value_type ParserInt::LessEq(value_type v1, value_type v2) { return Round(v1) <= Round(v2); } +value_type ParserInt::GreaterEq(value_type v1, value_type v2) { return Round(v1) >= Round(v2); } +value_type ParserInt::Equal(value_type v1, value_type v2) { return Round(v1) == Round(v2); } +value_type ParserInt::NotEqual(value_type v1, value_type v2) { return Round(v1) != Round(v2); } +value_type ParserInt::Not(value_type v) { return !Round(v); } +value_type ParserInt::Pow(value_type v1, value_type v2) { return std::pow((value_type)Round(v1), (int)Round(v2)); } + +//--------------------------------------------------------------------------- +// Unary operator Callbacks: Infix operators +value_type ParserInt::UnaryMinus(value_type v) +{ + return -Round(v); +} + +//--------------------------------------------------------------------------- +value_type ParserInt::Sum(const value_type* a_afArg, int a_iArgc) +{ + if (!a_iArgc) + throw ParserError(_T("too few arguments for function sum.")); + + value_type fRes=0; + for (int i=0; i<a_iArgc; ++i) + fRes += a_afArg[i]; + + return fRes; +} + +//--------------------------------------------------------------------------- +value_type ParserInt::Min(const value_type* a_afArg, int a_iArgc) +{ + if (!a_iArgc) + throw ParserError( _T("too few arguments for function min.") ); + + value_type fRes=a_afArg[0]; + for (int i=0; i<a_iArgc; ++i) + fRes = std::min(fRes, a_afArg[i]); + + return fRes; +} + +//--------------------------------------------------------------------------- +value_type ParserInt::Max(const value_type* a_afArg, int a_iArgc) +{ + if (!a_iArgc) + throw ParserError(_T("too few arguments for function min.")); + + value_type fRes=a_afArg[0]; + for (int i=0; i<a_iArgc; ++i) + fRes = std::max(fRes, a_afArg[i]); + + return fRes; +} + +//--------------------------------------------------------------------------- +// Default value recognition callback +int ParserInt::IsVal(const char_type *a_szExpr, int *a_iPos, value_type *a_fVal) +{ + string_type buf(a_szExpr); + std::size_t pos = buf.find_first_not_of(_T("0123456789")); + if (pos==std::string::npos) + return 0; + + stringstream_type stream( buf.substr(0, pos ) ); + int iVal(0); + + stream >> iVal; + stringstream_type::pos_type iEnd = stream.tellg(); // Position after reading + + if (iEnd==(stringstream_type::pos_type)-1) + return 0; + + *a_iPos += (int)iEnd; + *a_fVal = (value_type)iVal; + return 1; +} + +//--------------------------------------------------------------------------- +/** \brief Check a given position in the expression for the presence of + a hex value. + \param a_szExpr Pointer to the expression string + \param [in/out] a_iPos Pointer to an interger value holding the current parsing + position in the expression. + \param [out] a_fVal Pointer to the position where the detected value shall be stored. + + Hey values must be prefixed with "0x" in order to be detected properly. +*/ +int ParserInt::IsHexVal(const char_type *a_szExpr, int *a_iPos, value_type *a_fVal) +{ + if (a_szExpr[1]==0 || (a_szExpr[0]!='0' || a_szExpr[1]!='x') ) + return 0; + + unsigned iVal(0); + + // New code based on streams for UNICODE compliance: + stringstream_type::pos_type nPos(0); + stringstream_type ss(a_szExpr + 2); + ss >> std::hex >> iVal; + nPos = ss.tellg(); + + if (nPos==(stringstream_type::pos_type)0) + return 1; + + *a_iPos += (int)(2 + nPos); + *a_fVal = (value_type)iVal; + return 1; +} + +//--------------------------------------------------------------------------- +int ParserInt::IsBinVal(const char_type *a_szExpr, int *a_iPos, value_type *a_fVal) +{ + if (a_szExpr[0]!='#') + return 0; + + unsigned iVal(0), + iBits(sizeof(iVal)*8), + i(0); + + for (i=0; (a_szExpr[i+1]=='0' || a_szExpr[i+1]=='1') && i<iBits; ++i) + iVal |= (int)(a_szExpr[i+1]=='1') << ((iBits-1)-i); + + if (i==0) + return 0; + + if (i==iBits) + throw exception_type(_T("Binary to integer conversion error (overflow).")); + + *a_fVal = (unsigned)(iVal >> (iBits-i) ); + *a_iPos += i+1; + + return 1; +} + +//--------------------------------------------------------------------------- +/** \brief Constructor. + + Call ParserBase class constructor and trigger Function, Operator and Constant initialization. +*/ +ParserInt::ParserInt() + :ParserBase() +{ + AddValIdent(IsHexVal); + AddValIdent(IsBinVal); + AddValIdent(IsVal); + + InitCharSets(); + InitFun(); + InitOprt(); +} + +//--------------------------------------------------------------------------- +void ParserInt::InitConst() +{ +} + +//--------------------------------------------------------------------------- +void ParserInt::InitCharSets() +{ + DefineNameChars( _T("0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") ); + DefineOprtChars( _T("+-*^/?<>=!%&|~'_") ); + DefineInfixOprtChars( _T("/+-*^?<>=!%&|~'_") ); +} + +//--------------------------------------------------------------------------- +/** \brief Initialize the default functions. */ +void ParserInt::InitFun() +{ + DefineFun( _T("sign"), Sign); + DefineFun( _T("abs"), Abs); + DefineFun( _T("if"), Ite); + DefineFun( _T("sum"), Sum); + DefineFun( _T("min"), Min); + DefineFun( _T("max"), Max); +} + +//--------------------------------------------------------------------------- +/** \brief Initialize operators. */ +void ParserInt::InitOprt() +{ + // disable all built in operators, not all of them usefull for integer numbers + // (they don't do rounding of values) + EnableBuiltInOprt(false); + + // Disable all built in operators, they wont work with integer numbers + // since they are designed for floating point numbers + DefineInfixOprt( _T("-"), UnaryMinus); + DefineInfixOprt( _T("!"), Not); + + DefineOprt( _T("&"), LogAnd, prLOGIC); + DefineOprt( _T("|"), LogOr, prLOGIC); + DefineOprt( _T("&&"), And, prLOGIC); + DefineOprt( _T("||"), Or, prLOGIC); + + DefineOprt( _T("<"), Less, prCMP); + DefineOprt( _T(">"), Greater, prCMP); + DefineOprt( _T("<="), LessEq, prCMP); + DefineOprt( _T(">="), GreaterEq, prCMP); + DefineOprt( _T("=="), Equal, prCMP); + DefineOprt( _T("!="), NotEqual, prCMP); + + DefineOprt( _T("+"), Add, prADD_SUB); + DefineOprt( _T("-"), Sub, prADD_SUB); + + DefineOprt( _T("*"), Mul, prMUL_DIV); + DefineOprt( _T("/"), Div, prMUL_DIV); + DefineOprt( _T("%"), Mod, prMUL_DIV); + + DefineOprt( _T("^"), Pow, prPOW, oaRIGHT); + DefineOprt( _T(">>"), Shr, prMUL_DIV+1); + DefineOprt( _T("<<"), Shl, prMUL_DIV+1); +} + +} // namespace mu diff --git a/AMDiS/lib/muparser_v134/src/muParserTest.cpp b/AMDiS/lib/muparser_v134/src/muParserTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0c3081bc593dc7f3bf5097d1dc033b045b34c491 --- /dev/null +++ b/AMDiS/lib/muparser_v134/src/muParserTest.cpp @@ -0,0 +1,1246 @@ +/* + __________ + _____ __ __\______ \_____ _______ ______ ____ _______ + / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ + | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ + |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| + \/ \/ \/ \/ + Copyright (C) 2010 Ingo Berg + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include "muParserTest.h" + +#include <cstdio> +#include <cmath> +#include <iostream> + +#define PARSER_CONST_PI 3.141592653589793238462643 +#define PARSER_CONST_E 2.718281828459045235360287 + +using namespace std; + +/** \file + \brief This file contains the implementation of parser test cases. +*/ + + +namespace mu +{ + namespace Test + { + int ParserTester::c_iCount = 0; + + //--------------------------------------------------------------------------- + ParserTester::ParserTester() + :m_vTestFun() + { + AddTest(&ParserTester::TestNames); + AddTest(&ParserTester::TestSyntax); + AddTest(&ParserTester::TestPostFix); + AddTest(&ParserTester::TestInfixOprt); + AddTest(&ParserTester::TestVarConst); + AddTest(&ParserTester::TestVolatile); + AddTest(&ParserTester::TestMultiArg); + AddTest(&ParserTester::TestExpression); + AddTest(&ParserTester::TestInterface); + AddTest(&ParserTester::TestBinOprt); + AddTest(&ParserTester::TestException); + AddTest(&ParserTester::TestStrArg); + + ParserTester::c_iCount = 0; + } + + //--------------------------------------------------------------------------- + int ParserTester::TestInterface() + { + int iStat = 0; + mu::console() << _T("testing member functions..."); + + // Test RemoveVar + value_type afVal[3] = {1,2,3}; + Parser p; + + try + { + p.DefineVar( _T("a"), &afVal[0]); + p.DefineVar( _T("b"), &afVal[1]); + p.DefineVar( _T("c"), &afVal[2]); + p.SetExpr( _T("a+b+c") ); + p.Eval(); + } + catch(...) + { + iStat += 1; // this is not supposed to happen + } + + try + { + p.RemoveVar( _T("c") ); + p.Eval(); + iStat += 1; // not supposed to reach this, nonexisting variable "c" deleted... + } + catch(...) + { + // failure is expected... + } + + if (iStat==0) + mu::console() << _T("passed") << endl; + else + mu::console() << _T("\n failed with ") << iStat << _T(" errors") << endl; + + return iStat; + } + + //--------------------------------------------------------------------------- + int ParserTester::TestStrArg() + { + int iStat = 0; + mu::console() << _T("testing string arguments..."); + + iStat += EqnTest(_T("valueof(\"\")"), 123, true); // empty string arguments caused a crash + iStat += EqnTest(_T("valueof(\"aaa\")+valueof(\"bbb\") "), 246, true); + iStat += EqnTest(_T("2*(valueof(\"aaa\")-23)+valueof(\"bbb\")"), 323, true); + // use in expressions with variables + iStat += EqnTest(_T("a*(atof(\"10\")-b)"), 8, true); + iStat += EqnTest(_T("a-(atof(\"10\")*b)"), -19, true); + // string + numeric arguments + iStat += EqnTest(_T("strfun1(\"100\")"), 100, true); + iStat += EqnTest(_T("strfun2(\"100\",1)"), 101, true); + iStat += EqnTest(_T("strfun3(\"99\",1,2)"), 102, true); + + if (iStat==0) + mu::console() << _T("passed") << endl; + else + mu::console() << _T("\n failed with ") << iStat << _T(" errors") << endl; + + return iStat; + } + + //--------------------------------------------------------------------------- + int ParserTester::TestBinOprt() + { + int iStat = 0; + mu::console() << _T("testing binary operators..."); + + // built in operators + // xor operator + iStat += EqnTest(_T("1 xor 2"), 3, true); + iStat += EqnTest(_T("a xor b"), 3, true); // with a=1 and b=2 + iStat += EqnTest(_T("1 xor 2 xor 3"), 0, true); + iStat += EqnTest(_T("a xor b xor 3"), 0, true); // with a=1 and b=2 + iStat += EqnTest(_T("a xor b xor c"), 0, true); // with a=1 and b=2 + iStat += EqnTest(_T("(1 xor 2) xor 3"), 0, true); + iStat += EqnTest(_T("(a xor b) xor c"), 0, true); // with a=1 and b=2 + iStat += EqnTest(_T("(a) xor (b) xor c"), 0, true); // with a=1 and b=2 + iStat += EqnTest(_T("1 or 2"), 3, true); + iStat += EqnTest(_T("a or b"), 3, true); // with a=1 and b=2 + iStat += EqnTest(_T("a++b"), 3, true); + iStat += EqnTest(_T("a ++ b"), 3, true); + iStat += EqnTest(_T("1++2"), 3, true); + iStat += EqnTest(_T("1 ++ 2"), 3, true); + iStat += EqnTest(_T("a add b"), 3, true); + iStat += EqnTest(_T("1 add 2"), 3, true); + iStat += EqnTest(_T("a<b"), 1, true); + iStat += EqnTest(_T("b>a"), 1, true); + iStat += EqnTest(_T("a>a"), 0, true); + iStat += EqnTest(_T("a<a"), 0, true); + iStat += EqnTest(_T("a>a"), 0, true); + iStat += EqnTest(_T("a<=a"), 1, true); + iStat += EqnTest(_T("a<=b"), 1, true); + iStat += EqnTest(_T("b<=a"), 0, true); + iStat += EqnTest(_T("a>=a"), 1, true); + iStat += EqnTest(_T("b>=a"), 1, true); + iStat += EqnTest(_T("a>=b"), 0, true); + + // Assignement operator + iStat += EqnTest(_T("a = b"), 2, true); + iStat += EqnTest(_T("a = sin(b)"), 0.909297, true); + iStat += EqnTest(_T("a = 1+sin(b)"), 1.909297, true); + iStat += EqnTest(_T("(a=b)*2"), 4, true); + iStat += EqnTest(_T("2*(a=b)"), 4, true); + iStat += EqnTest(_T("2*(a=b+1)"), 6, true); + iStat += EqnTest(_T("(a=b+1)*2"), 6, true); + + iStat += EqnTest(_T("2^2^3"), 256, true); + iStat += EqnTest(_T("1/2/3"), 1.0/6.0, true); + + // reference: http://www.wolframalpha.com/input/?i=3%2B4*2%2F%281-5%29^2^3 + iStat += EqnTest(_T("3+4*2/(1-5)^2^3"), 3.0001220703125, true); + + // Test user defined binary operators + iStat += EqnTestInt(_T("1 | 2"), 3, true); + iStat += EqnTestInt(_T("1 || 2"), 1, true); + iStat += EqnTestInt(_T("123 & 456"), 72, true); + iStat += EqnTestInt(_T("(123 & 456) % 10"), 2, true); + iStat += EqnTestInt(_T("1 && 0"), 0, true); + iStat += EqnTestInt(_T("123 && 456"), 1, true); + iStat += EqnTestInt(_T("1 << 3"), 8, true); + iStat += EqnTestInt(_T("8 >> 3"), 1, true); + iStat += EqnTestInt(_T("9 / 4"), 2, true); + iStat += EqnTestInt(_T("9 % 4"), 1, true); + iStat += EqnTestInt(_T("if(5%2,1,0)"), 1, true); + iStat += EqnTestInt(_T("if(4%2,1,0)"), 0, true); + iStat += EqnTestInt(_T("-10+1"), -9, true); + iStat += EqnTestInt(_T("1+2*3"), 7, true); + iStat += EqnTestInt(_T("const1 != const2"), 1, true); + iStat += EqnTestInt(_T("const1 != const2"), 0, false); + iStat += EqnTestInt(_T("const1 == const2"), 0, true); + iStat += EqnTestInt(_T("const1 == 1"), 1, true); + iStat += EqnTestInt(_T("10*(const1 == 1)"), 10, true); + iStat += EqnTestInt(_T("2*(const1 | const2)"), 6, true); + iStat += EqnTestInt(_T("2*(const1 | const2)"), 7, false); + iStat += EqnTestInt(_T("const1 < const2"), 1, true); + iStat += EqnTestInt(_T("const2 > const1"), 1, true); + iStat += EqnTestInt(_T("const1 <= 1"), 1, true); + iStat += EqnTestInt(_T("const2 >= 2"), 1, true); + iStat += EqnTestInt(_T("2*(const1 + const2)"), 6, true); + iStat += EqnTestInt(_T("2*(const1 - const2)"), -2, true); + iStat += EqnTestInt(_T("a != b"), 1, true); + iStat += EqnTestInt(_T("a != b"), 0, false); + iStat += EqnTestInt(_T("a == b"), 0, true); + iStat += EqnTestInt(_T("a == 1"), 1, true); + iStat += EqnTestInt(_T("10*(a == 1)"), 10, true); + iStat += EqnTestInt(_T("2*(a | b)"), 6, true); + iStat += EqnTestInt(_T("2*(a | b)"), 7, false); + iStat += EqnTestInt(_T("a < b"), 1, true); + iStat += EqnTestInt(_T("b > a"), 1, true); + iStat += EqnTestInt(_T("a <= 1"), 1, true); + iStat += EqnTestInt(_T("b >= 2"), 1, true); + iStat += EqnTestInt(_T("2*(a + b)"), 6, true); + iStat += EqnTestInt(_T("2*(a - b)"), -2, true); + iStat += EqnTestInt(_T("a + (a << b)"), 5, true); + iStat += EqnTestInt(_T("-2^2"), -4, true); + iStat += EqnTestInt(_T("3--a"), 4, true); + iStat += EqnTestInt(_T("3+-3^2"), -6, true); + + // Test reading of hex values: + iStat += EqnTestInt(_T("0xff"), 255, true); + iStat += EqnTestInt(_T("10+0xff"), 265, true); + iStat += EqnTestInt(_T("0xff+10"), 265, true); + iStat += EqnTestInt(_T("10*0xff"), 2550, true); + iStat += EqnTestInt(_T("0xff*10"), 2550, true); + iStat += EqnTestInt(_T("10+0xff+1"), 266, true); + iStat += EqnTestInt(_T("1+0xff+10"), 266, true); + +// incorrect: '^' is yor here, not power +// iStat += EqnTestInt("-(1+2)^2", -9, true); +// iStat += EqnTestInt("-1^3", -1, true); + + // Test precedence + // a=1, b=2, c=3 + iStat += EqnTestInt(_T("a + b * c"), 7, true); + iStat += EqnTestInt(_T("a * b + c"), 5, true); + iStat += EqnTestInt(_T("a<b && b>10"), 0, true); + iStat += EqnTestInt(_T("a<b && b<10"), 1, true); + + iStat += EqnTestInt(_T("a + b << c"), 17, true); + iStat += EqnTestInt(_T("a << b + c"), 7, true); + iStat += EqnTestInt(_T("c * b < a"), 0, true); + iStat += EqnTestInt(_T("c * b == 6 * a"), 1, true); + iStat += EqnTestInt(_T("2^2^3"), 256, true); + + + if (iStat==0) + mu::console() << _T("passed") << endl; + else + mu::console() << _T("\n failed with ") << iStat << _T(" errors") << endl; + + return iStat; + } + + //--------------------------------------------------------------------------- + /** \brief Check muParser name restriction enforcement. */ + int ParserTester::TestNames() + { + int iStat= 0, + iErr = 0; + + mu::console() << "testing name restriction enforcement..."; + + Parser p; + + #define PARSER_THROWCHECK(DOMAIN, FAIL, EXPR, ARG) \ + iErr = 0; \ + ParserTester::c_iCount++; \ + try \ + { \ + p.Define##DOMAIN(EXPR, ARG); \ + } \ + catch(Parser::exception_type&) \ + { \ + iErr = (FAIL==false) ? 0 : 1; \ + } \ + iStat += iErr; + + // constant names + PARSER_THROWCHECK(Const, false, _T("0a"), 1) + PARSER_THROWCHECK(Const, false, _T("9a"), 1) + PARSER_THROWCHECK(Const, false, _T("+a"), 1) + PARSER_THROWCHECK(Const, false, _T("-a"), 1) + PARSER_THROWCHECK(Const, false, _T("a-"), 1) + PARSER_THROWCHECK(Const, false, _T("a*"), 1) + PARSER_THROWCHECK(Const, false, _T("a?"), 1) + PARSER_THROWCHECK(Const, true, _T("a"), 1) + PARSER_THROWCHECK(Const, true, _T("a_min"), 1) + PARSER_THROWCHECK(Const, true, _T("a_min0"), 1) + PARSER_THROWCHECK(Const, true, _T("a_min9"), 1) + // variable names + value_type a; + p.ClearConst(); + PARSER_THROWCHECK(Var, false, _T("123abc"), &a) + PARSER_THROWCHECK(Var, false, _T("9a"), &a) + PARSER_THROWCHECK(Var, false, _T("0a"), &a) + PARSER_THROWCHECK(Var, false, _T("+a"), &a) + PARSER_THROWCHECK(Var, false, _T("-a"), &a) + PARSER_THROWCHECK(Var, false, _T("?a"), &a) + PARSER_THROWCHECK(Var, false, _T("!a"), &a) + PARSER_THROWCHECK(Var, false, _T("a+"), &a) + PARSER_THROWCHECK(Var, false, _T("a-"), &a) + PARSER_THROWCHECK(Var, false, _T("a*"), &a) + PARSER_THROWCHECK(Var, false, _T("a?"), &a) + PARSER_THROWCHECK(Var, true, _T("a"), &a) + PARSER_THROWCHECK(Var, true, _T("a_min"), &a) + PARSER_THROWCHECK(Var, true, _T("a_min0"), &a) + PARSER_THROWCHECK(Var, true, _T("a_min9"), &a) + PARSER_THROWCHECK(Var, false, _T("a_min9"), 0) + // Postfix operators + // fail + PARSER_THROWCHECK(PostfixOprt, false, _T("(k"), f1of1) + PARSER_THROWCHECK(PostfixOprt, false, _T("9+"), f1of1) + PARSER_THROWCHECK(PostfixOprt, false, _T("+"), 0) + // pass + PARSER_THROWCHECK(PostfixOprt, true, _T("-a"), f1of1) + PARSER_THROWCHECK(PostfixOprt, true, _T("?a"), f1of1) + PARSER_THROWCHECK(PostfixOprt, true, _T("_"), f1of1) + PARSER_THROWCHECK(PostfixOprt, true, _T("#"), f1of1) + PARSER_THROWCHECK(PostfixOprt, true, _T("&&"), f1of1) + PARSER_THROWCHECK(PostfixOprt, true, _T("||"), f1of1) + PARSER_THROWCHECK(PostfixOprt, true, _T("&"), f1of1) + PARSER_THROWCHECK(PostfixOprt, true, _T("|"), f1of1) + PARSER_THROWCHECK(PostfixOprt, true, _T("++"), f1of1) + PARSER_THROWCHECK(PostfixOprt, true, _T("--"), f1of1) + PARSER_THROWCHECK(PostfixOprt, true, _T("?>"), f1of1) + PARSER_THROWCHECK(PostfixOprt, true, _T("?<"), f1of1) + PARSER_THROWCHECK(PostfixOprt, true, _T("**"), f1of1) + PARSER_THROWCHECK(PostfixOprt, true, _T("xor"), f1of1) + PARSER_THROWCHECK(PostfixOprt, true, _T("and"), f1of1) + PARSER_THROWCHECK(PostfixOprt, true, _T("or"), f1of1) + PARSER_THROWCHECK(PostfixOprt, true, _T("not"), f1of1) + PARSER_THROWCHECK(PostfixOprt, true, _T("!"), f1of1) + // Binary operator + // The following must fail with builtin operators activated + // p.EnableBuiltInOp(true); -> this is the default + PARSER_THROWCHECK(Oprt, false, _T("+"), f1of2) + PARSER_THROWCHECK(Oprt, false, _T("-"), f1of2) + PARSER_THROWCHECK(Oprt, false, _T("*"), f1of2) + PARSER_THROWCHECK(Oprt, false, _T("/"), f1of2) + // without activated built in operators it should work + p.EnableBuiltInOprt(false); + PARSER_THROWCHECK(Oprt, true, _T("+"), f1of2) + PARSER_THROWCHECK(Oprt, true, _T("-"), f1of2) + PARSER_THROWCHECK(Oprt, true, _T("*"), f1of2) + PARSER_THROWCHECK(Oprt, true, _T("/"), f1of2) + #undef PARSER_THROWCHECK + + if (iStat==0) + mu::console() << _T("passed") << endl; + else + mu::console() << _T("\n failed with ") << iStat << _T(" errors") << endl; + + return iStat; + } + + //--------------------------------------------------------------------------- + int ParserTester::TestSyntax() + { + int iStat = 0; + mu::console() << _T("testing syntax engine..."); + + iStat += EqnTest(_T("(1+ 2*a)"), 3, true); // Spaces within formula + iStat += EqnTest(_T("sqrt((4))"), 2, true); // Multiple brackets + iStat += EqnTest(_T("sqrt((2)+2)"), 2, true);// Multiple brackets + iStat += EqnTest(_T("sqrt(2+(2))"), 2, true);// Multiple brackets + iStat += EqnTest(_T("sqrt(a+(3))"), 2, true);// Multiple brackets + iStat += EqnTest(_T("sqrt((3)+a)"), 2, true);// Multiple brackets + iStat += EqnTest(_T("order(1,2)"), 1, true); // May not cause name collision with operator "or" + iStat += EqnTest(_T("(2+"), 0, false); // missing closing bracket + iStat += EqnTest(_T("2++4"), 0, false); // unexpected operator + iStat += EqnTest(_T("2+-4"), 0, false); // unexpected operator + iStat += EqnTest(_T("(2+)"), 0, false); // unexpected closing bracket + iStat += EqnTest(_T("--2"), 0, false); // double sign + iStat += EqnTest(_T("ksdfj"), 0, false); // unknown token + iStat += EqnTest(_T("()"), 0, false); // empty bracket without a function + iStat += EqnTest(_T("5+()"), 0, false); // empty bracket without a function + iStat += EqnTest(_T("sin(cos)"), 0, false); // unexpected function + iStat += EqnTest(_T("5t6"), 0, false); // unknown token + iStat += EqnTest(_T("5 t 6"), 0, false); // unknown token + iStat += EqnTest(_T("8*"), 0, false); // unexpected end of formula + iStat += EqnTest(_T(",3"), 0, false); // unexpected comma + iStat += EqnTest(_T("3,5"), 0, false); // unexpected comma + iStat += EqnTest(_T("sin(8,8)"), 0, false); // too many function args + iStat += EqnTest(_T("(7,8)"), 0, false); // too many function args + iStat += EqnTest(_T("sin)"), 0, false); // unexpected closing bracket + iStat += EqnTest(_T("a)"), 0, false); // unexpected closing bracket + iStat += EqnTest(_T("pi)"), 0, false); // unexpected closing bracket + iStat += EqnTest(_T("sin(())"), 0, false); // unexpected closing bracket + iStat += EqnTest(_T("sin()"), 0, false); // unexpected closing bracket + + if (iStat==0) + mu::console() << _T("passed") << endl; + else + mu::console() << _T("\n failed with ") << iStat << _T(" errors") << endl; + + return iStat; + } + + //--------------------------------------------------------------------------- + int ParserTester::TestVarConst() + { + int iStat = 0; + mu::console() << _T("testing variable/constant name recognition..."); + + // distinguish constants with same basename + iStat += EqnTest( _T("const"), 1, true); + iStat += EqnTest( _T("const1"), 2, true); + iStat += EqnTest( _T("const2"), 3, true); + iStat += EqnTest( _T("2*const"), 2, true); + iStat += EqnTest( _T("2*const1"), 4, true); + iStat += EqnTest( _T("2*const2"), 6, true); + iStat += EqnTest( _T("2*const+1"), 3, true); + iStat += EqnTest( _T("2*const1+1"), 5, true); + iStat += EqnTest( _T("2*const2+1"), 7, true); + iStat += EqnTest( _T("const"), 0, false); + iStat += EqnTest( _T("const1"), 0, false); + iStat += EqnTest( _T("const2"), 0, false); + + // distinguish variables with same basename + iStat += EqnTest( _T("a"), 1, true); + iStat += EqnTest( _T("aa"), 2, true); + iStat += EqnTest( _T("2*a"), 2, true); + iStat += EqnTest( _T("2*aa"), 4, true); + iStat += EqnTest( _T("2*a-1"), 1, true); + iStat += EqnTest( _T("2*aa-1"), 3, true); + + // Finally test querying of used variables + try + { + int idx; + mu::Parser p; + mu::value_type vVarVal[] = { 1, 2, 3, 4, 5}; + p.DefineVar( _T("a"), &vVarVal[0]); + p.DefineVar( _T("b"), &vVarVal[1]); + p.DefineVar( _T("c"), &vVarVal[2]); + p.DefineVar( _T("d"), &vVarVal[3]); + p.DefineVar( _T("e"), &vVarVal[4]); + + // Test lookup of defined variables + // 4 used variables + p.SetExpr( _T("a+b+c+d") ); + mu::varmap_type UsedVar = p.GetUsedVar(); + int iCount = (int)UsedVar.size(); + if (iCount!=4) + throw false; + + // the next check will fail if the parser + // erroneousely creates new variables internally + if (p.GetVar().size()!=5) + throw false; + + mu::varmap_type::const_iterator item = UsedVar.begin(); + for (idx=0; item!=UsedVar.end(); ++item) + { + if (&vVarVal[idx++]!=item->second) + throw false; + } + + // Test lookup of undefined variables + p.SetExpr( _T("undef1+undef2+undef3") ); + UsedVar = p.GetUsedVar(); + iCount = (int)UsedVar.size(); + if (iCount!=3) + throw false; + + // the next check will fail if the parser + // erroneousely creates new variables internally + if (p.GetVar().size()!=5) + throw false; + + for (item = UsedVar.begin(); item!=UsedVar.end(); ++item) + { + if (item->second!=0) + throw false; // all pointers to undefined variables must be null + } + + // 1 used variables + p.SetExpr( _T("a+b") ); + UsedVar = p.GetUsedVar(); + iCount = (int)UsedVar.size(); + if (iCount!=2) throw false; + item = UsedVar.begin(); + for (idx=0; item!=UsedVar.end(); ++item) + if (&vVarVal[idx++]!=item->second) throw false; + + } + catch(...) + { + iStat += 1; + } + + if (iStat==0) + mu::console() << _T("passed") << endl; + else + mu::console() << _T("\n failed with ") << iStat << _T(" errors") << endl; + + return iStat; + } + + //--------------------------------------------------------------------------- + int ParserTester::TestMultiArg() + { + int iStat = 0; + mu::console() << _T("testing multiarg functions..."); + + // Compound expressions + iStat += EqnTest( _T("1,2,3"), 3, true); + iStat += EqnTest( _T("a,b,c"), 3, true); + iStat += EqnTest( _T("a=10,b=20,c=a*b"), 200, true); + iStat += EqnTest( _T("1,\n2,\n3"), 3, true); + iStat += EqnTest( _T("a,\nb,\nc"), 3, true); + iStat += EqnTest( _T("a=10,\nb=20,\nc=a*b"), 200, true); + iStat += EqnTest( _T("1,\r\n2,\r\n3"), 3, true); + iStat += EqnTest( _T("a,\r\nb,\r\nc"), 3, true); + iStat += EqnTest( _T("a=10,\r\nb=20,\r\nc=a*b"), 200, true); + + // picking the right argument + iStat += EqnTest( _T("f1of1(1)"), 1, true); + iStat += EqnTest( _T("f1of2(1, 2)"), 1, true); + iStat += EqnTest( _T("f2of2(1, 2)"), 2, true); + iStat += EqnTest( _T("f1of3(1, 2, 3)"), 1, true); + iStat += EqnTest( _T("f2of3(1, 2, 3)"), 2, true); + iStat += EqnTest( _T("f3of3(1, 2, 3)"), 3, true); + iStat += EqnTest( _T("f1of4(1, 2, 3, 4)"), 1, true); + iStat += EqnTest( _T("f2of4(1, 2, 3, 4)"), 2, true); + iStat += EqnTest( _T("f3of4(1, 2, 3, 4)"), 3, true); + iStat += EqnTest( _T("f4of4(1, 2, 3, 4)"), 4, true); + iStat += EqnTest( _T("f1of5(1, 2, 3, 4, 5)"), 1, true); + iStat += EqnTest( _T("f2of5(1, 2, 3, 4, 5)"), 2, true); + iStat += EqnTest( _T("f3of5(1, 2, 3, 4, 5)"), 3, true); + iStat += EqnTest( _T("f4of5(1, 2, 3, 4, 5)"), 4, true); + iStat += EqnTest( _T("f5of5(1, 2, 3, 4, 5)"), 5, true); + // Too few arguments / Too many arguments + iStat += EqnTest( _T("1+ping()"), 11, true); + iStat += EqnTest( _T("ping()+1"), 11, true); + iStat += EqnTest( _T("2*ping()"), 20, true); + iStat += EqnTest( _T("ping()*2"), 20, true); + iStat += EqnTest( _T("ping(1,2)"), 0, false); + iStat += EqnTest( _T("1+ping(1,2)"), 0, false); + iStat += EqnTest( _T("f1of1(1,2)"), 0, false); + iStat += EqnTest( _T("f1of1()"), 0, false); + iStat += EqnTest( _T("f1of2(1, 2, 3)"), 0, false); + iStat += EqnTest( _T("f1of2(1)"), 0, false); + iStat += EqnTest( _T("f1of3(1, 2, 3, 4)"), 0, false); + iStat += EqnTest( _T("f1of3(1)"), 0, false); + iStat += EqnTest( _T("f1of4(1, 2, 3, 4, 5)"), 0, false); + iStat += EqnTest( _T("f1of4(1)"), 0, false); + iStat += EqnTest( _T("(1,2,3)"), 0, false); + iStat += EqnTest( _T("1,2,3"), 0, false); + iStat += EqnTest( _T("(1*a,2,3)"), 0, false); + iStat += EqnTest( _T("1,2*a,3"), 0, false); + + // correct calculation of arguments + iStat += EqnTest( _T("min(a, 1)"), 1, true); + iStat += EqnTest( _T("min(3*2, 1)"), 1, true); + iStat += EqnTest( _T("min(3*2, 1)"), 6, false); + iStat += EqnTest( _T("firstArg(2,3,4)"), 2, true); + iStat += EqnTest( _T("lastArg(2,3,4)"), 4, true); + iStat += EqnTest( _T("min(3*a+1, 1)"), 1, true); + iStat += EqnTest( _T("max(3*a+1, 1)"), 4, true); + iStat += EqnTest( _T("max(3*a+1, 1)*2"), 8, true); + iStat += EqnTest( _T("2*max(3*a+1, 1)+2"), 10, true); + + // functions with Variable argument count + iStat += EqnTest( _T("sum(a)"), 1, true); + iStat += EqnTest( _T("sum(1,2,3)"), 6, true); + iStat += EqnTest( _T("sum(a,b,c)"), 6, true); + iStat += EqnTest( _T("sum(1,-max(1,2),3)*2"), 4, true); + iStat += EqnTest( _T("2*sum(1,2,3)"), 12, true); + iStat += EqnTest( _T("2*sum(1,2,3)+2"), 14, true); + iStat += EqnTest( _T("2*sum(-1,2,3)+2"), 10, true); + iStat += EqnTest( _T("2*sum(-1,2,-(-a))+2"), 6, true); + iStat += EqnTest( _T("2*sum(-1,10,-a)+2"), 18, true); + iStat += EqnTest( _T("2*sum(1,2,3)*2"), 24, true); + iStat += EqnTest( _T("sum(1,-max(1,2),3)*2"), 4, true); + iStat += EqnTest( _T("sum(1*3, 4, a+2)"), 10, true); + iStat += EqnTest( _T("sum(1*3, 2*sum(1,2,2), a+2)"), 16, true); + iStat += EqnTest( _T("sum(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2)"), 24, true); + + // some failures + iStat += EqnTest( _T("sum()"), 0, false); + iStat += EqnTest( _T("sum(,)"), 0, false); + iStat += EqnTest( _T("sum(1,2,)"), 0, false); + iStat += EqnTest( _T("sum(,1,2)"), 0, false); + + if (iStat==0) + mu::console() << _T("passed") << endl; + else + mu::console() << _T("\n failed with ") << iStat << _T(" errors") << endl; + + return iStat; + } + + + //--------------------------------------------------------------------------- + int ParserTester::TestInfixOprt() + { + int iStat(0); + mu::console() << "testing infix operators..."; + + iStat += EqnTest( _T("-1"), -1, true); + iStat += EqnTest( _T("-(-1)"), 1, true); + iStat += EqnTest( _T("-(-1)*2"), 2, true); + iStat += EqnTest( _T("-(-2)*sqrt(4)"), 4, true); + iStat += EqnTest( _T("-a"), -1, true); + iStat += EqnTest( _T("-(a)"), -1, true); + iStat += EqnTest( _T("-(-a)"), 1, true); + iStat += EqnTest( _T("-(-a)*2"), 2, true); + iStat += EqnTest( _T("-(8)"), -8, true); + iStat += EqnTest( _T("-8"), -8, true); + iStat += EqnTest( _T("-(2+1)"), -3, true); + iStat += EqnTest( _T("-(f1of1(1+2*3)+1*2)"), -9, true); + iStat += EqnTest( _T("-(-f1of1(1+2*3)+1*2)"), 5, true); + iStat += EqnTest( _T("-sin(8)"), -0.989358, true); + iStat += EqnTest( _T("3-(-a)"), 4, true); + iStat += EqnTest( _T("3--a"), 4, true); + + // Postfix / infix priorities + iStat += EqnTest( _T("~2#"), 8, true); + iStat += EqnTest( _T("~f1of1(2)#"), 8, true); + iStat += EqnTest( _T("~(b)#"), 8, true); + iStat += EqnTest( _T("(~b)#"), 12, true); + iStat += EqnTest( _T("~(2#)"), 8, true); + iStat += EqnTest( _T("~(f1of1(2)#)"), 8, true); + // + iStat += EqnTest( _T("-2^2"),-4, true); + iStat += EqnTest( _T("-(a+b)^2"),-9, true); + iStat += EqnTest( _T("(-3)^2"),9, true); + iStat += EqnTest( _T("-(-2^2)"),4, true); + iStat += EqnTest( _T("3+-3^2"),-6, true); + // The following assumes use of sqr as postfix operator ("?") together + // withn a sign operator of low priority: + iStat += EqnTest( _T("-2?"), -4, true); + iStat += EqnTest( _T("-(1+1)?"),-4, true); + iStat += EqnTest( _T("2+-(1+1)?"),-2, true); + iStat += EqnTest( _T("2+-2?"), -2, true); + // This is the classic behaviour of the infix sign operator (here: "$") which is + // now deprecated: + iStat += EqnTest( _T("$2^2"),4, true); + iStat += EqnTest( _T("$(a+b)^2"),9, true); + iStat += EqnTest( _T("($3)^2"),9, true); + iStat += EqnTest( _T("$($2^2)"),-4, true); + iStat += EqnTest( _T("3+$3^2"),12, true); + + if (iStat==0) + mu::console() << _T("passed") << endl; + else + mu::console() << _T("\n failed with ") << iStat << _T(" errors") << endl; + + return iStat; + } + + + //--------------------------------------------------------------------------- + int ParserTester::TestPostFix() + { + int iStat = 0; + mu::console() << _T("testing postfix operators..."); + + // application + iStat += EqnTest( _T("3{m}+5"), 5.003, true); + iStat += EqnTest( _T("1000{m}"), 1, true); + iStat += EqnTest( _T("1000 {m}"), 1, true); + iStat += EqnTest( _T("(a){m}"), 1e-3, true); + iStat += EqnTest( _T("a{m}"), 1e-3, true); + iStat += EqnTest( _T("a {m}"), 1e-3, true); + iStat += EqnTest( _T("-(a){m}"), -1e-3, true); + iStat += EqnTest( _T("-2{m}"), -2e-3, true); + iStat += EqnTest( _T("-2 {m}"), -2e-3, true); + iStat += EqnTest( _T("f1of1(1000){m}"), 1, true); + iStat += EqnTest( _T("-f1of1(1000){m}"), -1, true); + iStat += EqnTest( _T("-f1of1(-1000){m}"), 1, true); + iStat += EqnTest( _T("f4of4(0,0,0,1000){m}"), 1, true); + iStat += EqnTest( _T("2+(a*1000){m}"), 3, true); + + // some incorrect results + iStat += EqnTest( _T("1000{m}"), 0.1, false); + iStat += EqnTest( _T("(a){m}"), 2, false); + // failure due to syntax checking + iStat += ThrowTest(_T("0x"), ecUNASSIGNABLE_TOKEN); // incomplete hex definition + iStat += ThrowTest(_T("3+"), ecUNEXPECTED_EOF); + iStat += ThrowTest( _T("4 + {m}"), ecUNEXPECTED_OPERATOR); + iStat += ThrowTest( _T("{m}4"), ecUNEXPECTED_OPERATOR); + iStat += ThrowTest( _T("sin({m})"), ecUNEXPECTED_OPERATOR); + iStat += ThrowTest( _T("{m} {m}"), ecUNEXPECTED_OPERATOR); + iStat += ThrowTest( _T("{m}(8)"), ecUNEXPECTED_OPERATOR); + iStat += ThrowTest( _T("4,{m}"), ecUNEXPECTED_OPERATOR); + iStat += ThrowTest( _T("-{m}"), ecUNEXPECTED_OPERATOR); + iStat += ThrowTest( _T("2(-{m})"), ecUNEXPECTED_PARENS); + iStat += ThrowTest( _T("2({m})"), ecUNEXPECTED_PARENS); + + if (iStat==0) + mu::console() << _T("passed") << endl; + else + mu::console() << _T("\n failed with ") << iStat << _T(" errors") << endl; + + return iStat; + } + + //--------------------------------------------------------------------------- + /** \brief Test volatile (nonoptimizeable functions). */ + int ParserTester::TestVolatile() + { + int iStat = 0; + mu::console() << "testing volatile/nonvolatile functions..."; + + // First test with volatile flag turned on + try + { + mu::Parser p; + p.DefineFun( _T("rnd"), Rnd, false); + p.DefineFun( _T("valueof"), RndWithString, false); + + // 1st test, compare results from sucessive calculations + p.SetExpr( _T("3+rnd(8)") ); + if (p.Eval()==p.Eval()) iStat += 1; + + // 2nd test, force bytecode creation, compare two results both + // calculated from bytecode + p.SetExpr( _T("3+rnd(8)") ); + p.Eval(); //<- Force bytecode creation + if (p.Eval()==p.Eval()) iStat += 1; + + p.SetExpr( _T("3*rnd(8)+3") ); + p.Eval(); //<- Force bytecode creation + if (p.Eval()==p.Eval()) iStat += 1; + + p.SetExpr( _T("10+3*sin(rnd(8))-1") ); + p.Eval(); //<- Force bytecode creation + if (p.Eval()==p.Eval()) iStat += 1; + + p.SetExpr( _T("3+rnd(rnd(8))*2") ); + p.Eval(); //<- Force bytecode creation + if (p.Eval()==p.Eval()) iStat += 1; + + p.SetExpr( _T("valueof(\"Das ist ein Test\")") ); + p.Eval(); //<- Force bytecode creation + if (p.Eval()==p.Eval()) iStat += 1; + } + catch(Parser::exception_type &e) + { + mu::console() << _T("\n ") << e.GetExpr() << _T(" : ") << e.GetMsg(); + iStat += 1; + } + + // Second test with volatile flag turned off + try + { + mu::Parser p; + p.DefineFun( _T("rnd"), Rnd); + p.DefineFun( _T("valueof"), RndWithString); + + // compare string parsing with bytecode + p.SetExpr( _T("3+rnd(8)") ); + if (p.Eval()!=p.Eval()) iStat += 1; + + p.SetExpr( _T("3+rnd(8)") ); + p.Eval(); //<- Force bytecode creation + if (p.Eval()!=p.Eval()) iStat += 1; + + p.SetExpr( _T("3*rnd(8)+3") ); + p.Eval(); //<- Force bytecode creation + if (p.Eval()!=p.Eval()) iStat += 1; + + p.SetExpr( _T("10+3*sin(rnd(8))-1") ); + p.Eval(); //<- Force bytecode creation + if (p.Eval()!=p.Eval()) iStat += 1; + + p.SetExpr( _T("3+rnd(rnd(8))*2") ); + p.Eval(); //<- Force bytecode creation + if (p.Eval()!=p.Eval()) iStat += 1; + } + catch(Parser::exception_type &e) + { + mu::console() << _T("\n ") << e.GetExpr() << _T(" : ") << e.GetMsg(); + iStat += 1; + } + + if (iStat==0) + mu::console() << _T("passed") << endl; + else + mu::console() << _T("\n failed with ") << iStat << _T(" errors") << endl; + + return iStat; + } + + //--------------------------------------------------------------------------- + int ParserTester::TestExpression() + { + int iStat = 0; + mu::console() << _T("testing expression samples..."); + + // operator precedencs + iStat += EqnTest( _T("1+2-3*4/5^6"), 2.99923, true); + iStat += EqnTest( _T("1^2/3*4-5+6"), 2.3333, true); + iStat += EqnTest( _T("1+2*3"), 7, true); + iStat += EqnTest( _T("1+2*3"), 7, true); + iStat += EqnTest( _T("(1+2)*3"), 9, true); + iStat += EqnTest( _T("(1+2)*(-3)"), -9, true); + iStat += EqnTest( _T("2/4"), 0.5, true); + + iStat += EqnTest( _T("exp(ln(7))"), 7, true); + iStat += EqnTest( _T("e^ln(7)"), 7, true); + iStat += EqnTest( _T("e^(ln(7))"), 7, true); + iStat += EqnTest( _T("(e^(ln(7)))"), 7, true); + iStat += EqnTest( _T("1-(e^(ln(7)))"), -6, true); + iStat += EqnTest( _T("2*(e^(ln(7)))"), 14, true); + iStat += EqnTest( _T("10^log(5)"), 5, true); + iStat += EqnTest( _T("10^log10(5)"), 5, true); + iStat += EqnTest( _T("2^log2(4)"), 4, true); + iStat += EqnTest( _T("-(sin(0)+1)"), -1, true); + iStat += EqnTest( _T("-(2^1.1)"), -2.14354692, true); + + iStat += EqnTest( _T("(cos(2.41)/b)"), -0.372056, true); + iStat += EqnTest( _T("(1*(2*(3*(4*(5*(6*(a+b)))))))"), 2160, true); + iStat += EqnTest( _T("(1*(2*(3*(4*(5*(6*(7*(a+b))))))))"), 15120, true); + iStat += EqnTest( _T("(a/((((b+(((e*(((((pi*((((3.45*((pi+a)+pi))+b)+b)*a))+0.68)+e)+a)/a))+a)+b))+b)*a)-pi))"), 0.00377999, true); + + // long formula (Reference: Matlab) + iStat += EqnTest( + _T("(((-9))-e/(((((((pi-(((-7)+(-3)/4/e))))/(((-5))-2)-((pi+(-0))*(sqrt((e+e))*(-8))*(((-pi)+(-pi)-(-9)*(6*5))") + _T("/(-e)-e))/2)/((((sqrt(2/(-e)+6)-(4-2))+((5/(-2))/(1*(-pi)+3))/8)*pi*((pi/((-2)/(-6)*1*(-1))*(-6)+(-e)))))/") + _T("((e+(-2)+(-e)*((((-3)*9+(-e)))+(-9)))))))-((((e-7+(((5/pi-(3/1+pi)))))/e)/(-5))/(sqrt((((((1+(-7))))+((((-") + _T("e)*(-e)))-8))*(-5)/((-e)))*(-6)-((((((-2)-(-9)-(-e)-1)/3))))/(sqrt((8+(e-((-6))+(9*(-9))))*(((3+2-8))*(7+6") + _T("+(-5))+((0/(-e)*(-pi))+7)))+(((((-e)/e/e)+((-6)*5)*e+(3+(-5)/pi))))+pi))/sqrt((((9))+((((pi))-8+2))+pi))/e") + _T("*4)*((-5)/(((-pi))*(sqrt(e)))))-(((((((-e)*(e)-pi))/4+(pi)*(-9)))))))+(-pi)"), -12.23016549, true); + + // long formula (Reference: Matlab) + iStat += EqnTest( + _T("(atan(sin((((((((((((((((pi/cos((a/((((0.53-b)-pi)*e)/b))))+2.51)+a)-0.54)/0.98)+b)*b)+e)/a)+b)+a)+b)+pi)/e") + _T(")+a)))*2.77)"), -2.16995656, true); + + // long formula (Reference: Matlab) + iStat += EqnTest( _T("1+2-3*4/5^6*(2*(1-5+(3*7^9)*(4+6*7-3)))+12"), -7995810.09926, true); + + if (iStat==0) + mu::console() << _T("passed") << endl; + else + mu::console() << _T("\n failed with ") << iStat << _T(" errors") << endl; + + return iStat; + } + + + //--------------------------------------------------------------------------- + int ParserTester::TestException() + { + int iStat = 0; + mu::console() << _T("testing error codes..."); + + iStat += ThrowTest(_T("3+"), ecUNEXPECTED_EOF); + iStat += ThrowTest(_T("3+)"), ecUNEXPECTED_PARENS); + iStat += ThrowTest(_T("()"), ecUNEXPECTED_PARENS); + iStat += ThrowTest(_T("3+()"), ecUNEXPECTED_PARENS); + iStat += ThrowTest(_T("sin(3,4)"), ecTOO_MANY_PARAMS); + iStat += ThrowTest(_T("if(3)"), ecTOO_FEW_PARAMS); + iStat += ThrowTest(_T("(1+2"), ecMISSING_PARENS); + iStat += ThrowTest(_T("sin(3)3"), ecUNEXPECTED_VAL); + iStat += ThrowTest(_T("sin(3)xyz"), ecUNASSIGNABLE_TOKEN); + iStat += ThrowTest(_T("sin(3)cos(3)"), ecUNEXPECTED_FUN); + iStat += ThrowTest(_T("a+b+c=10"), ecUNEXPECTED_OPERATOR); + iStat += ThrowTest(_T("a=b=3"), ecUNEXPECTED_OPERATOR); + + // functions without parameter + iStat += ThrowTest( _T("3+ping(2)"), ecTOO_MANY_PARAMS); + iStat += ThrowTest( _T("3+ping(a+2)"), ecTOO_MANY_PARAMS); + iStat += ThrowTest( _T("3+ping(sin(a)+2)"), ecTOO_MANY_PARAMS); + iStat += ThrowTest( _T("3+ping(1+sin(a))"), ecTOO_MANY_PARAMS); + + // String function related + iStat += ThrowTest( _T("valueof(\"xxx\")"), 999, false); + iStat += ThrowTest( _T("valueof()"), ecUNEXPECTED_PARENS); + iStat += ThrowTest( _T("1+valueof(\"abc\""), ecMISSING_PARENS); + iStat += ThrowTest( _T("valueof(\"abc\""), ecMISSING_PARENS); + iStat += ThrowTest( _T("valueof(\"abc"), ecUNTERMINATED_STRING); + iStat += ThrowTest( _T("valueof(\"abc\",3)"), ecTOO_MANY_PARAMS); + iStat += ThrowTest( _T("valueof(3)"), ecSTRING_EXPECTED); + iStat += ThrowTest( _T("sin(\"abc\")"), ecVAL_EXPECTED); + iStat += ThrowTest( _T("valueof(\"\\\"abc\\\"\")"), 999, false); + iStat += ThrowTest( _T("\"hello world\""), ecSTR_RESULT); + iStat += ThrowTest( _T("(\"hello world\")"), ecSTR_RESULT); + iStat += ThrowTest( _T("\"abcd\"+100"), ecOPRT_TYPE_CONFLICT); + iStat += ThrowTest( _T("\"a\"+\"b\""), ecOPRT_TYPE_CONFLICT); + iStat += ThrowTest( _T("strfun1(\"100\",3)"), ecTOO_MANY_PARAMS); + iStat += ThrowTest( _T("strfun2(\"100\",3,5)"), ecTOO_MANY_PARAMS); + iStat += ThrowTest( _T("strfun3(\"100\",3,5,6)"), ecTOO_MANY_PARAMS); + iStat += ThrowTest( _T("strfun2(\"100\")"), ecTOO_FEW_PARAMS); + iStat += ThrowTest( _T("strfun3(\"100\",6)"), ecTOO_FEW_PARAMS); + iStat += ThrowTest( _T("strfun2(1,1)"), ecSTRING_EXPECTED); + iStat += ThrowTest( _T("strfun2(a,1)"), ecSTRING_EXPECTED); + iStat += ThrowTest( _T("strfun2(1,1,1)"), ecTOO_MANY_PARAMS); + iStat += ThrowTest( _T("strfun2(a,1,1)"), ecTOO_MANY_PARAMS); + iStat += ThrowTest( _T("strfun3(1,2,3)"), ecSTRING_EXPECTED); + iStat += ThrowTest( _T("strfun3(1, \"100\",3)"), ecSTRING_EXPECTED); + iStat += ThrowTest( _T("strfun3(\"1\", \"100\",3)"), ecVAL_EXPECTED); + iStat += ThrowTest( _T("strfun3(\"1\", 3, \"100\")"), ecVAL_EXPECTED); + iStat += ThrowTest( _T("strfun3(\"1\", \"100\", \"100\", \"100\")"), ecTOO_MANY_PARAMS); + + // assignement operator + iStat += ThrowTest( _T("3=4"), ecUNEXPECTED_OPERATOR); + iStat += ThrowTest( _T("sin(8)=4"), ecUNEXPECTED_OPERATOR); + iStat += ThrowTest( _T("\"test\"=a"), ecUNEXPECTED_OPERATOR); + + // <ibg 20090529> + // this is now legal, for reference see: + // https://sourceforge.net/forum/message.php?msg_id=7411373 + // iStat += ThrowTest( _T("sin=9"), ecUNEXPECTED_OPERATOR); + // </ibg> + + iStat += ThrowTest( _T("(8)=5"), ecUNEXPECTED_OPERATOR); + iStat += ThrowTest( _T("(a)=5"), ecUNEXPECTED_OPERATOR); + iStat += ThrowTest( _T("a=\"tttt\""), ecOPRT_TYPE_CONFLICT); + + if (iStat==0) + mu::console() << _T("passed") << endl; + else + mu::console() << _T("\n failed with ") << iStat << _T(" errors") << endl; + + return iStat; + } + + + //--------------------------------------------------------------------------- + void ParserTester::AddTest(testfun_type a_pFun) + { + m_vTestFun.push_back(a_pFun); + } + + //--------------------------------------------------------------------------- + void ParserTester::Run() + { + int iStat = 0; + try + { + for (int i=0; i<(int)m_vTestFun.size(); ++i) + iStat += (this->*m_vTestFun[i])(); + } + catch(Parser::exception_type &e) + { + mu::console() << "\n" << e.GetMsg() << endl; + mu::console() << e.GetToken() << endl; + Abort(); + } + catch(std::exception &e) + { + mu::console() << e.what() << endl; + Abort(); + } + catch(...) + { + mu::console() << "Internal error"; + Abort(); + } + + if (iStat==0) + { + mu::console() << "Test passed (" << ParserTester::c_iCount << " expressions)" << endl; + } + else + { + mu::console() << "Test failed with " << iStat + << " errors (" << ParserTester::c_iCount + << " expressions)" << endl; + } + ParserTester::c_iCount = 0; + } + + + //--------------------------------------------------------------------------- + int ParserTester::ThrowTest(const string_type &a_str, int a_iErrc, bool a_bFail) + { + ParserTester::c_iCount++; + + try + { + value_type fVal[] = {1,1,1}; + Parser p; + + p.DefineVar( _T("a"), &fVal[0]); + p.DefineVar( _T("b"), &fVal[1]); + p.DefineVar( _T("c"), &fVal[2]); + p.DefinePostfixOprt( _T("{m}"), Milli); + p.DefineFun( _T("ping"), Ping); + p.DefineFun( _T("valueof"), ValueOf); + p.DefineFun( _T("strfun1"), StrFun1); + p.DefineFun( _T("strfun2"), StrFun2); + p.DefineFun( _T("strfun3"), StrFun3); + p.SetExpr(a_str); + p.Eval(); + } + catch(ParserError &e) + { + // output the formula in case of an failed test + if (a_bFail==false || (a_bFail==true && a_iErrc!=e.GetCode()) ) + { + mu::console() << _T("\n ") + << _T("Expression: ") << a_str + << _T(" Code:") << e.GetCode() << _T("(") << e.GetMsg() << _T(")") + << _T(" Expected:") << a_iErrc; + } + + return (a_iErrc==e.GetCode()) ? 0 : 1; + } + + // if a_bFail==false no exception is expected + bool bRet((a_bFail==false) ? 0 : 1); + if (bRet==1) + { + mu::console() << _T("\n ") + << _T("Expression: ") << a_str + << _T(" did evaluate; Expected error:") << a_iErrc; + } + + return bRet; + } + + //--------------------------------------------------------------------------- + /** \brief Evaluate a tet expression. + + \return 1 in case of a failure, 0 otherwise. + */ + int ParserTester::EqnTest(const string_type &a_str, double a_fRes, bool a_fPass) + { + ParserTester::c_iCount++; + int iRet(0); + value_type fVal[4] = {-999, -998, -997, -996}; // initially should be different + + try + { +#if HAS_CXX11 + std::unique_ptr<Parser> p1; +#else + std::auto_ptr<Parser> p1; +#endif + Parser p2, p3; // three parser objects + // they will be used for testing copy and assihnment operators + // p1 is a pointer since i'm going to delete it in order to test if + // parsers after copy construction still refer to members of it. + // !! If this is the case this function will crash !! + + p1.reset(new mu::Parser()); + // Add constants + p1->DefineConst( _T("pi"), (value_type)PARSER_CONST_PI); + p1->DefineConst( _T("e"), (value_type)PARSER_CONST_E); + p1->DefineConst( _T("const"), 1); + p1->DefineConst( _T("const1"), 2); + p1->DefineConst( _T("const2"), 3); + // variables + value_type vVarVal[] = { 1, 2, 3, -2}; + p1->DefineVar( _T("a"), &vVarVal[0]); + p1->DefineVar( _T("aa"), &vVarVal[1]); + p1->DefineVar( _T("b"), &vVarVal[1]); + p1->DefineVar( _T("c"), &vVarVal[2]); + p1->DefineVar( _T("d"), &vVarVal[3]); + // functions + p1->DefineFun( _T("ping"), Ping); + p1->DefineFun( _T("f1of1"), f1of1); // one parameter + p1->DefineFun( _T("f1of2"), f1of2); // two parameter + p1->DefineFun( _T("f2of2"), f2of2); + p1->DefineFun( _T("f1of3"), f1of3); // three parameter + p1->DefineFun( _T("f2of3"), f2of3); + p1->DefineFun( _T("f3of3"), f3of3); + p1->DefineFun( _T("f1of4"), f1of4); // four parameter + p1->DefineFun( _T("f2of4"), f2of4); + p1->DefineFun( _T("f3of4"), f3of4); + p1->DefineFun( _T("f4of4"), f4of4); + p1->DefineFun( _T("f1of5"), f1of5); // five parameter + p1->DefineFun( _T("f2of5"), f2of5); + p1->DefineFun( _T("f3of5"), f3of5); + p1->DefineFun( _T("f4of5"), f4of5); + p1->DefineFun( _T("f5of5"), f5of5); + + // binary operators + p1->DefineOprt( _T("add"), add, 0); + p1->DefineOprt( _T("++"), add, 0); + + // sample functions + p1->DefineFun( _T("min"), Min); + p1->DefineFun( _T("max"), Max); + p1->DefineFun( _T("sum"), Sum); + p1->DefineFun( _T("valueof"), ValueOf); + p1->DefineFun( _T("atof"), StrToFloat); + p1->DefineFun( _T("strfun1"), StrFun1); + p1->DefineFun( _T("strfun2"), StrFun2); + p1->DefineFun( _T("strfun3"), StrFun3); + p1->DefineFun( _T("lastArg"), LastArg); + p1->DefineFun( _T("firstArg"), FirstArg); + p1->DefineFun( _T("order"), FirstArg); + + // infix / postfix operator + // (identifiers used here do not have any meaning or make any sense at all) + p1->DefineInfixOprt( _T("$"), sign, prPOW+1); // sign with high priority + p1->DefineInfixOprt( _T("~"), plus2); // high priority + p1->DefinePostfixOprt( _T("{m}"), Milli); + p1->DefinePostfixOprt( _T("{M}"), Mega); + p1->DefinePostfixOprt( _T("#"), times3); + p1->DefinePostfixOprt( _T("?"), sqr); // + p1->SetExpr(a_str); + + // Test bytecode integrity + // String parsing and bytecode parsing must yield the same result + fVal[0] = p1->Eval(); // result from stringparsing + fVal[1] = p1->Eval(); // result from bytecode + if (fVal[0]!=fVal[1]) + throw Parser::exception_type( _T("Bytecode / string parsing mismatch.") ); + + // Test copy and assignement operators + try + { + // Test copy constructor + std::vector<mu::Parser> vParser; + vParser.push_back(*(p1.get())); + mu::Parser p2 = vParser[0]; // take parser from vector + + // destroy the originals from p2 + vParser.clear(); // delete the vector + p1.reset(0); + + fVal[2] = p2.Eval(); + + // Test assignement operator + // additionally disable Optimizer this time + mu::Parser p3; + p3 = p2; + p3.EnableOptimizer(false); + fVal[3] = p3.Eval(); + } + catch(std::exception &e) + { + mu::console() << _T("\n ") << e.what() << _T("\n"); + } + + // limited floating point accuracy requires the following test + bool bCloseEnough(true); + for (int i=0; i<4; ++i) + { + bCloseEnough &= (fabs(a_fRes-fVal[i]) <= fabs(fVal[i]*0.0001)); + } + + iRet = ((bCloseEnough && a_fPass) || (!bCloseEnough && !a_fPass)) ? 0 : 1; + if (iRet==1) + { + mu::console() << _T("\n fail: ") << a_str.c_str() + << _T(" (incorrect result; expected: ") << a_fRes + << _T(" ;calculated: ") << fVal[0]<< _T(")."); + } + } + catch(Parser::exception_type &e) + { + if (a_fPass) + { + if (fVal[0]!=fVal[2] && fVal[0]!=-999 && fVal[1]!=-998) + mu::console() << _T("\n fail: ") << a_str.c_str() << _T(" (copy construction)"); + else + mu::console() << _T("\n fail: ") << a_str.c_str() << _T(" (") << e.GetMsg() << _T(")"); + return 1; + } + } + catch(std::exception &e) + { + mu::console() << _T("\n fail: ") << a_str.c_str() << _T(" (") << e.what() << _T(")"); + return 1; // always return a failure since this exception is not expected + } + catch(...) + { + mu::console() << _T("\n fail: ") << a_str.c_str() << _T(" (unexpected exception)"); + return 1; // exceptions other than ParserException are not allowed + } + + return iRet; + } + + //--------------------------------------------------------------------------- + int ParserTester::EqnTestInt(const string_type &a_str, double a_fRes, bool a_fPass) + { + ParserTester::c_iCount++; + + value_type vVarVal[] = {1, 2, 3}; // variable values + value_type fVal[2] = {-99, -999}; // results: initially should be different + int iRet(0); + + try + { + ParserInt p; + p.DefineConst( _T("const1"), 1); + p.DefineConst( _T("const2"), 2); + p.DefineVar( _T("a"), &vVarVal[0]); + p.DefineVar( _T("b"), &vVarVal[1]); + p.DefineVar( _T("c"), &vVarVal[2]); + + p.SetExpr(a_str); + fVal[0] = p.Eval(); // result from stringparsing + fVal[1] = p.Eval(); // result from bytecode + + if (fVal[0]!=fVal[1]) + throw Parser::exception_type( _T("Bytecode corrupt.") ); + + iRet = ( (a_fRes==fVal[0] && a_fPass) || + (a_fRes!=fVal[0] && !a_fPass) ) ? 0 : 1; + if (iRet==1) + { + mu::console() << _T("\n fail: ") << a_str.c_str() + << _T(" (incorrect result; expected: ") << a_fRes + << _T(" ;calculated: ") << fVal[0]<< _T(")."); + } + } + catch(Parser::exception_type &e) + { + if (a_fPass) + { + mu::console() << _T("\n fail: ") << e.GetExpr() << _T(" : ") << e.GetMsg(); + iRet = 1; + } + } + catch(...) + { + mu::console() << _T("\n fail: ") << a_str.c_str() << _T(" (unexpected exception)"); + iRet = 1; // exceptions other than ParserException are not allowed + } + + return iRet; + } + + //--------------------------------------------------------------------------- + /** \brief Internal error in test class Test is going to be aborted. */ + void ParserTester::Abort() const + { + mu::console() << _T("Test failed (internal error in test class)") << endl; + while (!getchar()); + exit(-1); + } + } // namespace test +} // namespace mu diff --git a/AMDiS/lib/muparser_v134/src/muParserTokenReader.cpp b/AMDiS/lib/muparser_v134/src/muParserTokenReader.cpp new file mode 100644 index 0000000000000000000000000000000000000000..350cdfdc7dcb26b91d9ce94fcd33e9a953834531 --- /dev/null +++ b/AMDiS/lib/muparser_v134/src/muParserTokenReader.cpp @@ -0,0 +1,907 @@ +/* + __________ + _____ __ __\______ \_____ _______ ______ ____ _______ + / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ + | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ + |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| + \/ \/ \/ \/ + Copyright (C) 2010 Ingo Berg + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +#include <cassert> +#include <cstdio> +#include <cstring> +#include <map> +#include <stack> +#include <string> + +#include "muParserTokenReader.h" +#include "muParserBase.h" + +/** \file + \brief This file contains the parser token reader implementation. +*/ + + +namespace mu +{ + + // Forward declaration + class ParserBase; + + //--------------------------------------------------------------------------- + /** \brief Copy constructor. + + \sa Assign + \throw nothrow + */ + ParserTokenReader::ParserTokenReader(const ParserTokenReader &a_Reader) + { + Assign(a_Reader); + } + + //--------------------------------------------------------------------------- + /** \brief Assignement operator. + + Self assignement will be suppressed otherwise #Assign is called. + + \param a_Reader Object to copy to this token reader. + \throw nothrow + */ + ParserTokenReader& ParserTokenReader::operator=(const ParserTokenReader &a_Reader) + { + if (&a_Reader!=this) + Assign(a_Reader); + + return *this; + } + + //--------------------------------------------------------------------------- + /** \brief Assign state of a token reader to this token reader. + + \param a_Reader Object from which the state should be copied. + \throw nothrow + */ + void ParserTokenReader::Assign(const ParserTokenReader &a_Reader) + { + m_pParser = a_Reader.m_pParser; + m_strFormula = a_Reader.m_strFormula; + m_iPos = a_Reader.m_iPos; + m_iSynFlags = a_Reader.m_iSynFlags; + + m_UsedVar = a_Reader.m_UsedVar; + m_pFunDef = a_Reader.m_pFunDef; + m_pConstDef = a_Reader.m_pConstDef; + m_pVarDef = a_Reader.m_pVarDef; + m_pStrVarDef = a_Reader.m_pStrVarDef; + m_pPostOprtDef = a_Reader.m_pPostOprtDef; + m_pInfixOprtDef = a_Reader.m_pInfixOprtDef; + m_pOprtDef = a_Reader.m_pOprtDef; + m_bIgnoreUndefVar = a_Reader.m_bIgnoreUndefVar; + m_vIdentFun = a_Reader.m_vIdentFun; + m_pFactory = a_Reader.m_pFactory; + m_pFactoryData = a_Reader.m_pFactoryData; + m_iBrackets = a_Reader.m_iBrackets; + m_cArgSep = a_Reader.m_cArgSep; + } + + //--------------------------------------------------------------------------- + /** \brief Constructor. + + Create a Token reader and bind it to a parser object. + + \pre [assert] a_pParser may not be NULL + \post #m_pParser==a_pParser + \param a_pParent Parent parser object of the token reader. + */ + ParserTokenReader::ParserTokenReader(ParserBase *a_pParent) + :m_pParser(a_pParent) + ,m_strFormula() + ,m_iPos(0) + ,m_iSynFlags(0) + ,m_bIgnoreUndefVar(false) + ,m_pFunDef(NULL) + ,m_pPostOprtDef(NULL) + ,m_pInfixOprtDef(NULL) + ,m_pOprtDef(NULL) + ,m_pConstDef(NULL) + ,m_pStrVarDef(NULL) + ,m_pVarDef(NULL) + ,m_pFactory(NULL) + ,m_pFactoryData(NULL) + ,m_vIdentFun() + ,m_UsedVar() + ,m_fZero(0) + ,m_iBrackets(0) + ,m_lastTok() + ,m_cArgSep(',') + { + assert(m_pParser); + SetParent(m_pParser); + } + + //--------------------------------------------------------------------------- + /** \brief Create instance of a ParserTokenReader identical with this + and return its pointer. + + This is a factory method the calling function must take care of the object destruction. + + \return A new ParserTokenReader object. + \throw nothrow + */ + ParserTokenReader* ParserTokenReader::Clone(ParserBase *a_pParent) const + { +#if HAS_CXX11 + std::unique_ptr<ParserTokenReader> ptr(new ParserTokenReader(*this)); +#else + std::auto_ptr<ParserTokenReader> ptr(new ParserTokenReader(*this)); +#endif + ptr->SetParent(a_pParent); + return ptr.release(); + } + + //--------------------------------------------------------------------------- + ParserTokenReader::token_type& ParserTokenReader::SaveBeforeReturn(const token_type &tok) + { + m_lastTok = tok; + return m_lastTok; + } + + //--------------------------------------------------------------------------- + void ParserTokenReader::AddValIdent(identfun_type a_pCallback) + { + m_vIdentFun.push_back(a_pCallback); + } + + //--------------------------------------------------------------------------- + void ParserTokenReader::SetVarCreator(facfun_type a_pFactory, void *pUserData) + { + m_pFactory = a_pFactory; + m_pFactoryData = pUserData; + } + + //--------------------------------------------------------------------------- + /** \brief Return the current position of the token reader in the formula string. + + \return #m_iPos + \throw nothrow + */ + int ParserTokenReader::GetPos() const + { + return m_iPos; + } + + //--------------------------------------------------------------------------- + /** \brief Return a reference to the formula. + + \return #m_strFormula + \throw nothrow + */ + const string_type& ParserTokenReader::GetExpr() const + { + return m_strFormula; + } + + //--------------------------------------------------------------------------- + /** \brief Return a map containing the used variables only. */ + const varmap_type& ParserTokenReader::GetUsedVar() const + { + return m_UsedVar; + } + + //--------------------------------------------------------------------------- + /** \brief Initialize the token Reader. + + Sets the formula position index to zero and set Syntax flags to default for initial formula parsing. + \pre [assert] triggered if a_szFormula==0 + */ + void ParserTokenReader::SetFormula(const string_type &a_strFormula) + { + m_strFormula = a_strFormula; + ReInit(); + } + + //--------------------------------------------------------------------------- + /** \brief Set Flag that contronls behaviour in case of undefined variables beeing found. + + If true, the parser does not throw an exception if an undefined variable is found. + otherwise it does. This variable is used internally only! + It supresses a "undefined variable" exception in GetUsedVar(). + Those function should return a complete list of variables including + those the are not defined by the time of it's call. + */ + void ParserTokenReader::IgnoreUndefVar(bool bIgnore) + { + m_bIgnoreUndefVar = bIgnore; + } + + //--------------------------------------------------------------------------- + /** \brief Reset the token reader to the start of the formula. + + The syntax flags will be reset to a value appropriate for the + start of a formula. + \post #m_iPos==0, #m_iSynFlags = noOPT | noBC | noPOSTOP | noSTR + \throw nothrow + \sa ESynCodes + */ + void ParserTokenReader::ReInit() + { + m_iPos = 0; + m_iSynFlags = noOPT | noBC | noPOSTOP | noASSIGN; + m_iBrackets = 0; + m_UsedVar.clear(); + m_lastTok = token_type(); + } + + //--------------------------------------------------------------------------- + /** \brief Read the next token from the string. */ + ParserTokenReader::token_type ParserTokenReader::ReadNextToken() + { + assert(m_pParser); + + std::stack<int> FunArgs; + const char_type *szFormula = m_strFormula.c_str(); + token_type tok; + + // Ignore all non printable characters when reading the expression + while (szFormula[m_iPos]>0 && szFormula[m_iPos]<=0x20) + ++m_iPos; + + if ( IsEOF(tok) ) return SaveBeforeReturn(tok); // Check for end of formula + if ( IsOprt(tok) ) return SaveBeforeReturn(tok); // Check for user defined binary operator + if ( IsFunTok(tok) ) return SaveBeforeReturn(tok); // Check for function token + if ( IsBuiltIn(tok) ) return SaveBeforeReturn(tok); // Check built in operators / tokens + if ( IsArgSep(tok) ) return SaveBeforeReturn(tok); // Check for function argument separators + if ( IsValTok(tok) ) return SaveBeforeReturn(tok); // Check for values / constant tokens + if ( IsVarTok(tok) ) return SaveBeforeReturn(tok); // Check for variable tokens + if ( IsStrVarTok(tok) ) return SaveBeforeReturn(tok); // Check for string variables + if ( IsString(tok) ) return SaveBeforeReturn(tok); // Check for String tokens + if ( IsInfixOpTok(tok) ) return SaveBeforeReturn(tok); // Check for unary operators + if ( IsPostOpTok(tok) ) return SaveBeforeReturn(tok); // Check for unary operators + + // Check String for undefined variable token. Done only if a + // flag is set indicating to ignore undefined variables. + // This is a way to conditionally avoid an error if + // undefined variables occur. + // The GetUsedVar function must supress the error for + // undefined variables in order to collect all variable + // names including the undefined ones. + if ( (m_bIgnoreUndefVar || m_pFactory) && IsUndefVarTok(tok) ) + return SaveBeforeReturn(tok); + + // Check for unknown token + // + // !!! From this point on there is no exit without an exception possible... + // + string_type strTok; + int iEnd = ExtractToken(m_pParser->ValidNameChars(), strTok, m_iPos); + if (iEnd!=m_iPos) + Error(ecUNASSIGNABLE_TOKEN, m_iPos, strTok); + + Error(ecUNASSIGNABLE_TOKEN, m_iPos, m_strFormula.substr(m_iPos)); + return token_type(); // never reached + } + + //--------------------------------------------------------------------------- + void ParserTokenReader::SetParent(ParserBase *a_pParent) + { + m_pParser = a_pParent; + m_pFunDef = &a_pParent->m_FunDef; + m_pOprtDef = &a_pParent->m_OprtDef; + m_pInfixOprtDef = &a_pParent->m_InfixOprtDef; + m_pPostOprtDef = &a_pParent->m_PostOprtDef; + m_pVarDef = &a_pParent->m_VarDef; + m_pStrVarDef = &a_pParent->m_StrVarDef; + m_pConstDef = &a_pParent->m_ConstDef; + } + + //--------------------------------------------------------------------------- + /** \brief Extract all characters that belong to a certain charset. + + \param a_szCharSet [in] Const char array of the characters allowed in the token. + \param a_strTok [out] The string that consists entirely of characters listed in a_szCharSet. + \param a_iPos [in] Position in the string from where to start reading. + \return The Position of the first character not listed in a_szCharSet. + \throw nothrow + */ + int ParserTokenReader::ExtractToken(const char_type *a_szCharSet, + string_type &a_sTok, + int a_iPos) const + { + int iEnd = (int)m_strFormula.find_first_not_of(a_szCharSet, a_iPos); + + if (iEnd==(int)string_type::npos) + iEnd = (int)m_strFormula.length(); + + // Assign token string if there was something found + if (a_iPos!=iEnd) + a_sTok = string_type( m_strFormula.begin()+a_iPos, m_strFormula.begin()+iEnd); + + return iEnd; + } + + //--------------------------------------------------------------------------- + /** \brief Check Expression for the presence of a binary operator token. + + Userdefined binary operator "++" gives inconsistent parsing result for + the equations "a++b" and "a ++ b" if alphabetic characters are allowed + in operator tokens. To avoid this this function checks specifically + for operator tokens. + */ + int ParserTokenReader::ExtractOperatorToken(string_type &a_sTok, + int a_iPos) const + { + int iEnd = (int)m_strFormula.find_first_not_of(m_pParser->ValidInfixOprtChars(), a_iPos); + if (iEnd==(int)string_type::npos) + iEnd = (int)m_strFormula.length(); + + // Assign token string if there was something found + if (a_iPos!=iEnd) + { + a_sTok = string_type( m_strFormula.begin() + a_iPos, m_strFormula.begin() + iEnd); + return iEnd; + } + else + { + // There is still the chance of having to deal with an operator consisting exclusively + // of alphabetic characters. + return ExtractToken(MUP_CHARS, a_sTok, a_iPos); + } + } + + //--------------------------------------------------------------------------- + /** \brief Check if a built in operator or other token can be found + \param a_Tok [out] Operator token if one is found. This can either be a binary operator or an infix operator token. + \return true if an operator token has been found. + */ + bool ParserTokenReader::IsBuiltIn(token_type &a_Tok) + { + const char_type **const pOprtDef = m_pParser->GetOprtDef(), + *const szFormula = m_strFormula.c_str(); + + // Compare token with function and operator strings + // check string for operator/function + for (int i=0; pOprtDef[i]; i++) + { + std::size_t len( std::char_traits<char_type>::length(pOprtDef[i]) ); + if ( string_type(pOprtDef[i]) == string_type(szFormula + m_iPos, szFormula + m_iPos + len) ) + { + switch(i) + { + case cmAND: + case cmOR: + case cmXOR: + case cmLT: + case cmGT: + case cmLE: + case cmGE: + case cmNEQ: + case cmEQ: + case cmADD: + case cmSUB: + case cmMUL: + case cmDIV: + case cmPOW: + case cmASSIGN: + //if (len!=sTok.length()) + // continue; + + // The assignement operator need special treatment + if (i==cmASSIGN && m_iSynFlags & noASSIGN) + Error(ecUNEXPECTED_OPERATOR, m_iPos, pOprtDef[i]); + + if (!m_pParser->HasBuiltInOprt()) continue; + if (m_iSynFlags & noOPT) + { + // Maybe its an infix operator not an operator + // Both operator types can share characters in + // their identifiers + if ( IsInfixOpTok(a_Tok) ) + return true; + + Error(ecUNEXPECTED_OPERATOR, m_iPos, pOprtDef[i]); + } + + m_iSynFlags = noBC | noOPT | noARG_SEP | noPOSTOP | noASSIGN; + m_iSynFlags |= ( (i != cmEND) && ( i != cmBC) ) ? noEND : 0; + break; + + case cmBO: + if (m_iSynFlags & noBO) + Error(ecUNEXPECTED_PARENS, m_iPos, pOprtDef[i]); + + if (m_lastTok.GetCode()==cmFUNC) + m_iSynFlags = noOPT | noEND | noARG_SEP | noPOSTOP | noASSIGN; + else + m_iSynFlags = noBC | noOPT | noEND | noARG_SEP | noPOSTOP | noASSIGN; + + ++m_iBrackets; + break; + + case cmBC: + if (m_iSynFlags & noBC) + Error(ecUNEXPECTED_PARENS, m_iPos, pOprtDef[i]); + + m_iSynFlags = noBO | noVAR | noVAL | noFUN | noINFIXOP | noSTR | noASSIGN; + + if (--m_iBrackets<0) + Error(ecUNEXPECTED_PARENS, m_iPos, pOprtDef[i]); + break; + + default: // The operator is listed in c_DefaultOprt, but not here. This is a bad thing... + Error(ecINTERNAL_ERROR); + } // switch operator id + + m_iPos += (int)len; + a_Tok.Set( (ECmdCode)i, pOprtDef[i] ); + return true; + } // if operator string found + } // end of for all operator strings + + return false; + } + + //--------------------------------------------------------------------------- + bool ParserTokenReader::IsArgSep(token_type &a_Tok) + { + const char_type* szFormula = m_strFormula.c_str(); + + if (szFormula[m_iPos]==m_cArgSep) + { + // copy the separator into null terminated string + char_type szSep[2]; + szSep[0] = m_cArgSep; + szSep[1] = 0; + + if (m_iSynFlags & noARG_SEP) + Error(ecUNEXPECTED_ARG_SEP, m_iPos, szSep); + + m_iSynFlags = noBC | noOPT | noEND | noARG_SEP | noPOSTOP | noASSIGN; + m_iPos++; + a_Tok.Set(cmARG_SEP, szSep); + return true; + } + + return false; + } + + //--------------------------------------------------------------------------- + /** \brief Check for End of Formula. + + \return true if an end of formula is found false otherwise. + \param a_Tok [out] If an eof is found the corresponding token will be stored there. + \throw nothrow + \sa IsOprt, IsFunTok, IsStrFunTok, IsValTok, IsVarTok, IsString, IsInfixOpTok, IsPostOpTok + */ + bool ParserTokenReader::IsEOF(token_type &a_Tok) + { + const char_type* szFormula = m_strFormula.c_str(); + + // check for EOF + if ( !szFormula[m_iPos] /*|| szFormula[m_iPos] == '\n'*/) + { + if ( m_iSynFlags & noEND ) + Error(ecUNEXPECTED_EOF, m_iPos); + + if (m_iBrackets>0) + Error(ecMISSING_PARENS, m_iPos, _T(")")); + + m_iSynFlags = 0; + a_Tok.Set(cmEND); + return true; + } + + return false; + } + + //--------------------------------------------------------------------------- + /** \brief Check if a string position contains a unary infix operator. + \return true if a function token has been found false otherwise. + */ + bool ParserTokenReader::IsInfixOpTok(token_type &a_Tok) + { + string_type sTok; + int iEnd = ExtractToken(m_pParser->ValidInfixOprtChars(), sTok, m_iPos); + if (iEnd==m_iPos) + return false; + + funmap_type::const_iterator item = m_pInfixOprtDef->find(sTok); + if (item==m_pInfixOprtDef->end()) + return false; + + a_Tok.Set(item->second, sTok); + m_iPos = (int)iEnd; + + if (m_iSynFlags & noINFIXOP) + Error(ecUNEXPECTED_OPERATOR, m_iPos, a_Tok.GetAsString()); + + m_iSynFlags = noPOSTOP | noINFIXOP | noOPT | noBC | noSTR | noASSIGN; + return true; + } + + //--------------------------------------------------------------------------- + /** \brief Check whether the token at a given position is a function token. + \param a_Tok [out] If a value token is found it will be placed here. + \throw ParserException if Syntaxflags do not allow a function at a_iPos + \return true if a function token has been found false otherwise. + \pre [assert] m_pParser!=0 + */ + bool ParserTokenReader::IsFunTok(token_type &a_Tok) + { + string_type strTok; + int iEnd = ExtractToken(m_pParser->ValidNameChars(), strTok, m_iPos); + if (iEnd==m_iPos) + return false; + + funmap_type::const_iterator item = m_pFunDef->find(strTok); + if (item==m_pFunDef->end()) + return false; + + // Check if the next sign is an opening bracket + const char_type *szFormula = m_strFormula.c_str(); + if (szFormula[iEnd]!='(') + return false; + + a_Tok.Set(item->second, strTok); + + m_iPos = (int)iEnd; + if (m_iSynFlags & noFUN) + Error(ecUNEXPECTED_FUN, m_iPos-(int)a_Tok.GetAsString().length(), a_Tok.GetAsString()); + + m_iSynFlags = noANY ^ noBO; + return true; + } + + //--------------------------------------------------------------------------- + /** \brief Check if a string position contains a binary operator. + \param a_Tok [out] Operator token if one is found. This can either be a binary operator or an infix operator token. + \return true if an operator token has been found. + */ + bool ParserTokenReader::IsOprt(token_type &a_Tok) + { + const char_type *const szExpr = m_strFormula.c_str(); + string_type strTok; + + int iEnd = ExtractOperatorToken(strTok, m_iPos); + if (iEnd==m_iPos) + return false; + + // Note: + // All tokens in oprt_bin_maptype are have been sorted by their length + // Long operators must come first! Otherwise short names (like: "add") that + // are part of long token names (like: "add123") will be found instead + // of the long ones. + // Length sorting is done with ascending length so we use a reverse iterator here. + funmap_type::const_reverse_iterator it = m_pOprtDef->rbegin(); + for ( ; it!=m_pOprtDef->rend(); ++it) + { + const string_type &sID = it->first; + if ( sID == string_type(szExpr + m_iPos, szExpr + m_iPos + sID.length()) ) + { + a_Tok.Set(it->second, strTok); + + // operator was found + if (m_iSynFlags & noOPT) + { + // An operator was found but is not expected to occur at + // this position of the formula, maybe it is an infix + // operator, not a binary operator. Both operator types + // can share characters in their identifiers. + if ( IsInfixOpTok(a_Tok) ) + return true; + // nope, no infix operator + Error(ecUNEXPECTED_OPERATOR, m_iPos, a_Tok.GetAsString()); + } + + m_iPos += (int)sID.length(); + m_iSynFlags = noBC | noOPT | noARG_SEP | noPOSTOP | noEND | noBC | noASSIGN; + return true; + } + } + + return false; + } + + //--------------------------------------------------------------------------- + /** \brief Check if a string position contains a unary post value operator. */ + bool ParserTokenReader::IsPostOpTok(token_type &a_Tok) + { + // Tricky problem with equations like "3m+5": + // m is a postfix operator, + is a valid sign for postfix operators and + // for binary operators parser detects "m+" as operator string and + // finds no matching postfix operator. + // + // This is a special case so this routine slightly differs from the other + // token readers. + + // Test if there could be a postfix operator + string_type sTok; + int iEnd = ExtractToken(m_pParser->ValidOprtChars(), sTok, m_iPos); + if (iEnd==m_iPos) + return false; + + // iteraterate over all postfix operator strings + funmap_type::const_iterator item = m_pPostOprtDef->begin(); + for (item=m_pPostOprtDef->begin(); item!=m_pPostOprtDef->end(); ++item) + { + if (sTok.find(item->first)!=0) + continue; + + a_Tok.Set(item->second, sTok); + m_iPos += (int)item->first.length(); + + if (m_iSynFlags & noPOSTOP) + Error(ecUNEXPECTED_OPERATOR, m_iPos-(int)item->first.length(), item->first); + + m_iSynFlags = noVAL | noVAR | noFUN | noBO | noPOSTOP | noSTR | noASSIGN; + return true; + } + + return false; + } + + //--------------------------------------------------------------------------- + /** \brief Check whether the token at a given position is a value token. + + Value tokens are either values or constants. + + \param a_Tok [out] If a value token is found it will be placed here. + \return true if a value token has been found. + */ + bool ParserTokenReader::IsValTok(token_type &a_Tok) + { + assert(m_pConstDef); + assert(m_pParser); + + #if defined(_MSC_VER) + #pragma warning( disable : 4244 ) + #endif + + string_type strTok; + value_type fVal(0); + int iEnd(0); + + // 2.) Check for user defined constant + // Read everything that could be a constant name + iEnd = ExtractToken(m_pParser->ValidNameChars(), strTok, m_iPos); + if (iEnd!=m_iPos) + { + valmap_type::const_iterator item = m_pConstDef->find(strTok); + if (item!=m_pConstDef->end()) + { + m_iPos = iEnd; + a_Tok.SetVal(item->second, strTok); + + if (m_iSynFlags & noVAL) + Error(ecUNEXPECTED_VAL, m_iPos - (int)strTok.length(), strTok); + + m_iSynFlags = noVAL | noVAR | noFUN | noBO | noINFIXOP | noSTR | noASSIGN; + return true; + } + } + + // 3.call the value recognition functions provided by the user + // Call user defined value recognition functions + std::vector<identfun_type>::const_iterator item = m_vIdentFun.begin(); + for (item = m_vIdentFun.begin(); item!=m_vIdentFun.end(); ++item) + { + int iStart = m_iPos; + if ( (*item)(m_strFormula.c_str() + m_iPos, &m_iPos, &fVal)==1 ) + { + strTok.assign(m_strFormula.c_str(), iStart, m_iPos); + if (m_iSynFlags & noVAL) + Error(ecUNEXPECTED_VAL, m_iPos - (int)strTok.length(), strTok); + + a_Tok.SetVal(fVal, strTok); + m_iSynFlags = noVAL | noVAR | noFUN | noBO | noINFIXOP | noSTR | noASSIGN; + return true; + } + } + + return false; + + #if defined(_MSC_VER) + #pragma warning( default : 4244 ) + #endif + } + + //--------------------------------------------------------------------------- + /** \brief Check wheter a token at a given position is a variable token. + \param a_Tok [out] If a variable token has been found it will be placed here. + \return true if a variable token has been found. + */ + bool ParserTokenReader::IsVarTok(token_type &a_Tok) + { + if (!m_pVarDef->size()) + return false; + + string_type strTok; + int iEnd = ExtractToken(m_pParser->ValidNameChars(), strTok, m_iPos); + if (iEnd==m_iPos) + return false; + + varmap_type::const_iterator item = m_pVarDef->find(strTok); + if (item==m_pVarDef->end()) + return false; + + if (m_iSynFlags & noVAR) + Error(ecUNEXPECTED_VAR, m_iPos, strTok); + + m_pParser->OnDetectVar(&m_strFormula, m_iPos, iEnd); + + m_iPos = iEnd; + a_Tok.SetVar(item->second, strTok); + m_UsedVar[item->first] = item->second; // Add variable to used-var-list + + m_iSynFlags = noVAL | noVAR | noFUN | noBO | noINFIXOP | noSTR; + +// Zur Info hier die SynFlags von IsVal(): +// m_iSynFlags = noVAL | noVAR | noFUN | noBO | noINFIXOP | noSTR | noASSIGN; + return true; + } + + //--------------------------------------------------------------------------- + bool ParserTokenReader::IsStrVarTok(token_type &a_Tok) + { + if (!m_pStrVarDef || !m_pStrVarDef->size()) + return false; + + string_type strTok; + int iEnd = ExtractToken(m_pParser->ValidNameChars(), strTok, m_iPos); + if (iEnd==m_iPos) + return false; + + strmap_type::const_iterator item = m_pStrVarDef->find(strTok); + if (item==m_pStrVarDef->end()) + return false; + + if (m_iSynFlags & noSTR) + Error(ecUNEXPECTED_VAR, m_iPos, strTok); + + m_iPos = iEnd; + if (!m_pParser->m_vStringVarBuf.size()) + Error(ecINTERNAL_ERROR); + + a_Tok.SetString(m_pParser->m_vStringVarBuf[item->second], m_pParser->m_vStringVarBuf.size() ); + + m_iSynFlags = m_iSynFlags = noANY ^ ( noBC | noOPT | noEND | noARG_SEP); + return true; + } + + + //--------------------------------------------------------------------------- + /** \brief Check wheter a token at a given position is an undefined variable. + + \param a_Tok [out] If a variable tom_pParser->m_vStringBufken has been found it will be placed here. + \return true if a variable token has been found. + \throw nothrow + */ + bool ParserTokenReader::IsUndefVarTok(token_type &a_Tok) + { + string_type strTok; + int iEnd( ExtractToken(m_pParser->ValidNameChars(), strTok, m_iPos) ); + if ( iEnd==m_iPos ) + return false; + + if (m_iSynFlags & noVAR) + { + // <ibg/> 20061021 added token string strTok instead of a_Tok.GetAsString() as the + // token identifier. + // related bug report: + // http://sourceforge.net/tracker/index.php?func=detail&aid=1578779&group_id=137191&atid=737979 + Error(ecUNEXPECTED_VAR, m_iPos - (int)a_Tok.GetAsString().length(), strTok); + } + + // If a factory is available implicitely create new variables + if (m_pFactory) + { + value_type *fVar = m_pFactory(strTok.c_str(), m_pFactoryData); + a_Tok.SetVar(fVar, strTok ); + + // Do not use m_pParser->DefineVar( strTok, fVar ); + // in order to define the new variable, it will clear the + // m_UsedVar array which will kill previousely defined variables + // from the list + // This is safe because the new variable can never override an existing one + // because they are checked first! + (*m_pVarDef)[strTok] = fVar; + m_UsedVar[strTok] = fVar; // Add variable to used-var-list + } + else + { + a_Tok.SetVar((value_type*)&m_fZero, strTok); + m_UsedVar[strTok] = 0; // Add variable to used-var-list + } + + m_iPos = iEnd; + + // Call the variable factory in order to let it define a new parser variable + m_iSynFlags = noVAL | noVAR | noFUN | noBO | noPOSTOP | noINFIXOP | noSTR; + return true; + } + + + //--------------------------------------------------------------------------- + /** \brief Check wheter a token at a given position is a string. + \param a_Tok [out] If a variable token has been found it will be placed here. + \return true if a string token has been found. + \sa IsOprt, IsFunTok, IsStrFunTok, IsValTok, IsVarTok, IsEOF, IsInfixOpTok, IsPostOpTok + \throw nothrow + */ + bool ParserTokenReader::IsString(token_type &a_Tok) + { + if (m_strFormula[m_iPos]!='"') + return false; + + string_type strBuf(&m_strFormula[m_iPos+1]); + std::size_t iEnd(0), iSkip(0); + + // parser over escaped '\"' end replace them with '"' + for(iEnd=(int)strBuf.find( _T("\"") ); iEnd!=0 && iEnd!=string_type::npos; iEnd=(int)strBuf.find( _T("\""), iEnd)) + { + if (strBuf[iEnd-1]!='\\') break; + strBuf.replace(iEnd-1, 2, _T("\"") ); + iSkip++; + } + + if (iEnd==string_type::npos) + Error(ecUNTERMINATED_STRING, m_iPos, _T("\"") ); + + string_type strTok(strBuf.begin(), strBuf.begin()+iEnd); + + if (m_iSynFlags & noSTR) + Error(ecUNEXPECTED_STR, m_iPos, strTok); + + m_pParser->m_vStringBuf.push_back(strTok); // Store string in internal buffer + a_Tok.SetString(strTok, m_pParser->m_vStringBuf.size()); + + m_iPos += (int)strTok.length() + 2 + (int)iSkip; // +2 wg Anführungszeichen; +iSkip für entfernte escape zeichen + m_iSynFlags = m_iSynFlags = noANY ^ ( noARG_SEP | noBC | noOPT | noEND ); + + return true; + } + + //--------------------------------------------------------------------------- + /** \brief Create an error containing the parse error position. + + This function will create an Parser Exception object containing the error text and its position. + + \param a_iErrc [in] The error code of type #EErrorCodes. + \param a_iPos [in] The position where the error was detected. + \param a_strTok [in] The token string representation associated with the error. + \throw ParserException always throws thats the only purpose of this function. + */ + void ParserTokenReader::Error( EErrorCodes a_iErrc, + int a_iPos, + const string_type &a_sTok) const + { + m_pParser->Error(a_iErrc, a_iPos, a_sTok); + } + + //--------------------------------------------------------------------------- + void ParserTokenReader::SetArgSep(char_type cArgSep) + { + m_cArgSep = cArgSep; + } + + //--------------------------------------------------------------------------- + char_type ParserTokenReader::GetArgSep() const + { + return m_cArgSep; + } +} // namespace mu +