## `linalg::tr` -- trace of a matrix

#### Introduction

`linalg::tr``(A)` returns the trace of the square matrix A, i.e., the sum of the diagonal elements of A.

#### Call(s)

`linalg::tr(A)`

#### Parameters

`A` | - | a square matrix of a domain of category `Cat::Matrix`

#### Returns

an element of the component ring of `A`.

#### Related Functions

`linalg::det`

#### Example 1

We compute the trace of the following matrix:

    >> A := Dom::Matrix(Dom::Integer)
         (3, 3, (i, j) -> 3*(i - 1) + j)

                                   +-         -+
                                   |  1, 2, 3  |
                                   |           |
                                   |  4, 5, 6  |
                                   |           |
                                   |  7, 8, 9  |
                                   +-         -+

    >> linalg::tr(A)

                                        15

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000