source: trunk/ADOL-C/src/drivers/odedriversf.c @ 40

Last change on this file since 40 was 40, checked in by awalther, 11 years ago

adapted directoy structure

File size: 2.9 KB
Line 
1/*----------------------------------------------------------------------------
2 ADOL-C -- Automatic Differentiation by Overloading in C++
3 File:     drivers/odedriversf.c
4 Revision: $Id: odedriversf.c 37 2009-05-28 12:56:44Z awalther $
5 Contents: Easy to use drivers for optimization and nonlinear equations
6           (Implementation of the Fortran callable interfaces).
7 
8 Copyright (c) Andrea Walther, Andreas Griewank, Andreas Kowarz,
9               Hristo Mitev, Sebastian Schlenkrich, Jean Utke, Olaf Vogel
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#include <drivers/odedrivers.h>
17#include <interfaces.h>
18#include <adalloc.h>
19#include <fortutils.h>
20
21#include <math.h>
22
23BEGIN_C_DECLS
24
25/****************************************************************************/
26/*                                                         DRIVERS FOR ODEs */
27
28/*--------------------------------------------------------------------------*/
29/*                                                                  forodec */
30/* forodec(tag, n, tau, dold, dnew, X[n][d+1])                              */
31fint forodec_(fint* ftag,    /* tape identifier */
32              fint* fn,       /* space dimension */
33              fdouble* ftau,  /* scaling defaults to 1.0 */
34              fint* fdol,     /* previous degree defaults to zero */
35              fint* fdeg,     /* New degree of consistency        */
36              fdouble* fy)    /* Taylor series                    */
37{
38    int rc= -1;
39    short tag= (short) *ftag;
40    int n=*fn, dol=*fdol, deg=*fdeg;
41    int i;
42    double tau=*ftau;
43    double** Y = myalloc2(n,deg+1);
44    for(i=0;i<n;i++)
45        *Y[i] = fy[i];
46    rc= forodec(tag,n,tau,dol,deg,Y);
47    pack2(n,deg+1,Y,fy);
48    free((char*)*Y);
49    free((char*)Y);
50    return rc;
51}
52
53/*--------------------------------------------------------------------------*/
54/*                                                                  accodec */
55/* accodec(n, tau, d, Z[n][n][d+1], B[n][n][d+1], nz[n][n])                 */
56fint accodec_(fint* fn,             /* space dimension */
57              fdouble* ftau,        /* scaling defaults to 1.0 */
58              fint* fdeg,           /* highest degree          */
59              fdouble* fa,          /* input tensor of "partial" Jacobians */
60              fdouble* fb)          /* output tensor of "total" Jacobians  */
61{
62    int rc= 1;
63    int n=*fn, deg=*fdeg;
64    double tau=*ftau;
65    double*** A = myalloc3(n,n,deg);
66    double*** B = myalloc3(n,n,deg);
67    spread3(n,n,deg,fa,A);
68    accodec(n,tau,deg,A,B,0);
69    pack3(n,n,deg,B,fb);
70    free((char*)**A);
71    free((char*)*A);
72    free((char*)A);
73    free((char*)**B);
74    free((char*)*B);
75    free((char*)B);
76    return rc;
77}
78
79END_C_DECLS
Note: See TracBrowser for help on using the repository browser.