pi

Fast algorithm to calculate Pi in parallel

强颜欢笑 提交于 2019-11-30 04:46:41
I am starting to learn CUDA and I think calculating long digits of pi would be a nice, introductory project. I have already implemented the simple Monte Carlo method which is easily parallelize-able. I simply have each thread randomly generate points on the unit square, figure out how many lie within the unit circle, and tally up the results using a reduction operation. But that is certainly not the fastest algorithm for calculating the constant. Before, when I did this exercise on a single threaded CPU, I used Machin-like formulae to do the calculation for far faster convergence. For those

python overwrite previous line

旧城冷巷雨未停 提交于 2019-11-30 03:10:32
问题 how do you overwrite the previous print in python 2.7? I am making a simple program to calculate pi. here is the code: o = 0 hpi = 1.0 i = 1 print "pi calculator" acc= int(raw_input("enter accuracy:")) if(acc>999999): print "WARNING: this might take a VERY long time. to terminate, press CTRL+Z" print "precision: " + str(acc) while i < acc: if(o==0): hpi *= (1.0+i)/i o = 1 elif(o==1): hpi *= i/(1.0+i) o = 0 else: print "loop error." i += 1 if i % 100000 == 0: print str(hpi*2)) print str(hpi*2)

raspberry pi蓝牙4.0低功耗

烈酒焚心 提交于 2019-11-29 18:28:48
raspberry pi上有两个USB口,前面的文章已经用了一个USB wifi适配器实现了一个加载机,今天用另外一个USB口连接蓝牙适配器,在raspberry pi上实现蓝牙功能。硬件上在网上买了一个ORICO的蓝牙适配器,该适配器支持bluetooth4.0标准。在我的raspberry pi上通过命令$lsusb可以看到如下内容: Bus 001 Device 004: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode) 该内容表示系统已经识别出蓝牙适配器。另外通过命令$lsmod | grep "btusb"可以看到如下内容: btusb 15521 0 bluetooth 221259 21 bnep,btusb 该内容表示内核部分已经正确加载usb蓝牙适配器的驱动模块。至于蓝牙协议栈内核模块,可以通过/proc/config.gz文件查看相应的蓝牙协议栈是否编译进内核或编译成模块。 bluez-5以上的版本支持蓝牙4.0的低功耗模式,raspbian的最新镜像(2013-12-20)源上的bluez版本是4.99。因此需要通过源代码编译。从bluez的官方网站上下载最新的bluez-5.13。编译bluez-5.13时需要在raspberry pi上安装如下开发包:libglib2

香蕉派 banana pi BPI-M64 四核心64位开源单板计算机 全志A64方案

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 18:10:47
Banana pi BPI-M64搭载全志 A64 1.2 Ghz四核ARM Cortex A53 64位处理器, GPU采用双核500MHz Mali-400 MP2,具有的1.1 gpixel的吞吐量,让其图形能力远高于X-Box的性能水平 banana pi BPI-M64由最新的64位四核ARM A53 CPU供电,可提供比其他同行的32位开源开发板高出20%~30%的性能. BPI-M64 主要配置亮点: *64 位四核 ARM Cortex A53 1.2 Ghz CPU *Dual core Mali 400 MP2 GPU *板载2G DDR3内存 * MicroSD卡座,可以从TF卡启动系统 * 板载8G eMMC flash,系统可以烧录到eMMC,从eMMC启动 * 板载WIFI与蓝牙 * 支持IR遥控,2USB接口 * 支持1000M网口 * 支持Linux和Android 6.0系统 硬件接口: 规格书: 更多资料,请看gitbook 在线文档: https://bananapi.gitbooks.io/bpi-m64/content/en/ 来源: oschina 链接: https://my.oschina.net/u/1177513/blog/710759

香蕉派 banana pi BPI-M64 四核心64位开源单板计算机 全志A64方案

