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:3. Basic Torch Features...
- class
- virtual
- public
- all C keywords
- const, but only if compilers give a warning when you don't use it.
- new and delete for objects. If it's for table of standard types like int, float... use xalloc() and free().
In Torch, every class members are public.
namespace for "namespace Torch {}" and "using namespace Torch;" Indeed, the library is now embedded in the namespace "Torch".
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.
- string... no, no and no, please use char*.
- cin cout, and C++ streams: no, use message(), warning(), error(), print() or even printf(). And use FILE*.
- Templates.
- STL library.
- Multiple inheritance.
- Operator overload.
- References: use pointers.
Text inputs/output4. Naming conventionsUse message(), warning(), error(), print() instead of printf().Types
You should get inputs only from your main code, and you shoud use the CmdLine class for that purpose.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.Random functionsUse sreal if you want to use the sparse format.
You can use the List structure when you have simple chained-lists.
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 diskThere are several functions which handle BigEndian and LittleEndian formats for input and output on disk. Check the reference manual.
Easy:
- MyClassName
- myMethodName()
- my_variable_name
- myGlobalFunction()
- MY_CONSTANT (for #define constants or other)
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
and should end with#ifndef FOO_FOO_INC
#define FOO_FOO_INCnamespace Torch {
(The same applies for the .cc file, without, of course, the #ifndef/#define/#endif lines))}
#endif.