Tools

In this section, we describe some useful tools provided with the castor framework. For example, it is possible to produce formatted output with disp. It is also possible to get help or measure the execution time with tic and toc.

disp

template<typename T>
void castor::disp(matrix<T> const &A, int info = 2, std::ostream &flux = std::cout, std::size_t m = 3, std::size_t n = 3)

Warning

doxygenfunction: Unable to resolve function “disp” with arguments (T, int, std::ostream&) in doxygen xml output for project “castor” from directory: ../xml. Potential matches:

- template<typename T> void disp(T const &A, int info = 1, std::ostream &flux = std::cout)
- template<typename T> void disp(T const *A, int info = 1, std::ostream &flux = std::cout)
- template<typename T> void disp(cview<T> const &Av)
- template<typename T> void disp(hmatrix<T> const &Ah, int info = 2, std::ostream &flux = std::cout)
- template<typename T> void disp(matrix<T> const &A, int info = 2, std::ostream &flux = std::cout, std::size_t m = 3, std::size_t n = 3)
- template<typename T> void disp(matrix<T> const &A, std::size_t m, std::size_t n)
- template<typename T> void disp(scview<T> const &Av)
- template<typename T> void disp(smatrix<T> const &As, int info = 2, std::ostream &flux = std::cout, std::size_t r = 3)
- template<typename T> void disp(sview<T> const &Av)
- template<typename T> void disp(view<T> const &Av)
- void disp(matrix<ckiss> const &A, int info = 2, std::ostream &flux = std::cout, std::size_t m = 3, std::size_t n = 3)

See help, error, warning.

help

inline void castor::help(std::string name = "help", std::vector<std::string> filename = documentationFiles)

Display help text in command window.

help(“name”) displays the help for the functionality specified by name, such as a function, operator symbol, method, class, etc. “name” as to be written in lowercase. Source file(s) as to be given in static variable ‘documentationFiles’.

documentationFiles = {"path1/file1.hpp", "path2/file2.hpp", ...};
help("help");

help(“name”,{“filename1.hpp”,”filename2.hpp”}) specify source file(s) which stand for the functionality specified by name.

help("help",{"path1/file1.hpp", "path2/file2.hpp", ...});

The documentation offered here is inspired by that of the Matlab software: https://fr.mathworks.com/help/matlab/

See disp, error, warning.

error

inline void castor::error(std::string file, int line, std::string function, std::string comment)

Display message in command window and abort execution.

error(FILE, LINE, FUNCTION,”message”) displays a descriptive message when the currently-running program encounters an error condition and exit the program with code 1.

error(__FILE__, __LINE__, __FUNCTION__,"This is an error message.");

See warning, disp, help.

tic

inline void castor::tic()

Start a stopwatch timer.

tic() and toc() functions work together to measure elapsed time.

tic(), by itself, saves the current time that toc() uses later to measure the time elapsed between the two. Use toc(0) to avoid printing.

tic();
while (toc(0)<0.314159) {}
toc();

See toc.

toc

inline double castor::toc(bool disp = true)

Read the stopwatch timer.

tic() and toc() functions work together to measure elapsed time.

toc(), by itself, displays the elapsed time, in seconds, since the most recent execution of the tic() command. t = toc(); saves the elapsed time in t as a double scalar. Use toc(0) to avoid printing.

tic();
while (toc(0)<0.314159) {}
toc();

See tic.

warning

inline void castor::warning(std::string file, int line, std::string function, std::string comment)

Display warning message in command window.

warning(FILE, LINE, FUNCTION,”message”) displays a descriptive message when the currently-running program encounters a warning condition.

warning(__FILE__, __LINE__, __FUNCTION__,"This is a warning message.");

See error, disp, help.