source: trunk/ADOL-C/src/drivers/psdriversf.c @ 639

Last change on this file since 639 was 639, checked in by kulshres, 3 years ago

Merge branch 'pwsmooth' via 'master' into 'svn'

The following commits were merged:

commit 69054894c6c15baf4f1a4cb2670a4d1b7fd282b6
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri Sep 18 15:08:46 2015 +0200

add psdriversf.c to Makefile

commit b0ffeb28a7f7ae2beb592cc6bc8e45cdc8660dbb
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri Sep 18 15:05:28 2015 +0200

small bugfixes in fortran abs_normal

commit 4854bd634767c497e8b95a62e300865082302d3d
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri Sep 18 14:54:44 2015 +0200

create the fortran interface for abs_normal

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

commit 3b56c7cefacc9aeef6cac1ab5eeb6c5ff778392c
Author: Andrea Walther <awalther@…>
Date: Fri Sep 18 12:52:52 2015 +0200

-m"first version of directional_active_gradient working"

commit 8493b945b5d74ff80506e3f3040b28c3445db1cc
Author: Andrea Walther <awalther@…>
Date: Fri Sep 18 12:30:41 2015 +0200

zos_pl_reverse in directional_active_gradient

commit 1da8f554589718c4dac9ada0771668b6c850715f
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri Sep 18 12:30:24 2015 +0200

add a sanity check for number of switches

commit a274e10ab191f6029951bf015e206e1a6fc4c2dc
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri Sep 18 11:48:36 2015 +0200

added return to avoid "no return in non-void" error in pedantic compilers

commit 96f861841ac0d163626502fd7edd6deb6acd927c
Author: Andrea Walther <awalther@…>
Date: Fri Sep 18 11:44:42 2015 +0200

-m"fos_pl_sig_reverse call in psdrivers"

commit 0a9765bb9b6e80772596cb0c0b561184e1a4da67
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri Sep 18 11:41:22 2015 +0200

reduce memory usage in abs_normal() and also number of loops

commit 49b3675904683db4ce983d8d038e114da6c09fa3
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri Sep 18 11:01:30 2015 +0200

corrected usage of memset

commit 26a209a4f80e57757ec39bb62c85f6f04704ed1c
Author: Andrea Walther <awalther@…>
Date: Fri Sep 18 10:55:22 2015 +0200

fov_pl_sig without keep
new fos_pl_sig_reverse

commit f1720bfcd347a5f2e3917009a63a1e2ce1ed9749
Author: Andrea Walther <awalther@…>
Date: Fri Sep 18 09:43:03 2015 +0200

fov_pl_sig with keep

commit 08629c0f66e024729f05f55eaa2297ea7d5456ec
Author: Andrea Walther <awalther@…>
Date: Fri Sep 18 09:36:34 2015 +0200

next version psdrivers

commit f10b9debd97f14896294f09404ceb1e5d529ffed
Author: Andrea Walther <awalther@…>
Date: Thu Sep 17 15:49:48 2015 +0200

next version psdrivers

commit 76510d9940be38dd6dc0c81df6a82db0573fb39d
Author: Andrea Walther <awalther@…>
Date: Sat Sep 12 17:08:52 2015 +0200

psdriver first version

File size: 3.2 KB
Line 
1/*----------------------------------------------------------------------------
2 ADOL-C -- Automatic Differentiation by Overloading in C++
3 File:     drivers/psdrivers.c
4 Revision: $Id$
5 Contents: Easy to use drivers for piecewise smooth functions
6           (with C and C++ callable interfaces including Fortran
7            callable versions).
8
9 Copyright (c) Andrea Walther, Sabrina Fiege, Kshitij Kulshreshtha
10
11 This file is part of ADOL-C. This software is provided as open source.
12 Any use, reproduct ion, or distribution of the software constitutes
13 recipient's acceptance of the terms of the accompanying license file.
14
15----------------------------------------------------------------------------*/
16
17#include <adolc/drivers/psdrivers.h>
18#include <adolc/adalloc.h>
19#include <adolc/fortutils.h>
20
21#if !defined(ADOLC_NO_MALLOC)
22#   define ADOLC_CALLOC(n,m) calloc(n,m)
23#else
24#   define ADOLC_CALLOC(n,m) rpl_calloc(n,m)
25#endif
26#if defined(ADOLC_USE_CALLOC)
27#  if !defined(ADOLC_NO_MALLOC)
28#     define ADOLC_MALLOC(n,m) calloc(n,m)
29#  else
30#     define ADOLC_MALLOC(n,m) rpl_calloc(n,m)
31#  endif
32#else
33#  if !defined(ADOLC_NO_MALLOC)
34#     define ADOLC_MALLOC(n,m) malloc(n*m)
35#  else
36#     define ADOLC_MALLOC(n,m) rpl_malloc(n*m)
37#  endif
38#endif
39
40BEGIN_C_DECLS
41
42/****************************************************************************/
43/*                                                 DRIVERS FOR PS FUNCTIONS */
44
45/*--------------------------------------------------------------------------*/
46/*                                                          abs-normal form */
47/* abs_normal(tag,m,n,s,x[n],sig[s],y[m],z[s],cz[s],cy[m],                  */
48/*            J[m][n],Y[m][s],Z[s][n],L[s][s])                              */
49fint abs_normal_(fint* ftag,
50                 fint* fdepen,
51                 fint* findep,
52                 fint* fswchk,
53                 fdouble* fx,
54                 fint* fsigma,
55                 fdouble* fy,
56                 fdouble* fz,
57                 fdouble* fcz,
58                 fdouble* fcy,
59                 fdouble* fJ,
60                 fdouble* fY,
61                 fdouble* fZ,
62                 fdouble* fL) {
63    int rc = -1;
64    short tag = (short)*ftag;
65    int m = (int)*fdepen, n = (int)*findep, s=(int)*fswchk;
66    double **J, **Y, **Z, **L;
67    double *cy, *cz, *x, *y, *z;
68    short *sig = (short*)ADOLC_MALLOC(s,sizeof(short));
69    int i;
70    for (i=0;i<s; i++) {
71        sig[i] = (short)*fsigma++;
72    }
73    J = myalloc2(m,n);
74    Y = myalloc2(m,s);
75    Z = myalloc2(s,n);
76    L = myalloc2(s,s);
77    cy = myalloc1(m);
78    cz = myalloc1(s);
79    x = myalloc1(n);
80    y = myalloc1(m);
81    z = myalloc1(s);
82    spread1(n,fx,x);
83    rc = abs_normal(tag,m,n,s,x,sig,y,z,cz,cy,J,Y,Z,L);
84    pack1(m,y,fy);
85    pack1(s,z,fz);
86    pack1(s,cz,fcz);
87    pack1(m,cy,fcy);
88    pack2(m,n,J,fJ);
89    pack2(m,s,Y,fY);
90    pack2(s,n,Z,fZ);
91    pack2(s,s,L,fL);
92    myfree2(J);
93    myfree2(Y);
94    myfree2(Z);
95    myfree2(L);
96    myfree1(x);
97    myfree1(y);
98    myfree1(z);
99    free((char*)sig);
100    myfree1(cz);
101    myfree1(cy);
102    return rc;
103}
104
105/****************************************************************************/
106/*                                                               THAT'S ALL */
107
108END_C_DECLS
Note: See TracBrowser for help on using the repository browser.