diff --git a/Lectures_my/EMPP/2016/Lecture4/Exercises/Markov/Makefile b/Lectures_my/EMPP/2016/Lecture4/Exercises/Markov/Makefile new file mode 100644 index 0000000..369c5c1 --- /dev/null +++ b/Lectures_my/EMPP/2016/Lecture4/Exercises/Markov/Makefile @@ -0,0 +1,65 @@ +#---------------------------------------------------------------------- +# Przyklad linkowania bibliotek systemu ROOT z wlasnym programem +#---------------------------------------------------------------------- +.SUFFIXES: .o .c .cxx .cpp .C .f .l .s .sh .h .a +#====================================================================== +# Biblioteki ROOTa dla linkera +# 1) Jawnie: +## Sciezka to systemu ROOT - nalezy ja ustawic odpowiednio +#RPATH = /usr/local/root/ +#RLIB= -L$(RPATH)lib -lCore -lCint -lHist -lGraf -lGraf3d -lGpad -lTree \ +# -lRint -lPostscript -lMatrix -lPhysics -lm -ldl -lpthread -rdynamic +# 2) Niejawnie, przy uzyciu root-config +RLIB= `root-config --libs` +#====================================================================== +# Nazwa biezacego katalogu +DIRNAME = ./ +#====================================================================== +# Nazwa rdzeniowa modulu programu +NAME1 = mark1 +NAME2 = mark +#NAME2 = generatory +# Pliki objectowe (po kompilacji) +#OBJT1 = $(NAME1).o +OBJT2 = $(NAME2).o +# Pliki wykonawcze (po linkowaniu) +#EXEC1 = $(NAME1).x +EXEC1 = $(NAME2).x +# Nazwa i opcje kompilatora +CXX = g++ +# 1) Jawnie +#CXXFLAGS = -O -Wall -pthread -I$(RPATH)include +# 2) Przy uzyciu root-config +CXXFLAGS = -O -Wall `root-config --cflags` +# Nazwa i opcje linkera +LD = $(CXX) +LDFLAGS = `root-config --ldflags` +#============================================================================== +# Kompilacja dla modulow z plikami naglowkowymi +%.o: %.cxx %.h + $(CXX) $(CXXFLAGS) -c $< +# Kompilacja dla modulow bez plikow naglowkowych +%.o: %.cxx + $(CXX) $(CXXFLAGS) -c $< +#============================================================================== +.PHONY: all run clean tar +all: ${EXEC1} +#============================================================================== +# Linkowanie +${EXEC1}: ${OBJT1} ${OBJT2} + $(LD) -o $@ $(LDFLAGS) $^ $(RLIB) +#============================================================================== +# Uruchamianie +run: ${EXEC1} + ./${EXEC1} +#============================================================================== +clean: + (rm -f *.o *.a *~ *.exe *.x core lmap *.dvi *.aux *.log a.out) +#============================================================================== +tar: clean + (cd ../; tar -cvzf $(DIRNAME).tar.gz $(DIRNAME) ) +#============================================================================== +# Wszelkie akcje jakie należy podjąć aby program zaprezentował swoje działanie: +test: run + @echo 'Test run finished' +#============================================================================== diff --git a/Lectures_my/EMPP/2016/Lecture4/Exercises/Markov/mark.cc b/Lectures_my/EMPP/2016/Lecture4/Exercises/Markov/mark.cc new file mode 100644 index 0000000..591b56c --- /dev/null +++ b/Lectures_my/EMPP/2016/Lecture4/Exercises/Markov/mark.cc @@ -0,0 +1,50 @@ +#include +#include +#include +#include +#include + + +using namespace std; + +int main(int argc, char **argv) +{ + double h[3][4]={ {0.4, 0.2, 0.3,0.1},{0.1,0.4,0.3,0.2},{0.5,0.3,0.1,0.1}}; + double a[3]={1.5,-1.0,0.7}; + int j = atoi(argv[1]); + int original =j; + int n_of_samples = atoi(argv[2]); + TRandom1 *rand = new TRandom1(2131); + double result =0; + double result2=0; + for(int i =0;i< n_of_samples;++i) + { + int last; + j=original; + while(1) + { + last =j; + double tmp =rand->Rndm(); + if(tmp h[j-1][0] && tmp h[j-1][1]+h[j-1][0] && tmp h[j-1][2]+h[j-1][1]+h[j-1][0] && tmp