元气小坏坏 提交于 2019-11-29 18:10:34
Banana pi BPI-M64搭载全志 A64 1.2 Ghz四核ARM Cortex A53 64位处理器, GPU采用双核500MHz Mali-400 MP2,具有的1.1 gpixel的吞吐量,让其图形能力远高于X-Box的性能水平 banana pi BPI-M64由最新的64位四核ARM A53 CPU供电,可提供比其他同行的32位开源开发板高出20%~30%的性能. BPI-M64 主要配置亮点: *64 位四核 ARM Cortex A53 1.2 Ghz CPU *Dual core Mali 400 MP2 GPU *板载2G DDR3内存 * MicroSD卡座,可以从TF卡启动系统 * 板载8G eMMC flash,系统可以烧录到eMMC,从eMMC启动 * 板载WIFI与蓝牙 * 支持IR遥控,2USB接口 * 支持1000M网口 * 支持Linux和Android 6.0系统 硬件接口: banana pi BPI-M64 硬件规格: banana pi BPI-M64在线文档: https://bananapi.gitbooks.io/bpi-m64/content/en/ 论坛: http://www.banana-pi.org http://www.banana-pi.org.cn 来源: oschina 链接: https://my

banana pi gpio testing

巧了我就是萌 提交于 2019-11-29 18:09:43
安装GPIO库 (1)更新源: $ sudo apt-get update (2)安装python: $ sudo apt-get install python-dev (3)安装python-pip( python-pip是一个可以替代easy_install的安装和管python软件包的工具) $ sudo apt-get install python-pip (4)利用pip安装rpi.gpio: $ sudo pip install rpi.gpio (5)安装wringpi库: 安装git-core $ sudo apt-get install git-core 载winringPi库 $ git clone git://git.drogon.net/wiringPi 编译和安装库 (在/wiringPi/examples目录中有一些例子可供大家参考) $ cd wiringPi $ ./build 另外大家可以使用下面的命令对库进行更新 $ cd wiringPi 实物图: C语言示例 说明:使用wiringpi这个库,类似arduino的编程风格,代码设置的GPIO编号为wiringPi pin、如果你想使用BCM GPIO则可以将wiringPiSetup() 改为wiringPiSetupGpio(),那么对应的led_pin也需要改为BCM

香蕉派 banana pi 英文论坛与GITHUB正式上线

拟墨画扇 提交于 2019-11-29 18:08:51
经过BPI team 的艰苦工作,BPI-M1,BPI-M1+,BPI-M2的源代码已经上传到GITHUB, github: https://github.com/bpi-sinovoip 所有镜像,在中英文论坛中都有下载。 BPI-WiringPi 官方支持已经发布 (BPI-GitHub) 测试结果 Banana Pi GPIO Python test is OK. Code uploaded to Github 测试结果: 来源: oschina 链接: https://my.oschina.net/u/1177513/blog/487708

香蕉派(banana pi )2015年10月 13 号至10月16号参加香港贸发局香港秋季电子

∥☆過路亽.° 提交于 2019-11-29 18:08:39
香蕉派(banana pi )将于2015年10月 13 号至10月16号参加香港贸发局香港秋季电子产品展, 欢迎各位前来参观指导 展会名称:香港贸发局香港秋季电子产品展2015 时间: 2015年10月13号--10月16号 展台编号:3C-A38 地址: 香港湾仔博览道1号香港会议展览中心 期待您的到来!! 来源: oschina 链接: https://my.oschina.net/u/1177513/blog/516558

Calculating an Answer in Java with more than 16 decimal places

*爱你&永不变心* 提交于 2019-11-29 16:25:28
I've written a small program to calculate Pi in Java. My summations are currently typed double . I have two outputs, one which is Pi to 16 decimal places (the raw output). The second output is rounded using NumberFormat / DecimalFormat to 3-5 decimal places. I've spent a little while googling and browsing Stackoverflow but being a beginner I'm unsure of any keywords that may be needed to find the correct method I'm looking for, so please excuse my naivety... Is it possible to calculate an answer (i.e. Pi) to more than 16 decimal places? Say, 32? If so, how can I approach this? I've looked at

Can anyone make heads or tales of this spigot algorithm code Pitiny.c

与世无争的帅哥 提交于 2019-11-29 15:22:16
问题 This C program is just 143 characters long! But it “decompresses” into the first 10,000 digits of Pi . // Created by cheeseMan on 30/11/13. long a[35014],b,c=35014,d,e,f=1e4,g,h; int main(int argc, const char * argv[]) { for(;(b=c-=14); h=printf("%04ld",e+d/f)) for(e=d%=f;(g=--b*2);d/=g) d=d*b+f*(h?a[b]:f/5), a[b]=d%--g; } I was doing some research on loss-less compression algorithms, still no luck yet, when I came across this pitiny.c . The weird thing is that it compiles successfully no