Tutorials

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

Tutorials

Each tutorial in this section is contained in a single .cpp file. The file defines a function named TutorialN (with N being an ordinal number of the tutorial) and one or more helper functions. We show how the tutorials work by interleaving actual code with textual explanation. The complete code ready to be copied and pasted is located at the end of each subsection.

To ensure that tutorials are self-contained, there is some duplicated code defined in functions declared as static. For example, the function CreateCptNode is present in tutorials 1, 6, and 8.

If you want to create a program containing a single tutorial only, add a simple main function at the bottom of the tutorialN.cpp file, for example:

int main()

{

   return Tutorial1();

}

To run all tutorials you can use the main.cpp file included in the next sub-section of this manual. This approach requires compiling and linking main.cpp AND all of the tutorialN.cpp files.

You can also download tutorial sources from our documentation site at https://support.bayesfusion.com/docs.

C++11 standard is used (required for range-based for loops and std::initializer_list), compiling tutorial code with gcc or clang requires the -std=c++11, or -std option specifying a later standard. To compile all tutorials with gcc, use the following command:

g++ -std=c++11 main.cpp tutorial?.cpp -I./smile -L./smile -lsmile

The example command assumes that SMILE files are located in the ./smile subdirectory. Replace ./smile used with -I and -L with the path to directory containing SMILE's .h and .a files if the library can be found in other location in your file system.

Visual C++ users can load SmileTutorial.sln directly (included with the tutorial source files). Project properties are set to use the compiler from Visual Studio 2015 (toolkit v140). The toolkit version should be changed to the version appropriate for the version of the Visual Studio used, and correct SMILE for Visual Studio distribution used with tutorials.