--- /dev/null
+debian/patches
--- /dev/null
+cmake_minimum_required(VERSION 3.1.0)
+if(POLICY CMP0043)
+ cmake_policy(SET CMP0043 OLD)
+endif()
+
+project( MathGL2 )
+
+set(mgl_clean_files )
+set(MGL_DEP_LIBS)
+add_definitions(-DMGL_SRC)
+
+#add_definitions(-DZLIB_WINAPI)
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${MathGL2_SOURCE_DIR}/scripts)
+
+if(NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are:
+ None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE)
+endif(NOT CMAKE_BUILD_TYPE)
+
+set(CMAKE_VERBOSE_MAKEFILE ON)
+set(MathGL_VERSION_MAJOR 2)
+set(MathGL_VERSION_MINOR 4)
+set(MathGL_PATCH_VERSION 2)
+set(MathGL_VERSION ${MathGL_VERSION_MAJOR}.${MathGL_VERSION_MINOR}.${MathGL_PATCH_VERSION})
+set(MathGL_SOVERSION 7.5.0)
+string(TIMESTAMP MathGL_DATE UTC)
+
+if(CMAKE_BUILD_TYPE STREQUAL "Debug")
+ option(enable-lcov "Enable coverage." OFF)
+ if(enable-lcov)
+ include(CodeCoverage)
+ APPEND_COVERAGE_COMPILER_FLAGS()
+ endif(enable-lcov)
+else(CMAKE_BUILD_TYPE STREQUAL "Debug")
+ unset(enable-lcov CACHE)
+endif(CMAKE_BUILD_TYPE STREQUAL "Debug")
+
+#set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1)
+set(MathGL_INSTALL_LIB_DIR "lib" CACHE PATH "Installation directory for libraries")
+set(MathGL_INSTALL_BIN_DIR "bin" CACHE PATH "Installation directory for executables")
+set(MathGL_INSTALL_INCLUDE_DIR "include" CACHE PATH "Installation directory for headers")
+if(WIN32 AND NOT CYGWIN)
+ set(DEF_INSTALL_CMAKE_DIR cmake)
+else()
+ set(DEF_INSTALL_CMAKE_DIR lib/cmake/mathgl)
+endif()
+set(MathGL_INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for CMake files")
+# Make relative paths absolute (needed later on)
+foreach(p LIB BIN INCLUDE CMAKE)
+ set(var MathGL_INSTALL_${p}_DIR)
+ if(NOT IS_ABSOLUTE "${${var}}")
+ set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
+ endif()
+endforeach()
+
+macro(mgl_po_src)
+ set(l_files )
+ foreach(src_file ${ARGN})
+ get_filename_component(fp ${src_file} ABSOLUTE)
+ file(RELATIVE_PATH rel ${CMAKE_SOURCE_DIR} ${fp})
+ list(APPEND l_files "${rel}")
+ endforeach(src_file ${ARGN})
+ set(po_files ${po_files} ${l_files} PARENT_SCOPE)
+endmacro(mgl_po_src)
+
+function(mgl_add_lib mgl_tmp_lib)
+ if(${mgl_tmp_lib} MATCHES mgl)
+ set(mgllib mgl)
+ set(mgllib2 mgl2)
+ else(${mgl_tmp_lib} MATCHES mgl)
+ set(mgllib mgl-${mgl_tmp_lib})
+ set(mgllib2 mgl2-${mgl_tmp_lib})
+ endif(${mgl_tmp_lib} MATCHES mgl)
+ set(mgl_src_lst ${ARGV})
+ list(REMOVE_AT mgl_src_lst 0)
+ add_library(${mgllib} SHARED ${mgl_src_lst})
+ add_library(${mgllib}-static STATIC ${mgl_src_lst})
+ set_target_properties(${mgllib} PROPERTIES SOVERSION ${MathGL_SOVERSION})
+ set_target_properties(${mgllib} PROPERTIES DEFINE_SYMBOL "mgl_EXPORTS")
+ set_target_properties(${mgllib} PROPERTIES C_VISIBILITY_PRESET hidden)
+ set_target_properties(${mgllib} PROPERTIES CXX_VISIBILITY_PRESET hidden)
+ set_target_properties(${mgllib} PROPERTIES VISIBILITY_INLINES_HIDDEN 1)
+ target_compile_definitions(${mgllib}-static PUBLIC MGL_STATIC_DEFINE)
+ if(MSVC)
+ set(mgl_lib_static "-static")
+ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
+ set(mgl_lib_end "d")
+ else(CMAKE_BUILD_TYPE STREQUAL "Debug")
+ set(mgl_lib_end)
+ endif(CMAKE_BUILD_TYPE STREQUAL "Debug")
+ elseif(MSVC)
+ set(mgl_lib_static)
+ set_target_properties(${mgllib} PROPERTIES CLEAN_DIRECT_OUTPUT 1)
+ set_target_properties(${mgllib}-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
+ endif(MSVC)
+ if(enable-mgl2)
+ set_target_properties(${mgllib} PROPERTIES OUTPUT_NAME "${mgllib2}${mgl_lib_end}")
+ set_target_properties(${mgllib}-static PROPERTIES OUTPUT_NAME "${mgllib2}${mgl_lib_static}${mgl_lib_end}")
+ else(enable-mgl2)
+ set_target_properties(${mgllib} PROPERTIES OUTPUT_NAME "${mgllib}${mgl_lib_end}")
+ set_target_properties(${mgllib}-static PROPERTIES OUTPUT_NAME "${mgllib}${mgl_lib_static}${mgl_lib_end}")
+ endif(enable-mgl2)
+
+ install(
+ TARGETS ${mgllib} ${mgllib}-static
+ EXPORT MathGLTargets
+ RUNTIME DESTINATION ${MathGL_INSTALL_BIN_DIR}
+ ARCHIVE DESTINATION ${MathGL_INSTALL_LIB_DIR}
+ LIBRARY DESTINATION ${MathGL_INSTALL_LIB_DIR}
+ )
+endfunction(mgl_add_lib mgl_tmp_lib)
+
+MACRO(MGL_DEPENDENT_OPTION option doc default depends1 force1 depends2 force2)
+ IF(${option}_ISSET MATCHES "^${option}_ISSET$")
+ SET(${option}_AVAILABLE 1)
+ IF(${force1})
+ FOREACH(d ${depends1})
+ STRING(REGEX REPLACE " +" ";" CMAKE_DEPENDENT_OPTION_DEP "${d}")
+ IF(${CMAKE_DEPENDENT_OPTION_DEP})
+ ELSE(${CMAKE_DEPENDENT_OPTION_DEP})
+ SET(${option}_AVAILABLE 0)
+ SET(depends1_AVAILABLE 1)
+ ENDIF(${CMAKE_DEPENDENT_OPTION_DEP})
+ ENDFOREACH(d)
+ ENDIF(${force1})
+ IF(${force2})
+ FOREACH(d ${depends2})
+ STRING(REGEX REPLACE " +" ";" CMAKE_DEPENDENT_OPTION_DEP "${d}")
+ IF(${CMAKE_DEPENDENT_OPTION_DEP})
+ ELSE(${CMAKE_DEPENDENT_OPTION_DEP})
+ SET(${option}_AVAILABLE 0)
+ SET(depends2_AVAILABLE 1)
+ ENDIF(${CMAKE_DEPENDENT_OPTION_DEP})
+ ENDFOREACH(d)
+ ENDIF(${force2})
+ IF(${option}_AVAILABLE)
+ OPTION(${option} "${doc}" "${default}")
+ SET(${option} "${${option}}" CACHE BOOL "${doc}" FORCE)
+ ELSE(${option}_AVAILABLE)
+ IF(${option} MATCHES "^${option}$")
+ ELSE(${option} MATCHES "^${option}$")
+ SET(${option} "${${option}}" CACHE INTERNAL "${doc}")
+ ENDIF(${option} MATCHES "^${option}$")
+ IF(depends1_AVAILABLE)
+ SET(${option} OFF)
+ ELSEIF(depends2_AVAILABLE)
+ SET(${option} ON)
+ ENDIF(depends1_AVAILABLE)
+ ENDIF(${option}_AVAILABLE)
+ ELSE(${option}_ISSET MATCHES "^${option}_ISSET$")
+ SET(${option} "${${option}_ISSET}")
+ ENDIF(${option}_ISSET MATCHES "^${option}_ISSET$")
+ENDMACRO(MGL_DEPENDENT_OPTION)
+include(CMakeDependentOption)
+
+string(TIMESTAMP MGL_NIGHT "%d.%m.%y")
+
+if(WIN32)
+ option(enable-dep-dll "Enable copying off all dependent dll libraries to the install directory" OFF)
+endif(WIN32)
+
+option(enable-double "Enable double precision in MathGL library" ON)
+option(enable-mpi "Enable mpi")
+option(enable-opengl "Enable OpenGL support" ON)
+option(enable-all-docs "Enable all documentation building")
+#option(enable-doc "Enable documentation building")
+option(enable-all "Enable all core features")
+option(enable-all-widgets "Enable all Widgets")
+option(enable-all-swig "Enable all SWIG based interfaces")
+option(enable-rvalue "Enable move constructor support (need C++11)" OFF)
+option(enable-pthread "Enable POSIX threads support" OFF)
+if(MSVC)
+ option(enable-pthr-widget "Enable POSIX threads for widgets" OFF)
+else(MSVC)
+ option(enable-pthr-widget "Enable POSIX threads for widgets" ON)
+endif(MSVC)
+option(enable-openmp "Enable OpenMP support" ON)
+
+if(enable-pthread AND enable-openmp)
+ message(SEND_ERROR "You can't enable POSIX threads and OpenMP at the same time!")
+endif(enable-pthread AND enable-openmp)
+
+option(enable-lgpl "Enable only LGPL part of MathGL")
+option(enable-mgl2 "Use names 'libmgl2-*' instead of 'libmgl-*'")
+option(enable-ltdl "Enable loading modules support")
+option(enable-doc-site "Enable HTML documentation for website")
+#CMAKE_DEPENDENT_OPTION(enable-doc-site "Enable HTML documentation for website" OFF "NOT enable-all-docs" ON)
+CMAKE_DEPENDENT_OPTION(enable-doc-html "Enable HTML documentation" OFF "NOT enable-all-docs" ON)
+CMAKE_DEPENDENT_OPTION(enable-doc-info "Enable INFO documentation" OFF "NOT enable-all-docs" ON)
+CMAKE_DEPENDENT_OPTION(enable-doc-pdf-ru "Enable Russian PDF documentation" OFF "NOT enable-all-docs" ON)
+CMAKE_DEPENDENT_OPTION(enable-doc-pdf-en "Enable English PDF documentation" OFF "NOT enable-all-docs" ON)
+#CMAKE_DEPENDENT_OPTION(enable-doc-prc "Enable PDF samples for HTML docs" OFF "NOT enable-all-docs" ON)
+#CMAKE_DEPENDENT_OPTION(enable-doc-json "Enable JSON samples for HTML docs" OFF "NOT enable-all-docs" ON)
+option(enable-texi2html "Use texi2html (obsolete package) instead of texi2any" OFF)
+CMAKE_DEPENDENT_OPTION(enable-mgltex "Enable installation of mgltex package (MGL scripts in LATEX document)" OFF "NOT enable-lgpl" OFF)
+
+CMAKE_DEPENDENT_OPTION(enable-zlib "Enable zlib support" ON "NOT enable-all" ON)
+CMAKE_DEPENDENT_OPTION(enable-png "Enable png support" ON "NOT enable-all" ON)
+CMAKE_DEPENDENT_OPTION(enable-jpeg "Enable jpeg support" OFF "NOT enable-all" ON)
+MGL_DEPENDENT_OPTION(enable-gsl "Enable gsl support" OFF "NOT enable-lgpl" ON "NOT enable-all" ON)
+MGL_DEPENDENT_OPTION(enable-hdf4 "Enable hdf4 support" OFF "NOT enable-lgpl" ON "NOT enable-all" ON)
+MGL_DEPENDENT_OPTION(enable-hdf5 "Enable hdf5 support" OFF "NOT enable-lgpl" ON "NOT enable-all" ON)
+CMAKE_DEPENDENT_OPTION(enable-pdf "Enable pdf support" OFF "NOT enable-all" ON)
+CMAKE_DEPENDENT_OPTION(enable-gif "Enable gif support" OFF "NOT enable-all" ON)
+CMAKE_DEPENDENT_OPTION(enable-glut "Enable glut support" OFF "NOT enable-all-widgets" ON)
+CMAKE_DEPENDENT_OPTION(enable-fltk "Enable fltk widget" OFF "NOT enable-all-widgets" ON)
+CMAKE_DEPENDENT_OPTION(enable-wx "Enable wxWidget widget" OFF "NOT enable-all-widgets" ON)
+CMAKE_DEPENDENT_OPTION(enable-qt4 "Enable Qt4 widget" OFF "NOT enable-all-widgets" ON)
+CMAKE_DEPENDENT_OPTION(enable-qt4asqt "Set Qt4 as default libmgl-qt" OFF "enable-qt4" OFF)
+CMAKE_DEPENDENT_OPTION(enable-qt5 "Enable Qt5 widget" OFF "NOT enable-all-widgets" ON)
+CMAKE_DEPENDENT_OPTION(enable-qt5asqt "Set Qt5 as default libmgl-qt" OFF "enable-qt5" OFF)
+
+# msvc fwprintf print char* for the specifier of "%s" format
+if(MSVC AND MSVC_VERSION GREATER 1899)
+ SET(CMAKE_CXX_FLAGS "/EHsc -D_CRT_STDIO_ISO_WIDE_SPECIFIERS ${CMAKE_CXX_FLAGS}")
+ SET(CMAKE_C_FLAGS "-D_CRT_STDIO_ISO_WIDE_SPECIFIERS ${CMAKE_C_FLAGS}")
+endif(MSVC AND MSVC_VERSION GREATER 1899)
+
+include(CheckCXXSourceCompiles)
+
+if(${CMAKE_SIZEOF_VOID_P} EQUAL 4)
+ set(CMAKE_REQUIRED_FLAGS -msse2 -mfpmath=sse)
+ CHECK_CXX_SOURCE_COMPILES("
+ int main(void){}" mgl_sse)
+ if(mgl_sse)
+ SET(CMAKE_CXX_FLAGS "-msse2 -mfpmath=sse ${CMAKE_CXX_FLAGS}")
+ SET(CMAKE_C_FLAGS "-msse2 -mfpmath=sse ${CMAKE_C_FLAGS}")
+ endif(mgl_sse)
+ unset(CMAKE_REQUIRED_FLAGS)
+endif(${CMAKE_SIZEOF_VOID_P} EQUAL 4)
+
+if(enable-qt4 OR enable-qt5)
+ set(QT_ENABLED ON)
+ if(enable-qt4asqt AND enable-qt5asqt)
+ message(SEND_ERROR "You cannot make Qt4 and Qt5 as qt at the same time.")
+ endif(enable-qt4asqt AND enable-qt5asqt)
+ if(enable-qt4 AND NOT enable-qt5)
+ set(enable-qt4asqt TRUE)
+ endif(enable-qt4 AND NOT enable-qt5)
+ if(enable-qt5 AND NOT enable-qt4)
+ set(enable-qt5asqt TRUE)
+ endif(enable-qt5 AND NOT enable-qt4)
+# if(NOT enable-opengl)
+# message(SEND_ERROR "You cannot build MathGL with Qt4 or Qt5 without OpenGL enabled.")
+# endif(NOT enable-opengl)
+endif(enable-qt4 OR enable-qt5)
+
+CMAKE_DEPENDENT_OPTION(enable-json-sample "Enable JSON sample (WebKit variant is the default)." ON "QT_ENABLED" OFF)
+CMAKE_DEPENDENT_OPTION(enable-json-sample-we "Enable JSON sample (WebEngine variant)." OFF "enable-json-sample" OFF)
+MGL_DEPENDENT_OPTION(enable-python "Enable python interface" OFF "NOT enable-lgpl" ON "NOT enable-all-swig" ON)
+MGL_DEPENDENT_OPTION(enable-lua "Enable Lua (v.5.1) interface" OFF "NOT enable-lgpl" ON "NOT enable-all-swig" ON)
+MGL_DEPENDENT_OPTION(enable-octave "Enable octave interface" OFF "NOT enable-lgpl" ON "NOT enable-all-swig" ON)
+MGL_DEPENDENT_OPTION(enable-octave-install "Octave interface will install for all users" ON "NOT enable-lgpl" ON "NOT enable-all-swig" ON)
+
+include_directories( ${MathGL2_SOURCE_DIR}/include ${MathGL2_BINARY_DIR}/include)
+set(MGL_INCLUDE_PATH "${CMAKE_INSTALL_PREFIX}/include/mgl2")
+set(MGL_CGI_PATH_INSTALL "share/mathgl" CACHE STRING "Set CGI install directory")
+set(MGL_CGI_PATH "${CMAKE_INSTALL_PREFIX}/${MGL_CGI_PATH_INSTALL}")
+set(MGL_DEF_FONT "STIX" CACHE STRING "Set default font name")
+
+if(NOT WIN32)
+# set(MGL_CGI_PATH "${CMAKE_INSTALL_PREFIX}/share/mathgl")
+ set(MGL_DATA_PATH "${CMAKE_INSTALL_PREFIX}/share/mathgl")
+ set(MGL_DOC_PATH "${CMAKE_INSTALL_PREFIX}/share/doc/mathgl")
+ set(MGL_MAN_PATH "${CMAKE_INSTALL_PREFIX}/share/man")
+ set(MGL_INFO_PATH "${CMAKE_INSTALL_PREFIX}/share/info")
+ set(MGL_FONT_PATH "${MGL_DATA_PATH}/fonts")
+else(NOT WIN32)
+ set(MGL_FONT_PATH "${CMAKE_INSTALL_PREFIX}/fonts")
+endif(NOT WIN32)
+
+include(CheckFunctionExists)
+include(CMakePushCheckState)
+include(TestBigEndian)
+
+TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
+if(WORDS_BIGENDIAN)
+ ADD_DEFINITIONS(-DWORDS_BIGENDIAN)
+endif(WORDS_BIGENDIAN)
+
+CHECK_FUNCTION_EXISTS(sin MGL_SIN)
+CHECK_FUNCTION_EXISTS(memrchr HAVE_MEMRCHR)
+if(NOT MGL_SIN)
+ cmake_push_check_state()
+ set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m)
+ CHECK_FUNCTION_EXISTS(sin MGL_SIN_M)
+ cmake_pop_check_state()
+ if(MGL_SIN_M)
+ set(M_LIB m)
+ elseif(MGL_SIN_M)
+ message(SEND_ERROR "Math library not found")
+ endif(MGL_SIN_M)
+endif(NOT MGL_SIN)
+set(MGL_DEP_LIBS ${M_LIB} ${MGL_DEP_LIBS})
+
+if(HAVE_MEMRCHR)
+ ADD_DEFINITIONS(-DHAVE_MEMRCHR)
+endif(HAVE_MEMRCHR)
+
+include(CheckTypeSize)
+check_type_size("long" SIZEOF_LONG)
+
+#unset(MGL_HAVE_C99_COMPLEX)
+CHECK_CXX_SOURCE_COMPILES(
+"#include <complex>
+#include <complex.h>
+int main(int argc, char *args[])
+{std::complex<double> c(2.0, 1.0);
+double _Complex i=1.0i;
+double _Complex *a = reinterpret_cast<double _Complex *>(&c);
+std::complex<double> b(*a);return 0;}" MGL_HAVE_C99_COMPLEX)
+if(NOT MGL_HAVE_C99_COMPLEX)
+ set(MGL_HAVE_C99_COMPLEX 0)
+endif(NOT MGL_HAVE_C99_COMPLEX)
+
+#unset(MGL_HAVE_NAN_INF)
+CHECK_CXX_SOURCE_COMPILES(
+"#include <math.h>
+int main(){double a=NAN, b=INFINITY;return 0;}" MGL_HAVE_NAN_INF)
+if(NOT MGL_HAVE_NAN_INF)
+ set(MGL_HAVE_NAN_INF 0)
+endif(NOT MGL_HAVE_NAN_INF)
+
+#unset(MGL_HAVE_ATTRIBUTE)
+CHECK_CXX_SOURCE_COMPILES(
+"int __attribute__((pure)) test1() {return 0;}
+int __attribute__((const)) test2(int x) {return x*x;}
+int main(int argc, char* argv[]) {return 0;}" MGL_HAVE_ATTRIBUTE)
+if(NOT MGL_HAVE_ATTRIBUTE)
+ set(MGL_HAVE_ATTRIBUTE 0)
+endif(NOT MGL_HAVE_ATTRIBUTE)
+
+if(NOT MSVC AND enable-rvalue)
+ SET(CMAKE_CXX_FLAGS "-std=gnu++11 ${CMAKE_CXX_FLAGS}")
+ unset(MGL_HAVE_RVAL CACHE)
+ CHECK_CXX_SOURCE_COMPILES(
+ "struct test { test() {} test(test&& a){} };
+ int main() { test t; return 0; }" MGL_HAVE_RVAL)
+ if(NOT MGL_HAVE_RVAL)
+ message(SEND_ERROR "Couldn't enable rvalue.")
+# set(MGL_HAVE_RVAL 0)
+ endif(NOT MGL_HAVE_RVAL)
+else(NOT MSVC AND enable-rvalue)
+ set(MGL_HAVE_RVAL 0)
+endif(NOT MSVC AND enable-rvalue)
+
+
+
+CHECK_CXX_SOURCE_COMPILES(
+"#include <getopt.h>
+int main(int argc, char *args[]) {
+int ch = getopt(argc, args, \"1:2:3:4:5:6:7:8:9:hno:L:C:A:s:S:q:\"); return 0; }" MGL_HAVE_GETOPT)
+if(NOT MGL_HAVE_GETOPT)
+ include_directories(${MathGL2_SOURCE_DIR}/addons/getopt)
+ set(getopt_lib-static getopt-static)
+endif(NOT MGL_HAVE_GETOPT)
+
+if(enable-double)
+ set(MGL_USE_DOUBLE 1)
+else(enable-double)
+ set(MGL_USE_DOUBLE 0)
+endif(enable-double)
+
+if(enable-qt4 OR enable-qt5)
+ set(MGL_HAVE_QT 1)
+endif(enable-qt4 OR enable-qt5)
+
+if(enable-mpi)
+ set(MGL_HAVE_MPI 1)
+ find_package(MPI REQUIRED)
+ set(CMAKE_CXX_COMPILE_FLAGS ${CMAKE_CXX_COMPILE_FLAGS} ${MPI_COMPILE_FLAGS})
+ set(CMAKE_CXX_LINK_FLAGS ${CMAKE_CXX_LINK_FLAGS} ${MPI_LINK_FLAGS})
+ include_directories(${MPI_INCLUDE_PATH})
+else(enable-mpi)
+ set(MGL_HAVE_MPI 0)
+endif(enable-mpi)
+
+if(enable-pthr-widget OR enable-pthread)
+ if(enable-pthread)
+ set(MGL_HAVE_PTHREAD 1)
+ else(enable-pthread)
+ set(MGL_HAVE_PTHREAD 0)
+ endif(enable-pthread)
+ # cmake v.3.1
+ set(MGL_HAVE_PTHR_WIDGET 1)
+ set(CMAKE_THREAD_PREFER_PTHREAD ON)
+ set(THREADS_PREFER_PTHREAD_FLAG ON)
+ find_package(Threads REQUIRED)
+ # was for v.2.8.12
+ # include(FindThreads)
+ if(NOT CMAKE_USE_PTHREADS_INIT)
+ message(SEND_ERROR "Couldn't find POSIX threads library.")
+ endif(NOT CMAKE_USE_PTHREADS_INIT)
+ # cmake v.3.1
+ set(MGL_DEP_LIBS Threads::Threads ${MGL_DEP_LIBS})
+ # was for v.2.8.12
+ # set(MGL_DEP_LIBS ${CMAKE_THREAD_LIBS_INIT} ${MGL_DEP_LIBS})
+else(enable-pthr-widget OR enable-pthread)
+ set(MGL_HAVE_PTHR_WIDGET 0)
+ set(MGL_HAVE_PTHREAD 0)
+endif(enable-pthr-widget OR enable-pthread)
+
+if(enable-openmp)
+ find_package(OpenMP)
+ if(OPENMP_FOUND)
+ set(MGL_HAVE_OMP 1)
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
+ else(OPENMP_FOUND)
+ message(SEND_ERROR "Couldn't find OpenMP. You can enable POSIX threads instead.")
+ set(MGL_HAVE_OMP 0)
+ endif(OPENMP_FOUND)
+else(enable-openmp)
+ set(MGL_HAVE_OMP 0)
+endif(enable-openmp)
+
+if(enable-gsl)
+ set(MGL_HAVE_GSL 1)
+ find_library(GSL_LIB gsl)
+ find_library(GSL_CBLAS_LIB gslcblas)
+ find_path(GSL_INCLUDE_DIR gsl/gsl_fft_complex.h)
+ if(NOT GSL_LIB OR NOT GSL_CBLAS_LIB OR NOT GSL_INCLUDE_DIR)
+ message(SEND_ERROR "${GSL_LIB}")
+ message(SEND_ERROR "${GSL_CBLAS_LIB}")
+ message(SEND_ERROR "${GSL_INCLUDE_DIR}")
+ message(SEND_ERROR "Couldn't find GSL libraries.")
+ else(NOT GSL_LIB OR NOT GSL_CBLAS_LIB OR NOT GSL_INCLUDE_DIR)
+ set(CMAKE_REQUIRED_INCLUDES ${GSL_INCLUDE_DIR})
+ set(CMAKE_REQUIRED_LIBRARIES ${GSL_LIB} ${GSL_CBLAS_LIB})
+ CHECK_CXX_SOURCE_COMPILES("#include <gsl/gsl_multifit_nlin.h>
+ int main(){gsl_multifit_fdfsolver *s=0;gsl_matrix *J = 0;
+ gsl_multifit_fdfsolver_jac(s, J);}" MGL_HAVE_GSL2)
+ unset(CMAKE_REQUIRED_INCLUDES)
+ unset(CMAKE_REQUIRED_LIBRARIES)
+ endif(NOT GSL_LIB OR NOT GSL_CBLAS_LIB OR NOT GSL_INCLUDE_DIR)
+ set(MGL_DEP_LIBS ${GSL_LIB} ${GSL_CBLAS_LIB} ${MGL_DEP_LIBS})
+ include_directories(${GSL_INCLUDE_DIR})
+else(enable-gsl)
+ set(MGL_HAVE_GSL 0)
+endif(enable-gsl)
+
+if(enable-all OR enable-ltdl)
+ set(MGL_HAVE_LTDL 1)
+ find_library(LTDL_LIB ltdl)
+ find_path(LTDL_INCLUDE_DIR ltdl.h)
+ if(NOT LTDL_LIB OR NOT LTDL_INCLUDE_DIR)
+ message(SEND_ERROR "${LTDL_LIB}")
+ message(SEND_ERROR "${LTDL_INCLUDE_DIR}")
+ message(SEND_ERROR "Couldn't find LTDL library.")
+ endif(NOT LTDL_LIB OR NOT LTDL_INCLUDE_DIR)
+ set(MGL_DEP_LIBS ${LTDL_LIB} ${MGL_DEP_LIBS})
+ include_directories(${LTDL_INCLUDE_DIR})
+else(enable-all OR enable-ltdl)
+ set(MGL_HAVE_LTDL 0)
+endif(enable-all OR enable-ltdl)
+
+if(enable-hdf4)
+ set(MGL_HAVE_HDF4 1)
+ find_library(HDF4_LIB NAMES df hdf)
+ find_library(HDF4MF_LIB mfhdf)
+ find_path(HDF4_INCLUDE_DIR mfhdf.h PATH_SUFFIXES hdf)
+ if(NOT HDF4_LIB OR NOT HDF4MF_LIB OR NOT HDF4_INCLUDE_DIR)
+ message(SEND_ERROR "${HDF4_LIB}")
+ message(SEND_ERROR "${HDF4MF_LIB}")
+ message(SEND_ERROR "${HDF4_INCLUDE_DIR}")
+ message(SEND_ERROR "Couldn't find HDF4 libraries.")
+ endif(NOT HDF4_LIB OR NOT HDF4MF_LIB OR NOT HDF4_INCLUDE_DIR)
+ set(MGL_DEP_LIBS ${HDF4MF_LIB} ${HDF4_LIB} ${MGL_DEP_LIBS})
+ include_directories(${HDF4_INCLUDE_DIR})
+else(enable-hdf4)
+ set(MGL_HAVE_HDF4 0)
+endif(enable-hdf4)
+
+if(enable-hdf5)
+ set(MGL_HAVE_HDF5 1)
+ find_package(HDF5)
+ if(NOT HDF5_FOUND)
+ find_package(HDF5 NAMES hdf5 COMPONENTS C shared static)
+ if(NOT HDF5_FOUND)
+ message(SEND_ERROR "Couldn't find HDF5 library.")
+ endif(NOT HDF5_FOUND)
+ endif(NOT HDF5_FOUND)
+ set(MGL_DEP_LIBS ${HDF5_LIBRARIES} ${HDF5_C_SHARED_LIBRARY} ${MGL_DEP_LIBS})
+ include_directories(${HDF5_INCLUDE_DIRS})
+else(enable-hdf5)
+ set(MGL_HAVE_HDF5 0)
+endif(enable-hdf5)
+
+if(enable-jpeg)
+ set(MGL_HAVE_JPEG 1)
+ include(FindJPEG)
+ if(NOT JPEG_FOUND)
+ message(SEND_ERROR "Couldn't find JPEG library.")
+ endif(NOT JPEG_FOUND)
+ set(MGL_DEP_LIBS ${JPEG_LIBRARIES} ${MGL_DEP_LIBS})
+ include_directories(${JPEG_INCLUDE_DIR})
+else(enable-jpeg)
+ set(MGL_HAVE_JPEG 0)
+endif(enable-jpeg)
+
+
+if(enable-zlib)
+ set(MGL_HAVE_ZLIB 1)
+ include(FindZLIB)
+ if(NOT ZLIB_FOUND)
+ message(SEND_ERROR "Couldn't find ZLib library.")
+ endif(NOT ZLIB_FOUND)
+ set(MGL_DEP_LIBS ${ZLIB_LIBRARIES} ${MGL_DEP_LIBS})
+ include_directories(${ZLIB_INCLUDE_DIR})
+else(enable-zlib)
+ set(MGL_HAVE_ZLIB 0)
+endif(enable-zlib)
+
+if(enable-png)
+ set(MGL_HAVE_PNG 1)
+ if(NOT MGL_HAVE_ZLIB)
+ message(SEND_ERROR "You have to enable ZLib if you plan to use PNG export.")
+ endif(NOT MGL_HAVE_ZLIB)
+ include(FindPNG)
+ if(NOT PNG_FOUND)
+ message(SEND_ERROR "Couldn't find PNG library.")
+ endif(NOT PNG_FOUND)
+ set(MGL_DEP_LIBS ${PNG_LIBRARIES} ${MGL_DEP_LIBS})
+ include_directories(${PNG_INCLUDE_DIR})
+else(enable-png)
+ set(MGL_HAVE_PNG 0)
+endif(enable-png)
+
+
+if(enable-pdf)
+ set(MGL_HAVE_PDF 1)
+ if(NOT MGL_HAVE_PNG)
+ message(SEND_ERROR "You have to enable PNG if you plan to use PDF export.")
+ endif(NOT MGL_HAVE_PNG)
+ find_library(HPDF_LIB hpdf)
+ if(NOT HPDF_LIB)
+ message(SEND_ERROR "Couldn't find libHaru or libhpdf.")
+ endif(NOT HPDF_LIB)
+ find_path(HPDF_INCLUDE_DIR hpdf_u3d.h)
+ if(NOT HPDF_INCLUDE_DIR)
+ message(SEND_ERROR "Couldn't find headers of 3d-enabled version of libhpdf.")
+ endif(NOT HPDF_INCLUDE_DIR)
+ include_directories(${HPDF_INCLUDE_DIR})
+ set(MGL_DEP_LIBS ${HPDF_LIB} ${MGL_DEP_LIBS})
+else(enable-pdf)
+ set(MGL_HAVE_PDF 0)
+endif(enable-pdf)
+
+if(enable-gif)
+ set(MGL_HAVE_GIF 1)
+ include(FindGIF)
+ if(NOT GIF_FOUND)
+ message(SEND_ERROR "Couldn't find GIF library.")
+ endif(NOT GIF_FOUND)
+ set(MGL_DEP_LIBS ${GIF_LIBRARIES} ${MGL_DEP_LIBS})
+ include_directories(${GIF_INCLUDE_DIR})
+else(enable-gif)
+ set(MGL_HAVE_GIF 0)
+endif(enable-gif)
+
+if(enable-opengl)
+ set(MGL_HAVE_OPENGL 1)
+ include(FindOpenGL)
+ if(NOT OPENGL_FOUND)
+ message(SEND_ERROR "Couldn't find OpenGL libraries.")
+ endif(NOT OPENGL_FOUND)
+ set(MGL_DEP_LIBS ${OPENGL_LIBRARIES} ${MGL_DEP_LIBS})
+ include_directories(${OPENGL_INCLUDE_DIR} )
+else(enable-opengl)
+ set(MGL_HAVE_OPENGL 0)
+endif(enable-opengl)
+
+if(enable-glut)
+ set(MGL_HAVE_GLUT 1)
+ if(NOT MGL_HAVE_OPENGL)
+ message(SEND_ERROR "You have to enable OpenGL if you plan to use GLUT.")
+ endif(NOT MGL_HAVE_OPENGL)
+ include(FindGLUT)
+ if(NOT GLUT_FOUND)
+ message(SEND_ERROR "Couldn't find GLUT library.")
+ endif(NOT GLUT_FOUND)
+else(enable-glut)
+ set(MGL_HAVE_GLUT 0)
+endif(enable-glut)
+
+if(enable-fltk)
+ set(MGL_HAVE_FLTK 1)
+ FIND_PACKAGE(FLTK)
+ if(NOT FLTK_FOUND)
+ message(SEND_ERROR "Couldn't find FLTK library.")
+ else(NOT FLTK_FOUND)
+ include_directories(${FLTK_INCLUDE_DIR})
+ CHECK_CXX_SOURCE_COMPILES(
+ "#include <FL/Fl_Copy_Surface.H>
+ int main(){return 0;}" MGL_HAVE_FL_COPY)
+ endif(NOT FLTK_FOUND)
+ if(NOT MGL_HAVE_FL_COPY)
+ set(MGL_HAVE_FL_COPY 0)
+ endif(NOT MGL_HAVE_FL_COPY)
+else(enable-fltk)
+ set(MGL_HAVE_FLTK 0)
+endif(enable-fltk)
+
+if(enable-wx)
+ set(MGL_HAVE_WX 1)
+ FIND_PACKAGE(wxWidgets COMPONENTS base core gl)
+ if(NOT wxWidgets_FOUND)
+ message(SEND_ERROR "Couldn't find wxWidgets library.")
+ endif(NOT wxWidgets_FOUND)
+else(enable-wx)
+ set(MGL_HAVE_WX 0)
+endif(enable-wx)
+
+
+find_program(findxgettext xgettext)
+find_program(findmsgmerge msgmerge)
+find_program(findmsgfmt msgfmt)
+find_program(findmsgcat msgcat)
+if(NOT findmsgfmt OR NOT findxgettext OR NOT findmsgmerge OR NOT findmsgcat )
+ message("Building of translation files was disabled, because xgettext, msgmerge, msgcat or msgfmt was not found. Current translations will be just coped.")
+ set(USE_GETTEXT 0)
+else(NOT findmsgfmt OR NOT findxgettext OR NOT findmsgmerge OR NOT findmsgcat )
+ set(USE_GETTEXT 1)
+endif(NOT findmsgfmt OR NOT findxgettext OR NOT findmsgmerge OR NOT findmsgcat )
+find_package(Intl)
+if(NOT Intl_FOUND)
+ set(MGL_USE_LIBINTL 0)
+ message("Gettext and translations was fully disabled, because libintl was not found.")
+else(NOT Intl_FOUND)
+ set(MGL_USE_LIBINTL 1)
+ set(MGL_DEP_LIBS ${Intl_LIBRARIES} ${MGL_DEP_LIBS})
+ include_directories(${Intl_INCLUDE_DIRS})
+endif(NOT Intl_FOUND)
+set(po_files )
+if(WIN32)
+ set(USE_GETTEXT 0)
+ set(MGL_USE_LIBINTL 0)
+endif(WIN32)
+
+if(enable-doc-info)
+ set(MGL_HAVE_DOC_INFO 1)
+ find_program(findmi makeinfo)
+ if(NOT findmi)
+ message(SEND_ERROR "Couldn't find makeinfo needed for documentation building.")
+ endif(NOT findmi)
+else(enable-doc-info)
+ set(MGL_HAVE_DOC_INFO 0)
+endif(enable-doc-info)
+
+if(enable-doc-html OR enable-doc-site)
+ if(enable-texi2html)
+ find_program(findth texi2html)
+ if(NOT findth)
+ message(SEND_ERROR "Couldn't find texi2html needed for documentation building.")
+ endif(NOT findth)
+ else(enable-texi2html)
+ find_program(findth texi2any)
+ if(NOT findth)
+ message(SEND_ERROR "Couldn't find texi2any needed for documentation building.")
+ endif(NOT findth)
+ endif(enable-texi2html)
+endif(enable-doc-html OR enable-doc-site)
+
+if(enable-texi2html)
+ set(site_en ${CMAKE_BINARY_DIR}/texinfo/doc_en/doc_en.html)
+ set(site_ru ${CMAKE_BINARY_DIR}/texinfo/doc_ru/doc_ru.html)
+ set(th_opt )
+else(enable-texi2html)
+ set(th_opt --html)
+ set(site_en ${CMAKE_BINARY_DIR}/texinfo/doc_en/index.html)
+ set(site_ru ${CMAKE_BINARY_DIR}/texinfo/doc_ru/index.html)
+endif(enable-texi2html)
+
+if(enable-doc-html)
+ set(MGL_HAVE_DOC_HTML 1)
+else(enable-doc-html)
+ set(MGL_HAVE_DOC_HTML 0)
+endif(enable-doc-html)
+
+if(enable-doc-site)
+ set(MGL_HAVE_DOC_SITE 1)
+else(enable-doc-site)
+ set(MGL_HAVE_DOC_SITE 0)
+endif(enable-doc-site)
+
+if(enable-doc-pdf-ru)
+ set(MGL_HAVE_DOC_PDF_RU 1)
+ find_program(findtp texi2pdf)
+ if(NOT findtp)
+ message(SEND_ERROR "Couldn't find texi2pdf needed for documentation building.")
+ endif(NOT findtp)
+else(enable-doc-pdf-ru)
+ set(MGL_HAVE_DOC_PDF_RU 0)
+endif(enable-doc-pdf-ru)
+
+if(enable-doc-pdf-en)
+ set(MGL_HAVE_DOC_PDF_EN 1)
+ find_program(findtp texi2pdf)
+ if(NOT findtp)
+ message(SEND_ERROR "Couldn't find texi2pdf needed for documentation building.")
+ endif(NOT findtp)
+else(enable-doc-pdf-en)
+ set(MGL_HAVE_DOC_PDF_EN 0)
+endif(enable-doc-pdf-en)
+
+if(enable-doc-site)
+ set(MGL_HAVE_DOC_JSON 1)
+else(enable-doc-site)
+ set(MGL_HAVE_DOC_JSON 0)
+endif(enable-doc-site)
+
+if(enable-doc-site)
+ set(MGL_HAVE_DOC_PRC 1)
+ if(NOT enable-pdf)
+ message(SEND_ERROR "You need to enable pdf support for MathGL.")
+ endif(NOT enable-pdf)
+else(enable-doc-site)
+ set(MGL_HAVE_DOC_PRC 0)
+endif(enable-doc-site)
+
+if(UNIX)
+ add_definitions(-DNO_COLOR_ARRAY)
+endif(UNIX)
+
+if(WIN32)
+ add_definitions(-DWIN32)
+endif(WIN32)
+
+if(NOT MGL_HAVE_GETOPT)
+ add_subdirectory( addons/getopt )
+endif(NOT MGL_HAVE_GETOPT)
+
+add_subdirectory( src )
+add_subdirectory( widgets )
+add_subdirectory( include )
+if(NOT enable-lgpl)
+ if(MGL_HAVE_QT)
+ add_subdirectory( udav )
+ if(enable-json-sample)
+ add_subdirectory( json )
+ endif(enable-json-sample)
+ endif(MGL_HAVE_QT)
+ if(enable-python OR enable-lua OR enable-octave)
+ add_subdirectory( lang )
+ endif(enable-python OR enable-lua OR enable-octave)
+add_subdirectory( utils )
+add_subdirectory( examples )
+if(NOT WIN32)
+ add_subdirectory( fonts )
+endif(NOT WIN32)
+add_subdirectory( mgllab )
+endif(NOT enable-lgpl)
+
+if(NOT MSVC AND NOT BORLAND)
+
+ if(MGL_HAVE_DOC_HTML OR MGL_HAVE_DOC_SITE OR MGL_HAVE_DOC_INFO OR MGL_HAVE_DOC_PDF_RU OR MGL_HAVE_DOC_PDF_EN )
+ add_subdirectory( texinfo )
+ endif(MGL_HAVE_DOC_HTML OR MGL_HAVE_DOC_SITE OR MGL_HAVE_DOC_INFO OR MGL_HAVE_DOC_PDF_RU OR MGL_HAVE_DOC_PDF_EN )
+
+endif(NOT MSVC AND NOT BORLAND)
+
+if(enable-mgltex)
+ add_subdirectory( mgltex )
+endif(enable-mgltex)
+
+if(MGL_USE_LIBINTL)
+ if(USE_GETTEXT)
+ set(mgl_tl_list )
+ add_custom_command(OUTPUT mathgl.pot
+ COMMAND ${findxgettext} -s --keyword=_ -C -c --package-name=MathGL2 --package-version=${MathGL_VERSION} -o ${MathGL2_BINARY_DIR}/mathgl.pot ${po_files}
+ WORKING_DIRECTORY ${MathGL2_SOURCE_DIR}/
+ DEPENDS ${po_files} )
+ set(mgl_clean_files mathgl.pot ${mgl_clean_files})
+ foreach(tl ru es) # en)
+ add_custom_command(OUTPUT mathgl_${tl}.po.done
+ COMMAND ${findmsgmerge} -U mathgl_${tl}.po ${MathGL2_BINARY_DIR}/mathgl.pot
+ COMMAND ${CMAKE_COMMAND} -E touch ${MathGL2_BINARY_DIR}/mathgl_${tl}.po.done
+ WORKING_DIRECTORY ${MathGL2_SOURCE_DIR}/
+ DEPENDS mathgl.pot mathgl_${tl}.po)
+ add_custom_command(OUTPUT mathgl_${tl}.mo
+ COMMAND ${findmsgfmt} -o mathgl_${tl}.mo ${MathGL2_SOURCE_DIR}/mathgl_${tl}.po
+ DEPENDS mathgl_${tl}.po.done)
+ install( FILES ${MathGL2_BINARY_DIR}/mathgl_${tl}.mo DESTINATION "${CMAKE_INSTALL_PREFIX}/share/locale/${tl}/LC_MESSAGES/" RENAME mathgl.mo )
+ set(mgl_tl_list mathgl_${tl}.mo ${mgl_tl_list})
+ set(mgl_clean_files mathgl_${tl}.mo mathgl_${tl}.po.done ${mgl_clean_files})
+ endforeach(tl)
+ add_custom_target(mgl_translations ALL DEPENDS ${mgl_tl_list})
+ else(USE_GETTEXT)
+ foreach(tl ru es) # en)
+ install( FILES ${MathGL2_SOURCE_DIR}/translations/mathgl_${tl}.mo DESTINATION "${CMAKE_INSTALL_PREFIX}/share/locale/${tl}/LC_MESSAGES/" RENAME mathgl.mo )
+ endforeach(tl)
+ endif(USE_GETTEXT)
+endif(MGL_USE_LIBINTL)
+
+set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${mgl_clean_files}")
+
+# WARNING!!! DO NOT ADD ANYTHING AFTER THIS LINE!
+add_subdirectory ( scripts )
--- /dev/null
+CMakeLists.patch
+python2_and_python3.patch
--- /dev/null
+set(src_imp_dep
+../include/mgl2/type.h
+../include/mgl2/data.h
+../include/mgl2/mgl.h
+mgl.i
+data.i
+type.i
+)
+
+set(mgl_clean_files "")
+
+SET_SOURCE_FILES_PROPERTIES(mathgl.i numpy.i PROPERTIES CPLUSPLUS ON)
+
+FIND_PACKAGE(SWIG)
+if(NOT SWIG_FOUND)
+ message(SEND_ERROR "Couldn't find swig needed for interfaces compiling.")
+endif(NOT SWIG_FOUND)
+INCLUDE(${SWIG_USE_FILE})
+
+if(enable-python)
+ set(Python_ADDITIONAL_VERSIONS 2.7)
+ FIND_PACKAGE(PythonInterp)
+ if(NOT PYTHONINTERP_FOUND)
+ message(SEND_ERROR "Couldn't find python interpreter.")
+ endif(NOT PYTHONINTERP_FOUND)
+ FIND_PACKAGE(PythonLibs)
+ if(NOT PYTHONLIBS_FOUND)
+ message(SEND_ERROR "Couldn't find python development libraries.")
+ endif(NOT PYTHONLIBS_FOUND)
+ execute_process(
+ COMMAND ${PYTHON_EXECUTABLE} -c "import numpy; print numpy.get_include()"
+ OUTPUT_VARIABLE NUMPY_INCLUDE_PATH
+ RESULT_VARIABLE NUMPY_ERR
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ if(NOT NUMPY_INCLUDE_PATH)
+ message(SEND_ERROR "Couldn't find numpy.")
+ endif(NOT NUMPY_INCLUDE_PATH)
+
+ include_directories(${PYTHON_INCLUDE_DIR} ${NUMPY_INCLUDE_PATH})
+ execute_process(
+ COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(prefix='${CMAKE_INSTALL_PREFIX}')"
+ OUTPUT_VARIABLE MGL_PYTHON_SITE_PACKAGES
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ set(SWIG_MODULE_mathgl_EXTRA_DEPS numpy.i ${src_imp_dep})
+ if(${CMAKE_VERSION} VERSION_LESS "3.8.0")
+ SWIG_ADD_MODULE(mathgl python mathgl.i)
+ else(${CMAKE_VERSION} VERSION_LESS "3.8.0")
+ SWIG_ADD_LIBRARY(mathgl LANGUAGE python SOURCES mathgl.i)
+ endif(${CMAKE_VERSION} VERSION_LESS "3.8.0")
+ SWIG_LINK_LIBRARIES(mathgl mgl ${PYTHON_LIBRARIES})
+ set_target_properties(_mathgl PROPERTIES BUILD_WITH_INSTALL_RPATH ON)
+ add_custom_command(OUTPUT mathgl.pyc
+ COMMAND ${PYTHON_EXECUTABLE}
+ ARGS -c \"from py_compile import compile\; compile('mathgl.py') \"
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/lang
+ DEPENDS _mathgl
+ )
+ add_custom_target(mgl_python_module ALL DEPENDS _mathgl mathgl.pyc)
+
+ install(FILES ${MathGL2_BINARY_DIR}/lang/mathgl.py ${MathGL2_BINARY_DIR}/lang/mathgl.pyc DESTINATION ${MGL_PYTHON_SITE_PACKAGES})
+ install (TARGETS _mathgl LIBRARY DESTINATION ${MGL_PYTHON_SITE_PACKAGES})
+ set(mgl_clean_files ${mgl_clean_files} mathgl.py)
+endif(enable-python)
+
+if(enable-lua)
+ INCLUDE(FindLua51)
+ if(NOT LUA51_FOUND)
+ message(SEND_ERROR "Couldn't find Lua 5.1 library.")
+ endif(NOT LUA51_FOUND)
+
+ include_directories(${LUA_INCLUDE_DIR})
+ set(SWIG_MODULE_mgl-lua_EXTRA_DEPS numpy.i ${src_imp_dep})
+ if(${CMAKE_VERSION} VERSION_LESS "3.8.0")
+ SWIG_ADD_MODULE(mgl-lua lua mathgl.i)
+ else(${CMAKE_VERSION} VERSION_LESS "3.8.0")
+ SWIG_ADD_LIBRARY(mgl-lua LANGUAGE lua SOURCES mathgl.i)
+ endif(${CMAKE_VERSION} VERSION_LESS "3.8.0")
+ SWIG_LINK_LIBRARIES(mgl-lua mgl ${LUA_LIBRARIES})
+ set_target_properties(mgl-lua PROPERTIES PREFIX "" BUILD_WITH_INSTALL_RPATH ON)
+
+ install (TARGETS mgl-lua LIBRARY DESTINATION ${MathGL_INSTALL_LIB_DIR})
+endif(enable-lua)
+
+if(enable-octave)
+ find_program(oct_prog octave-config)
+ if(NOT oct_prog)
+ message(SEND_ERROR "Couldn't find octave-config needed for octave interfaces compiling.")
+ endif(NOT oct_prog)
+ find_program(oct_exec octave)
+ if(NOT oct_exec)
+ message(SEND_ERROR "Couldn't find octave needed for octave interfaces compiling.")
+ endif(NOT oct_exec)
+ find_program(oct_mk mkoctfile)
+ if(NOT oct_mk)
+ message(SEND_ERROR "Couldn't find mkoctfile needed for octave interfaces compiling.")
+ endif(NOT oct_mk)
+ find_program(oct_tar tar)
+ if(NOT oct_tar)
+ message(SEND_ERROR "Couldn't find tar needed for octave interfaces creation.")
+ endif(NOT oct_tar)
+
+ execute_process(COMMAND ${oct_prog} -p CANONICAL_HOST_TYPE
+ OUTPUT_VARIABLE oct_host
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ execute_process(COMMAND ${oct_prog} -p API_VERSION
+ OUTPUT_VARIABLE oct_api
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ execute_process(COMMAND ${oct_mk} -p INCFLAGS
+ OUTPUT_VARIABLE oct_inc
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ separate_arguments(oct_inc)
+message(STATUS "${oct_prog} ${oct_host} ${oct_api}")
+ set(oct_arch ${oct_host}-${oct_api})
+ set(pkg_name mathgl)
+ set(mgl_pkg_dir ${MathGL2_BINARY_DIR}/lang/${pkg_name}/inst/${oct_arch})
+
+ add_compile_options(${oct_inc})
+ SET(SWIG_MODULE_mgl-oct_EXTRA_DEPS numpy.i ${src_imp_dep})
+ if(${CMAKE_VERSION} VERSION_LESS "3.8.0")
+ SWIG_ADD_MODULE(mgl-oct octave mathgl.i)
+ else(${CMAKE_VERSION} VERSION_LESS "3.8.0")
+ SWIG_ADD_LIBRARY(mgl-oct LANGUAGE octave SOURCES mathgl.i)
+ endif(${CMAKE_VERSION} VERSION_LESS "3.8.0")
+ SWIG_LINK_LIBRARIES(mgl-oct mgl)
+ set_target_properties(mgl-oct PROPERTIES OUTPUT_NAME mathgl PREFIX "" SUFFIX ".oct" BUILD_WITH_INSTALL_RPATH ON)
+ add_custom_command(OUTPUT mathgl.tar.gz
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${mgl_pkg_dir}
+ COMMAND ${CMAKE_COMMAND} -E copy ${MathGL2_SOURCE_DIR}/COPYING ${MathGL2_BINARY_DIR}/lang/${pkg_name}
+ COMMAND ${CMAKE_COMMAND} -E copy ${MathGL2_SOURCE_DIR}/lang/DESCRIPTION ${MathGL2_BINARY_DIR}/lang/${pkg_name}
+ COMMAND ${CMAKE_COMMAND} -E copy ${MathGL2_SOURCE_DIR}/lang/INDEX ${MathGL2_BINARY_DIR}/lang/${pkg_name}
+ COMMAND ${CMAKE_COMMAND} -E copy ${MathGL2_SOURCE_DIR}/lang/PKG_ADD_template ${MathGL2_BINARY_DIR}/lang/${pkg_name}
+ COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:mgl-oct> ${mgl_pkg_dir}
+ COMMAND ${oct_tar} cpzf mathgl.tar.gz ${pkg_name}
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/lang
+ DEPENDS mgl-oct
+ )
+ add_custom_target(mgl_octave_module ALL DEPENDS mathgl.tar.gz)
+
+ install(FILES ${CMAKE_BINARY_DIR}/lang/mathgl.tar.gz DESTINATION ${MGL_DATA_PATH})
+ if(enable-octave-install)
+ install(CODE "execute_process(
+ COMMAND ${oct_exec} -q --eval \"pkg install mathgl.tar.gz\"
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/lang )")
+ endif(enable-octave-install)
+ set(mgl_clean_files ${mgl_clean_files} mathgl)
+endif(enable-octave)
+set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${mgl_clean_files}")
--- /dev/null
+/* -*- C -*- (not really, but good for syntax highlighting) */
+#ifdef SWIGPYTHON
+
+%{
+#ifndef SWIG_FILE_WITH_INIT
+# define NO_IMPORT_ARRAY
+#endif
+#include "stdio.h"
+#include <numpy/arrayobject.h>
+%}
+
+/**********************************************************************/
+
+%fragment("NumPy_Backward_Compatibility", "header")
+{
+/* Support older NumPy data type names
+*/
+%#if NDARRAY_VERSION < 0x01000000
+%#define NPY_BOOL PyArray_BOOL
+%#define NPY_BYTE PyArray_BYTE
+%#define NPY_UBYTE PyArray_UBYTE
+%#define NPY_SHORT PyArray_SHORT
+%#define NPY_USHORT PyArray_USHORT
+%#define NPY_INT PyArray_INT
+%#define NPY_UINT PyArray_UINT
+%#define NPY_LONG PyArray_LONG
+%#define NPY_ULONG PyArray_ULONG
+%#define NPY_LONGLONG PyArray_LONGLONG
+%#define NPY_ULONGLONG PyArray_ULONGLONG
+%#define NPY_FLOAT PyArray_FLOAT
+%#define NPY_DOUBLE PyArray_DOUBLE
+%#define NPY_LONGDOUBLE PyArray_LONGDOUBLE
+%#define NPY_CFLOAT PyArray_CFLOAT
+%#define NPY_CDOUBLE PyArray_CDOUBLE
+%#define NPY_CLONGDOUBLE PyArray_CLONGDOUBLE
+%#define NPY_OBJECT PyArray_OBJECT
+%#define NPY_STRING PyArray_STRING
+%#define NPY_UNICODE PyArray_UNICODE
+%#define NPY_VOID PyArray_VOID
+%#define NPY_NTYPES PyArray_NTYPES
+%#define NPY_NOTYPE PyArray_NOTYPE
+%#define NPY_CHAR PyArray_CHAR
+%#define NPY_USERDEF PyArray_USERDEF
+%#define npy_intp intp
+
+%#define NPY_MAX_BYTE MAX_BYTE
+%#define NPY_MIN_BYTE MIN_BYTE
+%#define NPY_MAX_UBYTE MAX_UBYTE
+%#define NPY_MAX_SHORT MAX_SHORT
+%#define NPY_MIN_SHORT MIN_SHORT
+%#define NPY_MAX_USHORT MAX_USHORT
+%#define NPY_MAX_INT MAX_INT
+%#define NPY_MIN_INT MIN_INT
+%#define NPY_MAX_UINT MAX_UINT
+%#define NPY_MAX_LONG MAX_LONG
+%#define NPY_MIN_LONG MIN_LONG
+%#define NPY_MAX_ULONG MAX_ULONG
+%#define NPY_MAX_LONGLONG MAX_LONGLONG
+%#define NPY_MIN_LONGLONG MIN_LONGLONG
+%#define NPY_MAX_ULONGLONG MAX_ULONGLONG
+%#define NPY_MAX_INTP MAX_INTP
+%#define NPY_MIN_INTP MIN_INTP
+
+%#define NPY_FARRAY FARRAY
+%#define NPY_F_CONTIGUOUS F_CONTIGUOUS
+%#endif
+}
+
+/**********************************************************************/
+
+/* The following code originally appeared in
+ * enthought/kiva/agg/src/numeric.i written by Eric Jones. It was
+ * translated from C++ to C by John Hunter. Bill Spotz has modified
+ * it to fix some minor bugs, upgrade from Numeric to numpy (all
+ * versions), add some comments and functionality, and convert from
+ * direct code insertion to SWIG fragments.
+ */
+
+%fragment("NumPy_Macros", "header")
+{
+/* Macros to extract array attributes.
+ */
+%#define is_array(a) ((a) && PyArray_Check((PyArrayObject *)a))
+%#define array_type(a) (int)(PyArray_TYPE(a))
+%#define array_numdims(a) (((PyArrayObject *)a)->nd)
+%#define array_dimensions(a) (((PyArrayObject *)a)->dimensions)
+%#define array_size(a,i) (((PyArrayObject *)a)->dimensions[i])
+%#define array_data(a) (((PyArrayObject *)a)->data)
+%#define array_is_contiguous(a) (PyArray_ISCONTIGUOUS(a))
+%#define array_is_native(a) (PyArray_ISNOTSWAPPED(a))
+%#define array_is_fortran(a) (PyArray_ISFORTRAN(a))
+}
+
+/**********************************************************************/
+
+%fragment("NumPy_Utilities", "header")
+{
+ /* Given a PyObject, return a string describing its type.
+ */
+ char* pytype_string(PyObject* py_obj) {
+ if (py_obj == NULL ) return "C NULL value";
+ if (py_obj == Py_None ) return "Python None" ;
+ if (PyCallable_Check(py_obj)) return "callable" ;
+ if (PyString_Check( py_obj)) return "string" ;
+ if (PyInt_Check( py_obj)) return "int" ;
+ if (PyFloat_Check( py_obj)) return "float" ;
+ if (PyDict_Check( py_obj)) return "dict" ;
+ if (PyList_Check( py_obj)) return "list" ;
+ if (PyTuple_Check( py_obj)) return "tuple" ;
+ if (PyFile_Check( py_obj)) return "file" ;
+ if (PyModule_Check( py_obj)) return "module" ;
+ if (PyInstance_Check(py_obj)) return "instance" ;
+
+ return "unknow type";
+ }
+
+ /* Given a NumPy typecode, return a string describing the type.
+ */
+ char* typecode_string(int typecode) {
+ static char* type_names[25] = {"bool", "byte", "unsigned byte",
+ "short", "unsigned short", "int",
+ "unsigned int", "long", "unsigned long",
+ "long long", "unsigned long long",
+ "float", "double", "long double",
+ "complex float", "complex double",
+ "complex long double", "object",
+ "string", "unicode", "void", "ntypes",
+ "notype", "char", "unknown"};
+ return typecode < 24 ? type_names[typecode] : type_names[24];
+ }
+
+ /* Make sure input has correct numpy type. Allow character and byte
+ * to match. Also allow int and long to match. This is deprecated.
+ * You should use PyArray_EquivTypenums() instead.
+ */
+ int type_match(int actual_type, int desired_type) {
+ return PyArray_EquivTypenums(actual_type, desired_type);
+ }
+}
+
+/**********************************************************************/
+
+%fragment("NumPy_Object_to_Array", "header",
+ fragment="NumPy_Backward_Compatibility",
+ fragment="NumPy_Macros",
+ fragment="NumPy_Utilities")
+{
+ /* Given a PyObject pointer, cast it to a PyArrayObject pointer if
+ * legal. If not, set the python error string appropriately and
+ * return NULL.
+ */
+ PyArrayObject* obj_to_array_no_conversion(PyObject* input, int typecode)
+ {
+ PyArrayObject* ary = NULL;
+ if (is_array(input) && (typecode == NPY_NOTYPE ||
+ PyArray_EquivTypenums(array_type(input), typecode)))
+ {
+ ary = (PyArrayObject*) input;
+ }
+ else if is_array(input)
+ {
+ char* desired_type = typecode_string(typecode);
+ char* actual_type = typecode_string(array_type(input));
+ PyErr_Format(PyExc_TypeError,
+ "Array of type '%s' required. Array of type '%s' given",
+ desired_type, actual_type);
+ ary = NULL;
+ }
+ else
+ {
+ char * desired_type = typecode_string(typecode);
+ char * actual_type = pytype_string(input);
+ PyErr_Format(PyExc_TypeError,
+ "Array of type '%s' required. A '%s' was given",
+ desired_type, actual_type);
+ ary = NULL;
+ }
+ return ary;
+ }
+
+ /* Convert the given PyObject to a NumPy array with the given
+ * typecode. On success, return a valid PyArrayObject* with the
+ * correct type. On failure, the python error string will be set and
+ * the routine returns NULL.
+ */
+ PyArrayObject* obj_to_array_allow_conversion(PyObject* input, int typecode,
+ int* is_new_object)
+ {
+ PyArrayObject* ary = NULL;
+ PyObject* py_obj;
+ if (is_array(input) && (typecode == NPY_NOTYPE ||
+ PyArray_EquivTypenums(array_type(input),typecode)))
+ {
+ ary = (PyArrayObject*) input;
+ *is_new_object = 0;
+ }
+ else
+ {
+ py_obj = PyArray_FROMANY(input, typecode, 0, 0, NPY_DEFAULT);
+ /* If NULL, PyArray_FromObject will have set python error value.*/
+ ary = (PyArrayObject*) py_obj;
+ *is_new_object = 1;
+ }
+ return ary;
+ }
+
+ /* Given a PyArrayObject, check to see if it is contiguous. If so,
+ * return the input pointer and flag it as not a new object. If it is
+ * not contiguous, create a new PyArrayObject using the original data,
+ * flag it as a new object and return the pointer.
+ */
+ PyArrayObject* make_contiguous(PyArrayObject* ary, int* is_new_object,
+ int min_dims, int max_dims)
+ {
+ PyArrayObject* result;
+ if (array_is_contiguous(ary))
+ {
+ result = ary;
+ *is_new_object = 0;
+ }
+ else
+ {
+ result = (PyArrayObject*) PyArray_ContiguousFromObject((PyObject*)ary,
+ array_type(ary),
+ min_dims,
+ max_dims);
+ *is_new_object = 1;
+ }
+ return result;
+ }
+
+ /* Given a PyArrayObject, check to see if it is Fortran-contiguous.
+ * If so, return the input pointer, but do not flag it as not a new
+ * object. If it is not Fortran-contiguous, create a new
+ * PyArrayObject using the original data, flag it as a new object
+ * and return the pointer.
+ */
+ PyArrayObject* make_fortran(PyArrayObject* ary, int* is_new_object,
+ int min_dims, int max_dims)
+ {
+ PyArrayObject* result;
+ if (array_is_fortran(ary))
+ {
+ result = ary;
+ *is_new_object = 0;
+ }
+ else
+ {
+ Py_INCREF(ary->descr);
+ result = (PyArrayObject*) PyArray_FromArray(ary, ary->descr, NPY_FORTRAN);
+ *is_new_object = 1;
+ }
+ return result;
+ }
+
+ /* Convert a given PyObject to a contiguous PyArrayObject of the
+ * specified type. If the input object is not a contiguous
+ * PyArrayObject, a new one will be created and the new object flag
+ * will be set.
+ */
+ PyArrayObject* obj_to_array_contiguous_allow_conversion(PyObject* input,
+ int typecode,
+ int* is_new_object)
+ {
+ int is_new1 = 0;
+ int is_new2 = 0;
+ PyArrayObject* ary2;
+ PyArrayObject* ary1 = obj_to_array_allow_conversion(input, typecode,
+ &is_new1);
+ if (ary1)
+ {
+ ary2 = make_contiguous(ary1, &is_new2, 0, 0);
+ if ( is_new1 && is_new2)
+ {
+ Py_DECREF(ary1);
+ }
+ ary1 = ary2;
+ }
+ *is_new_object = is_new1 || is_new2;
+ return ary1;
+ }
+
+ /* Convert a given PyObject to a Fortran-ordered PyArrayObject of the
+ * specified type. If the input object is not a Fortran-ordered
+ * PyArrayObject, a new one will be created and the new object flag
+ * will be set.
+ */
+ PyArrayObject* obj_to_array_fortran_allow_conversion(PyObject* input,
+ int typecode,
+ int* is_new_object)
+ {
+ int is_new1 = 0;
+ int is_new2 = 0;
+ PyArrayObject* ary2;
+ PyArrayObject* ary1 = obj_to_array_allow_conversion(input, typecode,
+ &is_new1);
+ if (ary1)
+ {
+ ary2 = make_fortran(ary1, &is_new2, 0, 0);
+ if (is_new1 && is_new2)
+ {
+ Py_DECREF(ary1);
+ }
+ ary1 = ary2;
+ }
+ *is_new_object = is_new1 || is_new2;
+ return ary1;
+ }
+
+} /* end fragment */
+
+
+/**********************************************************************/
+
+%fragment("NumPy_Array_Requirements", "header",
+ fragment="NumPy_Backward_Compatibility",
+ fragment="NumPy_Macros")
+{
+ /* Test whether a python object is contiguous. If array is
+ * contiguous, return 1. Otherwise, set the python error string and
+ * return 0.
+ */
+ int require_contiguous(PyArrayObject* ary)
+ {
+ int contiguous = 1;
+ if (!array_is_contiguous(ary))
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "Array must be contiguous. A non-contiguous array was given");
+ contiguous = 0;
+ }
+ return contiguous;
+ }
+
+ /* Require that a numpy array is not byte-swapped. If the array is
+ * not byte-swapped, return 1. Otherwise, set the python error string
+ * and return 0.
+ */
+ int require_native(PyArrayObject* ary)
+ {
+ int native = 1;
+ if (!array_is_native(ary))
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "Array must have native byteorder. "
+ "A byte-swapped array was given");
+ native = 0;
+ }
+ return native;
+ }
+
+ /* Require the given PyArrayObject to have a specified number of
+ * dimensions. If the array has the specified number of dimensions,
+ * return 1. Otherwise, set the python error string and return 0.
+ */
+ int require_dimensions(PyArrayObject* ary, int exact_dimensions)
+ {
+ int success = 1;
+ if (array_numdims(ary) != exact_dimensions)
+ {
+ PyErr_Format(PyExc_TypeError,
+ "Array must have %d dimensions. Given array has %d dimensions",
+ exact_dimensions, array_numdims(ary));
+ success = 0;
+ }
+ return success;
+ }
+
+ /* Require the given PyArrayObject to have one of a list of specified
+ * number of dimensions. If the array has one of the specified number
+ * of dimensions, return 1. Otherwise, set the python error string
+ * and return 0.
+ */
+ int require_dimensions_n(PyArrayObject* ary, int* exact_dimensions, int n)
+ {
+ int success = 0;
+ int i;
+ char dims_str[255] = "";
+ char s[255];
+ for (i = 0; i < n && !success; i++)
+ {
+ if (array_numdims(ary) == exact_dimensions[i])
+ {
+ success = 1;
+ }
+ }
+ if (!success)
+ {
+ for (i = 0; i < n-1; i++)
+ {
+ sprintf(s, "%d, ", exact_dimensions[i]);
+ strcat(dims_str,s);
+ }
+ sprintf(s, " or %d", exact_dimensions[n-1]);
+ strcat(dims_str,s);
+ PyErr_Format(PyExc_TypeError,
+ "Array must have %s dimensions. Given array has %d dimensions",
+ dims_str, array_numdims(ary));
+ }
+ return success;
+ }
+
+ /* Require the given PyArrayObject to have a specified shape. If the
+ * array has the specified shape, return 1. Otherwise, set the python
+ * error string and return 0.
+ */
+ int require_size(PyArrayObject* ary, npy_intp* size, int n)
+ {
+ int i;
+ int success = 1;
+ int len;
+ char desired_dims[255] = "[";
+ char s[255];
+ char actual_dims[255] = "[";
+ for(i=0; i < n;i++)
+ {
+ if (size[i] != -1 && size[i] != array_size(ary,i))
+ {
+ success = 0;
+ }
+ }
+ if (!success)
+ {
+ for (i = 0; i < n; i++)
+ {
+ if (size[i] == -1)
+ {
+ sprintf(s, "*,");
+ }
+ else
+ {
+ sprintf(s, "%ld,", (long int)size[i]);
+ }
+ strcat(desired_dims,s);
+ }
+ len = strlen(desired_dims);
+ desired_dims[len-1] = ']';
+ for (i = 0; i < n; i++)
+ {
+ sprintf(s, "%ld,", (long int)array_size(ary,i));
+ strcat(actual_dims,s);
+ }
+ len = strlen(actual_dims);
+ actual_dims[len-1] = ']';
+ PyErr_Format(PyExc_TypeError,
+ "Array must have shape of %s. Given array has shape of %s",
+ desired_dims, actual_dims);
+ }
+ return success;
+ }
+
+ /* Require the given PyArrayObject to to be FORTRAN ordered. If the
+ * the PyArrayObject is already FORTRAN ordered, do nothing. Else,
+ * set the FORTRAN ordering flag and recompute the strides.
+ */
+ int require_fortran(PyArrayObject* ary)
+ {
+ int success = 1;
+ int nd = array_numdims(ary);
+ int i;
+ if (array_is_fortran(ary)) return success;
+ /* Set the FORTRAN ordered flag */
+ ary->flags = NPY_FARRAY;
+ /* Recompute the strides */
+ ary->strides[0] = ary->strides[nd-1];
+ for (i=1; i < nd; ++i)
+ ary->strides[i] = ary->strides[i-1] * array_size(ary,i-1);
+ return success;
+ }
+}
+
+/* Combine all NumPy fragments into one for convenience */
+%fragment("NumPy_Fragments", "header",
+ fragment="NumPy_Backward_Compatibility",
+ fragment="NumPy_Macros",
+ fragment="NumPy_Utilities",
+ fragment="NumPy_Object_to_Array",
+ fragment="NumPy_Array_Requirements") { }
+
+/* End John Hunter translation (with modifications by Bill Spotz)
+ */
+
+/* %numpy_typemaps() macro
+ *
+ * This macro defines a family of 41 typemaps that allow C arguments
+ * of the form
+ *
+ * (DATA_TYPE IN_ARRAY1[ANY])
+ * (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
+ * (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
+ *
+ * (DATA_TYPE IN_ARRAY2[ANY][ANY])
+ * (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ * (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
+ * (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ * (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
+ *
+ * (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
+ * (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+ * (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
+ * (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+ * (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
+ *
+ * (DATA_TYPE INPLACE_ARRAY1[ANY])
+ * (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
+ * (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
+ *
+ * (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
+ * (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ * (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
+ * (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ * (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
+ *
+ * (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
+ * (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+ * (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3)
+ * (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+ * (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3)
+ *
+ * (DATA_TYPE ARGOUT_ARRAY1[ANY])
+ * (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
+ * (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
+ *
+ * (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
+ *
+ * (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
+ *
+ * (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1)
+ * (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1)
+ *
+ * (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
+ * (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2)
+ * (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
+ * (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2)
+ *
+ * (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
+ * (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3)
+ * (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
+ * (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_FARRAY3)
+ *
+ * where "DATA_TYPE" is any type supported by the NumPy module, and
+ * "DIM_TYPE" is any int-like type suitable for specifying dimensions.
+ * The difference between "ARRAY" typemaps and "FARRAY" typemaps is
+ * that the "FARRAY" typemaps expect FORTRAN ordering of
+ * multidimensional arrays. In python, the dimensions will not need
+ * to be specified (except for the "DATA_TYPE* ARGOUT_ARRAY1"
+ * typemaps). The IN_ARRAYs can be a numpy array or any sequence that
+ * can be converted to a numpy array of the specified type. The
+ * INPLACE_ARRAYs must be numpy arrays of the appropriate type. The
+ * ARGOUT_ARRAYs will be returned as new numpy arrays of the
+ * appropriate type.
+ *
+ * These typemaps can be applied to existing functions using the
+ * %apply directive. For example:
+ *
+ * %apply (double* IN_ARRAY1, int DIM1) {(double* series, int length)};
+ * double prod(double* series, int length);
+ *
+ * %apply (int DIM1, int DIM2, double* INPLACE_ARRAY2)
+ * {(int rows, int cols, double* matrix )};
+ * void floor(int rows, int cols, double* matrix, double f);
+ *
+ * %apply (double IN_ARRAY3[ANY][ANY][ANY])
+ * {(double tensor[2][2][2] )};
+ * %apply (double ARGOUT_ARRAY3[ANY][ANY][ANY])
+ * {(double low[2][2][2] )};
+ * %apply (double ARGOUT_ARRAY3[ANY][ANY][ANY])
+ * {(double upp[2][2][2] )};
+ * void luSplit(double tensor[2][2][2],
+ * double low[2][2][2],
+ * double upp[2][2][2] );
+ *
+ * or directly with
+ *
+ * double prod(double* IN_ARRAY1, int DIM1);
+ *
+ * void floor(int DIM1, int DIM2, double* INPLACE_ARRAY2, double f);
+ *
+ * void luSplit(double IN_ARRAY3[ANY][ANY][ANY],
+ * double ARGOUT_ARRAY3[ANY][ANY][ANY],
+ * double ARGOUT_ARRAY3[ANY][ANY][ANY]);
+ */
+
+%define %numpy_typemaps(DATA_TYPE, DATA_TYPECODE, DIM_TYPE)
+
+/************************/
+/* Input Array Typemaps */
+/************************/
+
+/* Typemap suite for (DATA_TYPE IN_ARRAY1[ANY])
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+ fragment="NumPy_Macros")
+ (DATA_TYPE IN_ARRAY1[ANY])
+{
+ $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+ fragment="NumPy_Fragments")
+ (DATA_TYPE IN_ARRAY1[ANY])
+ (PyArrayObject* array=NULL, int is_new_object=0)
+{
+ npy_intp size[1] = { $1_dim0 };
+ array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+ &is_new_object);
+ if (!array || !require_dimensions(array, 1) ||
+ !require_size(array, size, 1)) SWIG_fail;
+ $1 = ($1_ltype) array_data(array);
+}
+%typemap(freearg)
+ (DATA_TYPE IN_ARRAY1[ANY])
+{
+ if (is_new_object$argnum && array$argnum)
+ { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+ fragment="NumPy_Macros")
+ (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
+{
+ $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+ fragment="NumPy_Fragments")
+ (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
+ (PyArrayObject* array=NULL, int is_new_object=0)
+{
+ npy_intp size[1] = { -1 };
+ array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+ &is_new_object);
+ if (!array || !require_dimensions(array, 1) ||
+ !require_size(array, size, 1)) SWIG_fail;
+ $1 = (DATA_TYPE*) array_data(array);
+ $2 = (DIM_TYPE) array_size(array,0);
+}
+%typemap(freearg)
+ (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
+{
+ if (is_new_object$argnum && array$argnum)
+ { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+ fragment="NumPy_Macros")
+ (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
+{
+ $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+ fragment="NumPy_Fragments")
+ (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
+ (PyArrayObject* array=NULL, int is_new_object=0)
+{
+ npy_intp size[1] = {-1};
+ array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+ &is_new_object);
+ if (!array || !require_dimensions(array, 1) ||
+ !require_size(array, size, 1)) SWIG_fail;
+ $1 = (DIM_TYPE) array_size(array,0);
+ $2 = (DATA_TYPE*) array_data(array);
+}
+%typemap(freearg)
+ (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
+{
+ if (is_new_object$argnum && array$argnum)
+ { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DATA_TYPE IN_ARRAY2[ANY][ANY])
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+ fragment="NumPy_Macros")
+ (DATA_TYPE IN_ARRAY2[ANY][ANY])
+{
+ $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+ fragment="NumPy_Fragments")
+ (DATA_TYPE IN_ARRAY2[ANY][ANY])
+ (PyArrayObject* array=NULL, int is_new_object=0)
+{
+ npy_intp size[2] = { $1_dim0, $1_dim1 };
+ array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+ &is_new_object);
+ if (!array || !require_dimensions(array, 2) ||
+ !require_size(array, size, 2)) SWIG_fail;
+ $1 = ($1_ltype) array_data(array);
+}
+%typemap(freearg)
+ (DATA_TYPE IN_ARRAY2[ANY][ANY])
+{
+ if (is_new_object$argnum && array$argnum)
+ { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+ fragment="NumPy_Macros")
+ (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+{
+ $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+ fragment="NumPy_Fragments")
+ (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ (PyArrayObject* array=NULL, int is_new_object=0)
+{
+ npy_intp size[2] = { -1, -1 };
+ array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+ &is_new_object);
+ if (!array || !require_dimensions(array, 2) ||
+ !require_size(array, size, 2)) SWIG_fail;
+ $1 = (DATA_TYPE*) array_data(array);
+ $2 = (DIM_TYPE) array_size(array,0);
+ $3 = (DIM_TYPE) array_size(array,1);
+}
+%typemap(freearg)
+ (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+{
+ if (is_new_object$argnum && array$argnum)
+ { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+ fragment="NumPy_Macros")
+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
+{
+ $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+ fragment="NumPy_Fragments")
+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
+ (PyArrayObject* array=NULL, int is_new_object=0)
+{
+ npy_intp size[2] = { -1, -1 };
+ array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+ &is_new_object);
+ if (!array || !require_dimensions(array, 2) ||
+ !require_size(array, size, 2)) SWIG_fail;
+ $1 = (DIM_TYPE) array_size(array,0);
+ $2 = (DIM_TYPE) array_size(array,1);
+ $3 = (DATA_TYPE*) array_data(array);
+}
+%typemap(freearg)
+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
+{
+ if (is_new_object$argnum && array$argnum)
+ { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+ fragment="NumPy_Macros")
+ (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+{
+ $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+ fragment="NumPy_Fragments")
+ (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ (PyArrayObject* array=NULL, int is_new_object=0)
+{
+ npy_intp size[2] = { -1, -1 };
+ array = obj_to_array_fortran_allow_conversion($input, DATA_TYPECODE,
+ &is_new_object);
+ if (!array || !require_dimensions(array, 2) ||
+ !require_size(array, size, 2) || !require_fortran(array)) SWIG_fail;
+ $1 = (DATA_TYPE*) array_data(array);
+ $2 = (DIM_TYPE) array_size(array,0);
+ $3 = (DIM_TYPE) array_size(array,1);
+}
+%typemap(freearg)
+ (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+{
+ if (is_new_object$argnum && array$argnum)
+ { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+ fragment="NumPy_Macros")
+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
+{
+ $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+ fragment="NumPy_Fragments")
+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
+ (PyArrayObject* array=NULL, int is_new_object=0)
+{
+ npy_intp size[2] = { -1, -1 };
+ array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+ &is_new_object);
+ if (!array || !require_dimensions(array, 2) ||
+ !require_size(array, size, 2) || !require_fortran(array)) SWIG_fail;
+ $1 = (DIM_TYPE) array_size(array,0);
+ $2 = (DIM_TYPE) array_size(array,1);
+ $3 = (DATA_TYPE*) array_data(array);
+}
+%typemap(freearg)
+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
+{
+ if (is_new_object$argnum && array$argnum)
+ { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+ fragment="NumPy_Macros")
+ (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
+{
+ $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+ fragment="NumPy_Fragments")
+ (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
+ (PyArrayObject* array=NULL, int is_new_object=0)
+{
+ npy_intp size[3] = { $1_dim0, $1_dim1, $1_dim2 };
+ array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+ &is_new_object);
+ if (!array || !require_dimensions(array, 3) ||
+ !require_size(array, size, 3)) SWIG_fail;
+ $1 = ($1_ltype) array_data(array);
+}
+%typemap(freearg)
+ (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
+{
+ if (is_new_object$argnum && array$argnum)
+ { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
+ * DIM_TYPE DIM3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+ fragment="NumPy_Macros")
+ (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+{
+ $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+ fragment="NumPy_Fragments")
+ (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+ (PyArrayObject* array=NULL, int is_new_object=0)
+{
+ npy_intp size[3] = { -1, -1, -1 };
+ array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+ &is_new_object);
+ if (!array || !require_dimensions(array, 3) ||
+ !require_size(array, size, 3)) SWIG_fail;
+ $1 = (DATA_TYPE*) array_data(array);
+ $2 = (DIM_TYPE) array_size(array,0);
+ $3 = (DIM_TYPE) array_size(array,1);
+ $4 = (DIM_TYPE) array_size(array,2);
+}
+%typemap(freearg)
+ (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+{
+ if (is_new_object$argnum && array$argnum)
+ { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
+ * DATA_TYPE* IN_ARRAY3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+ fragment="NumPy_Macros")
+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
+{
+ $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+ fragment="NumPy_Fragments")
+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
+ (PyArrayObject* array=NULL, int is_new_object=0)
+{
+ npy_intp size[3] = { -1, -1, -1 };
+ array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+ &is_new_object);
+ if (!array || !require_dimensions(array, 3) ||
+ !require_size(array, size, 3)) SWIG_fail;
+ $1 = (DIM_TYPE) array_size(array,0);
+ $2 = (DIM_TYPE) array_size(array,1);
+ $3 = (DIM_TYPE) array_size(array,2);
+ $4 = (DATA_TYPE*) array_data(array);
+}
+%typemap(freearg)
+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
+{
+ if (is_new_object$argnum && array$argnum)
+ { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
+ * DIM_TYPE DIM3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+ fragment="NumPy_Macros")
+ (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+{
+ $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+ fragment="NumPy_Fragments")
+ (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+ (PyArrayObject* array=NULL, int is_new_object=0)
+{
+ npy_intp size[3] = { -1, -1, -1 };
+ array = obj_to_array_fortran_allow_conversion($input, DATA_TYPECODE,
+ &is_new_object);
+ if (!array || !require_dimensions(array, 3) ||
+ !require_size(array, size, 3) | !require_fortran(array)) SWIG_fail;
+ $1 = (DATA_TYPE*) array_data(array);
+ $2 = (DIM_TYPE) array_size(array,0);
+ $3 = (DIM_TYPE) array_size(array,1);
+ $4 = (DIM_TYPE) array_size(array,2);
+}
+%typemap(freearg)
+ (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+{
+ if (is_new_object$argnum && array$argnum)
+ { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
+ * DATA_TYPE* IN_FARRAY3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+ fragment="NumPy_Macros")
+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
+{
+ $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+ fragment="NumPy_Fragments")
+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
+ (PyArrayObject* array=NULL, int is_new_object=0)
+{
+ npy_intp size[3] = { -1, -1, -1 };
+ array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+ &is_new_object);
+ if (!array || !require_dimensions(array, 3) ||
+ !require_size(array, size, 3) || !require_fortran(array)) SWIG_fail;
+ $1 = (DIM_TYPE) array_size(array,0);
+ $2 = (DIM_TYPE) array_size(array,1);
+ $3 = (DIM_TYPE) array_size(array,2);
+ $4 = (DATA_TYPE*) array_data(array);
+}
+%typemap(freearg)
+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
+{
+ if (is_new_object$argnum && array$argnum)
+ { Py_DECREF(array$argnum); }
+}
+
+/***************************/
+/* In-Place Array Typemaps */
+/***************************/
+
+/* Typemap suite for (DATA_TYPE INPLACE_ARRAY1[ANY])
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+ fragment="NumPy_Macros")
+ (DATA_TYPE INPLACE_ARRAY1[ANY])
+{
+ $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+ DATA_TYPECODE);
+}
+%typemap(in,
+ fragment="NumPy_Fragments")
+ (DATA_TYPE INPLACE_ARRAY1[ANY])
+ (PyArrayObject* array=NULL)
+{
+ npy_intp size[1] = { $1_dim0 };
+ array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+ if (!array || !require_dimensions(array,1) || !require_size(array, size, 1) ||
+ !require_contiguous(array) || !require_native(array)) SWIG_fail;
+ $1 = ($1_ltype) array_data(array);
+}
+
+/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+ fragment="NumPy_Macros")
+ (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
+{
+ $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+ DATA_TYPECODE);
+}
+%typemap(in,
+ fragment="NumPy_Fragments")
+ (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
+ (PyArrayObject* array=NULL, int i=1)
+{
+ array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+ if (!array || !require_dimensions(array,1) || !require_contiguous(array)
+ || !require_native(array)) SWIG_fail;
+ $1 = (DATA_TYPE*) array_data(array);
+ $2 = 1;
+ for (i=0; i < array_numdims(array); ++i) $2 *= array_size(array,i);
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+ fragment="NumPy_Macros")
+ (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
+{
+ $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+ DATA_TYPECODE);
+}
+%typemap(in,
+ fragment="NumPy_Fragments")
+ (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
+ (PyArrayObject* array=NULL, int i=0)
+{
+ array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+ if (!array || !require_dimensions(array,1) || !require_contiguous(array)
+ || !require_native(array)) SWIG_fail;
+ $1 = 1;
+ for (i=0; i < array_numdims(array); ++i) $1 *= array_size(array,i);
+ $2 = (DATA_TYPE*) array_data(array);
+}
+
+/* Typemap suite for (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+ fragment="NumPy_Macros")
+ (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
+{
+ $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+ DATA_TYPECODE);
+}
+%typemap(in,
+ fragment="NumPy_Fragments")
+ (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
+ (PyArrayObject* array=NULL)
+{
+ npy_intp size[2] = { $1_dim0, $1_dim1 };
+ array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+ if (!array || !require_dimensions(array,2) || !require_size(array, size, 2) ||
+ !require_contiguous(array) || !require_native(array)) SWIG_fail;
+ $1 = ($1_ltype) array_data(array);
+}
+
+/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+ fragment="NumPy_Macros")
+ (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+{
+ $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+ DATA_TYPECODE);
+}
+%typemap(in,
+ fragment="NumPy_Fragments")
+ (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ (PyArrayObject* array=NULL)
+{
+ array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+ if (!array || !require_dimensions(array,2) || !require_contiguous(array)
+ || !require_native(array)) SWIG_fail;
+ $1 = (DATA_TYPE*) array_data(array);
+ $2 = (DIM_TYPE) array_size(array,0);
+ $3 = (DIM_TYPE) array_size(array,1);
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+ fragment="NumPy_Macros")
+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
+{
+ $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+ DATA_TYPECODE);
+}
+%typemap(in,
+ fragment="NumPy_Fragments")
+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
+ (PyArrayObject* array=NULL)
+{
+ array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+ if (!array || !require_dimensions(array,2) || !require_contiguous(array) ||
+ !require_native(array)) SWIG_fail;
+ $1 = (DIM_TYPE) array_size(array,0);
+ $2 = (DIM_TYPE) array_size(array,1);
+ $3 = (DATA_TYPE*) array_data(array);
+}
+
+/* Typemap suite for (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+ fragment="NumPy_Macros")
+ (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+{
+ $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+ DATA_TYPECODE);
+}
+%typemap(in,
+ fragment="NumPy_Fragments")
+ (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ (PyArrayObject* array=NULL)
+{
+ array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+ if (!array || !require_dimensions(array,2) || !require_contiguous(array)
+ || !require_native(array) || !require_fortran(array)) SWIG_fail;
+ $1 = (DATA_TYPE*) array_data(array);
+ $2 = (DIM_TYPE) array_size(array,0);
+ $3 = (DIM_TYPE) array_size(array,1);
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+ fragment="NumPy_Macros")
+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
+{
+ $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+ DATA_TYPECODE);
+}
+%typemap(in,
+ fragment="NumPy_Fragments")
+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
+ (PyArrayObject* array=NULL)
+{
+ array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+ if (!array || !require_dimensions(array,2) || !require_contiguous(array) ||
+ !require_native(array) || !require_fortran(array)) SWIG_fail;
+ $1 = (DIM_TYPE) array_size(array,0);
+ $2 = (DIM_TYPE) array_size(array,1);
+ $3 = (DATA_TYPE*) array_data(array);
+}
+
+/* Typemap suite for (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+ fragment="NumPy_Macros")
+ (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
+{
+ $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+ DATA_TYPECODE);
+}
+%typemap(in,
+ fragment="NumPy_Fragments")
+ (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
+ (PyArrayObject* array=NULL)
+{
+ npy_intp size[3] = { $1_dim0, $1_dim1, $1_dim2 };
+ array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+ if (!array || !require_dimensions(array,3) || !require_size(array, size, 3) ||
+ !require_contiguous(array) || !require_native(array)) SWIG_fail;
+ $1 = ($1_ltype) array_data(array);
+}
+
+/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
+ * DIM_TYPE DIM3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+ fragment="NumPy_Macros")
+ (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+{
+ $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+ DATA_TYPECODE);
+}
+%typemap(in,
+ fragment="NumPy_Fragments")
+ (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+ (PyArrayObject* array=NULL)
+{
+ array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+ if (!array || !require_dimensions(array,3) || !require_contiguous(array) ||
+ !require_native(array)) SWIG_fail;
+ $1 = (DATA_TYPE*) array_data(array);
+ $2 = (DIM_TYPE) array_size(array,0);
+ $3 = (DIM_TYPE) array_size(array,1);
+ $4 = (DIM_TYPE) array_size(array,2);
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
+ * DATA_TYPE* INPLACE_ARRAY3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+ fragment="NumPy_Macros")
+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3)
+{
+ $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+ DATA_TYPECODE);
+}
+%typemap(in,
+ fragment="NumPy_Fragments")
+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3)
+ (PyArrayObject* array=NULL)
+{
+ array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+ if (!array || !require_dimensions(array,3) || !require_contiguous(array)
+ || !require_native(array)) SWIG_fail;
+ $1 = (DIM_TYPE) array_size(array,0);
+ $2 = (DIM_TYPE) array_size(array,1);
+ $3 = (DIM_TYPE) array_size(array,2);
+ $4 = (DATA_TYPE*) array_data(array);
+}
+
+/* Typemap suite for (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
+ * DIM_TYPE DIM3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+ fragment="NumPy_Macros")
+ (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+{
+ $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+ DATA_TYPECODE);
+}
+%typemap(in,
+ fragment="NumPy_Fragments")
+ (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+ (PyArrayObject* array=NULL)
+{
+ array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+ if (!array || !require_dimensions(array,3) || !require_contiguous(array) ||
+ !require_native(array) || !require_fortran(array)) SWIG_fail;
+ $1 = (DATA_TYPE*) array_data(array);
+ $2 = (DIM_TYPE) array_size(array,0);
+ $3 = (DIM_TYPE) array_size(array,1);
+ $4 = (DIM_TYPE) array_size(array,2);
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
+ * DATA_TYPE* INPLACE_FARRAY3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+ fragment="NumPy_Macros")
+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3)
+{
+ $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+ DATA_TYPECODE);
+}
+%typemap(in,
+ fragment="NumPy_Fragments")
+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3)
+ (PyArrayObject* array=NULL)
+{
+ array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+ if (!array || !require_dimensions(array,3) || !require_contiguous(array)
+ || !require_native(array) || !require_fortran(array)) SWIG_fail;
+ $1 = (DIM_TYPE) array_size(array,0);
+ $2 = (DIM_TYPE) array_size(array,1);
+ $3 = (DIM_TYPE) array_size(array,2);
+ $4 = (DATA_TYPE*) array_data(array);
+}
+
+/*************************/
+/* Argout Array Typemaps */
+/*************************/
+
+/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY1[ANY])
+ */
+%typemap(in,numinputs=0,
+ fragment="NumPy_Backward_Compatibility,NumPy_Macros")
+ (DATA_TYPE ARGOUT_ARRAY1[ANY])
+ (PyObject * array = NULL)
+{
+ npy_intp dims[1] = { $1_dim0 };
+ array = PyArray_SimpleNew(1, dims, DATA_TYPECODE);
+ if (!array) SWIG_fail;
+ $1 = ($1_ltype) array_data(array);
+}
+%typemap(argout)
+ (DATA_TYPE ARGOUT_ARRAY1[ANY])
+{
+ $result = SWIG_Python_AppendOutput($result,array$argnum);
+}
+
+/* Typemap suite for (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
+ */
+%typemap(in,numinputs=1,
+ fragment="NumPy_Fragments")
+ (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
+ (PyObject * array = NULL)
+{
+ npy_intp dims[1];
+ if (!PyInt_Check($input))
+ {
+ char* typestring = pytype_string($input);
+ PyErr_Format(PyExc_TypeError,
+ "Int dimension expected. '%s' given.",
+ typestring);
+ SWIG_fail;
+ }
+ $2 = (DIM_TYPE) PyInt_AsLong($input);
+ dims[0] = (npy_intp) $2;
+ array = PyArray_SimpleNew(1, dims, DATA_TYPECODE);
+ if (!array) SWIG_fail;
+ $1 = (DATA_TYPE*) array_data(array);
+}
+%typemap(argout)
+ (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
+{
+ $result = SWIG_Python_AppendOutput($result,array$argnum);
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
+ */
+%typemap(in,numinputs=1,
+ fragment="NumPy_Fragments")
+ (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
+ (PyObject * array = NULL)
+{
+ npy_intp dims[1];
+ if (!PyInt_Check($input))
+ {
+ char* typestring = pytype_string($input);
+ PyErr_Format(PyExc_TypeError,
+ "Int dimension expected. '%s' given.",
+ typestring);
+ SWIG_fail;
+ }
+ $1 = (DIM_TYPE) PyInt_AsLong($input);
+ dims[0] = (npy_intp) $1;
+ array = PyArray_SimpleNew(1, dims, DATA_TYPECODE);
+ if (!array) SWIG_fail;
+ $2 = (DATA_TYPE*) array_data(array);
+}
+%typemap(argout)
+ (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
+{
+ $result = SWIG_Python_AppendOutput($result,array$argnum);
+}
+
+/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
+ */
+%typemap(in,numinputs=0,
+ fragment="NumPy_Backward_Compatibility,NumPy_Macros")
+ (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
+ (PyObject * array = NULL)
+{
+ npy_intp dims[2] = { $1_dim0, $1_dim1 };
+ array = PyArray_SimpleNew(2, dims, DATA_TYPECODE);
+ if (!array) SWIG_fail;
+ $1 = ($1_ltype) array_data(array);
+}
+%typemap(argout)
+ (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
+{
+ $result = SWIG_Python_AppendOutput($result,array$argnum);
+}
+
+/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
+ */
+%typemap(in,numinputs=0,
+ fragment="NumPy_Backward_Compatibility,NumPy_Macros")
+ (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
+ (PyObject * array = NULL)
+{
+ npy_intp dims[3] = { $1_dim0, $1_dim1, $1_dim2 };
+ array = PyArray_SimpleNew(3, dims, DATA_TYPECODE);
+ if (!array) SWIG_fail;
+ $1 = ($1_ltype) array_data(array);
+}
+%typemap(argout)
+ (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
+{
+ $result = SWIG_Python_AppendOutput($result,array$argnum);
+}
+
+/*****************************/
+/* Argoutview Array Typemaps */
+/*****************************/
+
+/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1)
+ */
+%typemap(in,numinputs=0)
+ (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1 )
+ (DATA_TYPE* data_temp , DIM_TYPE dim_temp)
+{
+ $1 = &data_temp;
+ $2 = &dim_temp;
+}
+%typemap(argout,
+ fragment="NumPy_Backward_Compatibility")
+ (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1)
+{
+ npy_intp dims[1] = { *$2 };
+ PyObject * array = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$1));
+ if (!array) SWIG_fail;
+ $result = SWIG_Python_AppendOutput($result,array);
+}
+
+/* Typemap suite for (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1)
+ */
+%typemap(in,numinputs=0)
+ (DIM_TYPE* DIM1 , DATA_TYPE** ARGOUTVIEW_ARRAY1)
+ (DIM_TYPE dim_temp, DATA_TYPE* data_temp )
+{
+ $1 = &dim_temp;
+ $2 = &data_temp;
+}
+%typemap(argout,
+ fragment="NumPy_Backward_Compatibility")
+ (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1)
+{
+ npy_intp dims[1] = { *$1 };
+ PyObject * array = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$2));
+ if (!array) SWIG_fail;
+ $result = SWIG_Python_AppendOutput($result,array);
+}
+
+/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
+ */
+%typemap(in,numinputs=0)
+ (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 )
+ (DATA_TYPE* data_temp , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp)
+{
+ $1 = &data_temp;
+ $2 = &dim1_temp;
+ $3 = &dim2_temp;
+}
+%typemap(argout,
+ fragment="NumPy_Backward_Compatibility")
+ (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
+{
+ npy_intp dims[2] = { *$2, *$3 };
+ PyObject * array = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1));
+ if (!array) SWIG_fail;
+ $result = SWIG_Python_AppendOutput($result,array);
+}
+
+/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2)
+ */
+%typemap(in,numinputs=0)
+ (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DATA_TYPE** ARGOUTVIEW_ARRAY2)
+ (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DATA_TYPE* data_temp )
+{
+ $1 = &dim1_temp;
+ $2 = &dim2_temp;
+ $3 = &data_temp;
+}
+%typemap(argout,
+ fragment="NumPy_Backward_Compatibility")
+ (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2)
+{
+ npy_intp dims[2] = { *$1, *$2 };
+ PyObject * array = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3));
+ if (!array) SWIG_fail;
+ $result = SWIG_Python_AppendOutput($result,array);
+}
+
+/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
+ */
+%typemap(in,numinputs=0)
+ (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 )
+ (DATA_TYPE* data_temp , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp)
+{
+ $1 = &data_temp;
+ $2 = &dim1_temp;
+ $3 = &dim2_temp;
+}
+%typemap(argout,
+ fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
+ (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
+{
+ npy_intp dims[2] = { *$2, *$3 };
+ PyObject * obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1));
+ PyArrayObject * array = (PyArrayObject*) obj;
+ if (!array || !require_fortran(array)) SWIG_fail;
+ $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2)
+ */
+%typemap(in,numinputs=0)
+ (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DATA_TYPE** ARGOUTVIEW_FARRAY2)
+ (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DATA_TYPE* data_temp )
+{
+ $1 = &dim1_temp;
+ $2 = &dim2_temp;
+ $3 = &data_temp;
+}
+%typemap(argout,
+ fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
+ (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2)
+{
+ npy_intp dims[2] = { *$1, *$2 };
+ PyObject * obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3));
+ PyArrayObject * array = (PyArrayObject*) obj;
+ if (!array || !require_fortran(array)) SWIG_fail;
+ $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
+ DIM_TYPE* DIM3)
+ */
+%typemap(in,numinputs=0)
+ (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
+ (DATA_TYPE* data_temp, DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp)
+{
+ $1 = &data_temp;
+ $2 = &dim1_temp;
+ $3 = &dim2_temp;
+ $4 = &dim3_temp;
+}
+%typemap(argout,
+ fragment="NumPy_Backward_Compatibility")
+ (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
+{
+ npy_intp dims[3] = { *$2, *$3, *$4 };
+ PyObject * array = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1));
+ if (!array) SWIG_fail;
+ $result = SWIG_Python_AppendOutput($result,array);
+}
+
+/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3,
+ DATA_TYPE** ARGOUTVIEW_ARRAY3)
+ */
+%typemap(in,numinputs=0)
+ (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3)
+ (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp)
+{
+ $1 = &dim1_temp;
+ $2 = &dim2_temp;
+ $3 = &dim3_temp;
+ $4 = &data_temp;
+}
+%typemap(argout,
+ fragment="NumPy_Backward_Compatibility")
+ (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3)
+{
+ npy_intp dims[3] = { *$1, *$2, *$3 };
+ PyObject * array = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$3));
+ if (!array) SWIG_fail;
+ $result = SWIG_Python_AppendOutput($result,array);
+}
+
+/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
+ DIM_TYPE* DIM3)
+ */
+%typemap(in,numinputs=0)
+ (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
+ (DATA_TYPE* data_temp, DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp)
+{
+ $1 = &data_temp;
+ $2 = &dim1_temp;
+ $3 = &dim2_temp;
+ $4 = &dim3_temp;
+}
+%typemap(argout,
+ fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
+ (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
+{
+ npy_intp dims[3] = { *$2, *$3, *$4 };
+ PyObject * obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1));
+ PyArrayObject * array = (PyArrayObject*) obj;
+ if (!array || require_fortran(array)) SWIG_fail;
+ $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3,
+ DATA_TYPE** ARGOUTVIEW_FARRAY3)
+ */
+%typemap(in,numinputs=0)
+ (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_FARRAY3)
+ (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp)
+{
+ $1 = &dim1_temp;
+ $2 = &dim2_temp;
+ $3 = &dim3_temp;
+ $4 = &data_temp;
+}
+%typemap(argout,
+ fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
+ (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_FARRAY3)
+{
+ npy_intp dims[3] = { *$1, *$2, *$3 };
+ PyObject * obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$3));
+ PyArrayObject * array = (PyArrayObject*) obj;
+ if (!array || require_fortran(array)) SWIG_fail;
+ $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+%enddef /* %numpy_typemaps() macro */
+/* *************************************************************** */
+
+/* Concrete instances of the %numpy_typemaps() macro: Each invocation
+ * below applies all of the typemaps above to the specified data type.
+ */
+%numpy_typemaps(signed char , NPY_BYTE , int)
+%numpy_typemaps(unsigned char , NPY_UBYTE , int)
+%numpy_typemaps(short , NPY_SHORT , int)
+%numpy_typemaps(unsigned short , NPY_USHORT , int)
+%numpy_typemaps(int , NPY_INT , int)
+%numpy_typemaps(unsigned int , NPY_UINT , int)
+%numpy_typemaps(long , NPY_LONG , int)
+%numpy_typemaps(unsigned long , NPY_ULONG , int)
+%numpy_typemaps(long long , NPY_LONGLONG , int)
+%numpy_typemaps(unsigned long long, NPY_ULONGLONG, int)
+%numpy_typemaps(float , NPY_FLOAT , int)
+%numpy_typemaps(double , NPY_DOUBLE , int)
+
+/* ***************************************************************
+ * The follow macro expansion does not work, because C++ bool is 4
+ * bytes and NPY_BOOL is 1 byte
+ *
+ * %numpy_typemaps(bool, NPY_BOOL, int)
+ */
+
+/* ***************************************************************
+ * On my Mac, I get the following warning for this macro expansion:
+ * 'swig/python detected a memory leak of type 'long double *', no destructor found.'
+ *
+ * %numpy_typemaps(long double, NPY_LONGDOUBLE, int)
+ */
+
+/* ***************************************************************
+ * Swig complains about a syntax error for the following macro
+ * expansions:
+ *
+ * %numpy_typemaps(complex float, NPY_CFLOAT , int)
+ *
+ * %numpy_typemaps(complex double, NPY_CDOUBLE, int)
+ *
+ * %numpy_typemaps(complex long double, NPY_CLONGDOUBLE, int)
+ */
+
+#endif /* SWIGPYTHON */
endif(WIN32)
option(enable-double "Enable double precision in MathGL library" ON)
-option(enable-mpi "Enable mpi")
+option(enable-mpi "Enable mpi" ON)
option(enable-opengl "Enable OpenGL support" ON)
option(enable-all-docs "Enable all documentation building")
#option(enable-doc "Enable documentation building")
option(enable-all-widgets "Enable all Widgets")
option(enable-all-swig "Enable all SWIG based interfaces")
option(enable-rvalue "Enable move constructor support (need C++11)" OFF)
-option(enable-pthread "Enable POSIX threads support" OFF)
+option(enable-pthread "Enable POSIX threads support" ON)
if(MSVC)
option(enable-pthr-widget "Enable POSIX threads for widgets" OFF)
else(MSVC)
option(enable-pthr-widget "Enable POSIX threads for widgets" ON)
endif(MSVC)
-option(enable-openmp "Enable OpenMP support" ON)
+option(enable-openmp "Enable OpenMP support" OFF)
if(enable-pthread AND enable-openmp)
message(SEND_ERROR "You can't enable POSIX threads and OpenMP at the same time!")
option(enable-lgpl "Enable only LGPL part of MathGL")
option(enable-mgl2 "Use names 'libmgl2-*' instead of 'libmgl-*'")
-option(enable-ltdl "Enable loading modules support")
+option(enable-ltdl "Enable loading modules support" ON)
option(enable-doc-site "Enable HTML documentation for website")
#CMAKE_DEPENDENT_OPTION(enable-doc-site "Enable HTML documentation for website" OFF "NOT enable-all-docs" ON)
CMAKE_DEPENDENT_OPTION(enable-doc-html "Enable HTML documentation" OFF "NOT enable-all-docs" ON)
CMAKE_DEPENDENT_OPTION(enable-zlib "Enable zlib support" ON "NOT enable-all" ON)
CMAKE_DEPENDENT_OPTION(enable-png "Enable png support" ON "NOT enable-all" ON)
-CMAKE_DEPENDENT_OPTION(enable-jpeg "Enable jpeg support" OFF "NOT enable-all" ON)
-MGL_DEPENDENT_OPTION(enable-gsl "Enable gsl support" OFF "NOT enable-lgpl" ON "NOT enable-all" ON)
-MGL_DEPENDENT_OPTION(enable-hdf4 "Enable hdf4 support" OFF "NOT enable-lgpl" ON "NOT enable-all" ON)
-MGL_DEPENDENT_OPTION(enable-hdf5 "Enable hdf5 support" OFF "NOT enable-lgpl" ON "NOT enable-all" ON)
-CMAKE_DEPENDENT_OPTION(enable-pdf "Enable pdf support" OFF "NOT enable-all" ON)
-CMAKE_DEPENDENT_OPTION(enable-gif "Enable gif support" OFF "NOT enable-all" ON)
-CMAKE_DEPENDENT_OPTION(enable-glut "Enable glut support" OFF "NOT enable-all-widgets" ON)
-CMAKE_DEPENDENT_OPTION(enable-fltk "Enable fltk widget" OFF "NOT enable-all-widgets" ON)
-CMAKE_DEPENDENT_OPTION(enable-wx "Enable wxWidget widget" OFF "NOT enable-all-widgets" ON)
+CMAKE_DEPENDENT_OPTION(enable-jpeg "Enable jpeg support" ON "NOT enable-all" ON)
+MGL_DEPENDENT_OPTION(enable-gsl "Enable gsl support" ON "NOT enable-lgpl" ON "NOT enable-all" ON)
+MGL_DEPENDENT_OPTION(enable-hdf4 "Enable hdf4 support" ON "NOT enable-lgpl" ON "NOT enable-all" ON)
+MGL_DEPENDENT_OPTION(enable-hdf5 "Enable hdf5 support" ON "NOT enable-lgpl" ON "NOT enable-all" ON)
+CMAKE_DEPENDENT_OPTION(enable-pdf "Enable pdf support" ON "NOT enable-all" ON)
+CMAKE_DEPENDENT_OPTION(enable-gif "Enable gif support" ON "NOT enable-all" ON)
+CMAKE_DEPENDENT_OPTION(enable-glut "Enable glut support" ON "NOT enable-all-widgets" ON)
+CMAKE_DEPENDENT_OPTION(enable-fltk "Enable fltk widget" ON "NOT enable-all-widgets" ON)
+CMAKE_DEPENDENT_OPTION(enable-wx "Enable wxWidget widget" ON "NOT enable-all-widgets" ON)
CMAKE_DEPENDENT_OPTION(enable-qt4 "Enable Qt4 widget" OFF "NOT enable-all-widgets" ON)
CMAKE_DEPENDENT_OPTION(enable-qt4asqt "Set Qt4 as default libmgl-qt" OFF "enable-qt4" OFF)
-CMAKE_DEPENDENT_OPTION(enable-qt5 "Enable Qt5 widget" OFF "NOT enable-all-widgets" ON)
-CMAKE_DEPENDENT_OPTION(enable-qt5asqt "Set Qt5 as default libmgl-qt" OFF "enable-qt5" OFF)
+CMAKE_DEPENDENT_OPTION(enable-qt5 "Enable Qt5 widget" ON "NOT enable-all-widgets" ON)
+CMAKE_DEPENDENT_OPTION(enable-qt5asqt "Set Qt5 as default libmgl-qt" ON "enable-qt5" OFF)
# msvc fwprintf print char* for the specifier of "%s" format
if(MSVC AND MSVC_VERSION GREATER 1899)
# endif(NOT enable-opengl)
endif(enable-qt4 OR enable-qt5)
-CMAKE_DEPENDENT_OPTION(enable-json-sample "Enable JSON sample (WebKit variant is the default)." ON "QT_ENABLED" OFF)
-CMAKE_DEPENDENT_OPTION(enable-json-sample-we "Enable JSON sample (WebEngine variant)." OFF "enable-json-sample" OFF)
-MGL_DEPENDENT_OPTION(enable-python "Enable python interface" OFF "NOT enable-lgpl" ON "NOT enable-all-swig" ON)
+CMAKE_DEPENDENT_OPTION(enable-json-sample "Enable JSON sample (WebKit variant is the default)." ON "QT_ENABLED" ON)
+CMAKE_DEPENDENT_OPTION(enable-json-sample-we "Enable JSON sample (WebEngine variant)." ON "enable-json-sample" ON)
+MGL_DEPENDENT_OPTION(enable-python "Enable python interface" ON "NOT enable-lgpl" ON "NOT enable-all-swig" ON)
MGL_DEPENDENT_OPTION(enable-lua "Enable Lua (v.5.1) interface" OFF "NOT enable-lgpl" ON "NOT enable-all-swig" ON)
-MGL_DEPENDENT_OPTION(enable-octave "Enable octave interface" OFF "NOT enable-lgpl" ON "NOT enable-all-swig" ON)
+MGL_DEPENDENT_OPTION(enable-octave "Enable octave interface" ON "NOT enable-lgpl" ON "NOT enable-all-swig" ON)
MGL_DEPENDENT_OPTION(enable-octave-install "Octave interface will install for all users" ON "NOT enable-lgpl" ON "NOT enable-all-swig" ON)
include_directories( ${MathGL2_SOURCE_DIR}/include ${MathGL2_BINARY_DIR}/include)
languages, such as, C, Fortran, Pascal, Forth, Python, Octave.
.
This package contains the development files.
+
+Package: python-mathgl
+Architecture: any
+Section: python
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${python:Depends}, python,
+ python-numpy
+Description: library for scientific graphs (Python v.2 module)
+ A free cross-platform library of fast C++ routines for plotting data in up
+ to 3 dimensions. It can export plots to bitmaps and vector EPS, SVG, IDTF
+ files. There are simple window interfaces based on GLUT, FLTK and/or Qt.
+ MathGL can also be used in the console. There are interfaces to a set of
+ languages, such as, C, Fortran, Pascal, Forth, Python, Octave.
+ .
+ This package provides the Python v.2 module for mathgl.
Package: python3-mathgl
Architecture: any
# msvc fwprintf print char* for the specifier of "%s" format
if(MSVC AND MSVC_VERSION GREATER 1899)
-@@ -245,11 +245,12 @@
+@@ -245,11 +245,11 @@
# endif(NOT enable-opengl)
endif(enable-qt4 OR enable-qt5)
-MGL_DEPENDENT_OPTION(enable-python "Enable python interface" OFF "NOT enable-lgpl" ON "NOT enable-all-swig" ON)
+CMAKE_DEPENDENT_OPTION(enable-json-sample "Enable JSON sample (WebKit variant is the default)." ON "QT_ENABLED" ON)
+CMAKE_DEPENDENT_OPTION(enable-json-sample-we "Enable JSON sample (WebEngine variant)." ON "enable-json-sample" ON)
-+#MGL_DEPENDENT_OPTION(enable-python "Enable python interface" ON "NOT enable-lgpl" ON "NOT enable-all-swig" ON)
-+MGL_DEPENDENT_OPTION(enable-python3 "Enable python v.3 interface" ON "NOT enable-lgpl" ON "NOT enable-all-swig" ON)
++MGL_DEPENDENT_OPTION(enable-python "Enable python interface" ON "NOT enable-lgpl" ON "NOT enable-all-swig" ON)
MGL_DEPENDENT_OPTION(enable-lua "Enable Lua (v.5.1) interface" OFF "NOT enable-lgpl" ON "NOT enable-all-swig" ON)
-MGL_DEPENDENT_OPTION(enable-octave "Enable octave interface" OFF "NOT enable-lgpl" ON "NOT enable-all-swig" ON)
+MGL_DEPENDENT_OPTION(enable-octave "Enable octave interface" ON "NOT enable-lgpl" ON "NOT enable-all-swig" ON)
+++ /dev/null
---- a/lang/CMakeLists.txt
-+++ b/lang/CMakeLists.txt
-@@ -9,7 +9,7 @@
-
- set(mgl_clean_files "")
-
--SET_SOURCE_FILES_PROPERTIES(mathgl.i numpy.i PROPERTIES CPLUSPLUS ON)
-+SET_SOURCE_FILES_PROPERTIES(mathgl.i numpy.i numpy_python3.i mathgl_python3.i PROPERTIES CPLUSPLUS ON)
-
- FIND_PACKAGE(SWIG)
- if(NOT SWIG_FOUND)
-@@ -17,8 +17,8 @@
- endif(NOT SWIG_FOUND)
- INCLUDE(${SWIG_USE_FILE})
-
--if(enable-python)
-- set(Python_ADDITIONAL_VERSIONS 2.7)
-+if(enable-python3)
-+ set(Python_ADDITIONAL_VERSIONS 3.6)
- FIND_PACKAGE(PythonInterp)
- if(NOT PYTHONINTERP_FOUND)
- message(SEND_ERROR "Couldn't find python interpreter.")
-@@ -28,7 +28,7 @@
- message(SEND_ERROR "Couldn't find python development libraries.")
- endif(NOT PYTHONLIBS_FOUND)
- execute_process(
-- COMMAND ${PYTHON_EXECUTABLE} -c "import numpy; print numpy.get_include()"
-+ COMMAND ${PYTHON_EXECUTABLE} -c "import numpy; print (numpy.get_include())"
- OUTPUT_VARIABLE NUMPY_INCLUDE_PATH
- RESULT_VARIABLE NUMPY_ERR
- OUTPUT_STRIP_TRAILING_WHITESPACE
-@@ -39,14 +39,14 @@
-
- include_directories(${PYTHON_INCLUDE_DIR} ${NUMPY_INCLUDE_PATH})
- execute_process(
-- COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(prefix='${CMAKE_INSTALL_PREFIX}')"
-+ COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print (get_python_lib(prefix='${CMAKE_INSTALL_PREFIX}'))"
- OUTPUT_VARIABLE MGL_PYTHON_SITE_PACKAGES
- OUTPUT_STRIP_TRAILING_WHITESPACE)
-- set(SWIG_MODULE_mathgl_EXTRA_DEPS numpy.i ${src_imp_dep})
-+ set(SWIG_MODULE_mathgl_EXTRA_DEPS numpy_python3.i ${src_imp_dep})
- if(${CMAKE_VERSION} VERSION_LESS "3.8.0")
-- SWIG_ADD_MODULE(mathgl python mathgl.i)
-+ SWIG_ADD_MODULE(mathgl python mathgl_python3.i)
- else(${CMAKE_VERSION} VERSION_LESS "3.8.0")
-- SWIG_ADD_LIBRARY(mathgl LANGUAGE python SOURCES mathgl.i)
-+ SWIG_ADD_LIBRARY(mathgl LANGUAGE python SOURCES mathgl_python3.i)
- endif(${CMAKE_VERSION} VERSION_LESS "3.8.0")
- SWIG_LINK_LIBRARIES(mathgl mgl ${PYTHON_LIBRARIES})
- set_target_properties(_mathgl PROPERTIES BUILD_WITH_INSTALL_RPATH ON)
-@@ -58,10 +58,10 @@
- )
- add_custom_target(mgl_python_module ALL DEPENDS _mathgl mathgl.pyc)
-
-- install(FILES ${MathGL2_BINARY_DIR}/lang/mathgl.py ${MathGL2_BINARY_DIR}/lang/mathgl.pyc DESTINATION ${MGL_PYTHON_SITE_PACKAGES})
-+ install(FILES ${MathGL2_BINARY_DIR}/lang/mathgl.py ${MathGL2_BINARY_DIR}/lang/__pycache__/mathgl.cpython-36.pyc DESTINATION ${MGL_PYTHON_SITE_PACKAGES})
- install (TARGETS _mathgl LIBRARY DESTINATION ${MGL_PYTHON_SITE_PACKAGES})
- set(mgl_clean_files ${mgl_clean_files} mathgl.py)
--endif(enable-python)
-+endif(enable-python3)
-
- if(enable-lua)
- INCLUDE(FindLua51)
+++ /dev/null
---- /dev/null
-+++ b/lang/mathgl_python3.i
-@@ -0,0 +1,100 @@
-+/***************************************************************************
-+ * mgl.i is part of Math Graphic Library
-+ * Copyright (C) 2007 Alexey Balakin <balakin@appl.sci-nnov.ru>,
-+ * Xavier Delacour <xavier.delacour@gmail.com>,
-+ * Alexander Filov <alexander.filov@gmail.com> *
-+ * *
-+ * This program 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., *
-+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
-+ ***************************************************************************/
-+
-+
-+%module mathgl
-+#ifdef SWIGOCTAVE
-+%feature("autodoc", 1);
-+#endif // SWIGOCTAVE
-+
-+%ignore operator!;
-+%ignore operator=;
-+%ignore *::operator=;
-+%ignore *::operator+=;
-+%ignore *::operator-=;
-+%ignore *::operator*=;
-+%ignore *::operator/=;
-+//%ignore mglDataA
-+
-+%{
-+#define SWIG_FILE_WITH_INIT
-+#include "mgl2/type.h"
-+#include "mgl2/data.h"
-+#include "mgl2/mgl.h"
-+const double All = -1;
-+const double Pi = M_PI;
-+const double NaN = NAN;
-+const double Inf = INFINITY;
-+%}
-+
-+#if MGL_USE_DOUBLE
-+typedef double mreal;
-+#else
-+typedef float mreal;
-+#endif
-+
-+
-+#ifdef SWIGOCTAVE
-+%rename(__add) operator+;
-+%rename(__sub) operator-;
-+%rename(__mul) operator*;
-+%rename(__div) operator/;
-+%rename(__eq) operator==;
-+%rename(__ne) operator!=;
-+%typemap(in,noblock=1) (double* d, int rows, int cols) (Matrix tmp) {
-+ if (!$input.is_matrix_type()) { error("A must be a matrix"); SWIG_fail; }
-+ tmp=$input.matrix_value();
-+ $1=tmp.data();
-+ $2=tmp.rows();
-+ $3=tmp.columns();
-+}
-+#endif
-+
-+#ifdef SWIGPYTHON
-+%rename(__add__) *::operator+(const mglData&, const mglData&);
-+%rename(__sub__) *::operator-(const mglData&, const mglData &);
-+%rename(__mul__) *::operator*(const mglData &, float);
-+%rename(__div__) *::operator/(const mglData &, float);
-+
-+// Get the NumPy typemaps
-+%include "numpy_python3.i"
-+%init %{
-+import_array();
-+%}
-+%apply (double* IN_ARRAY1, int DIM1) {(const double* d, int size)};
-+%apply (int DIM1, double* IN_ARRAY1) {(int size, const double* d)};
-+%apply (double* IN_ARRAY2, int DIM1, int DIM2) {(const double* d, int rows, int cols)};
-+%apply (int DIM1, int DIM2, double* IN_ARRAY2) {(int rows, int cols, const double* d)};
-+%apply (double* IN_ARRAY3, int DIM1, int DIM2, int DIM3) {(const double* d, int rows, int cols, int slc)};
-+%apply (int DIM1, int DIM2, int DIM3, double* IN_ARRAY3) {(int rows, int cols, int slc, const double* d)};
-+#endif
-+
-+%include "type.i"
-+%include "data.i"
-+%include "mgl.i"
-+%extend mglData
-+{
-+ mreal __getitem__( int i) { return self->GetVal(i); };
-+ mreal __paren( int i) { return self->GetVal(i); };
-+ void __setitem__( int i, mreal y) { self->SetVal(y,i); };
-+ void __paren_asgn( int i, mreal y) { self->SetVal(y,i); };
-+};
+++ /dev/null
---- /dev/null
-+++ b/lang/numpy_python3.i
-@@ -0,0 +1,1634 @@
-+/* -*- C -*- (not really, but good for syntax highlighting) */
-+#ifdef SWIGPYTHON
-+
-+%{
-+#ifndef SWIG_FILE_WITH_INIT
-+# define NO_IMPORT_ARRAY
-+#endif
-+#include "stdio.h"
-+#include <numpy/arrayobject.h>
-+%}
-+
-+/**********************************************************************/
-+
-+%fragment("NumPy_Backward_Compatibility", "header")
-+{
-+/* Support older NumPy data type names
-+*/
-+%#if NDARRAY_VERSION < 0x01000000
-+%#define NPY_BOOL PyArray_BOOL
-+%#define NPY_BYTE PyArray_BYTE
-+%#define NPY_UBYTE PyArray_UBYTE
-+%#define NPY_SHORT PyArray_SHORT
-+%#define NPY_USHORT PyArray_USHORT
-+%#define NPY_INT PyArray_INT
-+%#define NPY_UINT PyArray_UINT
-+%#define NPY_LONG PyArray_LONG
-+%#define NPY_ULONG PyArray_ULONG
-+%#define NPY_LONGLONG PyArray_LONGLONG
-+%#define NPY_ULONGLONG PyArray_ULONGLONG
-+%#define NPY_FLOAT PyArray_FLOAT
-+%#define NPY_DOUBLE PyArray_DOUBLE
-+%#define NPY_LONGDOUBLE PyArray_LONGDOUBLE
-+%#define NPY_CFLOAT PyArray_CFLOAT
-+%#define NPY_CDOUBLE PyArray_CDOUBLE
-+%#define NPY_CLONGDOUBLE PyArray_CLONGDOUBLE
-+%#define NPY_OBJECT PyArray_OBJECT
-+%#define NPY_STRING PyArray_STRING
-+%#define NPY_UNICODE PyArray_UNICODE
-+%#define NPY_VOID PyArray_VOID
-+%#define NPY_NTYPES PyArray_NTYPES
-+%#define NPY_NOTYPE PyArray_NOTYPE
-+%#define NPY_CHAR PyArray_CHAR
-+%#define NPY_USERDEF PyArray_USERDEF
-+%#define npy_intp intp
-+
-+%#define NPY_MAX_BYTE MAX_BYTE
-+%#define NPY_MIN_BYTE MIN_BYTE
-+%#define NPY_MAX_UBYTE MAX_UBYTE
-+%#define NPY_MAX_SHORT MAX_SHORT
-+%#define NPY_MIN_SHORT MIN_SHORT
-+%#define NPY_MAX_USHORT MAX_USHORT
-+%#define NPY_MAX_INT MAX_INT
-+%#define NPY_MIN_INT MIN_INT
-+%#define NPY_MAX_UINT MAX_UINT
-+%#define NPY_MAX_LONG MAX_LONG
-+%#define NPY_MIN_LONG MIN_LONG
-+%#define NPY_MAX_ULONG MAX_ULONG
-+%#define NPY_MAX_LONGLONG MAX_LONGLONG
-+%#define NPY_MIN_LONGLONG MIN_LONGLONG
-+%#define NPY_MAX_ULONGLONG MAX_ULONGLONG
-+%#define NPY_MAX_INTP MAX_INTP
-+%#define NPY_MIN_INTP MIN_INTP
-+
-+%#define NPY_FARRAY FARRAY
-+%#define NPY_F_CONTIGUOUS F_CONTIGUOUS
-+%#endif
-+}
-+
-+/**********************************************************************/
-+
-+/* The following code originally appeared in
-+ * enthought/kiva/agg/src/numeric.i written by Eric Jones. It was
-+ * translated from C++ to C by John Hunter. Bill Spotz has modified
-+ * it to fix some minor bugs, upgrade from Numeric to numpy (all
-+ * versions), add some comments and functionality, and convert from
-+ * direct code insertion to SWIG fragments.
-+ */
-+
-+%fragment("NumPy_Macros", "header")
-+{
-+/* Macros to extract array attributes.
-+ */
-+%#define is_array(a) ((a) && PyArray_Check((PyArrayObject *)a))
-+%#define array_type(a) (int)(PyArray_TYPE(a))
-+%#define array_numdims(a) (((PyArrayObject *)a)->nd)
-+%#define array_dimensions(a) (((PyArrayObject *)a)->dimensions)
-+%#define array_size(a,i) (((PyArrayObject *)a)->dimensions[i])
-+%#define array_data(a) (((PyArrayObject *)a)->data)
-+%#define array_is_contiguous(a) (PyArray_ISCONTIGUOUS(a))
-+%#define array_is_native(a) (PyArray_ISNOTSWAPPED(a))
-+%#define array_is_fortran(a) (PyArray_ISFORTRAN(a))
-+}
-+
-+/**********************************************************************/
-+
-+%fragment("NumPy_Utilities", "header")
-+{
-+ /* Given a PyObject, return a string describing its type.
-+ */
-+ char* pytype_string(PyObject* py_obj) {
-+ if (py_obj == NULL ) return "C NULL value";
-+ if (py_obj == Py_None ) return "Python None" ;
-+ if (PyCallable_Check(py_obj)) return "callable" ;
-+ if (PyString_Check( py_obj)) return "string" ;
-+ if (PyInt_Check( py_obj)) return "int" ;
-+ if (PyFloat_Check( py_obj)) return "float" ;
-+ if (PyDict_Check( py_obj)) return "dict" ;
-+ if (PyList_Check( py_obj)) return "list" ;
-+ if (PyTuple_Check( py_obj)) return "tuple" ;
-+ if (PyTuple_Check( py_obj)) return "file" ;
-+ if (PyModule_Check( py_obj)) return "module" ;
-+ if (PySequence_Check(py_obj)) return "instance" ;
-+
-+ return "unknow type";
-+ }
-+
-+ /* Given a NumPy typecode, return a string describing the type.
-+ */
-+ char* typecode_string(int typecode) {
-+ static char* type_names[25] = {"bool", "byte", "unsigned byte",
-+ "short", "unsigned short", "int",
-+ "unsigned int", "long", "unsigned long",
-+ "long long", "unsigned long long",
-+ "float", "double", "long double",
-+ "complex float", "complex double",
-+ "complex long double", "object",
-+ "string", "unicode", "void", "ntypes",
-+ "notype", "char", "unknown"};
-+ return typecode < 24 ? type_names[typecode] : type_names[24];
-+ }
-+
-+ /* Make sure input has correct numpy type. Allow character and byte
-+ * to match. Also allow int and long to match. This is deprecated.
-+ * You should use PyArray_EquivTypenums() instead.
-+ */
-+ int type_match(int actual_type, int desired_type) {
-+ return PyArray_EquivTypenums(actual_type, desired_type);
-+ }
-+}
-+
-+/**********************************************************************/
-+
-+%fragment("NumPy_Object_to_Array", "header",
-+ fragment="NumPy_Backward_Compatibility",
-+ fragment="NumPy_Macros",
-+ fragment="NumPy_Utilities")
-+{
-+ /* Given a PyObject pointer, cast it to a PyArrayObject pointer if
-+ * legal. If not, set the python error string appropriately and
-+ * return NULL.
-+ */
-+ PyArrayObject* obj_to_array_no_conversion(PyObject* input, int typecode)
-+ {
-+ PyArrayObject* ary = NULL;
-+ if (is_array(input) && (typecode == NPY_NOTYPE ||
-+ PyArray_EquivTypenums(array_type(input), typecode)))
-+ {
-+ ary = (PyArrayObject*) input;
-+ }
-+ else if is_array(input)
-+ {
-+ char* desired_type = typecode_string(typecode);
-+ char* actual_type = typecode_string(array_type(input));
-+ PyErr_Format(PyExc_TypeError,
-+ "Array of type '%s' required. Array of type '%s' given",
-+ desired_type, actual_type);
-+ ary = NULL;
-+ }
-+ else
-+ {
-+ char * desired_type = typecode_string(typecode);
-+ char * actual_type = pytype_string(input);
-+ PyErr_Format(PyExc_TypeError,
-+ "Array of type '%s' required. A '%s' was given",
-+ desired_type, actual_type);
-+ ary = NULL;
-+ }
-+ return ary;
-+ }
-+
-+ /* Convert the given PyObject to a NumPy array with the given
-+ * typecode. On success, return a valid PyArrayObject* with the
-+ * correct type. On failure, the python error string will be set and
-+ * the routine returns NULL.
-+ */
-+ PyArrayObject* obj_to_array_allow_conversion(PyObject* input, int typecode,
-+ int* is_new_object)
-+ {
-+ PyArrayObject* ary = NULL;
-+ PyObject* py_obj;
-+ if (is_array(input) && (typecode == NPY_NOTYPE ||
-+ PyArray_EquivTypenums(array_type(input),typecode)))
-+ {
-+ ary = (PyArrayObject*) input;
-+ *is_new_object = 0;
-+ }
-+ else
-+ {
-+ py_obj = PyArray_FROMANY(input, typecode, 0, 0, NPY_DEFAULT);
-+ /* If NULL, PyArray_FromObject will have set python error value.*/
-+ ary = (PyArrayObject*) py_obj;
-+ *is_new_object = 1;
-+ }
-+ return ary;
-+ }
-+
-+ /* Given a PyArrayObject, check to see if it is contiguous. If so,
-+ * return the input pointer and flag it as not a new object. If it is
-+ * not contiguous, create a new PyArrayObject using the original data,
-+ * flag it as a new object and return the pointer.
-+ */
-+ PyArrayObject* make_contiguous(PyArrayObject* ary, int* is_new_object,
-+ int min_dims, int max_dims)
-+ {
-+ PyArrayObject* result;
-+ if (array_is_contiguous(ary))
-+ {
-+ result = ary;
-+ *is_new_object = 0;
-+ }
-+ else
-+ {
-+ result = (PyArrayObject*) PyArray_ContiguousFromObject((PyObject*)ary,
-+ array_type(ary),
-+ min_dims,
-+ max_dims);
-+ *is_new_object = 1;
-+ }
-+ return result;
-+ }
-+
-+ /* Given a PyArrayObject, check to see if it is Fortran-contiguous.
-+ * If so, return the input pointer, but do not flag it as not a new
-+ * object. If it is not Fortran-contiguous, create a new
-+ * PyArrayObject using the original data, flag it as a new object
-+ * and return the pointer.
-+ */
-+ PyArrayObject* make_fortran(PyArrayObject* ary, int* is_new_object,
-+ int min_dims, int max_dims)
-+ {
-+ PyArrayObject* result;
-+ if (array_is_fortran(ary))
-+ {
-+ result = ary;
-+ *is_new_object = 0;
-+ }
-+ else
-+ {
-+ Py_INCREF(ary->descr);
-+ result = (PyArrayObject*) PyArray_FromArray(ary, ary->descr, NPY_FORTRAN);
-+ *is_new_object = 1;
-+ }
-+ return result;
-+ }
-+
-+ /* Convert a given PyObject to a contiguous PyArrayObject of the
-+ * specified type. If the input object is not a contiguous
-+ * PyArrayObject, a new one will be created and the new object flag
-+ * will be set.
-+ */
-+ PyArrayObject* obj_to_array_contiguous_allow_conversion(PyObject* input,
-+ int typecode,
-+ int* is_new_object)
-+ {
-+ int is_new1 = 0;
-+ int is_new2 = 0;
-+ PyArrayObject* ary2;
-+ PyArrayObject* ary1 = obj_to_array_allow_conversion(input, typecode,
-+ &is_new1);
-+ if (ary1)
-+ {
-+ ary2 = make_contiguous(ary1, &is_new2, 0, 0);
-+ if ( is_new1 && is_new2)
-+ {
-+ Py_DECREF(ary1);
-+ }
-+ ary1 = ary2;
-+ }
-+ *is_new_object = is_new1 || is_new2;
-+ return ary1;
-+ }
-+
-+ /* Convert a given PyObject to a Fortran-ordered PyArrayObject of the
-+ * specified type. If the input object is not a Fortran-ordered
-+ * PyArrayObject, a new one will be created and the new object flag
-+ * will be set.
-+ */
-+ PyArrayObject* obj_to_array_fortran_allow_conversion(PyObject* input,
-+ int typecode,
-+ int* is_new_object)
-+ {
-+ int is_new1 = 0;
-+ int is_new2 = 0;
-+ PyArrayObject* ary2;
-+ PyArrayObject* ary1 = obj_to_array_allow_conversion(input, typecode,
-+ &is_new1);
-+ if (ary1)
-+ {
-+ ary2 = make_fortran(ary1, &is_new2, 0, 0);
-+ if (is_new1 && is_new2)
-+ {
-+ Py_DECREF(ary1);
-+ }
-+ ary1 = ary2;
-+ }
-+ *is_new_object = is_new1 || is_new2;
-+ return ary1;
-+ }
-+
-+} /* end fragment */
-+
-+
-+/**********************************************************************/
-+
-+%fragment("NumPy_Array_Requirements", "header",
-+ fragment="NumPy_Backward_Compatibility",
-+ fragment="NumPy_Macros")
-+{
-+ /* Test whether a python object is contiguous. If array is
-+ * contiguous, return 1. Otherwise, set the python error string and
-+ * return 0.
-+ */
-+ int require_contiguous(PyArrayObject* ary)
-+ {
-+ int contiguous = 1;
-+ if (!array_is_contiguous(ary))
-+ {
-+ PyErr_SetString(PyExc_TypeError,
-+ "Array must be contiguous. A non-contiguous array was given");
-+ contiguous = 0;
-+ }
-+ return contiguous;
-+ }
-+
-+ /* Require that a numpy array is not byte-swapped. If the array is
-+ * not byte-swapped, return 1. Otherwise, set the python error string
-+ * and return 0.
-+ */
-+ int require_native(PyArrayObject* ary)
-+ {
-+ int native = 1;
-+ if (!array_is_native(ary))
-+ {
-+ PyErr_SetString(PyExc_TypeError,
-+ "Array must have native byteorder. "
-+ "A byte-swapped array was given");
-+ native = 0;
-+ }
-+ return native;
-+ }
-+
-+ /* Require the given PyArrayObject to have a specified number of
-+ * dimensions. If the array has the specified number of dimensions,
-+ * return 1. Otherwise, set the python error string and return 0.
-+ */
-+ int require_dimensions(PyArrayObject* ary, int exact_dimensions)
-+ {
-+ int success = 1;
-+ if (array_numdims(ary) != exact_dimensions)
-+ {
-+ PyErr_Format(PyExc_TypeError,
-+ "Array must have %d dimensions. Given array has %d dimensions",
-+ exact_dimensions, array_numdims(ary));
-+ success = 0;
-+ }
-+ return success;
-+ }
-+
-+ /* Require the given PyArrayObject to have one of a list of specified
-+ * number of dimensions. If the array has one of the specified number
-+ * of dimensions, return 1. Otherwise, set the python error string
-+ * and return 0.
-+ */
-+ int require_dimensions_n(PyArrayObject* ary, int* exact_dimensions, int n)
-+ {
-+ int success = 0;
-+ int i;
-+ char dims_str[255] = "";
-+ char s[255];
-+ for (i = 0; i < n && !success; i++)
-+ {
-+ if (array_numdims(ary) == exact_dimensions[i])
-+ {
-+ success = 1;
-+ }
-+ }
-+ if (!success)
-+ {
-+ for (i = 0; i < n-1; i++)
-+ {
-+ sprintf(s, "%d, ", exact_dimensions[i]);
-+ strcat(dims_str,s);
-+ }
-+ sprintf(s, " or %d", exact_dimensions[n-1]);
-+ strcat(dims_str,s);
-+ PyErr_Format(PyExc_TypeError,
-+ "Array must have %s dimensions. Given array has %d dimensions",
-+ dims_str, array_numdims(ary));
-+ }
-+ return success;
-+ }
-+
-+ /* Require the given PyArrayObject to have a specified shape. If the
-+ * array has the specified shape, return 1. Otherwise, set the python
-+ * error string and return 0.
-+ */
-+ int require_size(PyArrayObject* ary, npy_intp* size, int n)
-+ {
-+ int i;
-+ int success = 1;
-+ int len;
-+ char desired_dims[255] = "[";
-+ char s[255];
-+ char actual_dims[255] = "[";
-+ for(i=0; i < n;i++)
-+ {
-+ if (size[i] != -1 && size[i] != array_size(ary,i))
-+ {
-+ success = 0;
-+ }
-+ }
-+ if (!success)
-+ {
-+ for (i = 0; i < n; i++)
-+ {
-+ if (size[i] == -1)
-+ {
-+ sprintf(s, "*,");
-+ }
-+ else
-+ {
-+ sprintf(s, "%ld,", (long int)size[i]);
-+ }
-+ strcat(desired_dims,s);
-+ }
-+ len = strlen(desired_dims);
-+ desired_dims[len-1] = ']';
-+ for (i = 0; i < n; i++)
-+ {
-+ sprintf(s, "%ld,", (long int)array_size(ary,i));
-+ strcat(actual_dims,s);
-+ }
-+ len = strlen(actual_dims);
-+ actual_dims[len-1] = ']';
-+ PyErr_Format(PyExc_TypeError,
-+ "Array must have shape of %s. Given array has shape of %s",
-+ desired_dims, actual_dims);
-+ }
-+ return success;
-+ }
-+
-+ /* Require the given PyArrayObject to to be FORTRAN ordered. If the
-+ * the PyArrayObject is already FORTRAN ordered, do nothing. Else,
-+ * set the FORTRAN ordering flag and recompute the strides.
-+ */
-+ int require_fortran(PyArrayObject* ary)
-+ {
-+ int success = 1;
-+ int nd = array_numdims(ary);
-+ int i;
-+ if (array_is_fortran(ary)) return success;
-+ /* Set the FORTRAN ordered flag */
-+ ary->flags = NPY_FARRAY;
-+ /* Recompute the strides */
-+ ary->strides[0] = ary->strides[nd-1];
-+ for (i=1; i < nd; ++i)
-+ ary->strides[i] = ary->strides[i-1] * array_size(ary,i-1);
-+ return success;
-+ }
-+}
-+
-+/* Combine all NumPy fragments into one for convenience */
-+%fragment("NumPy_Fragments", "header",
-+ fragment="NumPy_Backward_Compatibility",
-+ fragment="NumPy_Macros",
-+ fragment="NumPy_Utilities",
-+ fragment="NumPy_Object_to_Array",
-+ fragment="NumPy_Array_Requirements") { }
-+
-+/* End John Hunter translation (with modifications by Bill Spotz)
-+ */
-+
-+/* %numpy_typemaps() macro
-+ *
-+ * This macro defines a family of 41 typemaps that allow C arguments
-+ * of the form
-+ *
-+ * (DATA_TYPE IN_ARRAY1[ANY])
-+ * (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
-+ * (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
-+ *
-+ * (DATA_TYPE IN_ARRAY2[ANY][ANY])
-+ * (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
-+ * (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
-+ * (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
-+ * (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
-+ *
-+ * (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
-+ * (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
-+ * (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
-+ * (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
-+ * (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
-+ *
-+ * (DATA_TYPE INPLACE_ARRAY1[ANY])
-+ * (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
-+ * (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
-+ *
-+ * (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
-+ * (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
-+ * (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
-+ * (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
-+ * (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
-+ *
-+ * (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
-+ * (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
-+ * (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3)
-+ * (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
-+ * (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3)
-+ *
-+ * (DATA_TYPE ARGOUT_ARRAY1[ANY])
-+ * (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
-+ * (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
-+ *
-+ * (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
-+ *
-+ * (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
-+ *
-+ * (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1)
-+ * (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1)
-+ *
-+ * (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
-+ * (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2)
-+ * (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
-+ * (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2)
-+ *
-+ * (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
-+ * (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3)
-+ * (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
-+ * (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_FARRAY3)
-+ *
-+ * where "DATA_TYPE" is any type supported by the NumPy module, and
-+ * "DIM_TYPE" is any int-like type suitable for specifying dimensions.
-+ * The difference between "ARRAY" typemaps and "FARRAY" typemaps is
-+ * that the "FARRAY" typemaps expect FORTRAN ordering of
-+ * multidimensional arrays. In python, the dimensions will not need
-+ * to be specified (except for the "DATA_TYPE* ARGOUT_ARRAY1"
-+ * typemaps). The IN_ARRAYs can be a numpy array or any sequence that
-+ * can be converted to a numpy array of the specified type. The
-+ * INPLACE_ARRAYs must be numpy arrays of the appropriate type. The
-+ * ARGOUT_ARRAYs will be returned as new numpy arrays of the
-+ * appropriate type.
-+ *
-+ * These typemaps can be applied to existing functions using the
-+ * %apply directive. For example:
-+ *
-+ * %apply (double* IN_ARRAY1, int DIM1) {(double* series, int length)};
-+ * double prod(double* series, int length);
-+ *
-+ * %apply (int DIM1, int DIM2, double* INPLACE_ARRAY2)
-+ * {(int rows, int cols, double* matrix )};
-+ * void floor(int rows, int cols, double* matrix, double f);
-+ *
-+ * %apply (double IN_ARRAY3[ANY][ANY][ANY])
-+ * {(double tensor[2][2][2] )};
-+ * %apply (double ARGOUT_ARRAY3[ANY][ANY][ANY])
-+ * {(double low[2][2][2] )};
-+ * %apply (double ARGOUT_ARRAY3[ANY][ANY][ANY])
-+ * {(double upp[2][2][2] )};
-+ * void luSplit(double tensor[2][2][2],
-+ * double low[2][2][2],
-+ * double upp[2][2][2] );
-+ *
-+ * or directly with
-+ *
-+ * double prod(double* IN_ARRAY1, int DIM1);
-+ *
-+ * void floor(int DIM1, int DIM2, double* INPLACE_ARRAY2, double f);
-+ *
-+ * void luSplit(double IN_ARRAY3[ANY][ANY][ANY],
-+ * double ARGOUT_ARRAY3[ANY][ANY][ANY],
-+ * double ARGOUT_ARRAY3[ANY][ANY][ANY]);
-+ */
-+
-+%define %numpy_typemaps(DATA_TYPE, DATA_TYPECODE, DIM_TYPE)
-+
-+/************************/
-+/* Input Array Typemaps */
-+/************************/
-+
-+/* Typemap suite for (DATA_TYPE IN_ARRAY1[ANY])
-+ */
-+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
-+ fragment="NumPy_Macros")
-+ (DATA_TYPE IN_ARRAY1[ANY])
-+{
-+ $1 = is_array($input) || PySequence_Check($input);
-+}
-+%typemap(in,
-+ fragment="NumPy_Fragments")
-+ (DATA_TYPE IN_ARRAY1[ANY])
-+ (PyArrayObject* array=NULL, int is_new_object=0)
-+{
-+ npy_intp size[1] = { $1_dim0 };
-+ array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
-+ &is_new_object);
-+ if (!array || !require_dimensions(array, 1) ||
-+ !require_size(array, size, 1)) SWIG_fail;
-+ $1 = ($1_ltype) array_data(array);
-+}
-+%typemap(freearg)
-+ (DATA_TYPE IN_ARRAY1[ANY])
-+{
-+ if (is_new_object$argnum && array$argnum)
-+ { Py_DECREF(array$argnum); }
-+}
-+
-+/* Typemap suite for (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
-+ */
-+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
-+ fragment="NumPy_Macros")
-+ (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
-+{
-+ $1 = is_array($input) || PySequence_Check($input);
-+}
-+%typemap(in,
-+ fragment="NumPy_Fragments")
-+ (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
-+ (PyArrayObject* array=NULL, int is_new_object=0)
-+{
-+ npy_intp size[1] = { -1 };
-+ array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
-+ &is_new_object);
-+ if (!array || !require_dimensions(array, 1) ||
-+ !require_size(array, size, 1)) SWIG_fail;
-+ $1 = (DATA_TYPE*) array_data(array);
-+ $2 = (DIM_TYPE) array_size(array,0);
-+}
-+%typemap(freearg)
-+ (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
-+{
-+ if (is_new_object$argnum && array$argnum)
-+ { Py_DECREF(array$argnum); }
-+}
-+
-+/* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
-+ */
-+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
-+ fragment="NumPy_Macros")
-+ (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
-+{
-+ $1 = is_array($input) || PySequence_Check($input);
-+}
-+%typemap(in,
-+ fragment="NumPy_Fragments")
-+ (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
-+ (PyArrayObject* array=NULL, int is_new_object=0)
-+{
-+ npy_intp size[1] = {-1};
-+ array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
-+ &is_new_object);
-+ if (!array || !require_dimensions(array, 1) ||
-+ !require_size(array, size, 1)) SWIG_fail;
-+ $1 = (DIM_TYPE) array_size(array,0);
-+ $2 = (DATA_TYPE*) array_data(array);
-+}
-+%typemap(freearg)
-+ (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
-+{
-+ if (is_new_object$argnum && array$argnum)
-+ { Py_DECREF(array$argnum); }
-+}
-+
-+/* Typemap suite for (DATA_TYPE IN_ARRAY2[ANY][ANY])
-+ */
-+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
-+ fragment="NumPy_Macros")
-+ (DATA_TYPE IN_ARRAY2[ANY][ANY])
-+{
-+ $1 = is_array($input) || PySequence_Check($input);
-+}
-+%typemap(in,
-+ fragment="NumPy_Fragments")
-+ (DATA_TYPE IN_ARRAY2[ANY][ANY])
-+ (PyArrayObject* array=NULL, int is_new_object=0)
-+{
-+ npy_intp size[2] = { $1_dim0, $1_dim1 };
-+ array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
-+ &is_new_object);
-+ if (!array || !require_dimensions(array, 2) ||
-+ !require_size(array, size, 2)) SWIG_fail;
-+ $1 = ($1_ltype) array_data(array);
-+}
-+%typemap(freearg)
-+ (DATA_TYPE IN_ARRAY2[ANY][ANY])
-+{
-+ if (is_new_object$argnum && array$argnum)
-+ { Py_DECREF(array$argnum); }
-+}
-+
-+/* Typemap suite for (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
-+ */
-+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
-+ fragment="NumPy_Macros")
-+ (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
-+{
-+ $1 = is_array($input) || PySequence_Check($input);
-+}
-+%typemap(in,
-+ fragment="NumPy_Fragments")
-+ (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
-+ (PyArrayObject* array=NULL, int is_new_object=0)
-+{
-+ npy_intp size[2] = { -1, -1 };
-+ array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
-+ &is_new_object);
-+ if (!array || !require_dimensions(array, 2) ||
-+ !require_size(array, size, 2)) SWIG_fail;
-+ $1 = (DATA_TYPE*) array_data(array);
-+ $2 = (DIM_TYPE) array_size(array,0);
-+ $3 = (DIM_TYPE) array_size(array,1);
-+}
-+%typemap(freearg)
-+ (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
-+{
-+ if (is_new_object$argnum && array$argnum)
-+ { Py_DECREF(array$argnum); }
-+}
-+
-+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
-+ */
-+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
-+ fragment="NumPy_Macros")
-+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
-+{
-+ $1 = is_array($input) || PySequence_Check($input);
-+}
-+%typemap(in,
-+ fragment="NumPy_Fragments")
-+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
-+ (PyArrayObject* array=NULL, int is_new_object=0)
-+{
-+ npy_intp size[2] = { -1, -1 };
-+ array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
-+ &is_new_object);
-+ if (!array || !require_dimensions(array, 2) ||
-+ !require_size(array, size, 2)) SWIG_fail;
-+ $1 = (DIM_TYPE) array_size(array,0);
-+ $2 = (DIM_TYPE) array_size(array,1);
-+ $3 = (DATA_TYPE*) array_data(array);
-+}
-+%typemap(freearg)
-+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
-+{
-+ if (is_new_object$argnum && array$argnum)
-+ { Py_DECREF(array$argnum); }
-+}
-+
-+/* Typemap suite for (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
-+ */
-+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
-+ fragment="NumPy_Macros")
-+ (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
-+{
-+ $1 = is_array($input) || PySequence_Check($input);
-+}
-+%typemap(in,
-+ fragment="NumPy_Fragments")
-+ (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
-+ (PyArrayObject* array=NULL, int is_new_object=0)
-+{
-+ npy_intp size[2] = { -1, -1 };
-+ array = obj_to_array_fortran_allow_conversion($input, DATA_TYPECODE,
-+ &is_new_object);
-+ if (!array || !require_dimensions(array, 2) ||
-+ !require_size(array, size, 2) || !require_fortran(array)) SWIG_fail;
-+ $1 = (DATA_TYPE*) array_data(array);
-+ $2 = (DIM_TYPE) array_size(array,0);
-+ $3 = (DIM_TYPE) array_size(array,1);
-+}
-+%typemap(freearg)
-+ (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
-+{
-+ if (is_new_object$argnum && array$argnum)
-+ { Py_DECREF(array$argnum); }
-+}
-+
-+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
-+ */
-+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
-+ fragment="NumPy_Macros")
-+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
-+{
-+ $1 = is_array($input) || PySequence_Check($input);
-+}
-+%typemap(in,
-+ fragment="NumPy_Fragments")
-+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
-+ (PyArrayObject* array=NULL, int is_new_object=0)
-+{
-+ npy_intp size[2] = { -1, -1 };
-+ array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
-+ &is_new_object);
-+ if (!array || !require_dimensions(array, 2) ||
-+ !require_size(array, size, 2) || !require_fortran(array)) SWIG_fail;
-+ $1 = (DIM_TYPE) array_size(array,0);
-+ $2 = (DIM_TYPE) array_size(array,1);
-+ $3 = (DATA_TYPE*) array_data(array);
-+}
-+%typemap(freearg)
-+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
-+{
-+ if (is_new_object$argnum && array$argnum)
-+ { Py_DECREF(array$argnum); }
-+}
-+
-+/* Typemap suite for (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
-+ */
-+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
-+ fragment="NumPy_Macros")
-+ (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
-+{
-+ $1 = is_array($input) || PySequence_Check($input);
-+}
-+%typemap(in,
-+ fragment="NumPy_Fragments")
-+ (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
-+ (PyArrayObject* array=NULL, int is_new_object=0)
-+{
-+ npy_intp size[3] = { $1_dim0, $1_dim1, $1_dim2 };
-+ array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
-+ &is_new_object);
-+ if (!array || !require_dimensions(array, 3) ||
-+ !require_size(array, size, 3)) SWIG_fail;
-+ $1 = ($1_ltype) array_data(array);
-+}
-+%typemap(freearg)
-+ (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
-+{
-+ if (is_new_object$argnum && array$argnum)
-+ { Py_DECREF(array$argnum); }
-+}
-+
-+/* Typemap suite for (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
-+ * DIM_TYPE DIM3)
-+ */
-+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
-+ fragment="NumPy_Macros")
-+ (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
-+{
-+ $1 = is_array($input) || PySequence_Check($input);
-+}
-+%typemap(in,
-+ fragment="NumPy_Fragments")
-+ (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
-+ (PyArrayObject* array=NULL, int is_new_object=0)
-+{
-+ npy_intp size[3] = { -1, -1, -1 };
-+ array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
-+ &is_new_object);
-+ if (!array || !require_dimensions(array, 3) ||
-+ !require_size(array, size, 3)) SWIG_fail;
-+ $1 = (DATA_TYPE*) array_data(array);
-+ $2 = (DIM_TYPE) array_size(array,0);
-+ $3 = (DIM_TYPE) array_size(array,1);
-+ $4 = (DIM_TYPE) array_size(array,2);
-+}
-+%typemap(freearg)
-+ (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
-+{
-+ if (is_new_object$argnum && array$argnum)
-+ { Py_DECREF(array$argnum); }
-+}
-+
-+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
-+ * DATA_TYPE* IN_ARRAY3)
-+ */
-+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
-+ fragment="NumPy_Macros")
-+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
-+{
-+ $1 = is_array($input) || PySequence_Check($input);
-+}
-+%typemap(in,
-+ fragment="NumPy_Fragments")
-+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
-+ (PyArrayObject* array=NULL, int is_new_object=0)
-+{
-+ npy_intp size[3] = { -1, -1, -1 };
-+ array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
-+ &is_new_object);
-+ if (!array || !require_dimensions(array, 3) ||
-+ !require_size(array, size, 3)) SWIG_fail;
-+ $1 = (DIM_TYPE) array_size(array,0);
-+ $2 = (DIM_TYPE) array_size(array,1);
-+ $3 = (DIM_TYPE) array_size(array,2);
-+ $4 = (DATA_TYPE*) array_data(array);
-+}
-+%typemap(freearg)
-+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
-+{
-+ if (is_new_object$argnum && array$argnum)
-+ { Py_DECREF(array$argnum); }
-+}
-+
-+/* Typemap suite for (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
-+ * DIM_TYPE DIM3)
-+ */
-+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
-+ fragment="NumPy_Macros")
-+ (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
-+{
-+ $1 = is_array($input) || PySequence_Check($input);
-+}
-+%typemap(in,
-+ fragment="NumPy_Fragments")
-+ (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
-+ (PyArrayObject* array=NULL, int is_new_object=0)
-+{
-+ npy_intp size[3] = { -1, -1, -1 };
-+ array = obj_to_array_fortran_allow_conversion($input, DATA_TYPECODE,
-+ &is_new_object);
-+ if (!array || !require_dimensions(array, 3) ||
-+ !require_size(array, size, 3) | !require_fortran(array)) SWIG_fail;
-+ $1 = (DATA_TYPE*) array_data(array);
-+ $2 = (DIM_TYPE) array_size(array,0);
-+ $3 = (DIM_TYPE) array_size(array,1);
-+ $4 = (DIM_TYPE) array_size(array,2);
-+}
-+%typemap(freearg)
-+ (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
-+{
-+ if (is_new_object$argnum && array$argnum)
-+ { Py_DECREF(array$argnum); }
-+}
-+
-+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
-+ * DATA_TYPE* IN_FARRAY3)
-+ */
-+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
-+ fragment="NumPy_Macros")
-+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
-+{
-+ $1 = is_array($input) || PySequence_Check($input);
-+}
-+%typemap(in,
-+ fragment="NumPy_Fragments")
-+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
-+ (PyArrayObject* array=NULL, int is_new_object=0)
-+{
-+ npy_intp size[3] = { -1, -1, -1 };
-+ array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
-+ &is_new_object);
-+ if (!array || !require_dimensions(array, 3) ||
-+ !require_size(array, size, 3) || !require_fortran(array)) SWIG_fail;
-+ $1 = (DIM_TYPE) array_size(array,0);
-+ $2 = (DIM_TYPE) array_size(array,1);
-+ $3 = (DIM_TYPE) array_size(array,2);
-+ $4 = (DATA_TYPE*) array_data(array);
-+}
-+%typemap(freearg)
-+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
-+{
-+ if (is_new_object$argnum && array$argnum)
-+ { Py_DECREF(array$argnum); }
-+}
-+
-+/***************************/
-+/* In-Place Array Typemaps */
-+/***************************/
-+
-+/* Typemap suite for (DATA_TYPE INPLACE_ARRAY1[ANY])
-+ */
-+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
-+ fragment="NumPy_Macros")
-+ (DATA_TYPE INPLACE_ARRAY1[ANY])
-+{
-+ $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
-+ DATA_TYPECODE);
-+}
-+%typemap(in,
-+ fragment="NumPy_Fragments")
-+ (DATA_TYPE INPLACE_ARRAY1[ANY])
-+ (PyArrayObject* array=NULL)
-+{
-+ npy_intp size[1] = { $1_dim0 };
-+ array = obj_to_array_no_conversion($input, DATA_TYPECODE);
-+ if (!array || !require_dimensions(array,1) || !require_size(array, size, 1) ||
-+ !require_contiguous(array) || !require_native(array)) SWIG_fail;
-+ $1 = ($1_ltype) array_data(array);
-+}
-+
-+/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
-+ */
-+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
-+ fragment="NumPy_Macros")
-+ (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
-+{
-+ $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
-+ DATA_TYPECODE);
-+}
-+%typemap(in,
-+ fragment="NumPy_Fragments")
-+ (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
-+ (PyArrayObject* array=NULL, int i=1)
-+{
-+ array = obj_to_array_no_conversion($input, DATA_TYPECODE);
-+ if (!array || !require_dimensions(array,1) || !require_contiguous(array)
-+ || !require_native(array)) SWIG_fail;
-+ $1 = (DATA_TYPE*) array_data(array);
-+ $2 = 1;
-+ for (i=0; i < array_numdims(array); ++i) $2 *= array_size(array,i);
-+}
-+
-+/* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
-+ */
-+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
-+ fragment="NumPy_Macros")
-+ (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
-+{
-+ $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
-+ DATA_TYPECODE);
-+}
-+%typemap(in,
-+ fragment="NumPy_Fragments")
-+ (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
-+ (PyArrayObject* array=NULL, int i=0)
-+{
-+ array = obj_to_array_no_conversion($input, DATA_TYPECODE);
-+ if (!array || !require_dimensions(array,1) || !require_contiguous(array)
-+ || !require_native(array)) SWIG_fail;
-+ $1 = 1;
-+ for (i=0; i < array_numdims(array); ++i) $1 *= array_size(array,i);
-+ $2 = (DATA_TYPE*) array_data(array);
-+}
-+
-+/* Typemap suite for (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
-+ */
-+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
-+ fragment="NumPy_Macros")
-+ (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
-+{
-+ $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
-+ DATA_TYPECODE);
-+}
-+%typemap(in,
-+ fragment="NumPy_Fragments")
-+ (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
-+ (PyArrayObject* array=NULL)
-+{
-+ npy_intp size[2] = { $1_dim0, $1_dim1 };
-+ array = obj_to_array_no_conversion($input, DATA_TYPECODE);
-+ if (!array || !require_dimensions(array,2) || !require_size(array, size, 2) ||
-+ !require_contiguous(array) || !require_native(array)) SWIG_fail;
-+ $1 = ($1_ltype) array_data(array);
-+}
-+
-+/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
-+ */
-+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
-+ fragment="NumPy_Macros")
-+ (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
-+{
-+ $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
-+ DATA_TYPECODE);
-+}
-+%typemap(in,
-+ fragment="NumPy_Fragments")
-+ (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
-+ (PyArrayObject* array=NULL)
-+{
-+ array = obj_to_array_no_conversion($input, DATA_TYPECODE);
-+ if (!array || !require_dimensions(array,2) || !require_contiguous(array)
-+ || !require_native(array)) SWIG_fail;
-+ $1 = (DATA_TYPE*) array_data(array);
-+ $2 = (DIM_TYPE) array_size(array,0);
-+ $3 = (DIM_TYPE) array_size(array,1);
-+}
-+
-+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
-+ */
-+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
-+ fragment="NumPy_Macros")
-+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
-+{
-+ $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
-+ DATA_TYPECODE);
-+}
-+%typemap(in,
-+ fragment="NumPy_Fragments")
-+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
-+ (PyArrayObject* array=NULL)
-+{
-+ array = obj_to_array_no_conversion($input, DATA_TYPECODE);
-+ if (!array || !require_dimensions(array,2) || !require_contiguous(array) ||
-+ !require_native(array)) SWIG_fail;
-+ $1 = (DIM_TYPE) array_size(array,0);
-+ $2 = (DIM_TYPE) array_size(array,1);
-+ $3 = (DATA_TYPE*) array_data(array);
-+}
-+
-+/* Typemap suite for (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
-+ */
-+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
-+ fragment="NumPy_Macros")
-+ (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
-+{
-+ $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
-+ DATA_TYPECODE);
-+}
-+%typemap(in,
-+ fragment="NumPy_Fragments")
-+ (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
-+ (PyArrayObject* array=NULL)
-+{
-+ array = obj_to_array_no_conversion($input, DATA_TYPECODE);
-+ if (!array || !require_dimensions(array,2) || !require_contiguous(array)
-+ || !require_native(array) || !require_fortran(array)) SWIG_fail;
-+ $1 = (DATA_TYPE*) array_data(array);
-+ $2 = (DIM_TYPE) array_size(array,0);
-+ $3 = (DIM_TYPE) array_size(array,1);
-+}
-+
-+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
-+ */
-+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
-+ fragment="NumPy_Macros")
-+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
-+{
-+ $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
-+ DATA_TYPECODE);
-+}
-+%typemap(in,
-+ fragment="NumPy_Fragments")
-+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
-+ (PyArrayObject* array=NULL)
-+{
-+ array = obj_to_array_no_conversion($input, DATA_TYPECODE);
-+ if (!array || !require_dimensions(array,2) || !require_contiguous(array) ||
-+ !require_native(array) || !require_fortran(array)) SWIG_fail;
-+ $1 = (DIM_TYPE) array_size(array,0);
-+ $2 = (DIM_TYPE) array_size(array,1);
-+ $3 = (DATA_TYPE*) array_data(array);
-+}
-+
-+/* Typemap suite for (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
-+ */
-+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
-+ fragment="NumPy_Macros")
-+ (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
-+{
-+ $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
-+ DATA_TYPECODE);
-+}
-+%typemap(in,
-+ fragment="NumPy_Fragments")
-+ (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
-+ (PyArrayObject* array=NULL)
-+{
-+ npy_intp size[3] = { $1_dim0, $1_dim1, $1_dim2 };
-+ array = obj_to_array_no_conversion($input, DATA_TYPECODE);
-+ if (!array || !require_dimensions(array,3) || !require_size(array, size, 3) ||
-+ !require_contiguous(array) || !require_native(array)) SWIG_fail;
-+ $1 = ($1_ltype) array_data(array);
-+}
-+
-+/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
-+ * DIM_TYPE DIM3)
-+ */
-+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
-+ fragment="NumPy_Macros")
-+ (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
-+{
-+ $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
-+ DATA_TYPECODE);
-+}
-+%typemap(in,
-+ fragment="NumPy_Fragments")
-+ (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
-+ (PyArrayObject* array=NULL)
-+{
-+ array = obj_to_array_no_conversion($input, DATA_TYPECODE);
-+ if (!array || !require_dimensions(array,3) || !require_contiguous(array) ||
-+ !require_native(array)) SWIG_fail;
-+ $1 = (DATA_TYPE*) array_data(array);
-+ $2 = (DIM_TYPE) array_size(array,0);
-+ $3 = (DIM_TYPE) array_size(array,1);
-+ $4 = (DIM_TYPE) array_size(array,2);
-+}
-+
-+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
-+ * DATA_TYPE* INPLACE_ARRAY3)
-+ */
-+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
-+ fragment="NumPy_Macros")
-+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3)
-+{
-+ $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
-+ DATA_TYPECODE);
-+}
-+%typemap(in,
-+ fragment="NumPy_Fragments")
-+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3)
-+ (PyArrayObject* array=NULL)
-+{
-+ array = obj_to_array_no_conversion($input, DATA_TYPECODE);
-+ if (!array || !require_dimensions(array,3) || !require_contiguous(array)
-+ || !require_native(array)) SWIG_fail;
-+ $1 = (DIM_TYPE) array_size(array,0);
-+ $2 = (DIM_TYPE) array_size(array,1);
-+ $3 = (DIM_TYPE) array_size(array,2);
-+ $4 = (DATA_TYPE*) array_data(array);
-+}
-+
-+/* Typemap suite for (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
-+ * DIM_TYPE DIM3)
-+ */
-+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
-+ fragment="NumPy_Macros")
-+ (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
-+{
-+ $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
-+ DATA_TYPECODE);
-+}
-+%typemap(in,
-+ fragment="NumPy_Fragments")
-+ (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
-+ (PyArrayObject* array=NULL)
-+{
-+ array = obj_to_array_no_conversion($input, DATA_TYPECODE);
-+ if (!array || !require_dimensions(array,3) || !require_contiguous(array) ||
-+ !require_native(array) || !require_fortran(array)) SWIG_fail;
-+ $1 = (DATA_TYPE*) array_data(array);
-+ $2 = (DIM_TYPE) array_size(array,0);
-+ $3 = (DIM_TYPE) array_size(array,1);
-+ $4 = (DIM_TYPE) array_size(array,2);
-+}
-+
-+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
-+ * DATA_TYPE* INPLACE_FARRAY3)
-+ */
-+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
-+ fragment="NumPy_Macros")
-+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3)
-+{
-+ $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
-+ DATA_TYPECODE);
-+}
-+%typemap(in,
-+ fragment="NumPy_Fragments")
-+ (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3)
-+ (PyArrayObject* array=NULL)
-+{
-+ array = obj_to_array_no_conversion($input, DATA_TYPECODE);
-+ if (!array || !require_dimensions(array,3) || !require_contiguous(array)
-+ || !require_native(array) || !require_fortran(array)) SWIG_fail;
-+ $1 = (DIM_TYPE) array_size(array,0);
-+ $2 = (DIM_TYPE) array_size(array,1);
-+ $3 = (DIM_TYPE) array_size(array,2);
-+ $4 = (DATA_TYPE*) array_data(array);
-+}
-+
-+/*************************/
-+/* Argout Array Typemaps */
-+/*************************/
-+
-+/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY1[ANY])
-+ */
-+%typemap(in,numinputs=0,
-+ fragment="NumPy_Backward_Compatibility,NumPy_Macros")
-+ (DATA_TYPE ARGOUT_ARRAY1[ANY])
-+ (PyObject * array = NULL)
-+{
-+ npy_intp dims[1] = { $1_dim0 };
-+ array = PyArray_SimpleNew(1, dims, DATA_TYPECODE);
-+ if (!array) SWIG_fail;
-+ $1 = ($1_ltype) array_data(array);
-+}
-+%typemap(argout)
-+ (DATA_TYPE ARGOUT_ARRAY1[ANY])
-+{
-+ $result = SWIG_Python_AppendOutput($result,array$argnum);
-+}
-+
-+/* Typemap suite for (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
-+ */
-+%typemap(in,numinputs=1,
-+ fragment="NumPy_Fragments")
-+ (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
-+ (PyObject * array = NULL)
-+{
-+ npy_intp dims[1];
-+ if (!PyInt_Check($input))
-+ {
-+ char* typestring = pytype_string($input);
-+ PyErr_Format(PyExc_TypeError,
-+ "Int dimension expected. '%s' given.",
-+ typestring);
-+ SWIG_fail;
-+ }
-+ $2 = (DIM_TYPE) PyInt_AsLong($input);
-+ dims[0] = (npy_intp) $2;
-+ array = PyArray_SimpleNew(1, dims, DATA_TYPECODE);
-+ if (!array) SWIG_fail;
-+ $1 = (DATA_TYPE*) array_data(array);
-+}
-+%typemap(argout)
-+ (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
-+{
-+ $result = SWIG_Python_AppendOutput($result,array$argnum);
-+}
-+
-+/* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
-+ */
-+%typemap(in,numinputs=1,
-+ fragment="NumPy_Fragments")
-+ (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
-+ (PyObject * array = NULL)
-+{
-+ npy_intp dims[1];
-+ if (!PyInt_Check($input))
-+ {
-+ char* typestring = pytype_string($input);
-+ PyErr_Format(PyExc_TypeError,
-+ "Int dimension expected. '%s' given.",
-+ typestring);
-+ SWIG_fail;
-+ }
-+ $1 = (DIM_TYPE) PyInt_AsLong($input);
-+ dims[0] = (npy_intp) $1;
-+ array = PyArray_SimpleNew(1, dims, DATA_TYPECODE);
-+ if (!array) SWIG_fail;
-+ $2 = (DATA_TYPE*) array_data(array);
-+}
-+%typemap(argout)
-+ (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
-+{
-+ $result = SWIG_Python_AppendOutput($result,array$argnum);
-+}
-+
-+/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
-+ */
-+%typemap(in,numinputs=0,
-+ fragment="NumPy_Backward_Compatibility,NumPy_Macros")
-+ (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
-+ (PyObject * array = NULL)
-+{
-+ npy_intp dims[2] = { $1_dim0, $1_dim1 };
-+ array = PyArray_SimpleNew(2, dims, DATA_TYPECODE);
-+ if (!array) SWIG_fail;
-+ $1 = ($1_ltype) array_data(array);
-+}
-+%typemap(argout)
-+ (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
-+{
-+ $result = SWIG_Python_AppendOutput($result,array$argnum);
-+}
-+
-+/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
-+ */
-+%typemap(in,numinputs=0,
-+ fragment="NumPy_Backward_Compatibility,NumPy_Macros")
-+ (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
-+ (PyObject * array = NULL)
-+{
-+ npy_intp dims[3] = { $1_dim0, $1_dim1, $1_dim2 };
-+ array = PyArray_SimpleNew(3, dims, DATA_TYPECODE);
-+ if (!array) SWIG_fail;
-+ $1 = ($1_ltype) array_data(array);
-+}
-+%typemap(argout)
-+ (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
-+{
-+ $result = SWIG_Python_AppendOutput($result,array$argnum);
-+}
-+
-+/*****************************/
-+/* Argoutview Array Typemaps */
-+/*****************************/
-+
-+/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1)
-+ */
-+%typemap(in,numinputs=0)
-+ (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1 )
-+ (DATA_TYPE* data_temp , DIM_TYPE dim_temp)
-+{
-+ $1 = &data_temp;
-+ $2 = &dim_temp;
-+}
-+%typemap(argout,
-+ fragment="NumPy_Backward_Compatibility")
-+ (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1)
-+{
-+ npy_intp dims[1] = { *$2 };
-+ PyObject * array = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$1));
-+ if (!array) SWIG_fail;
-+ $result = SWIG_Python_AppendOutput($result,array);
-+}
-+
-+/* Typemap suite for (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1)
-+ */
-+%typemap(in,numinputs=0)
-+ (DIM_TYPE* DIM1 , DATA_TYPE** ARGOUTVIEW_ARRAY1)
-+ (DIM_TYPE dim_temp, DATA_TYPE* data_temp )
-+{
-+ $1 = &dim_temp;
-+ $2 = &data_temp;
-+}
-+%typemap(argout,
-+ fragment="NumPy_Backward_Compatibility")
-+ (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1)
-+{
-+ npy_intp dims[1] = { *$1 };
-+ PyObject * array = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$2));
-+ if (!array) SWIG_fail;
-+ $result = SWIG_Python_AppendOutput($result,array);
-+}
-+
-+/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
-+ */
-+%typemap(in,numinputs=0)
-+ (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 )
-+ (DATA_TYPE* data_temp , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp)
-+{
-+ $1 = &data_temp;
-+ $2 = &dim1_temp;
-+ $3 = &dim2_temp;
-+}
-+%typemap(argout,
-+ fragment="NumPy_Backward_Compatibility")
-+ (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
-+{
-+ npy_intp dims[2] = { *$2, *$3 };
-+ PyObject * array = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1));
-+ if (!array) SWIG_fail;
-+ $result = SWIG_Python_AppendOutput($result,array);
-+}
-+
-+/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2)
-+ */
-+%typemap(in,numinputs=0)
-+ (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DATA_TYPE** ARGOUTVIEW_ARRAY2)
-+ (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DATA_TYPE* data_temp )
-+{
-+ $1 = &dim1_temp;
-+ $2 = &dim2_temp;
-+ $3 = &data_temp;
-+}
-+%typemap(argout,
-+ fragment="NumPy_Backward_Compatibility")
-+ (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2)
-+{
-+ npy_intp dims[2] = { *$1, *$2 };
-+ PyObject * array = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3));
-+ if (!array) SWIG_fail;
-+ $result = SWIG_Python_AppendOutput($result,array);
-+}
-+
-+/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
-+ */
-+%typemap(in,numinputs=0)
-+ (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 )
-+ (DATA_TYPE* data_temp , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp)
-+{
-+ $1 = &data_temp;
-+ $2 = &dim1_temp;
-+ $3 = &dim2_temp;
-+}
-+%typemap(argout,
-+ fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
-+ (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
-+{
-+ npy_intp dims[2] = { *$2, *$3 };
-+ PyObject * obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1));
-+ PyArrayObject * array = (PyArrayObject*) obj;
-+ if (!array || !require_fortran(array)) SWIG_fail;
-+ $result = SWIG_Python_AppendOutput($result,obj);
-+}
-+
-+/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2)
-+ */
-+%typemap(in,numinputs=0)
-+ (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DATA_TYPE** ARGOUTVIEW_FARRAY2)
-+ (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DATA_TYPE* data_temp )
-+{
-+ $1 = &dim1_temp;
-+ $2 = &dim2_temp;
-+ $3 = &data_temp;
-+}
-+%typemap(argout,
-+ fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
-+ (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2)
-+{
-+ npy_intp dims[2] = { *$1, *$2 };
-+ PyObject * obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3));
-+ PyArrayObject * array = (PyArrayObject*) obj;
-+ if (!array || !require_fortran(array)) SWIG_fail;
-+ $result = SWIG_Python_AppendOutput($result,obj);
-+}
-+
-+/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
-+ DIM_TYPE* DIM3)
-+ */
-+%typemap(in,numinputs=0)
-+ (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
-+ (DATA_TYPE* data_temp, DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp)
-+{
-+ $1 = &data_temp;
-+ $2 = &dim1_temp;
-+ $3 = &dim2_temp;
-+ $4 = &dim3_temp;
-+}
-+%typemap(argout,
-+ fragment="NumPy_Backward_Compatibility")
-+ (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
-+{
-+ npy_intp dims[3] = { *$2, *$3, *$4 };
-+ PyObject * array = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1));
-+ if (!array) SWIG_fail;
-+ $result = SWIG_Python_AppendOutput($result,array);
-+}
-+
-+/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3,
-+ DATA_TYPE** ARGOUTVIEW_ARRAY3)
-+ */
-+%typemap(in,numinputs=0)
-+ (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3)
-+ (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp)
-+{
-+ $1 = &dim1_temp;
-+ $2 = &dim2_temp;
-+ $3 = &dim3_temp;
-+ $4 = &data_temp;
-+}
-+%typemap(argout,
-+ fragment="NumPy_Backward_Compatibility")
-+ (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3)
-+{
-+ npy_intp dims[3] = { *$1, *$2, *$3 };
-+ PyObject * array = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$3));
-+ if (!array) SWIG_fail;
-+ $result = SWIG_Python_AppendOutput($result,array);
-+}
-+
-+/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
-+ DIM_TYPE* DIM3)
-+ */
-+%typemap(in,numinputs=0)
-+ (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
-+ (DATA_TYPE* data_temp, DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp)
-+{
-+ $1 = &data_temp;
-+ $2 = &dim1_temp;
-+ $3 = &dim2_temp;
-+ $4 = &dim3_temp;
-+}
-+%typemap(argout,
-+ fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
-+ (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
-+{
-+ npy_intp dims[3] = { *$2, *$3, *$4 };
-+ PyObject * obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1));
-+ PyArrayObject * array = (PyArrayObject*) obj;
-+ if (!array || require_fortran(array)) SWIG_fail;
-+ $result = SWIG_Python_AppendOutput($result,obj);
-+}
-+
-+/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3,
-+ DATA_TYPE** ARGOUTVIEW_FARRAY3)
-+ */
-+%typemap(in,numinputs=0)
-+ (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_FARRAY3)
-+ (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp)
-+{
-+ $1 = &dim1_temp;
-+ $2 = &dim2_temp;
-+ $3 = &dim3_temp;
-+ $4 = &data_temp;
-+}
-+%typemap(argout,
-+ fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
-+ (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_FARRAY3)
-+{
-+ npy_intp dims[3] = { *$1, *$2, *$3 };
-+ PyObject * obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$3));
-+ PyArrayObject * array = (PyArrayObject*) obj;
-+ if (!array || require_fortran(array)) SWIG_fail;
-+ $result = SWIG_Python_AppendOutput($result,obj);
-+}
-+
-+%enddef /* %numpy_typemaps() macro */
-+/* *************************************************************** */
-+
-+/* Concrete instances of the %numpy_typemaps() macro: Each invocation
-+ * below applies all of the typemaps above to the specified data type.
-+ */
-+%numpy_typemaps(signed char , NPY_BYTE , int)
-+%numpy_typemaps(unsigned char , NPY_UBYTE , int)
-+%numpy_typemaps(short , NPY_SHORT , int)
-+%numpy_typemaps(unsigned short , NPY_USHORT , int)
-+%numpy_typemaps(int , NPY_INT , int)
-+%numpy_typemaps(unsigned int , NPY_UINT , int)
-+%numpy_typemaps(long , NPY_LONG , int)
-+%numpy_typemaps(unsigned long , NPY_ULONG , int)
-+%numpy_typemaps(long long , NPY_LONGLONG , int)
-+%numpy_typemaps(unsigned long long, NPY_ULONGLONG, int)
-+%numpy_typemaps(float , NPY_FLOAT , int)
-+%numpy_typemaps(double , NPY_DOUBLE , int)
-+
-+/* ***************************************************************
-+ * The follow macro expansion does not work, because C++ bool is 4
-+ * bytes and NPY_BOOL is 1 byte
-+ *
-+ * %numpy_typemaps(bool, NPY_BOOL, int)
-+ */
-+
-+/* ***************************************************************
-+ * On my Mac, I get the following warning for this macro expansion:
-+ * 'swig/python detected a memory leak of type 'long double *', no destructor found.'
-+ *
-+ * %numpy_typemaps(long double, NPY_LONGDOUBLE, int)
-+ */
-+
-+/* ***************************************************************
-+ * Swig complains about a syntax error for the following macro
-+ * expansions:
-+ *
-+ * %numpy_typemaps(complex float, NPY_CFLOAT , int)
-+ *
-+ * %numpy_typemaps(complex double, NPY_CDOUBLE, int)
-+ *
-+ * %numpy_typemaps(complex long double, NPY_CLONGDOUBLE, int)
-+ */
-+
-+#endif /* SWIGPYTHON */
--- /dev/null
+Provide support for both python2 and python3 interfaces
+--- /dev/null
++++ b/lang/python2/CMakeLists.txt
+@@ -0,0 +1,60 @@
++set(src_imp_dep
++../../include/mgl2/type.h
++../../include/mgl2/data.h
++../../include/mgl2/mgl.h
++../mgl.i
++../data.i
++../type.i
++)
++
++set(mgl_clean_files "")
++
++SET_SOURCE_FILES_PROPERTIES(../mathgl.i ../numpy.i PROPERTIES CPLUSPLUS ON)
++
++if(enable-python)
++ set(Python_ADDITIONAL_VERSIONS 2.7)
++ FIND_PACKAGE(PythonInterp)
++ if(NOT PYTHONINTERP_FOUND)
++ message(SEND_ERROR "Couldn't find python interpreter.")
++ endif(NOT PYTHONINTERP_FOUND)
++ FIND_PACKAGE(PythonLibs)
++ if(NOT PYTHONLIBS_FOUND)
++ message(SEND_ERROR "Couldn't find python development libraries.")
++ endif(NOT PYTHONLIBS_FOUND)
++ execute_process(
++ COMMAND ${PYTHON_EXECUTABLE} -c "import numpy; print numpy.get_include()"
++ OUTPUT_VARIABLE NUMPY_INCLUDE_PATH
++ RESULT_VARIABLE NUMPY_ERR
++ OUTPUT_STRIP_TRAILING_WHITESPACE
++ )
++ if(NOT NUMPY_INCLUDE_PATH)
++ message(SEND_ERROR "Couldn't find numpy.")
++ endif(NOT NUMPY_INCLUDE_PATH)
++
++ include_directories(${PYTHON_INCLUDE_DIR} ${NUMPY_INCLUDE_PATH})
++ execute_process(
++ COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(prefix='${CMAKE_INSTALL_PREFIX}')"
++ OUTPUT_VARIABLE MGL_PYTHON_SITE_PACKAGES
++ OUTPUT_STRIP_TRAILING_WHITESPACE)
++ set(SWIG_MODULE_mathgl_EXTRA_DEPS ../numpy.i ${src_imp_dep})
++ if(${CMAKE_VERSION} VERSION_LESS "3.8.0")
++ SWIG_ADD_MODULE(mathgl python ../mathgl.i)
++ else(${CMAKE_VERSION} VERSION_LESS "3.8.0")
++ SWIG_ADD_LIBRARY(mathgl LANGUAGE python SOURCES ../mathgl.i)
++ endif(${CMAKE_VERSION} VERSION_LESS "3.8.0")
++ SWIG_LINK_LIBRARIES(mathgl mgl ${PYTHON_LIBRARIES})
++ set_target_properties(_mathgl PROPERTIES BUILD_WITH_INSTALL_RPATH ON)
++ add_custom_command(OUTPUT mathgl.pyc
++ COMMAND ${PYTHON_EXECUTABLE}
++ ARGS -c \"from py_compile import compile\; compile('mathgl.py') \"
++ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/lang/python2
++ DEPENDS _mathgl
++ )
++ add_custom_target(mgl_python_module ALL DEPENDS _mathgl mathgl.pyc)
++
++ install(FILES ${MathGL2_BINARY_DIR}/lang/python2/mathgl.py ${MathGL2_BINARY_DIR}/lang/python2/mathgl.pyc DESTINATION ${MGL_PYTHON_SITE_PACKAGES})
++ install (TARGETS _mathgl LIBRARY DESTINATION ${MGL_PYTHON_SITE_PACKAGES})
++ set(mgl_clean_files ${mgl_clean_files} mathgl.py)
++endif(enable-python)
++
++set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${mgl_clean_files}")
+--- /dev/null
++++ b/lang/python3/CMakeLists.txt
+@@ -0,0 +1,70 @@
++set(src_imp_dep
++../../include/mgl2/type.h
++../../include/mgl2/data.h
++../../include/mgl2/mgl.h
++../mgl.i
++../data.i
++../type.i
++)
++
++set(mgl_clean_files "")
++
++SET_SOURCE_FILES_PROPERTIES(../mathgl.i ../numpy.i PROPERTIES CPLUSPLUS ON)
++
++if(enable-python)
++ set(Python_ADDITIONAL_VERSIONS 3.6)
++ unset(PYTHONINTERP_FOUND)
++ unset(PYTHON_EXECUTABLE CACHE)
++ FIND_PACKAGE(PythonInterp 3.6 REQUIRED)
++ if(NOT PYTHONINTERP_FOUND)
++ message(SEND_ERROR "Couldn't find python interpreter.")
++ endif(NOT PYTHONINTERP_FOUND)
++ unset(PYTHONLIBS_FOUND)
++ unset(PYTHON_LIBRARIES CACHE)
++ unset(PYTHON_INCLUDE_PATH CACHE)
++ unset(PYTHON_INCLUDE_DIRS CACHE)
++ unset(PYTHON_DEBUG_LIBRARIES CACHE)
++ unset(PYTHONLIBS_VERSION_STRING CACHE)
++ unset(PYTHON_LIBRARY CACHE)
++ unset(PYTHON_INCLUDE_DIR CACHE)
++ FIND_PACKAGE(PythonLibs 3.6 REQUIRED)
++ if(NOT PYTHONLIBS_FOUND)
++ message(SEND_ERROR "Couldn't find python development libraries.")
++ endif(NOT PYTHONLIBS_FOUND)
++ execute_process(
++ COMMAND ${PYTHON_EXECUTABLE} -c "import numpy; print (numpy.get_include())"
++ OUTPUT_VARIABLE NUMPY_INCLUDE_PATH
++ RESULT_VARIABLE NUMPY_ERR
++ OUTPUT_STRIP_TRAILING_WHITESPACE
++ )
++ if(NOT NUMPY_INCLUDE_PATH)
++ message(SEND_ERROR "Couldn't find numpy.")
++ endif(NOT NUMPY_INCLUDE_PATH)
++
++ include_directories(${PYTHON_INCLUDE_DIR} ${NUMPY_INCLUDE_PATH})
++ execute_process(
++ COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print (get_python_lib(prefix='${CMAKE_INSTALL_PREFIX}'))"
++ OUTPUT_VARIABLE MGL_PYTHON_SITE_PACKAGES
++ OUTPUT_STRIP_TRAILING_WHITESPACE)
++ set(SWIG_MODULE_mathglp3_EXTRA_DEPS ../numpy.i ${src_imp_dep})
++ if(${CMAKE_VERSION} VERSION_LESS "3.8.0")
++ SWIG_ADD_MODULE(mathglp3 python ../mathgl.i)
++ else(${CMAKE_VERSION} VERSION_LESS "3.8.0")
++ SWIG_ADD_LIBRARY(mathglp3 LANGUAGE python SOURCES ../mathgl.i)
++ endif(${CMAKE_VERSION} VERSION_LESS "3.8.0")
++ SWIG_LINK_LIBRARIES(mathglp3 mgl ${PYTHON_LIBRARIES})
++ set_target_properties(_mathglp3 PROPERTIES BUILD_WITH_INSTALL_RPATH ON)
++ add_custom_command(OUTPUT mathgl.pyc
++ COMMAND ${PYTHON_EXECUTABLE}
++ ARGS -c \"from py_compile import compile\; compile('mathgl.py') \"
++ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/lang/python3
++ DEPENDS _mathglp3
++ )
++ add_custom_target(mglp3_python_module ALL DEPENDS _mathglp3 mathgl.pyc)
++
++ install(FILES ${MathGL2_BINARY_DIR}/lang/python3/mathgl.py ${MathGL2_BINARY_DIR}/lang/python3/__pycache__/mathgl.cpython-36.pyc DESTINATION ${MGL_PYTHON_SITE_PACKAGES}/__pycache__)
++ install (TARGETS _mathglp3 LIBRARY DESTINATION ${MGL_PYTHON_SITE_PACKAGES})
++ set(mgl_clean_files ${mgl_clean_files} mathgl.py)
++endif(enable-python)
++
++set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${mgl_clean_files}")
+--- a/lang/numpy.i
++++ b/lang/numpy.i
+@@ -107,11 +107,12 @@
+ if (PyDict_Check( py_obj)) return "dict" ;
+ if (PyList_Check( py_obj)) return "list" ;
+ if (PyTuple_Check( py_obj)) return "tuple" ;
+- if (PyFile_Check( py_obj)) return "file" ;
+ if (PyModule_Check( py_obj)) return "module" ;
+- if (PyInstance_Check(py_obj)) return "instance" ;
+-
+- return "unknow type";
++ %# if PY_MAJOR_VERSION < 3
++ if (PyFile_Check( py_obj)) return "file" ;
++ if (PyInstance_Check(py_obj)) return "instance" ;
++ %# endif
++ return "unknown type";
+ }
+
+ /* Given a NumPy typecode, return a string describing the type.
+--- a/lang/CMakeLists.txt
++++ b/lang/CMakeLists.txt
+@@ -17,52 +17,6 @@
+ endif(NOT SWIG_FOUND)
+ INCLUDE(${SWIG_USE_FILE})
+
+-if(enable-python)
+- set(Python_ADDITIONAL_VERSIONS 2.7)
+- FIND_PACKAGE(PythonInterp)
+- if(NOT PYTHONINTERP_FOUND)
+- message(SEND_ERROR "Couldn't find python interpreter.")
+- endif(NOT PYTHONINTERP_FOUND)
+- FIND_PACKAGE(PythonLibs)
+- if(NOT PYTHONLIBS_FOUND)
+- message(SEND_ERROR "Couldn't find python development libraries.")
+- endif(NOT PYTHONLIBS_FOUND)
+- execute_process(
+- COMMAND ${PYTHON_EXECUTABLE} -c "import numpy; print numpy.get_include()"
+- OUTPUT_VARIABLE NUMPY_INCLUDE_PATH
+- RESULT_VARIABLE NUMPY_ERR
+- OUTPUT_STRIP_TRAILING_WHITESPACE
+- )
+- if(NOT NUMPY_INCLUDE_PATH)
+- message(SEND_ERROR "Couldn't find numpy.")
+- endif(NOT NUMPY_INCLUDE_PATH)
+-
+- include_directories(${PYTHON_INCLUDE_DIR} ${NUMPY_INCLUDE_PATH})
+- execute_process(
+- COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(prefix='${CMAKE_INSTALL_PREFIX}')"
+- OUTPUT_VARIABLE MGL_PYTHON_SITE_PACKAGES
+- OUTPUT_STRIP_TRAILING_WHITESPACE)
+- set(SWIG_MODULE_mathgl_EXTRA_DEPS numpy.i ${src_imp_dep})
+- if(${CMAKE_VERSION} VERSION_LESS "3.8.0")
+- SWIG_ADD_MODULE(mathgl python mathgl.i)
+- else(${CMAKE_VERSION} VERSION_LESS "3.8.0")
+- SWIG_ADD_LIBRARY(mathgl LANGUAGE python SOURCES mathgl.i)
+- endif(${CMAKE_VERSION} VERSION_LESS "3.8.0")
+- SWIG_LINK_LIBRARIES(mathgl mgl ${PYTHON_LIBRARIES})
+- set_target_properties(_mathgl PROPERTIES BUILD_WITH_INSTALL_RPATH ON)
+- add_custom_command(OUTPUT mathgl.pyc
+- COMMAND ${PYTHON_EXECUTABLE}
+- ARGS -c \"from py_compile import compile\; compile('mathgl.py') \"
+- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/lang
+- DEPENDS _mathgl
+- )
+- add_custom_target(mgl_python_module ALL DEPENDS _mathgl mathgl.pyc)
+-
+- install(FILES ${MathGL2_BINARY_DIR}/lang/mathgl.py ${MathGL2_BINARY_DIR}/lang/mathgl.pyc DESTINATION ${MGL_PYTHON_SITE_PACKAGES})
+- install (TARGETS _mathgl LIBRARY DESTINATION ${MGL_PYTHON_SITE_PACKAGES})
+- set(mgl_clean_files ${mgl_clean_files} mathgl.py)
+-endif(enable-python)
+-
+ if(enable-lua)
+ INCLUDE(FindLua51)
+ if(NOT LUA51_FOUND)
+@@ -145,4 +99,8 @@
+ endif(enable-octave-install)
+ set(mgl_clean_files ${mgl_clean_files} mathgl)
+ endif(enable-octave)
++
++add_subdirectory( python2 )
++add_subdirectory( python3 )
++
+ set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${mgl_clean_files}")
-lang_CMakeLists.patch
CMakeLists.patch
-lang_numpy.patch
-lang_mathgl.patch
+python2_and_python3.patch
--- /dev/null
+debian/tmp/usr/lib/python2*/dist-packages/*.so
+debian/tmp/usr/lib/python2*/dist-packages/*.py
-debian/tmp/usr/lib/python*/dist-packages/*.so
-debian/tmp/usr/lib/python*/dist-packages/*.py
\ No newline at end of file
+debian/tmp/usr/lib/python3*/dist-packages/*.so
+debian/tmp/usr/lib/python3*/dist-packages/__pycache__/*.py usr/lib/python3/dist-packages/
export DH_OPTIONS=-v
%:
- dh $@ --buildsystem=cmake --with python3
+ dh $@ --buildsystem=cmake --with python2,python3
+override_dh_python2:
+ dh_numpy
+
override_dh_python3:
dh_numpy3
endif(NOT SWIG_FOUND)
INCLUDE(${SWIG_USE_FILE})
-if(enable-python)
- set(Python_ADDITIONAL_VERSIONS 2.7)
- FIND_PACKAGE(PythonInterp)
- if(NOT PYTHONINTERP_FOUND)
- message(SEND_ERROR "Couldn't find python interpreter.")
- endif(NOT PYTHONINTERP_FOUND)
- FIND_PACKAGE(PythonLibs)
- if(NOT PYTHONLIBS_FOUND)
- message(SEND_ERROR "Couldn't find python development libraries.")
- endif(NOT PYTHONLIBS_FOUND)
- execute_process(
- COMMAND ${PYTHON_EXECUTABLE} -c "import numpy; print numpy.get_include()"
- OUTPUT_VARIABLE NUMPY_INCLUDE_PATH
- RESULT_VARIABLE NUMPY_ERR
- OUTPUT_STRIP_TRAILING_WHITESPACE
- )
- if(NOT NUMPY_INCLUDE_PATH)
- message(SEND_ERROR "Couldn't find numpy.")
- endif(NOT NUMPY_INCLUDE_PATH)
-
- include_directories(${PYTHON_INCLUDE_DIR} ${NUMPY_INCLUDE_PATH})
- execute_process(
- COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(prefix='${CMAKE_INSTALL_PREFIX}')"
- OUTPUT_VARIABLE MGL_PYTHON_SITE_PACKAGES
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- set(SWIG_MODULE_mathgl_EXTRA_DEPS numpy.i ${src_imp_dep})
- if(${CMAKE_VERSION} VERSION_LESS "3.8.0")
- SWIG_ADD_MODULE(mathgl python mathgl.i)
- else(${CMAKE_VERSION} VERSION_LESS "3.8.0")
- SWIG_ADD_LIBRARY(mathgl LANGUAGE python SOURCES mathgl.i)
- endif(${CMAKE_VERSION} VERSION_LESS "3.8.0")
- SWIG_LINK_LIBRARIES(mathgl mgl ${PYTHON_LIBRARIES})
- set_target_properties(_mathgl PROPERTIES BUILD_WITH_INSTALL_RPATH ON)
- add_custom_command(OUTPUT mathgl.pyc
- COMMAND ${PYTHON_EXECUTABLE}
- ARGS -c \"from py_compile import compile\; compile('mathgl.py') \"
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/lang
- DEPENDS _mathgl
- )
- add_custom_target(mgl_python_module ALL DEPENDS _mathgl mathgl.pyc)
-
- install(FILES ${MathGL2_BINARY_DIR}/lang/mathgl.py ${MathGL2_BINARY_DIR}/lang/mathgl.pyc DESTINATION ${MGL_PYTHON_SITE_PACKAGES})
- install (TARGETS _mathgl LIBRARY DESTINATION ${MGL_PYTHON_SITE_PACKAGES})
- set(mgl_clean_files ${mgl_clean_files} mathgl.py)
-endif(enable-python)
-
if(enable-lua)
INCLUDE(FindLua51)
if(NOT LUA51_FOUND)
endif(enable-octave-install)
set(mgl_clean_files ${mgl_clean_files} mathgl)
endif(enable-octave)
+
+add_subdirectory( python2 )
+add_subdirectory( python3 )
+
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${mgl_clean_files}")
if (PyDict_Check( py_obj)) return "dict" ;
if (PyList_Check( py_obj)) return "list" ;
if (PyTuple_Check( py_obj)) return "tuple" ;
- if (PyFile_Check( py_obj)) return "file" ;
if (PyModule_Check( py_obj)) return "module" ;
- if (PyInstance_Check(py_obj)) return "instance" ;
-
- return "unknow type";
+ %# if PY_MAJOR_VERSION < 3
+ if (PyFile_Check( py_obj)) return "file" ;
+ if (PyInstance_Check(py_obj)) return "instance" ;
+ %# endif
+ return "unknown type";
}
/* Given a NumPy typecode, return a string describing the type.
--- /dev/null
+set(src_imp_dep
+../../include/mgl2/type.h
+../../include/mgl2/data.h
+../../include/mgl2/mgl.h
+../mgl.i
+../data.i
+../type.i
+)
+
+set(mgl_clean_files "")
+
+SET_SOURCE_FILES_PROPERTIES(../mathgl.i ../numpy.i PROPERTIES CPLUSPLUS ON)
+
+if(enable-python)
+ set(Python_ADDITIONAL_VERSIONS 2.7)
+ FIND_PACKAGE(PythonInterp)
+ if(NOT PYTHONINTERP_FOUND)
+ message(SEND_ERROR "Couldn't find python interpreter.")
+ endif(NOT PYTHONINTERP_FOUND)
+ FIND_PACKAGE(PythonLibs)
+ if(NOT PYTHONLIBS_FOUND)
+ message(SEND_ERROR "Couldn't find python development libraries.")
+ endif(NOT PYTHONLIBS_FOUND)
+ execute_process(
+ COMMAND ${PYTHON_EXECUTABLE} -c "import numpy; print numpy.get_include()"
+ OUTPUT_VARIABLE NUMPY_INCLUDE_PATH
+ RESULT_VARIABLE NUMPY_ERR
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ if(NOT NUMPY_INCLUDE_PATH)
+ message(SEND_ERROR "Couldn't find numpy.")
+ endif(NOT NUMPY_INCLUDE_PATH)
+
+ include_directories(${PYTHON_INCLUDE_DIR} ${NUMPY_INCLUDE_PATH})
+ execute_process(
+ COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(prefix='${CMAKE_INSTALL_PREFIX}')"
+ OUTPUT_VARIABLE MGL_PYTHON_SITE_PACKAGES
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ set(SWIG_MODULE_mathgl_EXTRA_DEPS ../numpy.i ${src_imp_dep})
+ if(${CMAKE_VERSION} VERSION_LESS "3.8.0")
+ SWIG_ADD_MODULE(mathgl python ../mathgl.i)
+ else(${CMAKE_VERSION} VERSION_LESS "3.8.0")
+ SWIG_ADD_LIBRARY(mathgl LANGUAGE python SOURCES ../mathgl.i)
+ endif(${CMAKE_VERSION} VERSION_LESS "3.8.0")
+ SWIG_LINK_LIBRARIES(mathgl mgl ${PYTHON_LIBRARIES})
+ set_target_properties(_mathgl PROPERTIES BUILD_WITH_INSTALL_RPATH ON)
+ add_custom_command(OUTPUT mathgl.pyc
+ COMMAND ${PYTHON_EXECUTABLE}
+ ARGS -c \"from py_compile import compile\; compile('mathgl.py') \"
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/lang/python2
+ DEPENDS _mathgl
+ )
+ add_custom_target(mgl_python_module ALL DEPENDS _mathgl mathgl.pyc)
+
+ install(FILES ${MathGL2_BINARY_DIR}/lang/python2/mathgl.py ${MathGL2_BINARY_DIR}/lang/python2/mathgl.pyc DESTINATION ${MGL_PYTHON_SITE_PACKAGES})
+ install (TARGETS _mathgl LIBRARY DESTINATION ${MGL_PYTHON_SITE_PACKAGES})
+ set(mgl_clean_files ${mgl_clean_files} mathgl.py)
+endif(enable-python)
+
+set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${mgl_clean_files}")
--- /dev/null
+set(src_imp_dep
+../../include/mgl2/type.h
+../../include/mgl2/data.h
+../../include/mgl2/mgl.h
+../mgl.i
+../data.i
+../type.i
+)
+
+set(mgl_clean_files "")
+
+SET_SOURCE_FILES_PROPERTIES(../mathgl.i ../numpy.i PROPERTIES CPLUSPLUS ON)
+
+if(enable-python)
+ set(Python_ADDITIONAL_VERSIONS 3.6)
+ unset(PYTHONINTERP_FOUND)
+ unset(PYTHON_EXECUTABLE CACHE)
+ FIND_PACKAGE(PythonInterp 3.6 REQUIRED)
+ if(NOT PYTHONINTERP_FOUND)
+ message(SEND_ERROR "Couldn't find python interpreter.")
+ endif(NOT PYTHONINTERP_FOUND)
+ unset(PYTHONLIBS_FOUND)
+ unset(PYTHON_LIBRARIES CACHE)
+ unset(PYTHON_INCLUDE_PATH CACHE)
+ unset(PYTHON_INCLUDE_DIRS CACHE)
+ unset(PYTHON_DEBUG_LIBRARIES CACHE)
+ unset(PYTHONLIBS_VERSION_STRING CACHE)
+ unset(PYTHON_LIBRARY CACHE)
+ unset(PYTHON_INCLUDE_DIR CACHE)
+ FIND_PACKAGE(PythonLibs 3.6 REQUIRED)
+ if(NOT PYTHONLIBS_FOUND)
+ message(SEND_ERROR "Couldn't find python development libraries.")
+ endif(NOT PYTHONLIBS_FOUND)
+ execute_process(
+ COMMAND ${PYTHON_EXECUTABLE} -c "import numpy; print (numpy.get_include())"
+ OUTPUT_VARIABLE NUMPY_INCLUDE_PATH
+ RESULT_VARIABLE NUMPY_ERR
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ if(NOT NUMPY_INCLUDE_PATH)
+ message(SEND_ERROR "Couldn't find numpy.")
+ endif(NOT NUMPY_INCLUDE_PATH)
+
+ include_directories(${PYTHON_INCLUDE_DIR} ${NUMPY_INCLUDE_PATH})
+ execute_process(
+ COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print (get_python_lib(prefix='${CMAKE_INSTALL_PREFIX}'))"
+ OUTPUT_VARIABLE MGL_PYTHON_SITE_PACKAGES
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ set(SWIG_MODULE_mathglp3_EXTRA_DEPS ../numpy.i ${src_imp_dep})
+ if(${CMAKE_VERSION} VERSION_LESS "3.8.0")
+ SWIG_ADD_MODULE(mathglp3 python ../mathgl.i)
+ else(${CMAKE_VERSION} VERSION_LESS "3.8.0")
+ SWIG_ADD_LIBRARY(mathglp3 LANGUAGE python SOURCES ../mathgl.i)
+ endif(${CMAKE_VERSION} VERSION_LESS "3.8.0")
+ SWIG_LINK_LIBRARIES(mathglp3 mgl ${PYTHON_LIBRARIES})
+ set_target_properties(_mathglp3 PROPERTIES BUILD_WITH_INSTALL_RPATH ON)
+ add_custom_command(OUTPUT mathgl.pyc
+ COMMAND ${PYTHON_EXECUTABLE}
+ ARGS -c \"from py_compile import compile\; compile('mathgl.py') \"
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/lang/python3
+ DEPENDS _mathglp3
+ )
+ add_custom_target(mglp3_python_module ALL DEPENDS _mathglp3 mathgl.pyc)
+
+ install(FILES ${MathGL2_BINARY_DIR}/lang/python3/mathgl.py ${MathGL2_BINARY_DIR}/lang/python3/__pycache__/mathgl.cpython-36.pyc DESTINATION ${MGL_PYTHON_SITE_PACKAGES}/__pycache__)
+ install (TARGETS _mathglp3 LIBRARY DESTINATION ${MGL_PYTHON_SITE_PACKAGES})
+ set(mgl_clean_files ${mgl_clean_files} mathgl.py)
+endif(enable-python)
+
+set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${mgl_clean_files}")