Using the C++ Math Library    

MATLAB C++ Math Library Basics

This section contains an overview of the MATLAB C++ Math Library. It provides an introduction to most of the basic concepts in the library. Because of its brevity, it does not discuss each concept in great detail; subsequent chapters provide much more depth. Before you read this section, make sure you understand all of the concepts in MATLAB Basics.

Like MATLAB, the MATLAB C++ Math Library's central data type is the array. Using the MATLAB C++ Math Library, you can create array variables, form arithmetic expressions with arrays, and call functions on arrays. In addition, you can print an array to a file or display it on the screen, or read an array from a file or from the screen.

Most of the built-in MATLAB functions and operators are vectorized, that is, they operate on an entire array. This is true of the routines in the MATLAB C++ Math Library as well. For example, to add one array to another, instead of writing a doubly nested for-loop, as you would in C or Fortran, simply call the library's + operator. Similarly, to compute the square root of all the elements in an array, don't loop through the array elements individually calling sqrt() on each one. Instead, call sqrt() on the entire array; sqrt() will loop for you.


 How C++ and the Library Differ from MATLAB Data Types