Prev Next library

Adding a New Routine to the Mat2cpp Library

Purpose
This guide lists the steps you must go through to add a new feature to the mat2cpp library. For the sake of presentation, we will call it new_routine.

Include File
In the file mat2cpp/mat2cpp.hpp: In the comments, under the heading mat2cpp Functions, add new_routine to the list of functions in the mat2cpp namespace. In the source code, an external prototype for new_routine.

Library
Create the file mat2cpp/lib/new_routine.cpp. This file should contain the source for the routine together with the proper comments so OMhelp can include the source code in the documentation. In addition, add mat2cpp/lib/new_routine.cpp to the file mat2cpp/lib/Makefile.am.

Documentation
Create the file mat2cpp/omh/new_routine.omh. This file should contain the OMhelp documentation for the routine. In addition, decide which documentation file should be the parent of this routine; for example, should it come under mat2cpp/omh/elementwise.omh or perhaps mat2cpp/omh/other.omh. Then add a reference to mat2cpp/omh/new_routine.omh in the parent documentation file. You should also add a link to the documentation for new_routine in mat2cpp/NEWS.

Octave Test
Create the file mat2cpp/mat/new_routine_ok.m This file should contain a test of the feature you are adding in the context of Matlab or Octave. You will also need to add mat2cpp/cpp/new_routine_ok to the file mat2cpp/cpp/mat2cpp_ok.m The execute the tests in Octave or Matlab to make sure that it is correct (before going ahead with a similar test in C++ using the new code).

C++ Test
Create the file mat2cpp/cpp/new_routine_ok.cpp. This file should contain a test of new_routine. In addition, add mat2cpp/cpp/new_routine_ok.cpp to the file mat2cpp/cpp/Makefile.am. You will also need to add mat2cpp/cpp/new_routine_ok to the file mat2cpp/cpp/mat2cpp_ok.cpp

Build
In the mat2cpp directory, execute the command
 
     ./Build version
     ./Build autoconf
     ./Build automake
This will make sure that your Makefile.am files can be processed by automake. If no errors result, continue on with the command
 
     ./Build configure
If the boost directory is not proper for your system, then edit the Build script so that it is and repeat this command. Then execute the commands
 
     ./Build make
     cpp/mat2cpp_ok
This should execute the complete set of tests including the one you just added. The next step is to execute
 
     ./Build omhelp
This will build you new documentation (and you may have to correct OMhelp errors before continuing). You can complete the changes by executing the commands:
 
     ./Build dist
     ./Build test
The change into the directory and test the distribution
     cd mat2cpp-
yy-mm-dd
     cpp/mat2cpp_ok
This should run the C++ version of the tests program.
 
     cd mat
     octave
     mat2cpp_ok
This should run the Octave version of the test program (running the Matlab is similar).

Distribution
The final distribution is
     mat2cpp-
yy-mm-dd.tar.gz

Input File: omh/library.omh