mirror of
https://github.com/MartinThoma/LaTeX-examples.git
synced 2025-04-26 06:48:04 +02:00
Misc; E-Mail von Moritz
This commit is contained in:
parent
9c0864f122
commit
0508de3f6a
14 changed files with 122 additions and 16 deletions
|
@ -1,18 +1,24 @@
|
|||
void my_bcast(void* data, int count, MPI_Datatype type,
|
||||
void my_bcast(void* data, int count,
|
||||
MPI_Datatype type,
|
||||
int root, MPI_Comm comm) {
|
||||
int my_rank;
|
||||
|
||||
int my_rank, comm_size;
|
||||
MPI_Comm_rank(comm, &my_rank);
|
||||
int comm_size;
|
||||
MPI_Comm_size(comm, &comm_size);
|
||||
|
||||
if (my_rank == root) {
|
||||
// If we are the root process, send our data to every one
|
||||
// If we are the root process, send our
|
||||
// data to every one
|
||||
for (int i = 0; i < comm_size; i++) {
|
||||
if (i != my_rank) {
|
||||
MPI_Send(data, count, type, i, 0, comm);
|
||||
MPI_Send(data, count,
|
||||
type, i, 0, comm);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// If we are a receiver process, receive the data from root
|
||||
MPI_Recv(data, count, type, root, 0, comm, MPI_STATUS_IGNORE);
|
||||
// If we are a receiver process,
|
||||
// receive the data from root
|
||||
MPI_Recv(data, count, type, root, 0,
|
||||
comm, MPI_STATUS_IGNORE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
cbal_tree(0,nil) :- !.
|
||||
cbal_tree(N,t(x,L,R)) :- N > 0,
|
||||
N0 is N - 1,
|
||||
N1 is N0//2, N2 is N0 - N1,
|
||||
distrib(N1,N2,NL,NR),
|
||||
cbal_tree(NL,L), cbal_tree(NR,R).
|
||||
|
||||
distrib(N,N,N,N) :- !.
|
||||
distrib(N1,N2,N1,N2).
|
||||
distrib(N1,N2,N2,N1).
|
|
@ -0,0 +1,8 @@
|
|||
T0 = t(a, nil, nil).
|
||||
T1 = t(a, t(b, nil), t(c, nil)).
|
||||
T2 = t(a, t(b, t(c, nil, nil),
|
||||
t(d, nil, nil)
|
||||
),
|
||||
t(e, nil, nil)
|
||||
).
|
||||
T3 = nil
|
2
documents/Programmierparadigmen/scripts/prolog/istree.pl
Normal file
2
documents/Programmierparadigmen/scripts/prolog/istree.pl
Normal file
|
@ -0,0 +1,2 @@
|
|||
istree(nil).
|
||||
istree(t(_,L,R)) :- istree(L), istree(R).
|
|
@ -0,0 +1,5 @@
|
|||
rev([], []).
|
||||
rev([X|Xs], Ys) :- rev(Xs, Zs), append(Zs, [X], Ys).
|
||||
|
||||
?- rev([1,2,3,4,5], L).
|
||||
L = [5, 4, 3, 2, 1].
|
Loading…
Add table
Add a link
Reference in a new issue