摘要:
先回顾一下范数的定义(en.wikipedia.org/wiki/Norm_(mathematics)):Given a vector space V over a subfield F of the complex numbers, a norm on V is a function p: V →... 阅读全文
摘要:
一直以为梯度下降很简单的,结果最近发现我写的一个梯度下降特别慢,后来终于找到原因:step size的选择很关键,有一种叫backtracking line search的梯度下降法就非常高效,该算法描述见下图:下面用一个简单的例子来展示,给一个无约束优化问题:minimize y = (x-3)*... 阅读全文
摘要:
http://oj.leetcode.com/problems/lru-cache/参考了这篇文章,是用双向链表和unordered_map来实现的,难点在于复杂的指针操作,以及每次get,set之后都要考虑map是否要改变,还有,要同步更新size,这也容易遗忘最后,我从中抽象出一个moveToHead的函数,简化了代码本来想用单链表实现的,到中途发现似乎不行事后的思考:也许有单独的不存储数据的头结点和尾节点会使得真正操作简单一点,可以避免考虑很多边界情况,NULL指针问题//seems that single linked list is not enough#include #inclu 阅读全文
摘要:
比如像下面这样for (int i : new int[]{1,4,8}){ System.out.println(i);}或者这样:for (String i : new String[]{"1","2a"}){ System.out.println(i);}可以感受到一点python遍历的风格#This is python codefor i in [1,2,'x']: print(i)python的list允许不同类型的object,所以,更强大一点。不过,像上面这样把数字和字符串混合起来遍历,还是很少见的,这只是个例子而已。这种J 阅读全文
摘要:
在eclipse使用log4j2的时候遇到个问题:我已经把log4j2.xml放到/src目录下了,而且设置从trace开始都打印到终端,但是我的程序里trace, info都不打印,到了error才打印后来我发现,要选中eclipse的项目,右键--刷新,使得能在eclipse里看到log4j2.xmlYou could also see my answer here:http://stackoverflow.com/questions/14733698/log4j-2-configuration-issue/19875543#19875543 阅读全文
摘要:
https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=20&page=show_problem&problem=1709在一个周长为10000的圆上等距分布着n个雕塑。现在又有m个新雕塑加入(位置可以随意放),希望所有n+m个雕塑在圆周上均匀分布。这就需要移动其中一些原有的雕塑。要求n个雕塑移动的总距离尽量小。2第7页n = 7;%original points on a circlem = 32;% points to be addeddist 阅读全文
摘要:
我的电脑是win7系统32位,ctex版本是v2.9.2.164 full(http://www.ctex.org/CTeXDownload)一直不太清楚moderncv里面类似\cventry这种东西的语法,搜了一下“moderncv manual”结果在ctan里看到这个Until a decent manual is written, you can always look in the "examples"directory for some examples.(http://www.ctan.org/tex-archive/macros/latex/contrib 阅读全文
摘要:
matlab中有newpnn这样一个函数,不过help里说的不够清楚,help里是这么说的% net = newpnn(P,T,spread) takes two or three arguments, P% R-by-Q matrix of Q input vectorsT % S-by-Q matrix of Q target class vectors spread % Spread of radial basis functions (default = 0.1)其实这里 Q 是样本数, S 类数(即训练数据有几个类号), R 特征数给一个可以跑得通的样例,用UCI的iris数据,把类 阅读全文
摘要:
http://stackoverflow.com/questions/21593/what-is-the-difference-between-include-filename-and-include-filenameThe sequence of characters between < and > uniquely refer to a header, which isn't necessarily a file. Implementations are pretty much free to use the character sequence as they wis 阅读全文
摘要:
搜索“ASP solver”可以得到若干个,clasp是其中一个http://www.cs.uni-potsdam.de/clasp/?page=main有本教程叫A User's Guide to gringo,clasp, clingo, and iclingo,Google一下就可以下到Answer Set Programming的优点在于,你只需要定义规则,求解的方法由ASP solver来解决,这是一种declarative language,和SQL同类看如下这个数独(http://www.sudoku.name/index-cn.php):首先描述facts(文件sudo 阅读全文
摘要:
Excel中有按某一列排序,同时扩展到其他列,Matlab中对应的有sortrows:The MATLAB functionsortrows(A,j)sorts the rows of the matrixabased on the entries of thej-th column. For example, enter the following in MATLAB: A = [1 2 3 3 0 9 6 5 4] B = sortrows(A,2) C = sortrows(A,3)You will receive the following output: B = 3 0 ... 阅读全文
摘要:
最近用Java写了个pagerank,发现最终算出来的PageRank值的和不是1,但是这个和应该是1的,所以就用python的networkx包中的PageRank算法做了一个测试:import osimport networkx as nxos.chdir('C:\\Users\\XXX\\Desktop\\')filename = 'Wiki-Vote.txt'G=nx.DiGraph()with open(filename) as file: for line in file: head, tail = [int(x) for x in line.spl 阅读全文
摘要:
http://stackoverflow.com/questions/2828255/how-do-i-increase-the-capacity-of-the-eclipse-output-consoleUnder Window > Preferences, go to the Run/Debug > Console section, then you should see an option "Limit console output." You can uncheck this or change the number in the "Conso 阅读全文
摘要:
如果需要复制一个对象,提供类似下面这种方法似乎是个不错的选择Foo copyFoo (Foo foo){ Foo f = new Foo(); //for all properties in FOo f.set(foo.get()); return f;}Effective Java,第11条有关于clone的讨论http://stackoverflow.com/questions/2427883/clone-vs-copy-constructor-which-is-recommended-in-javahttp://www.xenoveritas.org/blog/xeno/java... 阅读全文
摘要:
平台:ubuntu12.04LTS,boost1.531、应该用g++编译,而不是cc,本来想亲自解释一下的,然后发现有人写过了,看这里,简单来说,cc是指向gcc的符号链接,而gcc不能处理C++的linking.所以通常编译命令就是g++ myfile.cpp -o myfile,偶尔要链接额外的库,见第2条 还有一段觉得讲得不错(http://stackoverflow.com/questions/1516609/difference-between-cc-gcc-and-g)CCis an environment variable referring to the system' 阅读全文