File: compute.cc

package info (click to toggle)
ecbuild 3.13.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,068 kB
  • sloc: sh: 1,404; perl: 732; f90: 472; cpp: 466; python: 383; ansic: 304; fortran: 43; makefile: 15
file content (67 lines) | stat: -rw-r--r-- 1,143 bytes parent folder | download | duplicates (5)
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
#include <iostream>
#include <vector>

#ifdef HAVE_GSL
#include <gsl/gsl_sf_bessel.h>
#endif

using namespace std;

extern "C"
{
  double area_circle_(double *);

  void dgetrf_( int* m, int* n, double* a, int* lda, int* ipiv, int *info );
  void dgetrs_( char* trans, int* n, int* nrhs, const double* a, int* lda, const int* ipiv,double* b, int* ldb, int *info );
}

int main() {

  double x = 12.;
  std::cout << "x = "  << x << std::endl;

  double ca = area_circle_(&x);

  std::cout << "area_circle = " << ca << std::endl;

#ifdef HAVE_GSL
  double cb = gsl_sf_bessel_J0(x);
  std::cout << "Bessel J0 = " << cb << std::endl;
#endif


#ifdef HAVE_MATRIX_LAPACK

    char    TRANS = 'N';
    int     INFO=3;
    int     LDA = 3;
    int     LDB = 3;
    int     N = 3;
    int     NRHS = 1;
    int     IPIV[3] ;

    double  A[9] =
    {
    1, 2, 3,
    2, 3, 4,
    3, 4, 1
    };

    double B[3] =
    {
    -4,
    -1,
    -2
    };

    dgetrf_(&N,&N,A,&LDA,IPIV,&INFO);

    dgetrs_(&TRANS,&N,&NRHS,A,&LDA,IPIV,B,&LDB,&INFO);

    std::cout << "[" << B[0] << ", " << B[1] <<", " << B[2] << "]" << std::endl;

#endif

  return 0;
}