Skip to content

Commit

Permalink
Learn to use swig.
Browse files Browse the repository at this point in the history
  • Loading branch information
detu committed May 23, 2021
1 parent b30869a commit 12cacd9
Show file tree
Hide file tree
Showing 4 changed files with 796 additions and 0 deletions.
62 changes: 62 additions & 0 deletions ALM/swig/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
cmake_minimum_required(VERSION 3.16)
project(devQP)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
set(CMAKE_CXX_STANDARD 17)

set(CMAKE_BUILD_TYPE Debug)
#set(CMAKE_POSITION_INDEPENDENT_CODE ON)

## Defult build type: Debug ##
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()
## Debug definition: ##
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions("-DDEBUG")
endif()

find_package(Eigen3 REQUIRED)
#find_package(MATLAB COMPONENTS MX_LIBRARY)
find_package(OCTAVE COMPONENTS MX_LIBRARY)
find_package(MATIO)
find_package(fmt)
find_package(MKL REQUIRED)
find_package(MUMPS REQUIRED)

#set(MUMPS_HOME /home/detu/ThirdParty-Mumps/Debug)
#set(MUMPS_INCLUDE_DIR ${MUMPS_HOME}/include/coin-or/mumps)

include_directories(${EIGEN3_INCLUDE_DIR})
include_directories(${MUMPS_INCLUDE_DIRS})
#include_directories(${MATLAB_INCLUDE_DIRS})
include_directories(${OCTAVE_INCLUDE_DIRS})
include_directories(${MATIO_INCLUDE_DIRS})
include_directories(${fmt_INCLUDE_DIR})
include_directories(${MKL_INCLUDE_DIRS})

message("${CMAKE_MODULE_PATH}")
message("${EIGEN3_INCLUDE_DIR}")
message("${fmt_INCLUDE_DIR}")
message("${MUMPS_INCLUDE_DIRS}")
message("${MUMPS_LIBRARIES}")
message("${MKL_INCLUDE_DIRS}")
message("${OCTAVE_INCLUDE_DIRS}")

#add_library(eigenMumps SHARED)

#link_directories(
# ${MUMPS_HOME}/lib
#)
#set(EIG_MEXES almbound)
set(EIG_MEXES qpAL)

FOREACH(t ${EIG_MEXES})
#matlab_add_mex(NAME ${t} SRC ${t}.cpp LINK_TO ${MATLAB_LIBRARIES} libcoinmumps.so.2.1.0 ${fmt_LIBRARY} ${MKL_LIBRARY} gfortran)
# matlab_add_mex(NAME ${t} SRC ${t}.cpp LINK_TO ${MATLAB_LIBRARIES} ${MUMPS_LIBRARIES} ${fmt_LIBRARY} ${MKL_LIBRARY})
octave_add_oct(NAME ${t} SRC ${t}.cpp LINK_TO ${OCTAVE_LIBRARIES} ${MUMPS_LIBRARIES} ${fmt_LIBRARY} ${MKL_LIBRARY})
ENDFOREACH(t ${EIG_MEXES})


add_executable(main main.cpp)
target_link_libraries(main ${MATIO_LIBRARIES} ${fmt_LIBRARY} ${MKL_LIBRARY} ${MUMPS_LIBRARIES} gfortran)

48 changes: 48 additions & 0 deletions ALM/swig/MUMPSSupport
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

#ifndef EIGEN_MUMPSSUPPORT_MODULE_H
#define EIGEN_MUMPSSUPPORT_MODULE_H
#define EIGEN_USE_MKL_ALL
#include "Eigen/SparseCore"
#include "Eigen/src/Core/util/DisableStupidWarnings.h"

//#include <smumps_c.h>
#include <dmumps_c.h>
//#include <cmumps_c.h>
//#include <zmumps_c.h>

#ifdef complex
#undef complex
#endif

/** \ingroup Support_modules
* \defgroup MUMPSSupport_Module MUMPSSupport module
*
* This module provides an interface to the <a href="http://mumps.enseeiht.fr/">MUMPS</a>
* library. MUMPS is a general \b multifrontal, \b parallel and \b open-source sparse solver. It
* provides the two following main factorization classes:
* - class MUMPSLDLT: a multifrontal LDLt Cholesky factorization.
* - class MUMPSLU : a multifrontal LU factorization (optimized for a symmetric pattern).
*
* \code
* #include <Eigen/MUMPSSupport>
* \endcode
*
* In order to use this module, the MUMPS headers must be accessible from the
* include paths, and your binary must be linked to the MUMPS library and its
* dependencies. This wrapper requires MUMPS version 5.1.x compiled without MPI
* support. For a CMake based project, you can use our FindMUMPS.cmake module
* to help you in this task.
*/

#include "MUMPSSupport.h"

#include "Eigen/src/Core/util/ReenableStupidWarnings.h"

#endif // EIGEN_MUMPSSUPPORT_MODULE_H

Loading

0 comments on commit 12cacd9

Please sign in to comment.