sundeepblue

Computer Graphics, CAGD, Demoscene, intro [crack each line of code, cram each bit of byte, create each idea of mind]

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2007年10月7日

摘要: Iteration Vs. Recursion If a recursive method is called with a base case, the method returns a result. If a method is called with a more complex problem, the method divides the problem into two or more conceptual pieces: a piece that the method knows how to do and a slightly smaller version of the original problem. Because this new problem looks like the original problem, the method launches a recursive call to work on the smaller problem. For recursion to terminate, each time the 阅读全文
posted @ 2007-10-07 01:43 sundeepblue 阅读(636) 评论(0) 推荐(0) 编辑

摘要: Recursion, as a construct, is quite beautiful. It offers an elegant means of acheiving an algorithmic goal and is used in everything from mathematics to text processing and data structure manipulation. The problem is, using it in practice through today’s popular languages (such as my favorite, C#) can prove to be a disaster. At a minimum, standard recursion proves to be inefficient. Worst case scenario, it’ll consume all of your available memory. So how can you reap the benefits of recursive ele 阅读全文
posted @ 2007-10-07 01:29 sundeepblue 阅读(636) 评论(0) 推荐(0) 编辑

摘要: A recursive power function 1#include 2 3double power(double x, int n); 4 5int main() { 6 double x = 0.0; 7 int n = 0; 8 for(x = 2.0 ; x 9 for(n = 0 ; n10 printf("%.2lf raised to the power %d = %.2lf\n", x, n, power(x,n)); 11} 12 13/**//* Function to raise x to the power n.*/ 14double power(double x, int n) { 15 if(n == 0) 16 return 1.0; 17 else 18 return 阅读全文
posted @ 2007-10-07 00:59 sundeepblue 阅读(897) 评论(0) 推荐(0) 编辑

2007年8月10日

摘要: 图形学中最常用的底层类为矢量类(Vector)和矩阵类(Matrix).已经存在很多实现的版本,甚至包括用汇编语言写的内联函数库版本。但这些是否是最优化的类呢?下面介绍的矩阵类版本利用了SIMD指令集优化技术实现了数据对齐与并行处理,极大地提高了矩阵操作速度,甚至比微软d3dmatrix.h中的类速度快上两倍,比用内联汇编技术编写的类快上一倍多。 阅读全文
posted @ 2007-08-10 11:30 sundeepblue 阅读(2986) 评论(0) 推荐(0) 编辑

摘要: 合理使用缓存,注意数据对齐,可以极大优化代码,发挥cache高速运算的优势。 注意,真正的16位浮点数是不存在的!但下文介绍一种方法实现了16位浮点数,并与32位标准浮点数精度进行对比,发现16位浮点数既具有16位整形计算速度的优势,又有32位标准浮点数的精度优势,在z缓冲加、减、比较运算中效果非常理想。作者提到的这种处理方法非常值得我们借鉴与学习。文中没有大段代码,只举了两个典型例子,一个是z缓冲计算,另一个是纹理映射中纹理加载。 摘自gamedev. Leveraging the Power of Cache Memory 阅读全文
posted @ 2007-08-10 10:43 sundeepblue 阅读(1828) 评论(0) 推荐(0) 编辑

2007年8月7日

摘要: Introduction Inline Assembly is different in VC++ and gcc. VC uses Intel syntax while gcc uses AT&T syntax. Here we define the difference in syntax of AT&T and Intel's assembly. Source and Destination Ordering In AT&T syntax the source is always on the left, and the destination is always on the right which is opposite of the Intel's syntax. AT&T Intel Move ebx to eax movl %ebx, %eax mov eax, ebx Move 100 to ebx Movl $100, %ebx Mov ebx, 100 Pref 阅读全文
posted @ 2007-08-07 22:24 sundeepblue 阅读(791) 评论(1) 推荐(0) 编辑

摘要: 概述 —— 什么是makefile?或许很多Winodws的程序员都不知道这个东西,因为那些Windows的IDE都为你做了这个工作,但我觉得要作一个好的和professional的程序员,makefile还是要懂。这就好像现在有这么多的HTML的编辑器,但如果你想成为一个专业人士,你还是要了解HTML的标识的含义。特别在Unix下的软件编译,你就不能不自己写makefile了,会不会写makefile,从一个侧面说明了一个人是否具备完成大型工程的能力。 因为,makefile关系到了整个工程的编译规则。一个工程中的源文件不计数,其按类型、功能、模块分别放在若干个目录中,makefile定义了一系列的规则来指定,哪些文件需要先编译,哪些文件需要后编译,哪些文件需要重新编译,甚至于进行更复杂的功能操作,因为makefile就像一个Shell脚本一样,其中也可以执行操作系统的命令。 阅读全文
posted @ 2007-08-07 21:46 sundeepblue 阅读(221) 评论(0) 推荐(0) 编辑

2007年8月1日

摘要: 贡三元教授的演讲稿《IQ, EQ, AQ & 阿Q》可以这里下载。贡教授在普林斯顿大学的主页位于http://www.princeton.edu/~kung/。 阅读全文
posted @ 2007-08-01 15:57 sundeepblue 阅读(208) 评论(0) 推荐(0) 编辑

摘要: 摘自一个嵌入式开发网站,对用C/C++开发、代码优化、编译优化等也非常有帮助。 C语言测试是招聘嵌入式系统程序员过程中必须而且有效的方法。这些年,我既参加也组织了许多这种测试,在这过程中我意识到这些测试能为面试者和被面试者提供许多有用信息,此外,撇开面试的压力不谈,这种测试也是相当有趣的。 从被面试者的角度来讲,你能了解许多关于出题者或监考者的情况。这个测试只是出题者为显示其对ANSI标准细节的知识而不是技术技巧而设计吗?这是个愚蠢的问题吗?如要你答出某个字符的ASCII值。这些问题着重考察你的系统调用和内存分配策略方面的能力吗?这标志着出题者也许花时间在微机上而不是在嵌入式系统上。如果上述任何问题的答案是"是"的话,那么我知道我得认真考虑我是否应该去做这份工作。 阅读全文
posted @ 2007-08-01 15:52 sundeepblue 阅读(333) 评论(0) 推荐(0) 编辑

2007年7月31日

摘要: 在Vector/Vertex/Matrix类的设计中常用到单位化一个向量或矩阵。需要用到开平方函数sqrt().但math.h中的sqrt()函数最非最佳的选择,事实上,存在很多求平方根较好的算法。The article was originally created by Tomer Margolin and was originally published at www.CodeMaestro.... 阅读全文
posted @ 2007-07-31 13:18 sundeepblue 阅读(4706) 评论(2) 推荐(0) 编辑