Debian Codegraph @

debian/tests/build2

raw
1 #!/bin/sh
2 # autopkgtest check: Build and run a program against libmedc
3 # (C) 2013 Thomas Moulard
4 # (C) 2014 Anton Gladky
5 # Author: Thomas Moulard <[email protected]>
6 # Anton Gladky <[email protected]>
7
8 set -e
9
10 WORKDIR=$(mktemp -d)
11 echo $WORKDIR
12 trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
13 cd $WORKDIR
14 mkdir src
15 cd src
16
17 cat <<EOF > CMakeLists.txt
18 cmake_minimum_required(VERSION 3.18)
19 project(demo)
20 find_package(ALGLIB REQUIRED)
21 include_directories(\${ALGLIB_INCLUDE_DIRS})
22
23 add_executable(demo demo.cpp)
24 target_link_libraries(demo \${ALGLIB_LIB})
25 install(TARGETS demo DESTINATION bin)
26
27 EOF
28
29 cat <<EOF > demo.cpp
30 #include <stdio.h>
31 #include "interpolation.h"
32
33 int main()
34 { alglib::real_1d_array x("[0,1,2,3]");
35 alglib::real_1d_array y("[1,5,3,9]");
36 alglib::real_1d_array y2("[1,5,3,9,0]");
37 alglib::spline1dinterpolant s;
38
39 alglib::spline1dbuildlinear(x, y, 4, s); // 'expert' interface is used
40 alglib::spline1dbuildlinear(x, y, s); // 'friendly' interface - input size is
41 // automatically determined
42
43 alglib::spline1dbuildlinear(x, y2, 4, s); // y2.length() is 5, but it will work
44
45
46
47 alglib::real_2d_array a;
48 alglib::matinvreport rep;
49 alglib::ae_int_t info;
50
51 //
52 // 'Friendly' interface: spdmatrixinverse() accepts and returns symmetric matrix
53 //
54
55 // symmetric positive definite matrix
56 a = "[[2,1],[1,2]]";
57
58 // after this line A will contain [[0.66,-0.33],[-0.33,0.66]]
59 // which is symmetric too
60 alglib::spdmatrixinverse(a, info, rep);
61
62 // you may try to pass nonsymmetric matrix
63 a = "[[2,1],[0,2]]";
64
65 {
66 alglib::real_2d_array a;
67 alglib::matinvreport rep;
68 alglib::ae_int_t info;
69
70 //
71 // 'Expert' interface, spdmatrixinverse()
72 //
73
74 // only upper triangle is used; a[1][0] is initialized by NAN,
75 // but it can be arbitrary number
76 a = "[[2,1],[NAN,2]]";
77
78 // after this line A will contain [[0.66,-0.33],[NAN,0.66]]
79 // only upper triangle is modified
80 alglib::spdmatrixinverse(a, 2 /* N */, true /* upper triangle is used */, rep);
81 }
82
83 return 0;
84 }
85
86 EOF
87
88 cd ..
89 mkdir build
90 cd build
91 cmake -DCMAKE_INSTALL_PREFIX=./../inst ./../src
92 make
93 make install
94 echo "build: OK"
95 [ -x demo ]
96 ./demo
97 echo "run: OK"
98