source: trunk/ADOL-C/swig/pyedfclasses.hpp @ 764

Last change on this file since 764 was 764, checked in by mbanovic, 4 months ago

Merge branch swig into svn.

The following commits have been merged:

commit 15c64c07d051ef872afd8bc04f772624ac3c0580
Merge: a22cb31 617f278
Author: Mladen Banovic <mladenbanovic2705@…>
Date: Wed Jan 30 14:53:13 2019 +0100

Merge branch 'swig'

commit 617f2781bde18dd7c58f3a2554dec70d94cedd92
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri Dec 21 16:23:11 2018 +0100

remove unnecessary %include

commit b7718a5407516afea3b1dabafeb3fa084a9b1ab3
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri Dec 21 16:12:06 2018 +0100

fix destructors for EDF classes

commit 79ae7862f370fbbc04033d42cfd796b429c19e5f
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri Dec 21 15:52:29 2018 +0100

improve test.py example

commit 0dbe7842bde1f9f92909fed8459e8298183c7890
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri Dec 21 15:47:43 2018 +0100

add python examples

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 08ae3d98cadfb86016a48322319548d549ae3418
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri Dec 21 15:47:14 2018 +0100

Make external functions work

EDFobject_v2 is not implemented yet

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit acfd9c5e41c2c2e99d7e530f0837dd6a5b0dac96
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Tue Dec 11 12:07:01 2018 +0100

regenerate doc

commit c673f73ee35f8b8ce74258add01e085e68c0c13a
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Tue Dec 11 12:06:21 2018 +0100

add python and R installation to doc

commit 317c3c5a6744d38091e809d804c23d637d900fe9
Author: kulshres <kulshres@94ac48a7-3327-4b6a-8511-9a4036a20e83>
Date: Wed Jun 13 15:21:36 2018 +0000

make init_lib() static to avoid name clashes in other units

git-svn-id: https://projects.coin-or.org/svn/ADOL-C/trunk@758 94ac48a7-3327-4b6a-8511-9a4036a20e83

commit 9a291b9b5646ae665382efafc3e9993c51aa4bc0
Author: kulshres <kulshres@94ac48a7-3327-4b6a-8511-9a4036a20e83>
Date: Wed Jun 13 15:02:22 2018 +0000

rename void init() to void init_lib()

this function is totally internal to tape_handling.cpp and called
from the constructor of Keeper class. However the name init() seems to refer
to something else in the scope of the class and correct initialization
isn't done, causing errors later.

git-svn-id: https://projects.coin-or.org/svn/ADOL-C/trunk@757 94ac48a7-3327-4b6a-8511-9a4036a20e83

commit f84f47f5f12c9a69ef44ccefe1b654fa3524cda3
Merge: 5021e4a 6c0d2d5
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Oct 11 21:53:14 2017 +0200

Merge branch 'swig' of gitlab.com:adol-c/adol-c into swig

commit 5021e4ab8cab3fd0760635e13c1a59e25f3c7eb6
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Oct 11 21:44:36 2017 +0200

add abs and rename asin/acos/atan to arcsin/arccos/arctan etc

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 6c0d2d5c9c90350b384b360dfb9659c9f2ca4bd6
Merge: cba0df1 2444ff3
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Oct 5 19:39:47 2017 +0000

Merge branch 'swig' into 'swig'

Python setup.py and R interface

See merge request adol-c/adol-c!11

commit 2444ff3a28e4a33a4670c8ebf6956f7c85a2274e
Merge: 068b059 946c873
Author: Sri Hari Krishna Narayanan <snarayan@…>
Date: Thu Oct 5 12:26:38 2017 -0500

Merge branch 'swig' of gitlab.com:sriharikrishna/adol-c into swig

commit 068b0592f59cbd11a434dca90be74ffbb767bde3
Author: Sri Hari Krishna Narayanan <snarayan@…>
Date: Thu Oct 5 12:19:52 2017 -0500

Change all use of clib to lib

commit ac987aca06b5c932adbd31bcf08811008b325257
Author: Sri Hari Krishna Narayanan <snarayan@…>
Date: Thu Oct 5 12:10:27 2017 -0500

Add python linking libraries

commit cba0df178387670ec3a1b94c237e13542090e78d
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Tue Sep 5 13:37:03 2017 +0200

make psdrivers numpy conformant and remove one warning

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit e450b62a4b3e501e9940400137fc89351dbdb8ba
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Tue Sep 5 13:35:07 2017 +0200

Make interface of psdrivers conformant and remove redundant parameter

Letters are as represented in the 2017 OMS paper.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 83c5f035130849b98a299857c7c5524a6ffb29a2
Merge: a50a2e1 363e176
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Aug 3 14:05:37 2017 +0200

Merge branch 'master' into swig

commit a50a2e19f79d3178592948c400d6eb89ed828b06
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Jun 22 13:52:26 2017 +0200

make setup.py install do everything

Of course this assumes you have autotools, libtool, and C++ compiler
previously installed as well as boost library and colpack.

commit 1a5f22002c83b99e8d69c297ae89cb03cc304e50
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Jun 22 13:51:41 2017 +0200

add missing support for numpy.sqrt

this was seemingly just oversight

commit f06f5011e183a203eca79444d6b175556f242f6a
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri Jun 16 12:43:46 2017 +0200

add a setup.py for compatibilty with python installers

like pip or anaconda. In this case the setup.py will compile the C/C++
original library as well as the swig wrapper.
arguments to build are:
--lib-prefix=<DIR>

will install the C/C++ library andn headers in <DIR>/include <DIR>/lib64

--colpack-dir=<DIR>

will assume that ColPack? is installed in <DIR>/include and <DIR>/lib64

--boost-dir=<DIR>

will assume that boost is installed in <DIR>/include and <DIR>/lib64

I haven't tested on anything except 64-bit linux until now.

for install I've only tested installing with --user option

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit cd793f6a8503a1e3751cfaeb843af249c522ce46
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri May 5 10:16:23 2017 +0200

a slightly more meaningful naming

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 4c2a248fe5937daf292948e8ace9af0e4ccdffc1
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri May 5 10:08:24 2017 +0200

Fix Python Exception properly

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit f272c673fcb0941f3f054462eb9843be4e8b829a
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Apr 26 17:29:37 2017 +0200

export the cleanUp() function for wrappers

commit 0ed3a9394d3ed0e2804a3cef8b39dba105817e84
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Apr 19 18:09:39 2017 +0200

python3 compatibility and slight change in swigprocess.py

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit c085c16e96c2f5bce7f4a50a77d4164bcaa47cf6
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Feb 16 15:58:46 2017 +0100

add headers for implicit inclusions in edfclasses.h

commit 239078661e4d41e6ecdb131311f2fafe560874f3
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Feb 16 09:24:17 2017 +0100

add support for vectors and matrices in octave drivers

forward and reverse drivers to come. sparse drivers to come

commit 19e89992da84bdf392233c8add69d02bed714e60
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Dec 22 10:24:44 2016 +0100

Add swig interface for octave

commit 76a264d5412c5599102a4c9a182d3163a6ab6851
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri Nov 18 15:49:36 2016 +0100

rename persistent local header to .hpp

since it is a c++ header. And some temporary .h files are created that
will require cleaning in 'make clean'

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit b59d463221a708e98af350decd97bdd26feb27d7
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri Nov 18 14:01:19 2016 +0100

reorder some lines to fix compilation and %ignore issues

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 26535bfc6d9db954c246d991b5ef09d8cd8d66d1
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Nov 17 10:43:14 2016 +0100

