File: dvec.m

package info (click to toggle)
dsdp 5.8-11
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,180 kB
  • sloc: ansic: 27,119; makefile: 309; sh: 30
file content (37 lines) | stat: -rw-r--r-- 882 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
%%*******************************************************************
%%  Convert a square symmetric matrix to a vector 
%%  representation used by DSDP
%%
%%  [V] = dvec(A)
%%
%%  Input:  A = square symmetric matrix.  Lower triangular entries 
%%              are ignored.
%%
%%  Output: V = column vector representing half of a symmetric matrix.
%%              If A has n rows and columns, V is a column vector with
%%              n*(n+1)/2 rows.
%%
%%  See also: DSPARSE, DMAT (its inverse operator)
%%
%% DSDP5.0 
%% Copyright (c) 2003 by
%% S. Benson and Y. Ye
%% Last modified: December 2003
%%******************************************************************

function [V]=dvec(A); 

[n,n1]=size(A);

if (n~=n1) error('Matrix not square.'); end;

nn=n*(n+1)/2;

V=zeros(nn,1);

for i=1:n, 
    k1=i*(i-1)/2+1;  k2=i*(i+1)/2;
    V(k1:k2,1) = A(1:i,i); 
end;

V=sparse(V);