source: trunk/ADOL-C/src/param.cpp

Last change on this file 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: 22.6 KB
Line 
1/*----------------------------------------------------------------------------
2 ADOL-C -- Automatic Differentiation by Overloading in C++
3 File:     param.cpp
4 Revision: $Id$
5 Contents: class for parameter dependent functions
6 
7 Copyright (c) Kshitij Kulshreshtha
8
9 This file is part of ADOL-C. This software is provided as open source.
10 Any use, reproduction, or distribution of the software constitutes
11 recipient's acceptance of the terms of the accompanying license file.
12
13----------------------------------------------------------------------------*/
14
15
16#include "oplate.h"
17#include "taping_p.h"
18#include "dvlparms.h"
19#include <adolc/adouble.h>
20
21#include <limits>
22
23pdouble::pdouble(double pval) {
24    ADOLC_OPENMP_THREAD_NUMBER;
25    ADOLC_OPENMP_GET_THREAD_NUMBER;
26
27    _val = pval;
28    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
29        _idx = ADOLC_GLOBAL_TAPE_VARS.paramStoreMgrPtr->next_loc();
30        ADOLC_GLOBAL_TAPE_VARS.pStore[_idx] = _val;
31    } else {
32        _idx = std::numeric_limits<locint>::max();
33    }
34}
35
36pdouble::pdouble(locint idx) {
37    ADOLC_OPENMP_THREAD_NUMBER;
38    ADOLC_OPENMP_GET_THREAD_NUMBER;
39   
40    if (idx < ADOLC_GLOBAL_TAPE_VARS.numparam) {
41        _val = ADOLC_GLOBAL_TAPE_VARS.pStore[idx];
42        _idx = idx;
43    } else {
44        fprintf(DIAG_OUT, "ADOL-C error: Parameter index %d out of bounds, "
45                "# existing parameters = %zu\n", idx, 
46                ADOLC_GLOBAL_TAPE_VARS.numparam);
47        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
48    }
49}
50
51pdouble::operator pdouble*() const {
52    pdouble* ret = new pdouble(_idx);
53    return ret;
54}
55
56pdouble mkparam(double pval) {
57    locint _idx;
58    ADOLC_OPENMP_THREAD_NUMBER;
59    ADOLC_OPENMP_GET_THREAD_NUMBER;
60
61    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
62        _idx = ADOLC_GLOBAL_TAPE_VARS.paramStoreMgrPtr->next_loc();
63        ADOLC_GLOBAL_TAPE_VARS.pStore[_idx] = pval;
64    } else {
65        return pval;
66    }
67    return _idx;
68}
69
70pdouble getparam(locint index) {
71    return index;
72}
73
74locint mkparam_idx(double pval) {
75    locint _idx;
76    ADOLC_OPENMP_THREAD_NUMBER;
77    ADOLC_OPENMP_GET_THREAD_NUMBER;
78    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
79        _idx = ADOLC_GLOBAL_TAPE_VARS.paramStoreMgrPtr->next_loc();
80        ADOLC_GLOBAL_TAPE_VARS.pStore[_idx] = pval;
81    } else {
82        fprintf(DIAG_OUT, "ADOL-C error: cannot define indexed parameter "
83                "while tracing is turned off!\n");
84        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
85    }
86    return _idx;
87}
88
89pdouble::operator adub() const {
90    locint location;
91    ADOLC_OPENMP_THREAD_NUMBER;
92    ADOLC_OPENMP_GET_THREAD_NUMBER;
93
94    location = next_loc();
95    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
96        put_op(assign_p);
97        ADOLC_PUT_LOCINT(_idx);
98        ADOLC_PUT_LOCINT(location);
99
100        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
101        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
102            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[location]);
103    }
104    ADOLC_GLOBAL_TAPE_VARS.store[location] = _val;
105#if defined(ADOLC_TRACK_ACTIVITY)
106    ADOLC_GLOBAL_TAPE_VARS.actStore[location] = true;
107#endif
108    return location;
109}
110
111badouble& badouble::operator = (const pdouble& p) {
112    locint loc;
113    ADOLC_OPENMP_THREAD_NUMBER;
114    ADOLC_OPENMP_GET_THREAD_NUMBER;
115
116    loc = this->loc();
117    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
118        put_op(assign_p);
119        ADOLC_PUT_LOCINT(p._idx);
120        ADOLC_PUT_LOCINT(loc);
121
122        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
123        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
124            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[loc]);
125    }
126    ADOLC_GLOBAL_TAPE_VARS.store[loc] = p._val;
127#if defined(ADOLC_TRACK_ACTIVITY)
128    ADOLC_GLOBAL_TAPE_VARS.actStore[loc] = true;
129#endif
130    return *this;
131}
132
133adouble& adouble::operator = (const pdouble& p) {
134    this->loc();
135    (*this).badouble::operator=(p);
136    return (*this);
137}
138
139adubref& adubref::operator = (const pdouble& p) {
140    ADOLC_OPENMP_THREAD_NUMBER;
141    ADOLC_OPENMP_GET_THREAD_NUMBER;
142    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
143        put_op(ref_assign_p);
144        ADOLC_PUT_LOCINT(p._idx);
145        ADOLC_PUT_LOCINT(location);
146       
147        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
148        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
149            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[refloc]);
150    }
151    ADOLC_GLOBAL_TAPE_VARS.store[refloc] = p._val;
152#if defined(ADOLC_TRACK_ACTIVITY)
153    ADOLC_GLOBAL_TAPE_VARS.actStore[refloc] = true;
154#endif
155    return *this;
156}
157
158badouble& badouble::operator += (const pdouble& p) {
159    locint loc;
160    ADOLC_OPENMP_THREAD_NUMBER;
161    ADOLC_OPENMP_GET_THREAD_NUMBER;
162
163    loc = this->loc();
164    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
165        put_op(eq_plus_p);
166        ADOLC_PUT_LOCINT(p._idx);
167        ADOLC_PUT_LOCINT(loc);
168       
169        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
170        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
171            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[loc]);
172    }
173
174    ADOLC_GLOBAL_TAPE_VARS.store[loc] += p._val;
175#if defined(ADOLC_TRACK_ACTIVITY)
176    ADOLC_GLOBAL_TAPE_VARS.actStore[loc] = true;
177#endif
178    return *this;   
179}
180
181adubref& adubref::operator += (const pdouble& p) {
182    ADOLC_OPENMP_THREAD_NUMBER;
183    ADOLC_OPENMP_GET_THREAD_NUMBER;
184
185    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
186        put_op(ref_eq_plus_p);
187        ADOLC_PUT_LOCINT(p._idx);
188        ADOLC_PUT_LOCINT(location);
189
190        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
191        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
192            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[refloc]);
193    }
194
195    ADOLC_GLOBAL_TAPE_VARS.store[refloc] += p._val;
196#if defined(ADOLC_TRACK_ACTIVITY)
197    ADOLC_GLOBAL_TAPE_VARS.actStore[refloc] = true;
198#endif
199    return *this;
200}
201
202badouble& badouble::operator -= (const pdouble& p) {
203    ADOLC_OPENMP_THREAD_NUMBER;
204    ADOLC_OPENMP_GET_THREAD_NUMBER;
205    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) { // old: write_d_same_arg(eq_min_d,loc(),coval);
206        put_op(eq_min_p);
207        ADOLC_PUT_LOCINT(p._idx);
208        ADOLC_PUT_LOCINT(loc());
209
210        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
211        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
212            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[loc()]);
213    }
214
215    ADOLC_GLOBAL_TAPE_VARS.store[loc()] -= p._val;
216#if defined(ADOLC_TRACK_ACTIVITY)
217    ADOLC_GLOBAL_TAPE_VARS.actStore[loc()] = true;
218#endif
219    return *this;
220}
221
222adubref& adubref::operator -= (const pdouble& p) {
223    ADOLC_OPENMP_THREAD_NUMBER;
224    ADOLC_OPENMP_GET_THREAD_NUMBER;
225    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) { // old: write_d_same_arg(eq_min_d,location,coval);
226        put_op(ref_eq_min_p);
227        ADOLC_PUT_LOCINT(p._idx);
228        ADOLC_PUT_LOCINT(location);
229
230        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
231        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
232            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[refloc]);
233    }
234
235    ADOLC_GLOBAL_TAPE_VARS.store[refloc] -= p._val;
236#if defined(ADOLC_TRACK_ACTIVITY)
237    ADOLC_GLOBAL_TAPE_VARS.actStore[refloc] = true;
238#endif
239    return *this;
240}
241
242badouble& badouble::operator *= (const pdouble& p) {
243    ADOLC_OPENMP_THREAD_NUMBER;
244    ADOLC_OPENMP_GET_THREAD_NUMBER;
245    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) { // old: write_d_same_arg(eq_mult_d,loc(),coval);
246        put_op(eq_mult_p);
247        ADOLC_PUT_LOCINT(p._idx);       // = coval
248        ADOLC_PUT_LOCINT(loc()); // = res
249
250        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
251        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
252            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[loc()]);
253    }
254
255    ADOLC_GLOBAL_TAPE_VARS.store[loc()] *= p._val;
256#if defined(ADOLC_TRACK_ACTIVITY)
257    ADOLC_GLOBAL_TAPE_VARS.actStore[loc()] = true;
258#endif
259    return *this;
260}
261
262adubref& adubref::operator *= (const pdouble& p) {
263    ADOLC_OPENMP_THREAD_NUMBER;
264    ADOLC_OPENMP_GET_THREAD_NUMBER;
265    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) { // old: write_d_same_arg(eq_mult_d,location,coval);
266        put_op(ref_eq_mult_p);
267        ADOLC_PUT_LOCINT(p._idx);
268        ADOLC_PUT_LOCINT(location);
269
270        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
271        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
272            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[refloc]);
273    }
274
275    ADOLC_GLOBAL_TAPE_VARS.store[refloc] *= p._val;
276#if defined(ADOLC_TRACK_ACTIVITY)
277    ADOLC_GLOBAL_TAPE_VARS.actStore[refloc] = true;
278#endif
279    return *this;
280}
281
282adub operator + (const badouble& a, const pdouble& p) {
283    ADOLC_OPENMP_THREAD_NUMBER;
284    ADOLC_OPENMP_GET_THREAD_NUMBER;
285    locint locat = next_loc();
286
287    /* olvo 980708 test coval to be zero */
288    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) { // old: write_args_d_a(plus_d_a,locat,coval,y.loc());
289#if defined(ADOLC_TRACK_ACTIVITY)
290        if (! ADOLC_GLOBAL_TAPE_VARS.actStore[a.loc()] ) {
291            locint tmploc = a.loc();
292            double temp = ADOLC_GLOBAL_TAPE_VARS.store[a.loc()];
293            if (temp == 0.0) {
294                put_op(assign_d_zero);
295                ADOLC_PUT_LOCINT(tmploc);
296            } else if (temp == 1.0) {
297                put_op(assign_d_one);
298                ADOLC_PUT_LOCINT(tmploc);
299            } else {
300                put_op(assign_d);
301                ADOLC_PUT_LOCINT(tmploc);
302                ADOLC_PUT_VAL(temp);
303            }
304
305            ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
306            if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
307                ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[tmploc]);
308        }
309#endif
310        put_op(plus_a_p);
311        ADOLC_PUT_LOCINT(a.loc());
312        ADOLC_PUT_LOCINT(p._idx);
313        ADOLC_PUT_LOCINT(locat);
314
315        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
316        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
317            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[locat]);
318    }
319   
320    ADOLC_GLOBAL_TAPE_VARS.store[locat] = ADOLC_GLOBAL_TAPE_VARS.store[a.loc()] + p._val;
321#if defined(ADOLC_TRACK_ACTIVITY)
322    ADOLC_GLOBAL_TAPE_VARS.actStore[locat] = true;
323#endif
324    return locat;
325}
326
327adub operator - (const badouble& a, const pdouble& p) {
328    ADOLC_OPENMP_THREAD_NUMBER;
329    ADOLC_OPENMP_GET_THREAD_NUMBER;
330    locint locat = next_loc();
331
332    /* olvo 980708 test coval to be zero */
333    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) { // old: write_args_d_a(plus_d_a,locat,coval,y.loc());
334#if defined(ADOLC_TRACK_ACTIVITY)
335        if (! ADOLC_GLOBAL_TAPE_VARS.actStore[a.loc()] ) {
336            locint tmploc = a.loc();
337            double temp = ADOLC_GLOBAL_TAPE_VARS.store[a.loc()];
338            if (temp == 0.0) {
339                put_op(assign_d_zero);
340                ADOLC_PUT_LOCINT(tmploc);
341            } else if (temp == 1.0) {
342                put_op(assign_d_one);
343                ADOLC_PUT_LOCINT(tmploc);
344            } else {
345                put_op(assign_d);
346                ADOLC_PUT_LOCINT(tmploc);
347                ADOLC_PUT_VAL(temp);
348            }
349
350            ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
351            if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
352                ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[tmploc]);
353        }
354#endif
355        put_op(min_a_p);
356        ADOLC_PUT_LOCINT(a.loc());
357        ADOLC_PUT_LOCINT(p._idx);
358        ADOLC_PUT_LOCINT(locat);
359
360        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
361        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
362            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[locat]);
363    }
364   
365    ADOLC_GLOBAL_TAPE_VARS.store[locat] = ADOLC_GLOBAL_TAPE_VARS.store[a.loc()] - p._val;
366#if defined(ADOLC_TRACK_ACTIVITY)
367    ADOLC_GLOBAL_TAPE_VARS.actStore[locat] = true;
368#endif
369    return locat;
370}
371
372adub operator * (const badouble& a, const pdouble& p) {
373    ADOLC_OPENMP_THREAD_NUMBER;
374    ADOLC_OPENMP_GET_THREAD_NUMBER;
375    locint locat = next_loc();
376
377    /* olvo 980708 test coval to be zero */
378    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) { // old: write_args_d_a(plus_d_a,locat,coval,y.loc());
379#if defined(ADOLC_TRACK_ACTIVITY)
380        if (! ADOLC_GLOBAL_TAPE_VARS.actStore[a.loc()] ) {
381            locint tmploc = a.loc();
382            double temp = ADOLC_GLOBAL_TAPE_VARS.store[a.loc()];
383            if (temp == 0.0) {
384                put_op(assign_d_zero);
385                ADOLC_PUT_LOCINT(tmploc);
386            } else if (temp == 1.0) {
387                put_op(assign_d_one);
388                ADOLC_PUT_LOCINT(tmploc);
389            } else {
390                put_op(assign_d);
391                ADOLC_PUT_LOCINT(tmploc);
392                ADOLC_PUT_VAL(temp);
393            }
394
395            ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
396            if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
397                ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[tmploc]);
398        }
399#endif
400        put_op(mult_a_p);
401        ADOLC_PUT_LOCINT(a.loc());
402        ADOLC_PUT_LOCINT(p._idx);
403        ADOLC_PUT_LOCINT(locat);
404
405        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
406        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
407            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[locat]);
408    }
409   
410    ADOLC_GLOBAL_TAPE_VARS.store[locat] = ADOLC_GLOBAL_TAPE_VARS.store[a.loc()] * p._val;
411#if defined(ADOLC_TRACK_ACTIVITY)
412    ADOLC_GLOBAL_TAPE_VARS.actStore[locat] = true;
413#endif
414    return locat;
415}
416
417adub operator / (const pdouble& p, const badouble& a) {
418    ADOLC_OPENMP_THREAD_NUMBER;
419    ADOLC_OPENMP_GET_THREAD_NUMBER;
420    locint locat = next_loc();
421
422    /* olvo 980708 test coval to be zero */
423    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) { // old: write_args_d_a(plus_d_a,locat,coval,y.loc());
424#if defined(ADOLC_TRACK_ACTIVITY)
425        if (! ADOLC_GLOBAL_TAPE_VARS.actStore[a.loc()] ) {
426            locint tmploc = a.loc();
427            double temp = ADOLC_GLOBAL_TAPE_VARS.store[a.loc()];
428            if (temp == 0.0) {
429                put_op(assign_d_zero);
430                ADOLC_PUT_LOCINT(tmploc);
431            } else if (temp == 1.0) {
432                put_op(assign_d_one);
433                ADOLC_PUT_LOCINT(tmploc);
434            } else {
435                put_op(assign_d);
436                ADOLC_PUT_LOCINT(tmploc);
437                ADOLC_PUT_VAL(temp);
438            }
439
440            ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
441            if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
442                ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[tmploc]);
443        }
444#endif
445        put_op(div_p_a);
446        ADOLC_PUT_LOCINT(a.loc());
447        ADOLC_PUT_LOCINT(p._idx);
448        ADOLC_PUT_LOCINT(locat);
449
450        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
451        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
452            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[locat]);
453    }
454   
455    ADOLC_GLOBAL_TAPE_VARS.store[locat] = p._val/ADOLC_GLOBAL_TAPE_VARS.store[a.loc()];
456#if defined(ADOLC_TRACK_ACTIVITY)
457    ADOLC_GLOBAL_TAPE_VARS.actStore[locat] = true;
458#endif
459    return locat;   
460}
461
462adub pow( const badouble& x, const pdouble& p) {
463    ADOLC_OPENMP_THREAD_NUMBER;
464    ADOLC_OPENMP_GET_THREAD_NUMBER;
465    locint locat = next_loc();
466
467    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) { // old: write_args_d_a(pow_op,locat,cocval,x.loc());
468#if defined(ADOLC_TRACK_ACTIVITY)
469        if (! ADOLC_GLOBAL_TAPE_VARS.actStore[x.loc()] ) {
470            locint tmploc = x.loc();
471            double temp = ADOLC_GLOBAL_TAPE_VARS.store[x.loc()];
472            if (temp == 0.0) {
473                put_op(assign_d_zero);
474                ADOLC_PUT_LOCINT(tmploc);
475            } else if (temp == 1.0) {
476                put_op(assign_d_one);
477                ADOLC_PUT_LOCINT(tmploc);
478            } else {
479                put_op(assign_d);
480                ADOLC_PUT_LOCINT(tmploc);
481                ADOLC_PUT_VAL(temp);
482            }
483
484            ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
485            if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
486                ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[tmploc]);
487        }
488#endif
489        put_op(pow_op_p);
490        ADOLC_PUT_LOCINT(x.loc()); // = arg
491        ADOLC_PUT_LOCINT(p._idx);         // = coval
492        ADOLC_PUT_LOCINT(locat);      // = res
493
494        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
495        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
496            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[locat]);
497    }
498
499    ADOLC_GLOBAL_TAPE_VARS.store[locat] =
500        ADOLC_MATH_NSP::pow(ADOLC_GLOBAL_TAPE_VARS.store[x.loc()],p._val);
501#if defined(ADOLC_TRACK_ACTIVITY)
502    ADOLC_GLOBAL_TAPE_VARS.actStore[locat] = true;
503#endif
504    ADOLC_OPENMP_RESTORE_THREAD_NUMBER;
505    return locat;
506}
507adub recipr( const pdouble& p) {
508    locint location;
509    ADOLC_OPENMP_THREAD_NUMBER;
510    ADOLC_OPENMP_GET_THREAD_NUMBER;
511
512    location = next_loc();
513    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
514        put_op(recipr_p);
515        ADOLC_PUT_LOCINT(p._idx);
516        ADOLC_PUT_LOCINT(location);
517
518        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
519        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
520            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[location]);
521    }
522    ADOLC_GLOBAL_TAPE_VARS.store[location] = 1.0/p._val;
523#if defined(ADOLC_TRACK_ACTIVITY)
524    ADOLC_GLOBAL_TAPE_VARS.actStore[location] = true;
525#endif
526    return location;
527}
528
529adub operator - (const pdouble& p) {
530    locint location;
531    ADOLC_OPENMP_THREAD_NUMBER;
532    ADOLC_OPENMP_GET_THREAD_NUMBER;
533
534    location = next_loc();
535    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
536        put_op(neg_sign_p);
537        ADOLC_PUT_LOCINT(p._idx);
538        ADOLC_PUT_LOCINT(location);
539
540        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
541        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
542            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[location]);
543    }
544    ADOLC_GLOBAL_TAPE_VARS.store[location] = -p._val;
545#if defined(ADOLC_TRACK_ACTIVITY)
546    ADOLC_GLOBAL_TAPE_VARS.actStore[location] = true;
547#endif
548    return location;
549}
550
551adouble pow( const pdouble& p, const badouble& y) {
552    adouble a1, a2, ret;
553    double vx = p._val;
554    double vy = y.getValue();
555    if (!(vx > 0)) { 
556        if (vx < 0 || vy >= 0)
557            fprintf(DIAG_OUT,"\nADOL-C message: exponent of zero/negative basis deactivated\n");
558        else
559            fprintf(DIAG_OUT,"\nADOL-C message: negative exponent and zero basis deactivated\n");
560    }
561    condassign(a1, -y, (adouble) ADOLC_MATH_NSP::pow(vx,vy), pow(p,vy));
562    condassign(a2, fabs(adub(p)), pow(p, vy), a1);
563    condassign(ret, p, exp(y*log(adub(p))),a2);
564
565    return ret;
566}
567
568#if defined(ADOLC_ADVANCED_BRANCHING)
569adub operator != (const badouble& x, const pdouble& y) {
570    ADOLC_OPENMP_THREAD_NUMBER;
571    ADOLC_OPENMP_GET_THREAD_NUMBER;
572    double xval = ADOLC_GLOBAL_TAPE_VARS.store[x.loc()];
573    double yval = y._val;
574    double res = (double)(xval != yval);
575    locint locat = next_loc();
576    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
577        put_op(neq_a_p);
578        ADOLC_PUT_LOCINT(x.loc()); // arg
579        ADOLC_PUT_LOCINT(y._idx); // arg1
580        ADOLC_PUT_VAL(res);           // check for branch switch
581        ADOLC_PUT_LOCINT(locat);      // res
582
583        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
584        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
585            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[locat]);
586    }
587    ADOLC_GLOBAL_TAPE_VARS.store[locat] = res;
588    return locat;
589}
590/*--------------------------------------------------------------------------*/
591adub operator == (const badouble& x, const pdouble& y) {
592    ADOLC_OPENMP_THREAD_NUMBER;
593    ADOLC_OPENMP_GET_THREAD_NUMBER;
594    double xval = ADOLC_GLOBAL_TAPE_VARS.store[x.loc()];
595    double yval = y._val;
596    double res = (double)(xval == yval);
597    locint locat = next_loc();
598    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
599        put_op(eq_a_p);
600        ADOLC_PUT_LOCINT(x.loc()); // arg
601        ADOLC_PUT_LOCINT(y._idx); // arg1
602        ADOLC_PUT_VAL(res);           // check for branch switch
603        ADOLC_PUT_LOCINT(locat);      // res
604
605        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
606        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
607            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[locat]);
608    }
609    ADOLC_GLOBAL_TAPE_VARS.store[locat] = res;
610    return locat;
611}
612/*--------------------------------------------------------------------------*/
613adub operator <= (const badouble& x, const pdouble& y) {
614    ADOLC_OPENMP_THREAD_NUMBER;
615    ADOLC_OPENMP_GET_THREAD_NUMBER;
616    double xval = ADOLC_GLOBAL_TAPE_VARS.store[x.loc()];
617    double yval = y._val;
618    double res = (double)(xval <= yval);
619    locint locat = next_loc();
620    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
621        put_op(le_a_p);
622        ADOLC_PUT_LOCINT(x.loc()); // arg
623        ADOLC_PUT_LOCINT(y._idx); // arg1
624        ADOLC_PUT_VAL(res);           // check for branch switch
625        ADOLC_PUT_LOCINT(locat);      // res
626
627        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
628        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
629            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[locat]);
630    }
631    ADOLC_GLOBAL_TAPE_VARS.store[locat] = res;
632    return locat;
633}
634/*--------------------------------------------------------------------------*/
635adub operator >= (const badouble& x, const pdouble& y) {
636    ADOLC_OPENMP_THREAD_NUMBER;
637    ADOLC_OPENMP_GET_THREAD_NUMBER;
638    double xval = ADOLC_GLOBAL_TAPE_VARS.store[x.loc()];
639    double yval = y._val;
640    double res = (double)(xval >= yval);
641    locint locat = next_loc();
642    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
643        put_op(ge_a_p);
644        ADOLC_PUT_LOCINT(x.loc()); // arg
645        ADOLC_PUT_LOCINT(y._idx); // arg1
646        ADOLC_PUT_VAL(res);           // check for branch switch
647        ADOLC_PUT_LOCINT(locat);      // res
648
649        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
650        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
651            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[locat]);
652    }
653    ADOLC_GLOBAL_TAPE_VARS.store[locat] = res;
654    return locat;
655}
656/*--------------------------------------------------------------------------*/
657adub operator > (const badouble& x, const pdouble& y) {
658    ADOLC_OPENMP_THREAD_NUMBER;
659    ADOLC_OPENMP_GET_THREAD_NUMBER;
660    double xval = ADOLC_GLOBAL_TAPE_VARS.store[x.loc()];
661    double yval = y._val;
662    double res = (double)(xval > yval);
663    locint locat = next_loc();
664    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
665        put_op(gt_a_p);
666        ADOLC_PUT_LOCINT(x.loc()); // arg
667        ADOLC_PUT_LOCINT(y._idx); // arg1
668        ADOLC_PUT_VAL(res);           // check for branch switch
669        ADOLC_PUT_LOCINT(locat);      // res
670
671        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
672        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
673            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[locat]);
674    }
675    ADOLC_GLOBAL_TAPE_VARS.store[locat] = res;
676    return locat;
677}
678/*--------------------------------------------------------------------------*/
679adub operator < (const badouble& x, const pdouble& y) {
680    ADOLC_OPENMP_THREAD_NUMBER;
681    ADOLC_OPENMP_GET_THREAD_NUMBER;
682    double xval = ADOLC_GLOBAL_TAPE_VARS.store[x.loc()];
683    double yval = y._val;
684    double res = (double)(xval < yval);
685    locint locat = next_loc();
686    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
687        put_op(lt_a_p);
688        ADOLC_PUT_LOCINT(x.loc()); // arg
689        ADOLC_PUT_LOCINT(y._idx); // arg1
690        ADOLC_PUT_VAL(res);           // check for branch switch
691        ADOLC_PUT_LOCINT(locat);      // res
692
693        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
694        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
695            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[locat]);
696    }
697    ADOLC_GLOBAL_TAPE_VARS.store[locat] = res;
698    return locat;
699}
700#endif
Note: See TracBrowser for help on using the repository browser.