# [Boost-bugs] [Boost C++ Libraries] #3510: Introduce new diag function for creating diagonal matrices and for returning the diagonal of a matrix

Subject: [Boost-bugs] [Boost C++ Libraries] #3510: Introduce new diag function for creating diagonal matrices and for returning the diagonal of a matrix
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-10-05 08:37:11

#3510: Introduce new diag function for creating diagonal matrices and for
returning the diagonal of a matrix
--------------------------------------+-------------------------------------
Reporter: marco.guazzone@â€¦ | Owner: guwi17
Type: Feature Requests | Status: new
Milestone: Boost 1.41.0 | Component: uBLAS
Version: Boost 1.40.0 | Severity: Not Applicable
Keywords: |
--------------------------------------+-------------------------------------
Introduce a new '''diag''' free function in the spirit of the MATLAB's
''diag'' function and Mathematica's ''DiagonalMatrix function''.

Basically it allows both the creation of a ''generalized'' diagonal matrix
and the creation of a ''diagonal'' view of an existing matrix.

A ''generalized'' k-th diagonal matrix is a special kind of matrix which
has all elements set to zero but the ones on its k-th diagonal. The
integer k is the offset from the main diagonal, that is:

* k = 0: the elements on the main diagonal can be different from zero.

* k > 0: only the elements on the k-th upper diagonal can be different
from zero.

* k < 0: only the elements on the k-th lower diagonal can be different
from zero.

A generalized diagonal matrix can be a rectangular matrix.

Here below is a list of the requested cases:

* Create a square diagonal matrix M with vector V
being the k-th diagonal
{{{M = diag(v,k)}}}

* Like the above, but M has layout l (e.g., column major)
{{{M = diag(v,k,l)}}}

* Create a rectangular diagonal matrix M of size mXn with vector V being
the k-th diagonal
{{{M = diag(v,m,n,k)}}}

* Like the above, but M has layout l (e.g., column major)
{{{M = diag(v,m,n,k,l)}}}

* Create a diagonal view of the k-th diagonal of matrix M
{{{v = diag(M,k)}}}

```--
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3510>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.
```

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:01 UTC