Add directors for python extension of edfclasses.h

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit c522a5f6400e819eb393cfe44a68cae06fbb9ffe
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Nov 2 14:26:11 2016 -0500

call() must not be overloaded by child classes either

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 98fc1f127e71c3ffef73ed43525cd21ec45942b1
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Nov 2 14:19:59 2016 -0500

init_edf() must not be overloaded by child classes

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 1e5e0c68a7a0ff3369e9a3991edaa7d04164a3e5
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Nov 2 14:05:40 2016 -0500

design a C++ object oriented wrapper for external functions

it is easier to work with classes, inheritence and overloaded member
functions in scripting languages like python and R instead of raw
pointers to functions in order to call arbitrary code.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 782465d4175a2453934cd1ffe9649e3f78a42c75
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Sep 14 09:49:12 2016 +0200

add support for calling numpy.cos and friends on adouble arrays

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit b0ed723914bdc46ce9128727972dc287288b0a71
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Aug 10 18:28:43 2016 +0200

helper for printing exception

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 6f263543749e7fcb688e8af5cde68da3745886b5
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Aug 10 18:06:59 2016 +0200

expose FatalError? to swig python interface

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 7f579bb5629eb5f5c5a49ce4d0484a306640748d
Merge: d2f49d3 3bbd2a2
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Aug 10 17:54:41 2016 +0200

Merge branch 'master' into swig

commit d2f49d373e00f583e9b7c0ee69c160fbae1322c7
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Aug 10 13:37:10 2016 +0200

improve logic in fmin and fmax

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit e138ca65b6361b23a4000c77128d0ed684662e1c
Merge: cafefb7 3c5e311
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Aug 10 13:31:06 2016 +0200

Merge remote-tracking branch 'origin/swig' into swig

commit cafefb7081ff8d5ba7c772b5b022404101b813e0
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Aug 10 13:30:32 2016 +0200

wrap newly added functions in master branch

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit ff975ebd035995f0e9dc01578ac3e84b91b1604f
Merge: 02e32a7 4c79b27
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Aug 10 13:11:42 2016 +0200

Merge remote-tracking branch 'origin/master' into swig

commit 02e32a7aa72d4310238f7ae9b85a52e29b46cf4a
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Aug 10 13:09:31 2016 +0200

add fmin, fmax, fabs, and printTapeStats for swig-python

fmin, fmax and fabs should work on scalars as well as badoubles

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 3c5e3112cdb978f0274f4d6cacd128abc034ff9b
Merge: dd06803 7aa4b9a
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Mon Aug 8 13:37:12 2016 +0200

Merge branch 'master' into swig

commit dd06803b3f40b3057976c315241f583bc0007397
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Aug 4 15:08:45 2016 +0200

raise exceptions for retracing in python

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit d253dfaa74f38b5b545f4f88ba08d86a65aa960a
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Jul 21 13:49:16 2016 +0200

fix typo in variable name

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit ade470ecf44fad03025ef9fcfadc5cac5d3e9f80
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Jul 21 11:36:06 2016 +0200

handle locint as an unsigned long

for some reason swig doesn't do this on it's own.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit e60c95d9dd70d962aed3caed4e05d0ef48ffcab2
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Jul 21 11:04:44 2016 +0200

use the compiler set up in ${CXX}

if ${CXX} is not set it defaults to 'c++'

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 42b439a47e2601325cb4d02aa27ac4b9c0535eea
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Jul 21 03:12:12 2016 +0200

add numpy compatible set_param_vec()

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 774a2204590aeb57cbc18e654bc6fe21763142c2
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Jul 21 02:41:22 2016 +0200

add function to convert numpy arrays directly to adouble arrays

works for any contiguous iterable type like list, tuple etc.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit c3e04155d83b3ee76df294c2adea78ca1df865f0
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Jul 14 10:57:43 2016 +0200

refresh swig patches for current swig master branch

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 48e0ef1cf7650d5b2e232d0d5450a158080d7849
Merge: 52445e4 06427e9
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Jul 14 10:36:59 2016 +0200

Merge branch 'master' into swig

commit 52445e41a8b768299084702418973ec79bd972c2
Merge: 666ba79 7507929
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Mar 23 14:59:05 2016 +0100

Merge branch 'master' into swig

commit 666ba7931e001bfd78171c7347b400b359dbd2d2
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Mar 23 14:58:59 2016 +0100

add reverse drivers and use kwargs for overloaded forward/reverse call

also add tapestats.
more reverse drivers coming.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit c16bf7ff198728740896a804d85684c0575c1e47
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Mon Mar 21 16:08:10 2016 +0100

add conversion for contiguous matrices and tensors

this time in the swig interface only, because they aren't
needed anywhere else.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit f3895ffd1dbb07b8a04e867982683ae8de7a5052
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Mon Mar 21 15:45:22 2016 +0100

Revert "add conversion for contiguous matrices and tensors"

This reverts commit 7ad2746027b650147ec1d2da6567a3e5a7ecb876.

commit 76eb5d0899280cb9e3b4f4c1902823a45e884774
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Mon Mar 21 13:46:12 2016 +0100

change forward drivers to return numpy arrays

instead of expecting inplace arguments

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 73bde825b256809ae07d124c1c6c66e9ae50eb82
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Mon Mar 21 12:57:20 2016 +0100

change drivers to return numpy arrays

instead of expecting inplace arguments for output

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 946c87335675e68b7ea826eadd801d8d6fca4f54
Author: Sri Hari Krishna Narayanan <sriharikrishna@…>
Date: Thu Mar 17 07:55:25 2016 -0500

R: Added special handling for sparse_jac

commit 74d1c42cf5704c5ed7ae193cab6b2344334219c5
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Tue Mar 15 14:32:47 2016 +0100

fix inclusion of sparse drivers for swig (and other users)

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit e97a73cc2a33645c517a83367d3e709ff3f4a244
Merge: de9eef7 dbc9f38
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 10 22:52:57 2016 +0000

Merge branch 'swig' into 'swig'

Swig/R

Cleanup

See merge request !4

commit dbc9f3847b58781367d8bcfd0545f3283d3ce350
Merge: b2dd718 de9eef7
Author: Sri Hari Krishna Narayanan <sriharikrishna@…>
Date: Thu Mar 10 16:45:26 2016 -0600

Merge remote-tracking branch 'origin/swig' into swig

commit b2dd71855ce277d4f956c99f04e03f954b0ff344
Author: Sri Hari Krishna Narayanan <sriharikrishna@…>
Date: Thu Mar 10 16:45:01 2016 -0600

R: removed extraneous pragmas

commit de9eef7ce7ba0d5a4256018f4d0bbf79bba25f7f
Merge: 0096858 fdaa52b
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 10 22:37:21 2016 +0000

Merge branch 'swig' into 'swig'

Swig/R

Bugfixes for SWIG/R interface

See merge request !3

commit fdaa52bf6654fa2558c2982738f4de1f49c2c960
Merge: 2fa790a 0096858
Author: Sri Hari Krishna Narayanan <sriharikrishna@…>
Date: Thu Mar 10 16:20:57 2016 -0600

Merge remote-tracking branch 'origin/swig' into swig

commit 2fa790a85c04b41755e5587baa21e59fe7416ab9
Author: Sri Hari Krishna Narayanan <sriharikrishna@…>
Date: Thu Mar 10 16:13:41 2016 -0600

R: debug all SWIG and R related bugs.

