Macaulay2 » Documentation
Packages » SemidefiniteProgramming :: smat2vec
next | previous | forward | backward | up | index | toc

smat2vec -- vectorization of a symmetric matrix

Synopsis

Description

The method smat2vec obtains the vectorization of a symmetric matrix. The method vec2smat performs the reverse operation.

i1 : A = matrix(QQ, {{1,2,3,4},{2,5,6,7},{3,6,8,9},{4,7,9,10}})

o1 = | 1 2 3 4  |
     | 2 5 6 7  |
     | 3 6 8 9  |
     | 4 7 9 10 |

              4       4
o1 : Matrix QQ  <-- QQ
i2 : v = smat2vec A

o2 = | 1  |
     | 2  |
     | 3  |
     | 4  |
     | 5  |
     | 6  |
     | 7  |
     | 8  |
     | 9  |
     | 10 |

              10       1
o2 : Matrix QQ   <-- QQ
i3 : vec2smat v

o3 = | 1 2 3 4  |
     | 2 5 6 7  |
     | 3 6 8 9  |
     | 4 7 9 10 |

              4       4
o3 : Matrix QQ  <-- QQ

The scaling of the off-diagonal entries can be controlled with the optional parameter.

i4 : smat2vec(A,Scaling=>2)

o4 = | 1  |
     | 4  |
     | 6  |
     | 8  |
     | 5  |
     | 12 |
     | 14 |
     | 8  |
     | 18 |
     | 10 |

              10       1
o4 : Matrix QQ   <-- QQ

      

Ways to use smat2vec :

For the programmer

The object smat2vec is a method function with options.