There are several classes providing functianallity for matrices.
The most important classes are defined in `dMatrix.h`

(real matrices) and in `CMatrix.h`

(complex matrices).
The class for normal matrices is called `Matrix`

and for complex ones `ComplexMatrix`

.
Furthermore one can use two classes for diagonal matrices `DiagMatrix`

and the in case of complex matrieces `ComplexDiagMatrix`

.

Since all classes contain a great amount of different functions, we concentrate on the most important ones in the following.
All further information can be extracted from the header files directly or from the not very detailed octave `doxygen`

documentation which can be found at
octave.sourceforge.net/doxygen
The two classes `Matrix`

and `ComplexMatrix`

provide the user with several different constructors, we just present a usefull subset of all of those:

Matrix (

// constructor to generate an object Matrix with r rows and c columns

Matrix (

// constructor to generate an object Matrix with r rows and c columns

// and fill it with the real value val

Matrix (

// standard constructor of the class ComplexMatrix

ComplexMatrix (

// constructor to generate a ComplexMatrix with r rows and c columns

ComplexMatrix (

// constructor to generate a ComplexMatrix with r rows and c columns

// filled with the Complex value val

ComplexMatrix (

Find a simple example for the definition and initialization of a 2 2 complex matrix in the following code.

matrix = ComplexMatrix (2, 2);

{

for(

{

matrix (r, c) = Complex (r+1, c+1);

}

}

std::cout « matrix « std::endl;

(2,1) (2,2)

Note that it is very easy to put the Octave objects to the standard output as done in the last line of the above code example.
Octave defines its one output rules to the standard output `std`

.
Each element can be put to `std`

or into a file by using just the standard commands, i.e., `std::cout <<`

followed by the name of the data structure.
(Note that there is a problem with using the namespace `std`

see 5.)

Further constructors for diagonal matrices are difined as shown in the following. Here we discuss those for real matrices only, even if the same type of expressions excist also for all complex matrix classes.

DiagMatrix (

// constructor to generate a Matrix with r rows and c columns

DiagMatrix (

// constructor to generate a Matrix, RowVector first diagonal

DiagMatrix (

// constructor to generate a Matrix, ColumnVector first diagonal

DiagMatrix (

Objects of the two diagonal classes can be transformed into their basic class by using

Matrix (

// generating a ComplexMatrix from a

ComplexMatrix (

After you have build an instance of any of the above introduced classes, Octave provides you with lot of tools to manipulate those objects. To account for the size of a matrix (normal as well as complex) one can use the member functions

// number of columns

The transposed and the inverse matrix can be computed using

// invert the matrix

Additionally for complex matrices there is a function which conjugates each entry and one which adjoints the matrix

// adjoint the matrix

In the following example we show how to use some of these functions. Therefore we define the same matrix as before in the above example.

...

std::cout « matrix;

// dimension of the matrix

r = matrix.rows();

c = matrix.cols();

std::cout « "dimensions of the matrix:";

std::cout « r « "x" « c « endl;

// transpose matrix

std::cout « matrix.transpose();

std::cout « matrix.hermitian();

(2,1) (2,2)

dimensions of the matrix: 2x2

(1,1) (2,1)

(1,2) (2,2)

(1,-1) (2,-1)

(1,-2) (2,-2)

Functions for extracting parts of a matrix:

// extract the ith column of a matrix

// extract the ith row of a complex matrix

// extract the ith column of a complex matrix

// extract the diagonal of a matrix

// extract the diagonal of a complex matrix

// extract a submatrix with upper left corner at the elements

// r1 and c1 and the bottem right corner at r2 c2

// extract a submatrix with upper left corner at the elements

// r1 and c1 and nr rows and nc columns

Most mathematical operators +, -, *, operators as +=, -= as well as comparison operators ==, != are defined. This means that you can mostly use these operators without any further definition of functions and they operate intuitively. For example

// definition of size and setting of entries

...

c_matrix = a_matrix + b_matrix;