SWIG 3.0.8 needs the two patches and the generated adolc.R needs
the diff. Then ADOL-C can be imported into the R runtime by
source ("init_adolc.R")

commit 009685847f9d81b97d7efcc85d02aa7325bb6b6a
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 10 22:05:52 2016 +0100

reflect file rename in Makefile.am for packaging

commit 9c10d2065974fe1afba0284f5970e55f2e7f28b7
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 10 22:05:04 2016 +0100

add numpy implementation for common drivers

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 08b723756aa4e6ab2e6ff3f6c3d532691c831019
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 10 22:04:26 2016 +0100

change header extension to .hpp to suppress clang warning

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 109cb5ca0ae4c07592854af2a48cb6935e2e629b
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 10 20:51:16 2016 +0100

numpy: Be more verbose in error message for mismatch of dimension

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit d76918c8e2306ca2e13665fae7feb183b45652aa
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 10 19:58:08 2016 +0100

more licensing info

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 075bda30cf9d1a6432a9db4e587d6f3897ec8f1d
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 10 18:47:47 2016 +0100

compile interface based on choice

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit c368a02f8d44ad772da5659234a8bdeed254ab7c
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 10 18:21:54 2016 +0100

add numpy support to python swig interface for forward mode

also in swigprocess compatibility with macosx and general bugfixing

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 7ad2746027b650147ec1d2da6567a3e5a7ecb876
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 10 18:13:35 2016 +0100

add conversion for contiguous matrices and tensors

Just a contiguous row major chunk for matrices ins't
good for indexing using 2 indices, we need to convert
it to double and add pointers. Similarly for tensors.

These will do just that, required for supporting numpy
arrays in the python swig interface

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 41cb636430fa636b4e25ab81da73d2e6fd741dec
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 3 17:08:03 2016 +0100

more verbosity for invoking shell commands

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 82ee8be28c090f84da7eb8a1254440d301fc5675
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 3 17:07:43 2016 +0100

add copyright and licensing everywhere

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit e5ec0154c1743d68b28e3fba1864742b23e3715b
Merge: 6ac52a6 a539d68
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 3 16:28:40 2016 +0100

Merge branch 'master' into swig

commit 6ac52a6a45d8fc9c11c9b0c3b1d0399f6537eadc
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 3 16:28:33 2016 +0100

make script more verbose

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit a6ef9a80ea9593ea5f1861d3ff19315b92a75130
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Tue Feb 2 08:09:26 2016 +0100

correction in documentation of sparse functions

commit dbd7a07a1f5bcd6871d9a728f34a3d0679e01e4f
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Dec 17 22:50:11 2015 +0100

add error handling and make script python3 compatible

the swig generated interface may still not be python3 compatible

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 35ee8b63bea8bf7a0dea7af0e85f69336c6702e5
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Dec 17 18:14:12 2015 +0100

define better python operators

just renaming doesn't work. Maybe we'll need something similar in R too
but since I don't know R, I can't say.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 9654fa7e3b2a83187ee828f2ec9b39e6300ecaa7
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Dec 17 14:34:58 2015 +0100

Add a swig based python and R interface to ADOL-C

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

