Commit 6e14b178 authored by amitjans's avatar amitjans
Browse files

Finish exercise 3

parent d5e91c9c
# require minimum version of CMake
cmake_minimum_required(VERSION 3.21)
# set name of project
project(Square)
# set warning compile flags
add_compile_options(-Wall -Wextra -Wpedantic)
# option to build STATIC or SHARED library
option(BUILD_SQUARE_SHARED "Build the square library shared." OFF)
if(BUILD_SQUARED_SHARED)
set(SQUARE_LIBRARY_TYPE SHARED)
else()
set(SQUARE_LIBRARY_TYPE STATIC)
endif()
# tell CMake that there is another CMakeLists.txt in this subdirectory
add_subdirectory(integrator)
# add executable to the project
add_executable(print_integrals main.cpp)
# specify that we need the library
target_link_libraries(print_integrals integratorLib)
# specify install rules
install(TARGETS print_integrals DESTINATION bin)
2 2.00455975498442
3 2.00086318967354
4 2.00026916994839
5 2.000109517315
6 2.00005262434119
7 2.00002834355147
8 2.00001659104794
9 2.00001034770577
10 2.0000067844418
11 2.00000463149847
12 2.00000326887716
13 2.00000237256946
14 2.00000176350254
15 2.00000133794795
16 2.00000103336941
17 2.00000081074242
18 2.00000064497198
19 2.00000051948867
20 2.00000042309318
21 2.00000034805603
22 2.00000028894149
23 2.00000024186156
24 2.00000020399219
25 2.00000017325314
26 2.00000014809226
27 2.00000012733769
28 2.000000110095
29 2.00000009567461
30 2.00000008353986
31 2.00000007326946
32 2.00000006453
33 2.00000005705562
34 2.00000005063277
35 2.00000004508883
36 2.00000004028334
37 2.00000003610134
38 2.00000003244823
39 2.00000002924573
40 2.00000002642876
41 2.00000002394294
42 2.00000002174264
43 2.00000001978938
44 2.00000001805062
45 2.00000001649871
46 2.00000001511005
47 2.00000001386447
48 2.00000001274464
49 2.00000001173561
50 2.0000000108245
51 2.00000001000012
52 2.00000000925275
53 2.00000000857391
54 2.0000000079562
55 2.00000000739313
56 2.00000000687901
57 2.0000000064088
58 2.0000000059781
59 2.00000000558297
60 2.00000000521996
61 2.00000000488598
62 2.00000000457829
63 2.00000000429444
64 2.00000000403226
65 2.00000000378978
66 2.00000000356525
67 2.00000000335712
68 2.00000000316395
69 2.00000000298447
70 2.00000000281754
71 2.00000000266213
72 2.00000000251728
73 2.00000000238215
74 2.00000000225597
75 2.00000000213803
76 2.0000000020277
77 2.0000000019244
78 2.00000000182759
79 2.0000000017368
80 2.00000000165157
81 2.00000000157151
82 2.00000000149624
83 2.00000000142542
84 2.00000000135875
85 2.00000000129592
86 2.00000000123669
87 2.0000000011808
88 2.00000000112804
89 2.00000000107818
90 2.00000000103106
91 2.00000000098648
92 2.00000000094428
93 2.00000000090432
94 2.00000000086644
95 2.00000000083053
96 2.00000000079647
97 2.00000000076412
98 2.00000000073341
99 2.00000000070422
100 2.00000000067647
# add library
add_library(integratorLib ${SQUARE_LIBRARY_TYPE} simpson.cpp)
# add include directories (header files)
target_include_directories(integratorLib PUBLIC ./)
# specify install rules
install(TARGETS integratorLib
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
# specify install rules for the header
install(FILES simpson.hpp DESTINATION include)
# Programming Techniques for Scientific Simulations, HS 2021
# Create a library from the object code.
libintegrate.a: simpson.o
ar rvs $@ $^
# Object code depending on header and implementation.
simpson.o: simpson.cpp simpson.hpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
# Always offer a way to clean up!
.PHONY: clean
clean:
rm -f *.o *.a
# Note: in the target simpson.o we could rely on implicit integration (leave the
# body empty). It is shown for verbosity: CXXFLAGS is inherited.
......@@ -17,7 +17,6 @@ int main() {
std::cout << "Integrator maximum resolution?" << std::endl;
size_t N;
std::cin >> N;
std::cout << N << std::endl;
std::ofstream of("data/results.txt");
of.precision(15);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment