aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@serenitascapital.com>2016-02-22 16:04:27 -0500
committerGuillaume Horel <guillaume.horel@gmail.com>2016-02-25 19:56:22 -0500
commit487d2e11fac749bec8018be3eafb5f3e307182b6 (patch)
treee4f0f86b13e5a885b106badc180c046ed5dfb277
parentd637151c4acae4a06ffef927bf7ececd77d67a44 (diff)
downloadprojet_C++-487d2e11fac749bec8018be3eafb5f3e307182b6.tar.gz
Idée pour le rapportlatex
- J'ai rajouté une target rapport.pdf qui génère le rapport en latex - rapport.pdf dépend lui-même de table.tex qui est généré en exécutant le programme make_table - make_table est un programme C++ qui fait les calculs et génère une table latex Il y a juste une petite subtilité. En C++ les backslashs veulent dire qqc. Par example "\n" est le caractère de fin de ligne. Pour avoir "\n" explicitement, il faut doubler le backslash. J'ai utilisé une autre option qui d'utiliser des "raw string literals" en écrivant R"(\n)", ce qui vaut dire écrire exactement ce qu'il y a à l'intérieur de R"(...)". Il faut que aussi tu installes latex (sudo pacman -S texlive-core).
-rw-r--r--Makefile22
-rw-r--r--doc/rapport.tex14
-rw-r--r--src/make_table.cpp17
3 files changed, 47 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index 19d3fd4..7085018 100644
--- a/Makefile
+++ b/Makefile
@@ -3,8 +3,18 @@ CC=gcc
RM = rm
CXXFLAGS=-std=c++11 -g -O3 -Wall
GSL_FLAGS:=$(shell pkg-config --libs gsl)
-NLOPT_FLAGS:=$(shell pkg-config --libs nlopt)
-VPATH=src
+VPATH = src:doc
+
+all: rapport.pdf
+
+rapport.pdf: rapport.tex table.tex
+ latexmk -lualatex $<
+
+table.tex: make_table
+ ./make_table
+
+make_table: make_table.o mt19937.o
+ $(CXX) $^ -o $@
main: main.o rtnorm.o stratified_sampling.o mt19937.o var_alea.o opti.o
$(CXX) $^ -o $@ $(GSL_FLAGS) $(NLOPT_FLAGS)
@@ -22,8 +32,8 @@ rqmc: rqmc.o mt19937.o
option: option.o mt19937.o p_adic.o var_alea.o
$(CXX) $^ -o $@ $(GSL_FLAGS)
-opti: opti.o
- $(CXX) $^ -o $@ NLOPT_FLAGS
-
+.PHONY: clean
+
clean:
- -$(RM) -f *.o test stratified_sampling main option
+ -$(RM) -f *.o test stratified_sampling main option make_table
+ -latexmk -C rapport.pdf
diff --git a/doc/rapport.tex b/doc/rapport.tex
new file mode 100644
index 0000000..4d9b2bd
--- /dev/null
+++ b/doc/rapport.tex
@@ -0,0 +1,14 @@
+\documentclass[a4paper, 11pt]{article}
+\usepackage{fontspec}
+\begin{document}
+\section{Introduction}
+blablaba
+\section{Mes supers résultats}
+Voilà une équation:
+
+\[e^{\iota \pi}+1 =0\]
+
+\begin{center}
+\input{doc/table.tex}
+\end{center}
+\end{document}
diff --git a/src/make_table.cpp b/src/make_table.cpp
new file mode 100644
index 0000000..2eeca6e
--- /dev/null
+++ b/src/make_table.cpp
@@ -0,0 +1,17 @@
+#include <fstream>
+#include "var_alea.hpp"
+
+int main() {
+ std::fstream fs("doc/table.tex", std::fstream::out);
+ gaussian G(0,1);
+ uniform U(0,1);
+ expo E(1);
+ fs<<R"(\begin{tabular}{|l|l|l|l})"<<std::endl;
+ fs<<" " <<" & "<<"gaussienne"<<" & "<<"uniforme"<<" & "<<"exponentielle"<<R"(\\ \hline)"<<std::endl;
+ fs<<"valeur1"<<" & "<<G() <<" & "<<U() <<" & "<<E() <<R"(\\ \hline)"<<std::endl;
+ fs<<"valeur2"<<" & "<<G() <<" & "<<U() <<" & "<<E() <<R"(\\ \hline)"<<std::endl;
+ fs<<"valeur3"<<" & "<<G() <<" & "<<U() <<" & "<<E() <<R"(\\ \hline)"<<std::endl;
+ fs<<R"(\end{tabular})"<<std::endl;
+ fs.close();
+ return 0;
+}