Torch coding standards
===================

1. The kernel

The library is divided in several subdirectories. The main part of Torch is in "kernel". You should never change anything in this directory. If you find a bug, just send me an email. If you want to do your own algorithm, just create a new package (That is a new directory). I'll add in the kernel only well-known algorithms.
2. You said C++ ?
I hate C++. Too complicated. At the beginning I was thinking about writing the library in Objective C... unfortunately, only few people are using this language. Here are the C++ keywords that you're allowed to use in Torch: In Torch, every class members are public.

I don't want to see:

Okay ? In Torch we use C++ only for the object concept. The rest of your code should be almost like C.
3. Basic Torch Features...
Text inputs/output
Use message(), warning(), error(), print() instead of printf().
You should get inputs only from your main code, and you shoud use the CmdLine class for that purpose.
Types
Use real instead of double or float (except in very specific cases). The real type is defined to double if the flag USEDOUBLE is defined by the user when he compiles the library. Otherwise it's defined to float.

Use sreal if you want to use the sparse format.

You can use the List structure when you have simple chained-lists.

Random functions
Please,  don't use the srandom() and random() functions. Use instead functions provided by the library. (Have a look to the reference manual)
Inputs/ouputs on disk
There are several functions which handle BigEndian and LittleEndian formats for input and output on disk. Check the reference manual.
4. Naming conventions
Easy:
[new!] Note that each class should be divided into two files: one include file (.h, containing the class layout) and one source file (.cc, containing the implementation). In the include file, you should provide some documentation, with the DOC++ format for comments. Moreover, for the class FooFoo the include file should begin with
#ifndef FOO_FOO_INC
#define FOO_FOO_INC

namespace Torch {

and should end with
}
#endif.
(The same applies for the .cc file, without, of course, the #ifndef/#define/#endif lines))