0

Collection of cool URLs

Posted by Derek Jing on 6:33 PM in
FeedCry Full Text RSS
Very cool collection of full text RSS feeds from top business websites.

An alternative CHM viewer under windows: UltraCHM.

A nice free software for converting to ISO image: AnyToISO.

0

Compiling C++ codes by GCC

Posted by Derek Jing on 12:36 PM in
Compiling a single C++ program

Suppose we have a C++ source code 'hello.cpp', then we can use following command to compile it:

$g++ -Wall -c hello.cpp
  • This command compiles hello.cpp and outouts an object file hello.o.
  • The option -Wall displays complier warnings.
Then we can link the object file

$g++ hello.o -o hello.out

  • This command links the object file hello.o into an executable file hello.out;
  • It is not necessary to use .out as the extension for the executable file. It is also ok to give an executable filename without extension;
  • If the option '-o filename' is omitted, then the output executable will be a.out.
Alternatively, above two steps can be combined together as following

$ g++ -Wall hello.cpp -o hello.out

where an executable hello.out is output directly without generating intermediate object file hello.o.

Compiling multiple C++ codes simultaneously

Suppose we have three C++ codes
  • myclass.h: a header file, including the class interface;
  • myclass.cpp: the class implementation file, having #include "myclass.h";
  • main.cpp: the main file using the class, having #include "myclass.h"
Then we can compile the two CPP files simultaneously
$g++ -Wall main.cpp myclass.cpp -o myrun.out


Compiling multiple C++ codes independently

The benefit is independent compilation is that if one CPP file is edited, we just need to compile this file, saving time for compiling all other CPP files.
$g++ -Wall -c myclass.cpp ==> generate myclass.o
$g++ -Wall -c main.cpp ==> generate main.o
$g++ main.o myclass.o -o myrun ==> generate executable myrun.out

0

Breaking up long equations in Latex

Posted by Derek Jing on 11:50 PM in
Let us first see an example of a long equation. (Note, when you view the example document for this topic, you will see that this equation is in fact wider than the text width. It's not as obvious on this webpage!)

Latex doesn't break long equations to make them fit within the margins as it does with normal text. It is therefore up to you to format the equation appropriately (if they overrun the margin.) This typically requires some creative use of an eqnarray to get elements shifted to a new line and to align nicely. E.g.,


\begin{eqnarray*}
\left(1+x\right)^n & = & 1 + nx + \frac{n\left(n-1\right)}{2!}x^2 \\
& & + \frac{n\left(n-1\right)\left(n-2\right)}{3!}x^3 \\
& & + \frac{n\left(n-1\right)\left(n-2\right)\left(n-3\right)}{4!}x^4 \\
& & + \ldots
\end{eqnarray*}

0

Customize equation numbers in Latex

Posted by Derek Jing on 10:05 PM in
By default, LaTeX will number equations consecutively, as (1), (2), etc., assuming you use the automatic equation numbering mechanism. If the paper is very short, or if there are only a few numbered equations, this is fine, but once the numbers get into the twenties and higher, a scheme that numbers equations by section, as in (1.1), (1.2), ..., (2.1), etc., is preferable. In fact, for the vast majority of journal articles, the latter is probably the best numbering scheme. To get equations numbered by section, just put the following into the preamble: " \numberwithin{equation}{section} ". For books, theses, or very long papers, an equation numbering scheme that is three levels deep (with numbers like (4.1.1), etc.) may be appropriate. To get this, just replace "section" above by "subsection", or the corresponding innermost level. The same mechanism works for other counters, e.g., theorem counters, instead of "equation".

Source: click here.

Copyright © 2009 Derek's Technical Notes All rights reserved.