1 // $Id: cmake_test_link_lapack.cpp 149 2009-11-12 02:40:41Z tplante $
2 // $URL: https://software.sandia.gov/svn/hopspack/trunk/test/cmake_test_link_lapack.cpp $
3 
4 //@HEADER
5 // ************************************************************************
6 //
7 //         HOPSPACK: Hybrid Optimization Parallel Search Package
8 //                 Copyright 2009 Sandia Corporation
9 //
10 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
11 // the U.S. Government retains certain rights in this software.
12 //
13 // This file is part of HOPSPACK.
14 //
15 // HOPSPACK is free software; you can redistribute it and/or modify
16 // it under the terms of the GNU Lesser General Public License as
17 // published by the Free Software Foundation; either version 2.1 of the
18 // License, or (at your option) any later version.
19 //
20 // This library is distributed in the hope that it will be useful, but
21 // WITHOUT ANY WARRANTY; without even the implied warranty of
22 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23 // Lesser General Public License for more details.
24 //
25 // You should have received a copy of the GNU Lesser General Public
26 // License along with this library.  If not, see http://www.gnu.org/licenses/.
27 //
28 // Questions? Contact Tammy Kolda (tgkolda@sandia.gov)
29 //                 or Todd Plantenga (tplante@sandia.gov)
30 //
31 // ************************************************************************
32 //@HEADER
33 
34 /*!
35   @file cmake_test_link_lapack.cpp
36   @brief Main program used by ConfigureLapack.cmake to test LAPACK linking.
37 */
38 
39 
40 //--------------------------------------------------------------------
41 //! Main program used by ConfigureLapack.cmake to test LAPACK linking.
42 /*!
43  *  This may or may not be compiled during CMake configuration, but
44  *  is never executed.  The purpose is to test whether an LAPACK function
45  *  can be linked correctly.
46  */
47 //--------------------------------------------------------------------
48 
49 
50 extern "C"
51 {
52     //---- EXTERNAL DEFINITIONS ARE INFERRED FROM FORTRAN API.
53     double ddot_ (int    *  n,
54                   double *  x,        //-- VECTOR
55                   int    *  incx,
56                   double *  y,        //-- VECTOR
57                   int    *  incy);
58     void  dgemv_ (char   *  trans,
59                   int    *  m,
60                   int    *  n,
61                   double *  alpha,    //-- SCALAR
62                   double *  A,        //-- MATRIX
63                   int    *  ldA,
64                   double *  x,        //-- VECTOR
65                   int    *  incx,
66                   double *  beta,     //-- SCALAR
67                   double *  y,        //-- VECTOR
68                   int    *  incy);
69     void  dgemm_ (char   *  transA,
70                   char   *  transB,
71                   int    *  m,
72                   int    *  n,
73                   int    *  k,
74                   double *  alpha,    //-- SCALAR
75                   double *  A,        //-- MATRIX
76                   int    *  ldA,
77                   double *  B,        //-- MATRIX
78                   int    *  ldB,
79                   double *  beta,     //-- SCALAR
80                   double *  C,        //-- MATRIX
81                   int    *  ldC);
82     void  dgesvd_ (char   *  jobU,
83                    char   *  jobVT,
84                    int    *  m,
85                    int    *  n,
86                    double *  A,       //-- MATRIX
87                    int    *  ldA,
88                    double *  Sigma,   //-- VECTOR
89                    double *  U,       //-- MATRIX
90                    int    *  ldU,
91                    double *  VT,      //-- MATRIX
92                    int    *  ldVT,
93                    double *  work,    //-- VECTOR
94                    int    *  workSize,
95                    int    *  info);
96     void  dgglse_ (int    *  m,
97                    int    *  n,
98                    int    *  p,
99                    double *  A,       //-- MATRIX
100                    int    *  ldA,
101                    double *  B,       //-- MATRIX
102                    int    *  ldB,
103                    double *  c,       //-- VECTOR
104                    double *  d,       //-- VECTOR
105                    double *  x,       //-- VECTOR
106                    double *  work,    //-- VECTOR
107                    int    *  workSize,
108                    int    *  info);
109     void  dgelqf_ (int    *  m,
110                    int    *  n,
111                    double *  A,       //-- MATRIX
112                    int    *  ldA,
113                    double *  Tau,     //-- MATRIX
114                    double *  work,    //-- VECTOR
115                    int    *  workSize,
116                    int    *  info);
117 }
118 
119 
120 /*
121  *  LAPACK calls merely match the API.  They should compile but are not
122  *  intended for execution.
123  */
main(void)124 int  main (void)
125 {
126     char    c = 'U';
127     int     n = 1;
128     double  d = 1.0;
129     double  daA[1] = { 0.0 };
130 
131   #if defined(TEST_ddot)
132     ddot_ (&n, daA, &n, daA, &n);
133   #endif
134   #if defined(TEST_dgemv)
135     dgemv_ (&c, &n, &n, &d, daA, &n, daA, &n, &d, daA, &n);
136   #endif
137   #if defined(TEST_dgemm)
138     dgemm_ (&c, &c, &n, &n, &n, &d, daA, &n, daA, &n, &d, daA, &n);
139   #endif
140   #if defined(TEST_dgesvd)
141     dgesvd_ (&c, &c, &n, &n, daA, &n, daA, daA, &n, daA, &n, daA, &n, &n);
142   #endif
143   #if defined(TEST_dgglse)
144     dgglse_ (&n, &n, &n, daA, &n, daA, &n, &d, &d, &d, daA, &n, &n);
145   #endif
146   #if defined(TEST_dgelqf)
147     dgelqf_ (&n, &n, daA, &n, daA, &d, &n, &n);
148   #endif
149 
150     return( 0 );
151 }
152