File size: 29.0 KB
Line 
1/*----------------------------------------------------------------------------
2 ADOL-C -- Automatic Differentiation by Overloading in C++
3 File:     pyedfclasses.h
4 Revision: $Id$
5 Contents: public functions and data types for extern (differentiated)
6           functions in python using swig. This does not compile by itself
7           without python, numpy and swig declarations being included
8
9 Copyright (c) Kshitij Kulshreshtha
10
11 This file is part of ADOL-C. This software is provided as open source.
12 Any use, reproduction, or distribution of the software constitutes
13 recipient's acceptance of the terms of the accompanying license file.
14
15----------------------------------------------------------------------------*/
16
17#ifndef _ADOLC_PYEDFCLASSES_H_
18#define _ADOLC_PYEDFCLASSES_H_
19
20#include <adolc/edfclasses.h>
21#include "pydirectors.hpp"
22
23class PyEDFwrap : public EDFobject {
24protected:
25    PyEDF* pyobj;
26public:
27    PyEDFwrap() : EDFobject() {}
28    virtual ~PyEDFwrap() {}
29    void setPyObj(PyEDF* o) { pyobj = o; }
30    int function(int n, double *x, int m, double* y) {
31        PyObject* args = NULL; 
32        int rc;
33        npy_intp in[1] = { n }, out[1] = { m };
34        PyObject* xa = PyArray_SimpleNewFromData(1,in,NPY_DOUBLE,(void*)x);
35        PyObject* ya = PyArray_SimpleNewFromData(1,out,NPY_DOUBLE,(void*)y);
36        PyObject* no = PyInt_FromLong((long int)n);
37        PyObject* mo = PyInt_FromLong((long int)m);
38        PyArrayObject *xaa = (PyArrayObject*) xa, *yaa = (PyArrayObject*) ya;
39#ifdef SWIGPY_USE_CAPSULE
40        PyObject* capx = PyCapsule_New((void*)(x), SWIGPY_CAPSULE_NAME, NULL);
41        PyObject* capy = PyCapsule_New((void*)(y), SWIGPY_CAPSULE_NAME, NULL);
42#else
43        PyObject* capx = PyCObject_FromVoidPtr((void*)(x), NULL);
44        PyObject* capy = PyCObject_FromVoidPtr((void*)(y), NULL);
45#endif
46#if NPY_API_VERSION < 0x00000007
47        PyArray_BASE(xaa) = capx;
48        PyArray_BASE(yaa) = capy;
49#else
50        PyArray_SetBaseObject(xaa,capx);
51        PyArray_SetBaseObject(yaa,capy);
52#endif
53        //args = Py_BuildValue("OOOO:PyEDFobject_function",no,xa,mo,ya);
54        args = PyTuple_Pack(4,no,xa,mo,ya);
55        rc = pyobj->function(args);
56        if (PyErr_Occurred()) rc = -1;
57        Py_DECREF(args);
58        Py_DECREF(xaa);
59        Py_DECREF(yaa);
60        Py_DECREF(no);
61        Py_DECREF(mo);
62        return rc;
63    }
64    int zos_forward(int n, double *x, int m, double* y) {
65        PyObject* args = NULL; 
66        int rc;
67        npy_intp in[1] = { n }, out[1] = { m };
68        PyObject* xa = PyArray_SimpleNewFromData(1,in,NPY_DOUBLE,(void*)x);
69        PyObject* ya = PyArray_SimpleNewFromData(1,out,NPY_DOUBLE,(void*)y);
70        PyObject* no = PyInt_FromLong((long int)n);
71        PyObject* mo = PyInt_FromLong((long int)m);
72        PyArrayObject *xaa = (PyArrayObject*) xa, *yaa = (PyArrayObject*) ya;
73#ifdef SWIGPY_USE_CAPSULE
74        PyObject* capx = PyCapsule_New((void*)(x), SWIGPY_CAPSULE_NAME, NULL);
75        PyObject* capy = PyCapsule_New((void*)(y), SWIGPY_CAPSULE_NAME, NULL);
76#else
77        PyObject* capx = PyCObject_FromVoidPtr((void*)(x), NULL);
78        PyObject* capy = PyCObject_FromVoidPtr((void*)(y), NULL);
79#endif
80#if NPY_API_VERSION < 0x00000007
81        PyArray_BASE(xaa) = capx;
82        PyArray_BASE(yaa) = capy;
83#else
84        PyArray_SetBaseObject(xaa,capx);
85        PyArray_SetBaseObject(yaa,capy);
86#endif
87        //args = Py_BuildValue("OOOO:PyEDFobject_function",no,xa,mo,ya);
88        args = PyTuple_Pack(4,no,xa,mo,ya);
89        rc = pyobj->zos_forward(args);
90        if (PyErr_Occurred()) rc = -1;
91        Py_DECREF(args);
92        Py_DECREF(xaa);
93        Py_DECREF(yaa);
94        Py_DECREF(no);
95        Py_DECREF(mo);
96        return rc;
97    }
98    int fos_forward(int n, double *x, double *xp, int m, double *y, double *yp) {
99        PyObject* args = NULL; 
100        int rc;
101        npy_intp in[1] = { n }, out[1] = { m };
102        PyObject* xa = PyArray_SimpleNewFromData(1,in,NPY_DOUBLE,(void*)x);
103        PyObject* ya = PyArray_SimpleNewFromData(1,out,NPY_DOUBLE,(void*)y);
104        PyObject* xpa = PyArray_SimpleNewFromData(1,in,NPY_DOUBLE,(void*)xp);
105        PyObject* ypa = PyArray_SimpleNewFromData(1,out,NPY_DOUBLE,(void*)yp);
106        PyObject* no = PyInt_FromLong((long int)n);
107        PyObject* mo = PyInt_FromLong((long int)m);
108        PyArrayObject *xaa = (PyArrayObject*) xa, *yaa = (PyArrayObject*) ya;
109        PyArrayObject *xpaa = (PyArrayObject*) xpa, *ypaa = (PyArrayObject*) ypa;
110#ifdef SWIGPY_USE_CAPSULE
111        PyObject* capx = PyCapsule_New((void*)(x), SWIGPY_CAPSULE_NAME, NULL);
112        PyObject* capy = PyCapsule_New((void*)(y), SWIGPY_CAPSULE_NAME, NULL);
113        PyObject* capxp = PyCapsule_New((void*)(xp), SWIGPY_CAPSULE_NAME, NULL);
114        PyObject* capyp = PyCapsule_New((void*)(yp), SWIGPY_CAPSULE_NAME, NULL);
115#else
116        PyObject* capx = PyCObject_FromVoidPtr((void*)(x), NULL);
117        PyObject* capy = PyCObject_FromVoidPtr((void*)(y), NULL);
118        PyObject* capxp = PyCObject_FromVoidPtr((void*)(xp), NULL);
119        PyObject* capyp = PyCObject_FromVoidPtr((void*)(yp), NULL);
120#endif
121#if NPY_API_VERSION < 0x00000007
122        PyArray_BASE(xaa) = capx;
123        PyArray_BASE(yaa) = capy;
124        PyArray_BASE(xpaa) = capxp;
125        PyArray_BASE(ypaa) = capyp;
126#else
127        PyArray_SetBaseObject(xaa,capx);
128        PyArray_SetBaseObject(yaa,capy);
129        PyArray_SetBaseObject(xpaa,capxp);
130        PyArray_SetBaseObject(ypaa,capyp);
131#endif
132        args = PyTuple_Pack(6,no,xa,xpa,mo,ya,ypa);
133        rc = pyobj->fos_forward(args);
134        if (PyErr_Occurred()) rc = -1;
135        Py_DECREF(args);
136        Py_DECREF(xaa);
137        Py_DECREF(yaa);
138        Py_DECREF(xpaa);
139        Py_DECREF(ypaa);
140        Py_DECREF(no);
141        Py_DECREF(mo);
142        return rc;
143    }
144    int fov_forward(int n, double *x, int p, double **Xp, int m, double *y, double **Yp) {
145        PyObject* args = NULL; 
146        int rc;
147        npy_intp in[1] = { n }, out[1] = { m };
148        npy_intp inp[2] = { n,p }, outp[2] = { m,p };
149        PyObject* xa = PyArray_SimpleNewFromData(1,in,NPY_DOUBLE,(void*)x);
150        PyObject* ya = PyArray_SimpleNewFromData(1,out,NPY_DOUBLE,(void*)y);
151        PyObject* xpa = PyArray_SimpleNewFromData(2,inp,NPY_DOUBLE,(void*)&Xp[0][0]);
152        PyObject* ypa = PyArray_SimpleNewFromData(2,outp,NPY_DOUBLE,(void*)&Yp[0][0]);
153        PyObject* no = PyInt_FromLong((long int)n);
154        PyObject* mo = PyInt_FromLong((long int)m);
155        PyObject* po = PyInt_FromLong((long int)p);
156        PyArrayObject *xaa = (PyArrayObject*) xa, *yaa = (PyArrayObject*) ya;
157        PyArrayObject *xpaa = (PyArrayObject*) xpa, *ypaa = (PyArrayObject*) ypa;
158#ifdef SWIGPY_USE_CAPSULE
159        PyObject* capx = PyCapsule_New((void*)(x), SWIGPY_CAPSULE_NAME, NULL);
160        PyObject* capy = PyCapsule_New((void*)(y), SWIGPY_CAPSULE_NAME, NULL);
161        PyObject* capxp = PyCapsule_New((void*)(Xp), SWIGPY_CAPSULE_NAME, NULL);
162        PyObject* capyp = PyCapsule_New((void*)(Yp), SWIGPY_CAPSULE_NAME, NULL);
163#else
164        PyObject* capx = PyCObject_FromVoidPtr((void*)(x), NULL);
165        PyObject* capy = PyCObject_FromVoidPtr((void*)(y), NULL);
166        PyObject* capxp = PyCObject_FromVoidPtr((void*)(Xp), NULL);
167        PyObject* capyp = PyCObject_FromVoidPtr((void*)(Yp), NULL);
168#endif
169#if NPY_API_VERSION < 0x00000007
170        PyArray_BASE(xaa) = capx;
171        PyArray_BASE(yaa) = capy;
172        PyArray_BASE(xpaa) = capxp;
173        PyArray_BASE(ypaa) = capyp;
174#else
175        PyArray_SetBaseObject(xaa,capx);
176        PyArray_SetBaseObject(yaa,capy);
177        PyArray_SetBaseObject(xpaa,capxp);
178        PyArray_SetBaseObject(ypaa,capyp);
179#endif
180        args = PyTuple_Pack(7,no,xa,po,xpa,mo,ya,ypa);
181        rc = pyobj->fov_forward(args);
182        if (PyErr_Occurred()) rc = -1;
183        Py_DECREF(args);
184        Py_DECREF(xaa);
185        Py_DECREF(yaa);
186        Py_DECREF(xpaa);
187        Py_DECREF(ypaa);
188        Py_DECREF(no);
189        Py_DECREF(mo);
190        Py_DECREF(po);
191        return rc;
192    }
193    int fos_reverse(int m, double *U, int n, double *Z, double *x, double *y) {
194        PyObject* args = NULL; 
195        int rc;
196        npy_intp in[1] = { n }, out[1] = { m };
197        PyObject* xa = PyArray_SimpleNewFromData(1,in,NPY_DOUBLE,(void*)x);
198        PyObject* ya = PyArray_SimpleNewFromData(1,out,NPY_DOUBLE,(void*)y);
199        PyObject* ua = PyArray_SimpleNewFromData(1,out,NPY_DOUBLE,(void*)U);
200        PyObject* za = PyArray_SimpleNewFromData(1,in,NPY_DOUBLE,(void*)Z);
201        PyObject* no = PyInt_FromLong((long int)n);
202        PyObject* mo = PyInt_FromLong((long int)m);
203        PyArrayObject *xaa = (PyArrayObject*) xa, *yaa = (PyArrayObject*) ya;
204        PyArrayObject *uaa = (PyArrayObject*) ua, *zaa = (PyArrayObject*) za;
205#ifdef SWIGPY_USE_CAPSULE
206        PyObject* capx = PyCapsule_New((void*)(x), SWIGPY_CAPSULE_NAME, NULL);
207        PyObject* capy = PyCapsule_New((void*)(y), SWIGPY_CAPSULE_NAME, NULL);
208        PyObject* capu = PyCapsule_New((void*)(U), SWIGPY_CAPSULE_NAME, NULL);
209        PyObject* capz = PyCapsule_New((void*)(Z), SWIGPY_CAPSULE_NAME, NULL);
210#else
211        PyObject* capx = PyCObject_FromVoidPtr((void*)(x), NULL);
212        PyObject* capy = PyCObject_FromVoidPtr((void*)(y), NULL);
213        PyObject* capu = PyCObject_FromVoidPtr((void*)(U), NULL);
214        PyObject* capz = PyCObject_FromVoidPtr((void*)(Z), NULL);
215#endif
216#if NPY_API_VERSION < 0x00000007
217        PyArray_BASE(xaa) = capx;
218        PyArray_BASE(yaa) = capy;
219        PyArray_BASE(uaa) = capu;
220        PyArray_BASE(zaa) = capz;
221#else
222        PyArray_SetBaseObject(xaa,capx);
223        PyArray_SetBaseObject(yaa,capy);
224        PyArray_SetBaseObject(uaa,capu);
225        PyArray_SetBaseObject(zaa,capz);
226#endif
227        args = PyTuple_Pack(6,mo,ua,no,za,xa,ya);
228        rc = pyobj->fos_reverse(args);
229        if (PyErr_Occurred()) rc = -1;
230        Py_DECREF(args);
231        Py_DECREF(xaa);
232        Py_DECREF(yaa);
233        Py_DECREF(uaa);
234        Py_DECREF(zaa);
235        Py_DECREF(no);
236        Py_DECREF(mo);
237        return rc;
238    }
239    int fov_reverse(int m, int q, double **U, int n, double **Z, double *x, double *y) {
240        PyObject* args = NULL; 
241        int rc;
242        npy_intp in[1] = { n }, out[1] = { m };
243        npy_intp inq[2] = { n,q }, outq[2] = { m,q };
244        PyObject* xa = PyArray_SimpleNewFromData(1,in,NPY_DOUBLE,(void*)x);
245        PyObject* ya = PyArray_SimpleNewFromData(1,out,NPY_DOUBLE,(void*)y);
246        PyObject* ua = PyArray_SimpleNewFromData(1,outq,NPY_DOUBLE,(void*)&U[0][0]);
247        PyObject* za = PyArray_SimpleNewFromData(1,inq,NPY_DOUBLE,(void*)&Z[0][0]);
248        PyObject* no = PyInt_FromLong((long int)n);
249        PyObject* mo = PyInt_FromLong((long int)m);
250        PyObject* qo = PyInt_FromLong((long int)q);
251        PyArrayObject *xaa = (PyArrayObject*) xa, *yaa = (PyArrayObject*) ya;
252        PyArrayObject *uaa = (PyArrayObject*) ua, *zaa = (PyArrayObject*) za;
253#ifdef SWIGPY_USE_CAPSULE
254        PyObject* capx = PyCapsule_New((void*)(x), SWIGPY_CAPSULE_NAME, NULL);
255        PyObject* capy = PyCapsule_New((void*)(y), SWIGPY_CAPSULE_NAME, NULL);
256        PyObject* capu = PyCapsule_New((void*)(U), SWIGPY_CAPSULE_NAME, NULL);
257        PyObject* capz = PyCapsule_New((void*)(Z), SWIGPY_CAPSULE_NAME, NULL);
258#else
259        PyObject* capx = PyCObject_FromVoidPtr((void*)(x), NULL);
260        PyObject* capy = PyCObject_FromVoidPtr((void*)(y), NULL);
261        PyObject* capu = PyCObject_FromVoidPtr((void*)(U), NULL);
262        PyObject* capz = PyCObject_FromVoidPtr((void*)(Z), NULL);
263#endif
264#if NPY_API_VERSION < 0x00000007
265        PyArray_BASE(xaa) = capx;
266        PyArray_BASE(yaa) = capy;
267        PyArray_BASE(uaa) = capu;
268        PyArray_BASE(zaa) = capz;
269#else
270        PyArray_SetBaseObject(xaa,capx);
271        PyArray_SetBaseObject(yaa,capy);
272        PyArray_SetBaseObject(uaa,capu);
273        PyArray_SetBaseObject(zaa,capz);
274#endif
275        args = PyTuple_Pack(7,mo,qo,ua,no,za,xa,ya);
276        rc = pyobj->fov_reverse(args);
277        if (PyErr_Occurred()) rc = -1;
278        Py_DECREF(args);
279        Py_DECREF(xaa);
280        Py_DECREF(yaa);
281        Py_DECREF(uaa);
282        Py_DECREF(zaa);
283        Py_DECREF(no);
284        Py_DECREF(mo);
285        Py_DECREF(qo);
286        return rc;
287    }
288    int call(int n, adouble *xa, int m, adouble *ya) {
289        return EDFobject::call(n,xa,m,ya);
290    }
291    int call(int n, advector& x, int m, advector& y) {
292        return EDFobject::call(n,x,m,y);
293    }
294};
295
296PyEDF::PyEDF() {
297     cobj = new PyEDFwrap();
298     cobj->setPyObj(this);
299}
300
301PyEDF::~PyEDF() {
302    delete cobj;
303}
304
305int PyEDF::call(int n, adouble *xa, int m, adouble *ya) {
306    return cobj->call(n,xa,m,ya);
307}
308int PyEDF::call(int n, advector& x, int m, advector& y) {
309    return cobj->call(n,x,m,y);
310}
311
312class PyEDF_iArr_wrap : public EDFobject_iArr {
313protected:
314    PyEDF_iArr* pyobj;
315public:
316    PyEDF_iArr_wrap() : EDFobject_iArr() {}
317    virtual ~PyEDF_iArr_wrap() {}
318    void setPyObj(PyEDF_iArr* o) { pyobj = o; }
319    int function(int iArrLen, int* iArr, int n, double *x, int m, double* y) {
320        PyObject* args = NULL; 
321        int rc;
322        npy_intp in[1] = { n }, out[1] = { m }, arrsz[1] =  { iArrLen };
323        PyObject* iar = PyArray_SimpleNewFromData(1,arrsz,NPY_INT,(void*)iArr);
324        PyObject* xa = PyArray_SimpleNewFromData(1,in,NPY_DOUBLE,(void*)x);
325        PyObject* ya = PyArray_SimpleNewFromData(1,out,NPY_DOUBLE,(void*)y);
326        PyObject* no = PyInt_FromLong((long int)n);
327        PyObject* mo = PyInt_FromLong((long int)m);
328        PyObject* ial = PyInt_FromLong((long int)iArrLen);
329        PyArrayObject *xaa = (PyArrayObject*) xa, *yaa = (PyArrayObject*) ya;
330        PyArrayObject *iara = (PyArrayObject*) iar;
331#ifdef SWIGPY_USE_CAPSULE
332        PyObject* capiar = PyCapsule_New((void*)(iArr), SWIGPY_CAPSULE_NAME, NULL);
333        PyObject* capx = PyCapsule_New((void*)(x), SWIGPY_CAPSULE_NAME, NULL);
334        PyObject* capy = PyCapsule_New((void*)(y), SWIGPY_CAPSULE_NAME, NULL);
335#else
336        PyObject* capiar = PyCObject_FromVoidPtr((void*)(iArr), NULL);
337        PyObject* capx = PyCObject_FromVoidPtr((void*)(x), NULL);
338        PyObject* capy = PyCObject_FromVoidPtr((void*)(y), NULL);
339#endif
340#if NPY_API_VERSION < 0x00000007
341        PyArray_BASE(iara) = capiar;
342        PyArray_BASE(xaa) = capx;
343        PyArray_BASE(yaa) = capy;
344#else
345        PyArray_SetBaseObject(iara,capiar);
346        PyArray_SetBaseObject(xaa,capx);
347        PyArray_SetBaseObject(yaa,capy);
348#endif
349        //args = Py_BuildValue("OOOO:PyEDFobject_function",no,xa,mo,ya);
350        args = PyTuple_Pack(6,ial,iar,no,xa,mo,ya);
351        rc = pyobj->function(args);
352        if (PyErr_Occurred()) rc = -1;
353        Py_DECREF(args);
354        Py_DECREF(iara);
355        Py_DECREF(xaa);
356        Py_DECREF(yaa);
357        Py_DECREF(no);
358        Py_DECREF(mo);
359        Py_DECREF(ial);
360        return rc;
361    }
362    int zos_forward(int iArrLen, int* iArr, int n, double *x, int m, double* y) {
363        PyObject* args = NULL; 
364        int rc;
365        npy_intp in[1] = { n }, out[1] = { m }, arrsz[1] =  { iArrLen };
366        PyObject* iar = PyArray_SimpleNewFromData(1,arrsz,NPY_INT,(void*)iArr);
367        PyObject* xa = PyArray_SimpleNewFromData(1,in,NPY_DOUBLE,(void*)x);
368        PyObject* ya = PyArray_SimpleNewFromData(1,out,NPY_DOUBLE,(void*)y);
369        PyObject* no = PyInt_FromLong((long int)n);
370        PyObject* mo = PyInt_FromLong((long int)m);
371        PyObject* ial = PyInt_FromLong((long int)iArrLen);
372        PyArrayObject *xaa = (PyArrayObject*) xa, *yaa = (PyArrayObject*) ya;
373        PyArrayObject *iara = (PyArrayObject*) iar;
374#ifdef SWIGPY_USE_CAPSULE
375        PyObject* capiar = PyCapsule_New((void*)(iArr), SWIGPY_CAPSULE_NAME, NULL);
376        PyObject* capx = PyCapsule_New((void*)(x), SWIGPY_CAPSULE_NAME, NULL);
377        PyObject* capy = PyCapsule_New((void*)(y), SWIGPY_CAPSULE_NAME, NULL);
378#else
379        PyObject* capiar = PyCObject_FromVoidPtr((void*)(iArr), NULL);
380        PyObject* capx = PyCObject_FromVoidPtr((void*)(x), NULL);
381        PyObject* capy = PyCObject_FromVoidPtr((void*)(y), NULL);
382#endif
383#if NPY_API_VERSION < 0x00000007
384        PyArray_BASE(iara) = capiar;
385        PyArray_BASE(xaa) = capx;
386        PyArray_BASE(yaa) = capy;
387#else
388        PyArray_SetBaseObject(iara,capiar);
389        PyArray_SetBaseObject(xaa,capx);
390        PyArray_SetBaseObject(yaa,capy);
391#endif
392        //args = Py_BuildValue("OOOO:PyEDFobject_function",no,xa,mo,ya);
393        args = PyTuple_Pack(6,ial,iar,no,xa,mo,ya);
394        rc = pyobj->zos_forward(args);
395        if (PyErr_Occurred()) rc = -1;
396        Py_DECREF(args);
397        Py_DECREF(iara);
398        Py_DECREF(xaa);
399        Py_DECREF(yaa);
400        Py_DECREF(no);
401        Py_DECREF(mo);
402        Py_DECREF(ial);
403        return rc;
404    }
405    int fos_forward(int iArrLen, int* iArr, int n, double *x, double *xp, int m, double *y, double *yp) {
406        PyObject* args = NULL; 
407        int rc;
408        npy_intp in[1] = { n }, out[1] = { m }, arrsz[1] =  { iArrLen };
409        PyObject* iar = PyArray_SimpleNewFromData(1,arrsz,NPY_INT,(void*)iArr);
410        PyObject* xa = PyArray_SimpleNewFromData(1,in,NPY_DOUBLE,(void*)x);
411        PyObject* ya = PyArray_SimpleNewFromData(1,out,NPY_DOUBLE,(void*)y);
412        PyObject* xpa = PyArray_SimpleNewFromData(1,in,NPY_DOUBLE,(void*)xp);
413        PyObject* ypa = PyArray_SimpleNewFromData(1,out,NPY_DOUBLE,(void*)yp);
414        PyObject* no = PyInt_FromLong((long int)n);
415        PyObject* mo = PyInt_FromLong((long int)m);
416        PyObject* ial = PyInt_FromLong((long int)iArrLen);
417        PyArrayObject *xaa = (PyArrayObject*) xa, *yaa = (PyArrayObject*) ya;
418        PyArrayObject *xpaa = (PyArrayObject*) xpa, *ypaa = (PyArrayObject*) ypa;
419        PyArrayObject *iara = (PyArrayObject*) iar;
420#ifdef SWIGPY_USE_CAPSULE
421        PyObject* capiar = PyCapsule_New((void*)(iArr), SWIGPY_CAPSULE_NAME, NULL);
422        PyObject* capx = PyCapsule_New((void*)(x), SWIGPY_CAPSULE_NAME, NULL);
423        PyObject* capy = PyCapsule_New((void*)(y), SWIGPY_CAPSULE_NAME, NULL);
424        PyObject* capxp = PyCapsule_New((void*)(xp), SWIGPY_CAPSULE_NAME, NULL);
425        PyObject* capyp = PyCapsule_New((void*)(yp), SWIGPY_CAPSULE_NAME, NULL);
426#else
427        PyObject* capiar = PyCObject_FromVoidPtr((void*)(iArr), NULL);
428        PyObject* capx = PyCObject_FromVoidPtr((void*)(x), NULL);
429        PyObject* capy = PyCObject_FromVoidPtr((void*)(y), NULL);
430        PyObject* capxp = PyCObject_FromVoidPtr((void*)(xp), NULL);
431        PyObject* capyp = PyCObject_FromVoidPtr((void*)(yp), NULL);
432#endif
433#if NPY_API_VERSION < 0x00000007
434        PyArray_BASE(iara) = capiar;
435        PyArray_BASE(xaa) = capx;
436        PyArray_BASE(yaa) = capy;
437        PyArray_BASE(xpaa) = capxp;
438        PyArray_BASE(ypaa) = capyp;
439#else
440        PyArray_SetBaseObject(iara,capiar);
441        PyArray_SetBaseObject(xaa,capx);
442        PyArray_SetBaseObject(yaa,capy);
443        PyArray_SetBaseObject(xpaa,capxp);
444        PyArray_SetBaseObject(ypaa,capyp);
445#endif
446        args = PyTuple_Pack(8,ial,iar,no,xa,xpa,mo,ya,ypa);
447        rc = pyobj->fos_forward(args);
448        if (PyErr_Occurred()) rc = -1;
449        Py_DECREF(args);
450        Py_DECREF(iara);
451        Py_DECREF(xaa);
452        Py_DECREF(yaa);
453        Py_DECREF(xpaa);
454        Py_DECREF(ypaa);
455        Py_DECREF(no);
456        Py_DECREF(mo);
457        Py_DECREF(ial);
458        return rc;
459    }
460    int fov_forward(int iArrLen, int* iArr, int n, double *x, int p, double **Xp, int m, double *y, double **Yp) {
461        PyObject* args = NULL; 
462        int rc;
463        npy_intp in[1] = { n }, out[1] = { m }, arrsz[1] =  { iArrLen };
464        npy_intp inp[2] = { n,p }, outp[2] = { m,p };
465        PyObject* iar = PyArray_SimpleNewFromData(1,arrsz,NPY_INT,(void*)iArr);
466        PyObject* xa = PyArray_SimpleNewFromData(1,in,NPY_DOUBLE,(void*)x);
467        PyObject* ya = PyArray_SimpleNewFromData(1,out,NPY_DOUBLE,(void*)y);
468        PyObject* xpa = PyArray_SimpleNewFromData(2,inp,NPY_DOUBLE,(void*)&Xp[0][0]);
469        PyObject* ypa = PyArray_SimpleNewFromData(2,outp,NPY_DOUBLE,(void*)&Yp[0][0]);
470        PyObject* no = PyInt_FromLong((long int)n);
471        PyObject* mo = PyInt_FromLong((long int)m);
472        PyObject* po = PyInt_FromLong((long int)p);
473        PyObject* ial = PyInt_FromLong((long int)iArrLen);
474        PyArrayObject *xaa = (PyArrayObject*) xa, *yaa = (PyArrayObject*) ya;
475        PyArrayObject *xpaa = (PyArrayObject*) xpa, *ypaa = (PyArrayObject*) ypa;
476        PyArrayObject *iara = (PyArrayObject*) iar;
477#ifdef SWIGPY_USE_CAPSULE
478        PyObject* capiar = PyCapsule_New((void*)(iArr), SWIGPY_CAPSULE_NAME, NULL);
479        PyObject* capx = PyCapsule_New((void*)(x), SWIGPY_CAPSULE_NAME, NULL);
480        PyObject* capy = PyCapsule_New((void*)(y), SWIGPY_CAPSULE_NAME, NULL);
481        PyObject* capxp = PyCapsule_New((void*)(Xp), SWIGPY_CAPSULE_NAME, NULL);
482        PyObject* capyp = PyCapsule_New((void*)(Yp), SWIGPY_CAPSULE_NAME, NULL);
483#else
484        PyObject* capiar = PyCObject_FromVoidPtr((void*)(iArr), NULL);
485        PyObject* capx = PyCObject_FromVoidPtr((void*)(x), NULL);
486        PyObject* capy = PyCObject_FromVoidPtr((void*)(y), NULL);
487        PyObject* capxp = PyCObject_FromVoidPtr((void*)(Xp), NULL);
488        PyObject* capyp = PyCObject_FromVoidPtr((void*)(Yp), NULL);
489#endif
490#if NPY_API_VERSION < 0x00000007
491        PyArray_BASE(iara) = capiar;
492        PyArray_BASE(xaa) = capx;
493        PyArray_BASE(yaa) = capy;
494        PyArray_BASE(xpaa) = capxp;
495        PyArray_BASE(ypaa) = capyp;
496#else
497        PyArray_SetBaseObject(iara,capiar);
498        PyArray_SetBaseObject(xaa,capx);
499        PyArray_SetBaseObject(yaa,capy);
500        PyArray_SetBaseObject(xpaa,capxp);
501        PyArray_SetBaseObject(ypaa,capyp);
502#endif
503        args = PyTuple_Pack(9,ial,iar,no,xa,po,xpa,mo,ya,ypa);
504        rc = pyobj->fov_forward(args);
505        if (PyErr_Occurred()) rc = -1;
506        Py_DECREF(args);
507        Py_DECREF(iara);
508        Py_DECREF(xaa);
509        Py_DECREF(yaa);
510        Py_DECREF(xpaa);
511        Py_DECREF(ypaa);
512        Py_DECREF(no);
513        Py_DECREF(mo);
514        Py_DECREF(po);
515        Py_DECREF(ial);
516        return rc;
517    }
518    int fos_reverse(int iArrLen, int* iArr, int m, double *U, int n, double *Z, double *x, double *y) {
519        PyObject* args = NULL; 
520        int rc;
521        npy_intp in[1] = { n }, out[1] = { m }, arrsz[1] =  { iArrLen };
522        PyObject* iar = PyArray_SimpleNewFromData(1,arrsz,NPY_INT,(void*)iArr);
523        PyObject* xa = PyArray_SimpleNewFromData(1,in,NPY_DOUBLE,(void*)x);
524        PyObject* ya = PyArray_SimpleNewFromData(1,out,NPY_DOUBLE,(void*)y);
525        PyObject* ua = PyArray_SimpleNewFromData(1,out,NPY_DOUBLE,(void*)U);
526        PyObject* za = PyArray_SimpleNewFromData(1,in,NPY_DOUBLE,(void*)Z);
527        PyObject* no = PyInt_FromLong((long int)n);
528        PyObject* mo = PyInt_FromLong((long int)m);
529        PyObject* ial = PyInt_FromLong((long int)iArrLen);
530        PyArrayObject *xaa = (PyArrayObject*) xa, *yaa = (PyArrayObject*) ya;
531        PyArrayObject *uaa = (PyArrayObject*) ua, *zaa = (PyArrayObject*) za;
532        PyArrayObject *iara = (PyArrayObject*) iar;
533#ifdef SWIGPY_USE_CAPSULE
534        PyObject* capiar = PyCapsule_New((void*)(iArr), SWIGPY_CAPSULE_NAME, NULL);
535        PyObject* capx = PyCapsule_New((void*)(x), SWIGPY_CAPSULE_NAME, NULL);
536        PyObject* capy = PyCapsule_New((void*)(y), SWIGPY_CAPSULE_NAME, NULL);
537        PyObject* capu = PyCapsule_New((void*)(U), SWIGPY_CAPSULE_NAME, NULL);
538        PyObject* capz = PyCapsule_New((void*)(Z), SWIGPY_CAPSULE_NAME, NULL);
539#else
540        PyObject* capiar = PyCObject_FromVoidPtr((void*)(iArr), NULL);
541        PyObject* capx = PyCObject_FromVoidPtr((void*)(x), NULL);
542        PyObject* capy = PyCObject_FromVoidPtr((void*)(y), NULL);
543        PyObject* capu = PyCObject_FromVoidPtr((void*)(U), NULL);
544        PyObject* capz = PyCObject_FromVoidPtr((void*)(Z), NULL);
545#endif
546#if NPY_API_VERSION < 0x00000007
547        PyArray_BASE(iara) = capiar;
548        PyArray_BASE(xaa) = capx;
549        PyArray_BASE(yaa) = capy;
550        PyArray_BASE(uaa) = capu;
551        PyArray_BASE(zaa) = capz;
552#else
553        PyArray_SetBaseObject(iara,capiar);
554        PyArray_SetBaseObject(xaa,capx);
555        PyArray_SetBaseObject(yaa,capy);
556        PyArray_SetBaseObject(uaa,capu);
557        PyArray_SetBaseObject(zaa,capz);
558#endif
559        args = PyTuple_Pack(8,ial,iar,mo,ua,no,za,xa,ya);
560        rc = pyobj->fos_reverse(args);
561        if (PyErr_Occurred()) rc = -1;
562        Py_DECREF(args);
563        Py_DECREF(iara);
564        Py_DECREF(xaa);
565        Py_DECREF(yaa);
566        Py_DECREF(uaa);
567        Py_DECREF(zaa);
568        Py_DECREF(no);
569        Py_DECREF(mo);
570        Py_DECREF(ial);
571        return rc;
572    }
573    int fov_reverse(int iArrLen, int* iArr, int m, int q, double **U, int n, double **Z, double *x, double *y) {
574        PyObject* args = NULL; 
575        int rc;
576        npy_intp in[1] = { n }, out[1] = { m }, arrsz[1] =  { iArrLen };
577        npy_intp inq[2] = { n,q }, outq[2] = { m,q };
578        PyObject* iar = PyArray_SimpleNewFromData(1,arrsz,NPY_INT,(void*)iArr);
579        PyObject* xa = PyArray_SimpleNewFromData(1,in,NPY_DOUBLE,(void*)x);
580        PyObject* ya = PyArray_SimpleNewFromData(1,out,NPY_DOUBLE,(void*)y);
581        PyObject* ua = PyArray_SimpleNewFromData(1,outq,NPY_DOUBLE,(void*)&U[0][0]);
582        PyObject* za = PyArray_SimpleNewFromData(1,inq,NPY_DOUBLE,(void*)&Z[0][0]);
583        PyObject* no = PyInt_FromLong((long int)n);
584        PyObject* mo = PyInt_FromLong((long int)m);
585        PyObject* qo = PyInt_FromLong((long int)q);
586        PyObject* ial = PyInt_FromLong((long int)iArrLen);
587        PyArrayObject *xaa = (PyArrayObject*) xa, *yaa = (PyArrayObject*) ya;
588        PyArrayObject *uaa = (PyArrayObject*) ua, *zaa = (PyArrayObject*) za;
589        PyArrayObject *iara = (PyArrayObject*) iar;
590#ifdef SWIGPY_USE_CAPSULE
591        PyObject* capiar = PyCapsule_New((void*)(iArr), SWIGPY_CAPSULE_NAME, NULL);
592        PyObject* capx = PyCapsule_New((void*)(x), SWIGPY_CAPSULE_NAME, NULL);
593        PyObject* capy = PyCapsule_New((void*)(y), SWIGPY_CAPSULE_NAME, NULL);
594        PyObject* capu = PyCapsule_New((void*)(U), SWIGPY_CAPSULE_NAME, NULL);
595        PyObject* capz = PyCapsule_New((void*)(Z), SWIGPY_CAPSULE_NAME, NULL);
596#else
597        PyObject* capiar = PyCObject_FromVoidPtr((void*)(iArr), NULL);
598        PyObject* capx = PyCObject_FromVoidPtr((void*)(x), NULL);
599        PyObject* capy = PyCObject_FromVoidPtr((void*)(y), NULL);
600        PyObject* capu = PyCObject_FromVoidPtr((void*)(U), NULL);
601        PyObject* capz = PyCObject_FromVoidPtr((void*)(Z), NULL);
602#endif
603#if NPY_API_VERSION < 0x00000007
604        PyArray_BASE(iara) = capiar;
605        PyArray_BASE(xaa) = capx;
606        PyArray_BASE(yaa) = capy;
607        PyArray_BASE(uaa) = capu;
608        PyArray_BASE(zaa) = capz;
609#else
610        PyArray_SetBaseObject(iara,capiar);
611        PyArray_SetBaseObject(xaa,capx);
612        PyArray_SetBaseObject(yaa,capy);
613        PyArray_SetBaseObject(uaa,capu);
614        PyArray_SetBaseObject(zaa,capz);
615#endif
616        args = PyTuple_Pack(9,ial,iar,mo,qo,ua,no,za,xa,ya);
617        rc = pyobj->fov_reverse(args);
618        if (PyErr_Occurred()) rc = -1;
619        Py_DECREF(args);
620        Py_DECREF(iara);
621        Py_DECREF(xaa);
622        Py_DECREF(yaa);
623        Py_DECREF(uaa);
624        Py_DECREF(zaa);
625        Py_DECREF(no);
626        Py_DECREF(mo);
627        Py_DECREF(qo);
628        Py_DECREF(ial);
629        return rc;
630    }
631    int call(int iArrLen, int* iArr, int n, adouble *xa, int m, adouble *ya) {
632        return EDFobject_iArr::call(iArrLen,iArr,n,xa,m,ya);
633    }
634    int call(int iArrLen, int* iArr, int n, advector& x, int m, advector& y) {
635        return EDFobject_iArr::call(iArrLen,iArr,n,x,m,y);
636    }
637    int call(int iArrLen, PyObject* pyarr, int n, advector& x, int m, advector& y) {
638        int rc;
639        PyArrayObject *array2 = NULL;
640        int is_new_object2 = 0;
641        npy_intp size[1] = {
642            iArrLen
643        };
644        int *iArr = NULL;
645        array2 = obj_to_array_contiguous_allow_conversion(pyarr,
646                                                          NPY_INT,
647                                                          &is_new_object2);
648        if (!array2 || !require_dimensions(array2, 1) ||
649            !require_size(array2, size, 1)) SWIG_fail;
650        iArr = (int*) array_data(array2);
651        rc = call(iArrLen,iArr,n,x,m,y);
652        if (is_new_object2 && array2) {
653            Py_DECREF(array2);
654        }
655        return rc;
656    fail:
657        if (is_new_object2 && array2) {
658            Py_DECREF(array2);
659        }
660        return -1;
661    }
662};
663
664PyEDF_iArr::PyEDF_iArr() {
665    cobj = new PyEDF_iArr_wrap();
666    cobj->setPyObj(this);
667}
668
669PyEDF_iArr::~PyEDF_iArr() {
670    delete cobj;
671}
672
673int PyEDF_iArr::call(int iArrLen, int* iArr, int n, adouble *xa, int m, adouble *ya) {
674    return cobj->call(iArrLen,iArr,n,xa,m,ya);
675}
676int PyEDF_iArr::call(int iArrLen, int* iArr, int n, advector& x, int m, advector& y) {
677    return cobj->call(iArrLen,iArr,n,x,m,y);
678}
679int PyEDF_iArr::call(int iArrLen, PyObject* pyarr, int n, advector& x, int m, advector& y) {
680    int rc;
681    PyArrayObject *array2 = NULL;
682    int is_new_object2 = 0;
683    npy_intp size[1] = {
684        iArrLen
685    };
686    int *iArr = NULL;
687    array2 = obj_to_array_contiguous_allow_conversion(pyarr,
688                                                      NPY_INT,
689                                                      &is_new_object2);
690    if (!array2 || !require_dimensions(array2, 1) ||
691        !require_size(array2, size, 1)) SWIG_fail;
692    iArr = (int*) array_data(array2);
693    rc = cobj->call(iArrLen,iArr,n,x,m,y);
694    if (is_new_object2 && array2) {
695        Py_DECREF(array2);
696    }
697    return rc;
698  fail:
699    if (is_new_object2 && array2) {
700        Py_DECREF(array2);
701    }
702    return -1;
703}
704
705#endif
Note: See TracBrowser for help on using the repository browser.