[C++]
class matrix<T>
This class is now deprecated, and has been replaced by the more powerful classes descended from imtx<T>.
It is included for the benefit of code written with earlier versions (4.1 and below) of XLL+.
The matrix template is a container for two-dimensional arrays of type T. You can use them to read in arrays of numbers or strings from Excel OPER and XLOPER arguments passed to your add-in functions.
As well as saving programming time, the class offers three advantages over writing your own code to read array inputs:
Safety The class has methods to check for valid inputs while reading in arrays.Memory management The import methods automatically allocate sufficient memory to contain the input. The destructor automatically frees it, reducing the risk of memory leaks.Efficiency The class methods and supporting functions are written close to the 'C' structures
The class also contains methods and operators that make it convenient to pass values to functions expecting arrays of type T. See the Tutorial for further examples of using matrix<T>.
Data is always stored with columns together. The table below show the offsets of the items in a 3 row x 4 column array.
Columns | |||||
---|---|---|---|---|---|
0 | 1 | 2 | 3 | ||
Rows | 0 | Offset = 0 | Offset = 3 | Offset = 6 | Offset = 9 |
Offset = 1 | Offset = 1 | Offset = 4 | Offset = 7 | Offset = 10 | |
Offset = 2 | Offset = 2 | Offset = 5 | Offset = 8 | Offset = 11 |
You will notice that the naming conventions of matrix<T> differ from other XLL+ objects: the class is named after the conventions of the STL collection templates, and is expected to be used in conjunction with vector<T>.
Header: matrix.h