There will be maintenance performed on git.ligo.org, chat.ligo.org, containers.lig.org, and docs.ligo.org starting at 9am PDT on Tuesday 18th August 2020. There will be an extremely small period of downtime at the start of the maintenance window as various services are restarted. Please address any comments, questions, or concerns to computing-help@igwn.org.

Commit ca101df9 authored by Karl Wette's avatar Karl Wette

SWIG: add support for Octave 4.2

- Octave 4.2 requires SWIG 3.0.12 (not yet released)
- Prefer command-line octave-cli to (potentially GUI) octave
- Check output of `mkoctfile -p CXX` for any flags, e.g. -std=c++11
- Use Octave CXXFLAGS when checking headers, in case -std=* is present
- Random.h: _RANDOM_H conflicts with /usr/include/c++/5/bits/random.h (!)
- SWIGOctave.h:
  - toplev.h is already included by SWIG (and deprecated in Octave 4.2)
  - datevec.length() is deprecated, use datevec.numel() instead
  - Add as_double() and as_single() methods to array views
Original: b48d0200f538e244b1a74e0039ae50a43cd879fb
parent f42bd370
# -*- mode: autoconf; -*-
# lalsuite_swig.m4 - SWIG configuration
# Author: Karl Wette, 2011--2014
# Author: Karl Wette, 2011--2017
#
# serial 88
# serial 89
AC_DEFUN([_LALSUITE_CHECK_SWIG_VERSION],[
# $0: check the version of $1, and store it in ${swig_version}
......@@ -210,7 +210,7 @@ AC_DEFUN([LALSUITE_USE_SWIG_OCTAVE],[
LALSUITE_USE_SWIG_LANGUAGE([Octave],[C++],[cpp],[
# check for Octave
AC_PATH_PROG(OCTAVE,[octave],[],[])
AC_PATH_PROG(OCTAVE,[octave-cli octave],[],[])
AS_IF([test "x${OCTAVE}" = x],[
AC_MSG_ERROR([could not find octave in PATH])
])
......@@ -259,6 +259,12 @@ AC_DEFUN([LALSUITE_USE_SWIG_OCTAVE],[
swig_min_version_info="for Octave version ${octave_version}"
])
])
LALSUITE_VERSION_COMPARE([${octave_version}],[>=],[4.2.0],[
LALSUITE_VERSION_COMPARE([${swig_min_version}],[<],[3.0.12],[
swig_min_version=3.0.12
swig_min_version_info="for Octave version ${octave_version}"
])
])
# determine where to install Octave bindings: take versioned site .oct file
# directory given by octave-config, and strip off prefix; thus, if LALSuite
......@@ -334,9 +340,11 @@ int main() { std::string s = "a"; return 0; }
# determine Octave compiler flags
AC_SUBST([SWIG_OCTAVE_CXXFLAGS],[])
swig_octave_cxxflags=
for arg in CXXPICFLAG ALL_CXXFLAGS; do
for arg in CXX CXXPICFLAG ALL_CXXFLAGS; do
for flag in `${mkoctfile} -p ${arg} 2>/dev/null`; do
swig_octave_cxxflags="${swig_octave_cxxflags} ${flag}"
AS_CASE([${flag}],
[-*],[swig_octave_cxxflags="${swig_octave_cxxflags} ${flag}"]
)
done
done
LALSUITE_CHECK_COMPILE_FLAGS([
......@@ -367,6 +375,7 @@ int main() { std::string s = "a"; return 0; }
# check for Octave headers
LALSUITE_PUSH_UVARS
CPPFLAGS="${SWIG_OCTAVE_CPPFLAGS_IOCTAVE} ${SWIG_OCTAVE_CPPFLAGS}"
CXXFLAGS="${SWIG_OCTAVE_CXXFLAGS}"
AC_CHECK_HEADER([octave/oct.h],[],[
AC_MSG_ERROR([could not find the header "octave/oct.h"])
],[
......
......@@ -17,8 +17,8 @@
* MA 02111-1307 USA
*/
#ifndef _RANDOM_H
#define _RANDOM_H
#ifndef _LAL_RANDOM_H
#define _LAL_RANDOM_H
#include <lal/LALDatatypes.h>
#include <lal/AVFactories.h>
......@@ -155,4 +155,4 @@ void LALDestroyMTRandomParams(
}
#endif
#endif /* _RANDOM_H */
#endif /* _LAL_RANDOM_H */
//
// Copyright (C) 2011--2014 Karl Wette
// Copyright (C) 2011--2017 Karl Wette
//
// 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
......@@ -40,10 +40,14 @@ extern "C++" {
#include <octave/ov-re-mat.h>
#include <octave/ov-flt-cx-mat.h>
#include <octave/ov-cx-mat.h>
#include <octave/toplev.h>
#include <octave/Array-util.h>
}
#if defined(SWIG_OCTAVE_PREREQ)
# if SWIG_OCTAVE_PREREQ(4,2,0)
# define SWIGLAL_OCT_PREREQ_4_2_0 1
# else
# define SWIGLAL_OCT_PREREQ_4_2_0 0
# endif
# if SWIG_OCTAVE_PREREQ(4,0,0)
# define SWIGLAL_OCT_PREREQ_4_0_0 1
# else
......@@ -161,7 +165,7 @@ extern "C++" {
dim_vector dims = $input.dims();
if (dims.length() == 2 && dims.num_ones() == 1 && 3 <= dims.numel() && dims.numel() <= 6) {
RowVector datevec = $input.row_vector_value();
for (int i = 0; i < datevec.length(); ++i) {
for (int i = 0; i < datevec.numel(); ++i) {
datenum_args.append(octave_value(datevec(i)));
}
}
......@@ -641,6 +645,15 @@ SWIGINTERN bool swiglal_release_parent(void *ptr) {
#define SLOAV_OBV_METH_FROM_ARRAY_3(N, R, A, B, C) R N(A a, B b, C c) const { return sloav_array_out().N(a, b, c); }
#define SLOAV_OBV_METH_FROM_ARRAY_4(N, R, A, B, C, D) R N(A a, B b, C c, D d) const { return sloav_array_out().N(a, b, c, d); }
#define SLOAV_OBV_METH_FROM_ARRAY_5(N, R, A, B, C, D, E) R N(A a, B b, C c, D d, E e) const { return sloav_array_out().N(a, b, c, d, e); }
%#if SWIGLAL_OCT_PREREQ_4_2_0
SLOAV_OBV_METH_FROM_ARRAY_0(as_double, octave_value);
SLOAV_OBV_METH_FROM_ARRAY_0(as_single, octave_value);
%#endif
%#if SWIGLAL_OCT_PREREQ_3_3_52
SLOAV_OBV_METH_FROM_ARRAY_0(map_value, octave_map);
%#else
SLOAV_OBV_METH_FROM_ARRAY_0(map_value, Octave_map);
%#endif
SLOAV_OBV_METH_FROM_ARRAY_0(abs, octave_value);
SLOAV_OBV_METH_FROM_ARRAY_0(acos, octave_value);
SLOAV_OBV_METH_FROM_ARRAY_0(acosh, octave_value);
......@@ -683,11 +696,6 @@ SWIGINTERN bool swiglal_release_parent(void *ptr) {
SLOAV_OBV_METH_FROM_ARRAY_0(log10, octave_value);
SLOAV_OBV_METH_FROM_ARRAY_0(log1p, octave_value);
SLOAV_OBV_METH_FROM_ARRAY_0(log2, octave_value);
%#if SWIGLAL_OCT_PREREQ_3_3_52
SLOAV_OBV_METH_FROM_ARRAY_0(map_value, octave_map);
%#else
SLOAV_OBV_METH_FROM_ARRAY_0(map_value, Octave_map);
%#endif
SLOAV_OBV_METH_FROM_ARRAY_0(matrix_type, MatrixType);
SLOAV_OBV_METH_FROM_ARRAY_0(nnz, octave_idx_type);
SLOAV_OBV_METH_FROM_ARRAY_0(nzmax, octave_idx_type);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment