摘要: 应该说,cvxpy的安装说明是很棒的,一步一步非常清楚,www.cvxpy.org/en/latest/install/index.html可是,我照着做完之后,还是不能import cvxpy,不知道是不是因为第6步我用了第二种方法(install locally),如下面分割线之间部分所示。我现... 阅读全文
posted @ 2015-01-10 23:15 ttang 阅读(2707) 评论(0) 推荐(0) 编辑
摘要: 先回顾一下范数的定义(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 →... 阅读全文
posted @ 2015-01-01 11:38 ttang 阅读(39390) 评论(2) 推荐(7) 编辑
摘要: 一直以为梯度下降很简单的,结果最近发现我写的一个梯度下降特别慢,后来终于找到原因:step size的选择很关键,有一种叫backtracking line search的梯度下降法就非常高效,该算法描述见下图:下面用一个简单的例子来展示,给一个无约束优化问题:minimize y = (x-3)*... 阅读全文
posted @ 2014-12-30 01:03 ttang 阅读(10159) 评论(3) 推荐(3) 编辑
摘要: 用智能指针可以简化内存管理。以树为例,如果用普通指针,通常是在插入新节点时用new,在析构函数中调用delete;但有了unique_ptr类型的智能指针,就不需要在析构函数中delete了,因为当unique_ptr类型的指针P生命结束时(比如对于局部变量,程序执行到局部变量的作用域范围之外)... 阅读全文
posted @ 2014-08-31 14:49 ttang 阅读(3446) 评论(0) 推荐(0) 编辑
摘要: 平台:Windows7 64bit,编译器G++(mingw)工具:Dr Memory,项目主页:https://code.google.com/p/drmemory/ (可能要FQ,可能会很慢,所以,可以直接按照下面官方主页给出的链接下载,我也放了一份Windows版的在百度网盘,http://p... 阅读全文
posted @ 2014-08-30 13:03 ttang 阅读(9364) 评论(0) 推荐(0) 编辑
摘要: 环境要求:python (2.7版本可以,3.x没测过),mingw官方版(你可能已经有了),gdb2013-02-04(到这里https://code.google.com/p/qp-gcc/downloads/list下载,如果有更新版本,应该也可以,目前2013-02-04是最新版)推荐的GD... 阅读全文
posted @ 2014-08-03 09:57 ttang 阅读(3439) 评论(0) 推荐(1) 编辑
摘要: 发现Windows下的gvim支持Ctrl+S保存,Ctrl+A全选,Ctrl+C复制,Ctrl+V粘贴,Ctrl+Z撤销不过Ctrl+X貌似不太正常(可以剪切,但是不能粘贴)可能要在安装目录下的_vimrc文件中加上以下两句才能使用上面提到的快捷键:source $VIMRUNTIME/mswin... 阅读全文
posted @ 2014-06-25 11:46 ttang 阅读(1866) 评论(0) 推荐(0) 编辑
摘要: 论文提交时,要求所有的字体都是嵌入的,为这个问题折腾了很久,发现了一个很好的答案,记一下:http://stackoverflow.com/questions/4231656/how-do-i-embed-fonts-in-an-existing-pdf/4234150#4234150下面是我的补充... 阅读全文
posted @ 2014-06-16 16:34 ttang 阅读(464) 评论(0) 推荐(0) 编辑
摘要: https://oj.leetcode.com/problems/first-missing-positive/感觉这题还蛮难的,O(n)的时间,常数大小的额外空间,这个要求还是比较苛刻的首先,数组应该是可以修改的,否则恐怕没法做了,因为总要有一个地方来记忆一些信息,既然不给O(n)的额外的空间,只... 阅读全文
posted @ 2014-05-27 10:22 ttang 阅读(855) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2014-03-13 15:08 ttang 阅读(566) 评论(0) 推荐(0) 编辑
摘要: 比如像下面这样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 阅读全文
posted @ 2014-01-07 10:51 ttang 阅读(752) 评论(2) 推荐(0) 编辑
摘要: 最近用HtmlUnit/HtmlCleaner爬网页,这两个工具都使用XPath来定位html元素。发现chrome竟然有算出XPath的功能!打开一个网页,F12,在弹出的小窗口中选中一个标签,右键,看到“copy XPath”了吧!对chrome的崇敬之情++ 阅读全文
posted @ 2013-11-18 23:09 ttang 阅读(7689) 评论(0) 推荐(2) 编辑
摘要: 在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 阅读全文
posted @ 2013-11-09 20:02 ttang 阅读(611) 评论(0) 推荐(0) 编辑
摘要: options--preferences--appearance在show line numbers for modes下面的文本框里添加;Tex这样新建或者打开tex文件的时候就自动显示行号了(已经打开的文件不受影响) 阅读全文
posted @ 2013-10-13 22:01 ttang 阅读(15360) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2013-09-21 20:10 ttang 阅读(1238) 评论(0) 推荐(0) 编辑
摘要: 我的电脑是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 阅读全文
posted @ 2013-09-16 00:49 ttang 阅读(9055) 评论(0) 推荐(1) 编辑
摘要: 本来打算买域名,买空间,用wordpress写博客的。后来问了一个师兄,他说他是用github的空间,用Jekyll写博客,说很多人都这么做。于是我就研究了一下。比较有价值的文章有这么几篇:http://kyle.xlau.org/posts/blogging-like-a-hacker.html :这个是Jekyll原作者的文章的译文,必读http://www.ruanyifeng.com/blog/2012/08/blogging_with_jekyll.html 这个就是标题中提到的文章,清晰易懂,可以按部就班地跟着做。不过这篇文章有些注意点没提到,因为作者可能用的是Mac(我用的是wi 阅读全文
posted @ 2013-09-08 22:46 ttang 阅读(9435) 评论(4) 推荐(2) 编辑
摘要: 看下面这个课程链接,半小时学会http://study.163.com/course/courseMain.htm?courseId=352004#/courseMain这是我做的:http://pan.baidu.com/share/link?shareid=1035063229&uk=1292515846 阅读全文
posted @ 2013-09-06 11:14 ttang 阅读(800) 评论(0) 推荐(0) 编辑
摘要: snippet挺好用,但是不是我喜欢的那种风格,比如if是这样的if (){ XX}而我比较习惯这种:if () { XX}可以这么做:工具(Tools)——代码段管理器(Code Snippets Manager),选择语言,比如C++,可以看到那些snippet的目录,然后文件——打开——文件,找到那个目录,编辑对应的文件即可,要注意的是修改后要重启visual studio,才能生效 阅读全文
posted @ 2013-06-29 09:07 ttang 阅读(304) 评论(0) 推荐(0) 编辑
摘要: 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数据,把类 阅读全文
posted @ 2013-06-16 15:22 ttang 阅读(764) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2013-06-08 17:19 ttang 阅读(1769) 评论(0) 推荐(0) 编辑
摘要: 1、weka libsvm classes not in classpath按照这篇文章设置就可以:http://endual.iteye.com/blog/1278381,可以把几个classpath都添上 貌似最终还是没解决,又出了其它问题 阅读全文
posted @ 2013-06-04 14:16 ttang 阅读(246) 评论(0) 推荐(0) 编辑
摘要: 搜索“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 阅读全文
posted @ 2013-06-04 00:51 ttang 阅读(2079) 评论(1) 推荐(2) 编辑
摘要: 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 ... 阅读全文
posted @ 2013-06-02 10:43 ttang 阅读(18650) 评论(0) 推荐(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 阅读全文
posted @ 2013-06-01 23:36 ttang 阅读(16153) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2013-06-01 21:56 ttang 阅读(468) 评论(0) 推荐(0) 编辑
摘要: 如果需要复制一个对象,提供类似下面这种方法似乎是个不错的选择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... 阅读全文
posted @ 2013-05-31 10:42 ttang 阅读(380) 评论(0) 推荐(0) 编辑
摘要: 平台: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' 阅读全文
posted @ 2013-05-30 16:41 ttang 阅读(436) 评论(0) 推荐(0) 编辑
摘要: 觉得python中循环很灵活,比如遍历自定义的一个列表:for x in (1,2,3,5): print(x)其实Java也可以写出很短小干净的等效代码:for (int x : Arrays.asList(1, 2, 3, 5)) { System.out.println(x);} 阅读全文
posted @ 2013-05-26 10:46 ttang 阅读(266) 评论(0) 推荐(0) 编辑
摘要: 《C++沉思录》有个脚注提到作者本人在某种情况下出于实际考虑使用了public成员变量,为了严谨,我不应该用“有个脚注”这种说法,所以又特意翻了书,是《C++沉思录》的第16页的脚注,人民邮电出版社2002年第一版。 这条脚注是这样的:细心的读者可能会发现我把数据成员设为public,并为此惊讶。我是故意这样做的:machine_status是一个简单的类,其结构就是其接口。对于如此简单的类来说,把成员设为private没有任何好处。(从这个小小的脚注可以看到作者的实用主义态度,相对于后来很多人所奉行的教条主义,确实有很大的差别——译者注)。 是的,不仅原作者这么说,而且连译者都表示了... 阅读全文
posted @ 2013-05-23 22:27 ttang 阅读(2643) 评论(8) 推荐(1) 编辑