October 29, 2010
matlab syms
>>syms y
>> y=diff(0.25*3^x*exp(-3.56*x*(1-x)))
y =
(3^x*exp((89*x*(x - 1))/25)*((178*x)/25 - 89/25))/4 + (3^x*exp((89*x*(x - 1))/25)*log(3))/4
>> solve('-(178*x)/25 + 89/25-log(3)=0','x')
ans = 1/2 - (25*log(3))/178
>> x=1/2 - (25*log(3))/178
x = 0.3457
***OR***
>> solve('y=0','y','x')
% if x has only one solution, the value can be seen from the "Workspace"
% However, if it has more than one solution, i still do not know how to look into % the construction of syms......
backup: interview summary
1.
n支队伍比赛,分别编号为0,1,2。。。。n-1,已知它们之间的实力对比关系,存储在一个二维数组w[n][n] 中,w[i][j]
的值代表编号为i,j的队伍中更强的一支 所以w[i][j]=i 或者j,现在给出它们的出场顺序,并存储在数组order[n]中,
比如order[n] = {4,3,5,8,1......},那么第一轮比赛就是 4对3, 5对8。。。。。。
胜者晋级,败者淘汰,同一轮淘汰的所有队伍排名不再细分,即可以随便排,
下一轮由上一轮的胜者按照顺序,再依次两两比,比如可能是4对5,直至出现第一名
编程实现,给出二维数组w,一维数组order 和 用于输出比赛名次的数组result[n],求出result
2.题目说的比较花哨,根据我的理解,本质上就是有n个长为m+1的字符串,如果某个字符串的最后m个字符与某个字符串的前m个字符匹配,则两个字符串可以联接,问这n个字符串最多可以连成一个多长的字符串,如果出现循环,则返回错误
百度面试:
3.
用天平(只能比较,不能称重)从一堆小球中找出其中唯一一个较轻的,使用x次天平 最多可以从y个小球中找出较轻的那个,求y与x的关系式
4.有一个很大很大的输入流,大到没有存储器可以将其存储下来,而且只输入一次,如何从这个输入流中随机取得m个记录
5.大量的URL字符串,如何从中去除重复的,优化时间空间复杂度
网易有道笔试:
6. 求一个二叉树中任意两个节点间的最大距离,两个节点的距离的定义是
这两个节点间边的个数,比如某个孩子节点和父节点间的距离是1,和相邻兄弟节点间的距离是2,优化时间空间复杂度
7.求一个有向连通图的割点,割点的定义是,如果除去此节点和与其相关的边,有向图不再连通,描述算法
discussion can be found @:
http://topic.csdn.net/u/20100930/13/9f10c56c-9545-488e-9b53-edffc9b6761d.html
==========
GOOGLE今天晚上的笔试题,刚参加回来.
第一题比较简单,检测同一个平面上的两个矩形是否重合
第二题是,给定一个随机函数,对一个数组进行随机排列,保证所有可能的排列出现的概率相等,也就是n!分之一
第三题就是约瑟夫问题的最优解法~Knuth具体数学上有,不过我忘记了,自己没推导出来,就写了个模拟
discussion can be found @:
http://topic.csdn.net/u/20101018/23/75b6dc53-610f-401e-b8ae-5aebee5cabe8.html
==========
雅虎:
1.对于一个整数矩阵,存在一种运算,对矩阵中任意元素加一时,需要其相邻(上下左右)某一个元素也加一,现给出一正数矩阵,判断其是否能够由一个全零矩阵经过上述运算得到。
2.一个整数数组,长度为n,将其分为m份,使各份的和相等,求m的最大值
比如{3,2,4,3,6} 可以分成{3,2,4,3,6} m=1;
{3,6}{2,4,3} m=2
{3,3}{2,4}{6} m=3 所以m的最大值为3
搜狐:
3.四对括号可以有多少种匹配排列方式?比如两对括号可以有两种:()()和(())
创新工场:
4.求一个数组的最长递减子序列 比如{9,4,3,2,5,4,3,2}的最长递减子序列为{9,5,4,3,2}
微软:
5.一个数组是由一个递减数列左移若干位形成的,比如{4,3,2,1,6,5}是由{6,5,4,3,2,1}左移两位形成的,在这种数组中查找某一个数。
discussion can be found @:
http://topic.csdn.net/u/20101021/14/7fdbcd52-3ee6-42ce-b48e-8fb56c4418da.html
==========
雅虎:
1.对于一个整数矩阵,存在一种运算,对矩阵中任意元素加一时,需要其相邻(上下左右)某一个元素也加一,现给出一正数矩阵,判断其是否能够由一个全零矩阵经过上述运算得到。
2.一个整数数组,长度为n,将其分为m份,使各份的和相等,求m的最大值
比如{3,2,4,3,6} 可以分成{3,2,4,3,6} m=1;
{3,6}{2,4,3} m=2
{3,3}{2,4}{6} m=3 所以m的最大值为3
搜狐:
3.四对括号可以有多少种匹配排列方式?比如两对括号可以有两种:()()和(())
创新工场:
4.求一个数组的最长递减子序列 比如{9,4,3,2,5,4,3,2}的最长递减子序列为{9,5,4,3,2}
微软:
5.一个数组是由一个递减数列左移若干位形成的,比如{4,3,2,1,6,5}是由{6,5,4,3,2,1}左移两位形成的,在这种数组中查找某一个数。
discussion can be found @:
http://topic.csdn.net/u/20101021/14/7fdbcd52-3ee6-42ce-b48e-8fb56c4418da.html
sth. about usrp in gnuradio
> Hi all,
>
> We are working on USRP. Please can any let us know what the
> factors or on what basis the audio_decimation, if_freq, usrp_decim.
These values are choosen so that the sample rates through the
processing path "make sense". The USRP can sample and decimate at
particular rates. The audio sink/source can sample at particular
rates. We generally pick ratios such that they are related by simple
integer factors and that the signals of interest have appropriate
bandwidth at various points in the signal processing chain.
The API for using and controlling the usrp is documented in
usrp/host/lib/usrp_basic.h and usrp_standard.h
> It will be help if we can get what the following mention programs does:
> 1. usrp_fft_simple.py
Does the same thing as usrp_fft only with less gui cruft.
(Plots Fast Fourier Transform of samples received from USRP.)
> 2. benchmark_usb.py
An unreliable program to detemine maximum bandwidth of USB
>From the comment at the top of the file:
Benchmark the USB/USRP throughput. Finds the maximum full-duplex speed
the USRP/USB combination can sustain without errors.
> 3. usrp_oscope.py
Digital oscilloscope that uses a USRP as the source of samples.
> 4. dbs_debug.py
Program to assist in debugging the DBS_RX daughterboard.
The DBS_RX daughterboard is a receive-only daughterboard that covers
800 MHz to 2400 MHz.
> 5. nbfm_ptt_quick_and_dirty.py
Removed from CVS. See nbfm_ptt.py Narrow Band FM "Push to Talk" (wakie-talkie)
> 6. usrp_rx_cfile.py
Read samples from the USRP and write to file formatted as binary
single-precision complex values.
> 7. dbs_fft.py
Removed from CVS.
> 8. nbfm_rcv.py
Narrow Band FM receiver.
If you haven't already, I suggest that you spend some time with:
http://www.gnu.org/software/gnuradio/doc/exploring-gnuradio.html
http://www.gnu.org/software/gnuradio/doc/howto-write-a-block.html
Also, there are online docs for the C++ guts:
http://www.gnu.org/software/gnuradio/doc/index.html
matlab log
Syntax: Y = log(X)
Description:
The log function operates element-wise on arrays. Its domain includes
complex and negative numbers, which may lead to unexpected results if
used unintentionally.
Y = log(X) returns the natural logarithm of the elements of X. For
complex or negative , where , the complex logarithm is returned.
log(z) = log(abs(z)) + i*atan2(y,x)
Examples
The statement abs(log(-1)) is a clever way to generate .
ans =
3.1416
CS Conference Rankings: System Technology area
SIGCOMM: ACM Conf on Comm Architectures, Protocols & Apps
INFOCOM: Annual Joint Conf IEEE Comp & Comm Soc
SPAA: Symp on Parallel Algms and Architecture
PODC: ACM Symp on Principles of Distributed Computing
PPoPP: Principles and Practice of Parallel Programming
RTSS: Real Time Systems Symp
SOSP: ACM SIGOPS Symp on OS Principles
SOSDI: Usenix Symp on OS Design and Implementation
CCS: ACM Conf on Comp and Communications Security
IEEE Symposium on Security and Privacy
MOBICOM: ACM Intl Conf on Mobile Computing and Networking
USENIX Conf on Internet Tech and Sys
ICNP: Intl Conf on Network Protocols
PACT: Intl Conf on Parallel Arch and Compil Tech
RTAS: IEEE Real-Time and Embedded Technology and Applications Symposium
ICDCS: IEEE Intl Conf on Distributed Comp Systems
Rank 2:
CC: Compiler Construction
IPDPS: Intl Parallel and Dist Processing Symp
IC3N: Intl Conf on Comp Comm and Networks
ICPP: Intl Conf on Parallel Processing
SRDS: Symp on Reliable Distributed Systems
MPPOI: Massively Par Proc Using Opt Interconns
ASAP: Intl Conf on Apps for Specific Array Processors
Euro-Par: European Conf. on Parallel Computing
Fast Software Encryption
Usenix Security Symposium
European Symposium on Research in Computer Security
WCW: Web Caching Workshop
LCN: IEEE Annual Conference on Local Computer Networks
IPCCC: IEEE Intl Phoenix Conf on Comp & Communications
CCC: Cluster Computing Conference
ICC: Intl Conf on Comm
WCNC: IEEE Wireless Communications and Networking Conference
CSFW: IEEE Computer Security Foundations Workshop
Rank 3:
MPCS: Intl. Conf. on Massively Parallel Computing Systems
GLOBECOM: Global Comm
ICCC: Intl Conf on Comp Communication
NOMS: IEEE Network Operations and Management Symp
CONPAR: Intl Conf on Vector and Parallel Processing
VAPP: Vector and Parallel Processing
ICPADS: Intl Conf. on Parallel and Distributed Systems
Public Key Cryptosystems
Annual Workshop on Selected Areas in Cryptography
Australasia Conference on Information Security and Privacy
Int. Conf on Inofrm and Comm. Security
Financial Cryptography
Workshop on Information Hiding
Smart Card Research and Advanced Application Conference
ICON: Intl Conf on Networks
NCC: Nat Conf Comm
IN: IEEE Intell Network Workshop
Softcomm: Conf on Software in Tcomms and Comp Networks
INET: Internet Society Conf
Workshop on Security and Privacy in E-commerce
Un-ranked:
PARCO: Parallel Computing
SE: Intl Conf on Systems Engineering (**)
PDSECA: workshop on Parallel and Distributed Scientific and
Engineering Computing with Applications
CACS: Computer Audit, Control and Security Conference
SREIS: Symposium on Requirements Engineering for Information Security
SAFECOMP: International Conference on Computer Safety, Reliability and Security
IREJVM: Workshop on Intermediate Representation Engineering for the
Java Virtual Machine
EC: ACM Conference on Electronic Commerce
EWSPT: European Workshop on Software Process Technology
HotOS: Workshop on Hot Topics in Operating Systems
HPTS: High Performance Transaction Systems
Hybrid Systems
ICEIS: International Conference on Enterprise Information Systems
IOPADS: I/O in Parallel and Distributed Systems
IRREGULAR: Workshop on Parallel Algorithms for Irregularly Structured Problems
KiVS: Kommunikation in Verteilten Systemen
LCR: Languages, Compilers, and Run-Time Systems for Scalable Computers
MCS: Multiple Classifier Systems
MSS: Symposium on Mass Storage Systems
NGITS: Next Generation Information Technologies and Systems
OOIS: Object Oriented Information Systems
SCM: System Configuration Management
Security Protocols Workshop
SIGOPS European Workshop
SPDP: Symposium on Parallel and Distributed Processing
TreDS: Trends in Distributed Systems
USENIX Technical Conference
VISUAL: Visual Information and Information Systems
FoDS: Foundations of Distributed Systems: Design and Verification of
Protocols conference
RV: Post-CAV Workshop on Runtime Verification
ICAIS: International ICSC-NAISO Congress on Autonomous Intelligent Systems
ITiCSE: Conference on Integrating Technology into Computer Science Education
CSCS: CyberSystems and Computer Science Conference
AUIC: Australasian User Interface Conference
ITI: Meeting of Researchers in Computer Science, Information Systems
Research & Statistics
European Conference on Parallel Processing
RODLICS: Wses International Conference on Robotics, Distance Learning
& Intelligent Communication Systems
International Conference On Multimedia, Internet & Video Technologies
PaCT: Parallel Computing Technologies workshop
PPAM: International Conference on Parallel Processing and Applied Mathematics
International Conference On Information Networks, Systems And Technologies
AmiRE: Conference on Autonomous Minirobots for Research and Edutainment
DSN: The International Conference on Dependable Systems and Networks
IHW: Information Hiding Workshop
GTVMT: International Workshop on Graph Transformation and Visual
Modeling Techniques
October 22, 2010
basic python math calculation in gnuradio
####################
# Shared Functions
#####################
import numpy
import math
"""
# Python is a general purpose programming language.
It is interpreted and dynamically typed and is very
suited for interactive work and quick prototyping,
while being powerful enough to write large applications in.
# NumPy is a Python extension module, written mostly in C,
that defines the numerical array and matrix types
and basic operations on them.
"""
def get_exp(num):
"""
Get the exponent of the number in base 10.
@param num the floating point number
@return the exponent as an integer
"""
if num == 0: return 0
return int(math.floor(math.log10(abs(num))))
def get_clean_num(num):
"""
Get the closest clean number match to num with bases 1, 2, 5.
@param num the number
@return the closest number
"""
if num == 0: return 0
sign = num > 0 and 1 or -1
exp = get_exp(num)
nums = numpy.array((1, 2, 5, 10))*(10**exp)
return sign*nums[numpy.argmin(numpy.abs(nums - abs(num)))]
#numpy.argmin: Return the indices of the minimum values along an axis.
def get_clean_incr(num):
"""
Get the next higher clean number with bases 1, 2, 5.
@param num the number
@return the next higher number
"""
num = get_clean_num(num)
exp = get_exp(num)
coeff = int(round(num/10**exp))
return {
-5: -2,
-2: -1,
-1: -.5,
1: 2,
2: 5,
5: 10,
}[coeff]*(10**exp)
def get_clean_decr(num):
"""
Get the next lower clean number with bases 1, 2, 5.
@param num the number
@return the next lower number
"""
num = get_clean_num(num)
exp = get_exp(num)
coeff = int(round(num/10**exp))
return {
-5: -10,
-2: -5,
-1: -2,
1: .5,
2: 1,
5: 2,
}[coeff]*(10**exp)
def get_min_max(samples):
"""
Get the minimum and maximum bounds for an array of samples.
@param samples the array of real values
@return a tuple of min, max
"""
scale_factor = 3
mean = numpy.average(samples)
rms = numpy.max([scale_factor*((numpy.sum((samples-mean)**2)/len(samples))**.5),
.1])
min = mean - rms
max = mean + rms
return min, max
(ZT) unix vs. windows
文化,我首先想到的是文化。Unix和Windows从诞生之初的文化差异本质上划分了两者的界限。直观看来,一个装逼文化,一个傻逼文化。
Unix诞生在贝尔实验室的MULTICS项目之后。据说当时这个项目设计得十分复杂,功能设计也几乎是上天入地无所不能。虽说当时贝尔实验室是很牛,可以牛到不用装逼也能露逼一下的地步。但历史告诉我们这种项目最后绝对会死得很惨。当然,项目最终结果还是没有违背历史规律。当时一位MULTICS参与者Ken Thompson事后痛定思痛,准备重新自己开发一个多任务操作系统,摒弃了MULTICS过于复杂的系统设计,力求新系统的简洁紧凑。传闻时值Ken Thompson老婆带上孩子回娘家过日子去了,一时间Ken Thompson晚上无以为乐,只好天天以堆码为业。不到一个月,Ken Thompson用汇编把这套操作系统编写出来了,这就是后来流芳百世的UNIX。当然,当时的Ken Thompson根本没有意会到他这个业余时间的作品会改变整个计算机发展史。因此这个操作系统设计用户群只针对他预想的计算机科学家、黑客,再不济怎么也得算上个计算机科学技术本科生。Unix只面对政府、研究机构、大学等专业性很强的机构,简洁、高效、安全是Unix的文化哲学。同时结合到当时的硬件条件限制,也不难理解UNIX诞生之初就根深蒂固的文化:
1、计算机庞大的占地面积、高额的购买维护费用使得普通用户根本无力支撑起一台计算机的各种资源消耗,当时更多的是计算机专家在通过终端在控制整个计算机运作逻辑。没有GUI、没有多媒体,字符界面,这对于这批靠计算机完成科学任务的黑客来说已经完全够用了。
2、同时遵循简洁统一的输入输出接口,相比于GUI的事件驱动模型来说,更适合使用脚本将各种程序粘合起来,完成复杂多样的计算任务。
有人说起过UNIX正巧在当年GUI史前诞生,时运不济,所以只出了个字符怪胎,要是再踌躇几年,等到GUI日臻成熟,那诞生出的UNIX恐怕就是如今Windows的翻版了。对此我还是不太认可,UNIX的存在是计算机荒洪时代遗留的文化,即使现在丰富多彩的GUI也照样没有改变UNIX的基础设计恐怕就是一个极好的证据。目前大多数的服务器依然保持着当年UNIX诞生之初的风貌,依然CLI、依然Shell,因为我们需要把更多的资源让给使用服务器的客户,人类对计算机性能的榨取永远是贪婪的。这让我想起了几年前Windows渐入佳境PC,游戏刚大行其道,桌面游戏编写还不是那么方便时候,有人预言等几年之后,按照摩尔定律,编写星际争霸之类的游戏便不需要多牛逼的算法,甚至能用写脚本语言都能完成。这几年算是大致差不多算过来了吧,星际是有牛人用JavaScript完成了,不过现时最牛逼的游戏(如魔兽世界)还是会用很牛逼的算法,还是需要使用C/C++,还是需要精通图形学,还是需要熟悉图形硬件。所以不管硬件如何发展,UNIX文化中的简洁高效这些准则还是依然存在,因为我们会把最佳的性能留给我们服务器的客户,然后可以把敲打字符,玩弄指法的时间留给自己,在老板面前装逼一下。
Windows(以及其前任DOS)诞生在公司,公司不像学院,不会像UNIX一样如果能装逼就尽量装逼一下,公司直接面对客户,产品唯一使命就是取悦用户,只能把用户伺候好了,公司才能维系发展。所以Windows诞生之初就一直肩负比尔"让每一个家庭都有一台电脑"的使命,不装逼,不玩酷,一切功能照顾用户,就是用户是傻逼你也得当亲爹一样伺候。故而Windows一直就假定使用它的用户你就是一个傻逼,哪怕是删除文件这个小问题上,Windows也会想小娘们儿一样谨谨慎慎战战兢兢地一再向人确认"确实要删除****吗?""确实要删除只读文件****吗?"。当然,最终能够让大妈大叔阿公阿婆阿猫阿狗都能使用上计算机的Windows绝对占领了终端用户桌面,比尔也因此一夜暴富,摇身一变成为世界首富&慈善家。不得不承认,如果没有Windows,"让每一个家庭都有一台电脑"的崇高理想恐怕又得推迟几年才能够得以实现了。自然,微软技术是肯定不差的,而不是像一些Linux小菜鸟口中所言"微软技术很烂",相反微软技术是很牛的,牛到曾经豪言可以立马灭掉Google,试看如今还有谁可以发出这样傻逼的豪言。但是微软牛,不代表Windows就可以干过MULTICS,上天入地翻江倒海无所不能。Windows 在安全性、性能以及开源项目上与UNIX相比确实还是有一定差距,但这并不妨碍windows成为桌面第一大操作系统。
UNIX的黑客们,眼见着曾经引以为豪的计算机技术壁垒瞬间被Windows GUI冲击到荡然无存了,心中肯定是有落差的。不过这段技术演变技术普及已经成为了历史发展趋势。一个少数人才能驾驭的技术,哪怕就是敲一个ls这样简单的命令,你也可以把它吹破牛皮,扯虎皮拉大旗捧为艺术珍品,搞得善男甚广善女甚众。一旦技术被迫普及后,曾经视作的艺术瞬间就被廉价的工业化大生产所替代,现在满大街的廉价代码工就是计算机程序设计工业化后的结果。前段时间众人大骂Java程序员把自己的价位又拉低了。殊不知,拉低自己价位的非Java也,乃工业化大生产趋势。今不出Java,明儿准会出来个Bava,Cava,照样把你收拾成码农。时至如今,UNIX黑客们还在装逼,用CLI命令行跑出花花绿绿的文字,时不时感叹下曾经的软件英雄时代一去不复返,时不时像祥林嫂一般唠叨"当年哥可是写汇编的,没想到如今沦落到如此地步,人心不古,世风日下啊~",时不时还顾影自怜,想装逼下,可惜时光不再。
妈逼的给老子回去写代码!这个月还想不想领工资了!?
结语:
不管是UNIX的装逼文化,还是Windows的傻逼文化,最终在计算机产业工业化的历史滚滚长流中归于平庸,归于廉价。曾经的那批牛逼的、不牛逼的、风骚的、不风骚的UNIX文化精英们,如今早已是廉颇老矣,尚可喝粥。曾经被意淫为"计算机科学与艺术"如今也早已沦落为"软件码工"。软件英雄时代早已不再,编码也成为三百六十行中的一行,一种用以谋生的手段,一种混饭吃的活路。关键问题早已不在程序,不在编码:
编程只是一个工具,关键在于你拿这个工具来实现别人的事业,还是自己的事业。
