File: fortutils.c

package info (click to toggle)
adolc 2.5.2-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 7,684 kB
  • ctags: 3,333
  • sloc: cpp: 18,988; ansic: 15,599; sh: 11,184; makefile: 483
file content (72 lines) | stat: -rw-r--r-- 2,380 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*----------------------------------------------------------------------------
 ADOL-C -- Automatic Differentiation by Overloading in C++
 File:     fortutils.c
 Revision: $Id: fortutils.c 106 2010-06-29 17:19:50Z kulshres $
 Contents: Internal tools to handle Fortran arrays
 
 Copyright (c) Andrea Walther, Andreas Griewank, Andreas Kowarz, 
               Hristo Mitev, Sebastian Schlenkrich, Jean Utke, Olaf Vogel
  
 This file is part of ADOL-C. This software is provided as open source.
 Any use, reproduction, or distribution of the software constitutes 
 recipient's acceptance of the terms of the accompanying license file.
 
----------------------------------------------------------------------------*/

#include <adolc/fortutils.h>

BEGIN_C_DECLS

/****************************************************************************/
/*                                                                          */

/*--------------------------------------------------------------------------*/
void spread1(int m, fdouble* x, double* X) {
    int j;
    for (j=0; j<m; j++)
        X[j] = *x++;
}

/*--------------------------------------------------------------------------*/
void pack1(int m, double* X, fdouble* x) {
    int j;
    for (j=0; j<m; j++)
        *x++ = X[j];
}

/*--------------------------------------------------------------------------*/
void spread2(int m, int n, fdouble* x, double** X) {
    int i,j;
    for (j=0; j<n; j++)
        for (i=0; i<m; i++)
            X[i][j] = *x++;
}

/*--------------------------------------------------------------------------*/
void pack2(int m, int n, double** X, fdouble* x) {
    int i,j;
    for (j=0; j<n; j++)
        for (i=0; i<m; i++)
            *x++ = X[i][j];
}

/*--------------------------------------------------------------------------*/
void spread3(int m, int n, int p, fdouble* x, double*** X) {
    int i,j,k;
    for (k=0; k<p; k++)
        for (j=0; j<n; j++)
            for (i=0; i<m; i++)
                X[i][j][k] = *x++;
}

/*--------------------------------------------------------------------------*/
void pack3(int m, int n, int p, double*** X, fdouble* x) {
    int i,j,k;
    for (k=0; k<p; k++)
        for (j=0; j<n; j++)
            for (i=0; i<m; i++)
                *x++ = X[i][j][k];
}

/****************************************************************************/
END_C_DECLS