并行计算
li8630
读书和旅行
展开
-
Erlang-多核并发时的树形通信
这段代码不是我写的,谢谢实验室的的师妹,接下来要把树形通信应用到求Pi上去。-module(my).-export([main/1,temp/2,integer_to_atom/1,judge/3,ceil/1]).main(CoreNum) -> SumDie=temp(CoreNum,1), Time=erlang:now(),原创 2015-04-18 20:38:23 · 925 阅读 · 0 评论 -
Erlang-实现进程环
M是消息传递数目,N进程数量,Msg是传递的消息-module(exe3_2).-export([start/3,stop/0]).start(M,N,Msg) ->register(ring,spawn(fun()->ring_service(M,N,Msg) end)).stop() -> ring!stop.ring_service(M,N,Msg) -> Ring=ring_nod原创 2015-04-07 09:26:11 · 621 阅读 · 0 评论 -
Erlang-并行梯度积分法
这个代码写了两天,从没思路到有思路,还好最终搞定了~不过这个进程数必须为2^n个。 先贴一个运行截图: -module(exe4).-export([start/5]).start(F,X1,X2,Num,Cores) ->spawn(fun()->parent_proces(F,X1,X2,Num,Cores) end), io:format("").parent_proce原创 2015-04-13 23:38:37 · 966 阅读 · 0 评论 -
Erlang-蒙特卡洛方法求Pi
-module(exe5_2).-export([start/2]).%Points 是投掷点的个数 Cores是核数,为2的幂start(Points,Cores) ->spawn(fun()->parent_proces(Points,Cores) end), io:format("").parent_proces(Points,Cores) -> Poin原创 2015-04-20 15:02:46 · 771 阅读 · 0 评论 -
Erlang 并行快速排序
这个代码主要是参考同学的这篇博客:http://blog.csdn.net/mutx_lck/article/details/45603767 。-module (exe7). -export ([start/2,handle/5,partition/1,list_length/1]). start (Data,M) -> Pid= spawn(?MODULE,handle,[Da原创 2015-05-11 14:59:41 · 615 阅读 · 0 评论 -
多线程版本的Item_KNN的C语言实现
这里模仿了Word2vec里面构建Hash索引的思想。#include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>#include <stdlib.h>#include <time.h>#include <pthread.h>#define MaxString 50#define MaxUserSi原创 2015-05-11 15:04:10 · 1447 阅读 · 0 评论 -
多线程版本的User_KNN的C语言实现
其中的数据格式: 一行一个用户购买记录,uid pid1 pid2…#include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>#include <stdlib.h>#include <time.h>#include <pthread.h>#define MaxString 50#define M原创 2015-05-07 15:37:39 · 1056 阅读 · 0 评论 -
Erlang -奇偶并行排序
-module (exe9). -export ([start/2,handle/4]). % L=[2,12,14,25,31,42,43,43,13,34,34,41,41,312,352,354].% 将数据分给各个进程,并创建 nodecreater([],Pids,M,Id,Master) -> io:form原创 2015-05-22 09:36:52 · 853 阅读 · 0 评论