XLL+ Class Library

matrix<T> Class

[C++]
class matrix<T>

Status

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+.

Overview

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>.

    Alignment

    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
     0123
    Rows0Offset = 0Offset = 3Offset = 6Offset = 9
     Offset = 1Offset = 1Offset = 4Offset = 7Offset = 10
     Offset = 2Offset = 2Offset = 5Offset = 8Offset = 11

    Programming note

    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>.

    Examples

    COper::ColToVector() & RowToVector() Example | COper::ToMatrix() Example

    Requirements

    Header: matrix.h

    See Also

    matrix<T> Methods | matrix.h | imtx<T>