├── LICENCE.txt
├── README.txt
├── cdcs.m
├── cdcsInstall.m
├── cdcsOpts.m
├── cdcsTest.m
├── cdcsYALMIPtest.m
├── doc
├── ZFPGW_HSDE_2016.pdf
└── ZFPGW_Primal&Dual_2016.pdf
├── examples
├── ExLyapunov.mat
├── M1000.05.mat
├── M1000.10.mat
├── M1000.15.mat
├── exSOS.mat
├── infd1.mat
├── infd2.mat
├── infp1.mat
├── infp2.mat
├── maxG11.mat
├── maxG32.mat
├── mcp250-1.mat
├── mcp500-1.mat
├── mcp500-2.mat
├── qap9.mat
├── qpG11.mat
└── qpG51.mat
├── include
├── Include
│ └── cs.h
├── Source
│ ├── cs_dfs.c
│ ├── cs_lsolve.c
│ ├── cs_ltsolve.c
│ ├── cs_malloc.c
│ ├── cs_reach.c
│ ├── cs_spsolve.c
│ └── cs_util.c
├── UFget
│ ├── Contents.m
│ ├── Makefile
│ ├── README.txt
│ ├── UFget.m
│ ├── UFget_defaults.m
│ ├── UFget_example.m
│ ├── UFget_lookup.m
│ ├── UFgrep.m
│ ├── UFgui.java
│ ├── UFhelp.html
│ ├── UFkinds.m
│ ├── UFsettings.txt
│ ├── UFsvd.m
│ ├── UFweb.m
│ ├── mat
│ │ ├── Bai
│ │ │ ├── bfwa62.mat
│ │ │ ├── bfwb62.mat
│ │ │ ├── ck104.mat
│ │ │ ├── lop163.mat
│ │ │ ├── olm100.mat
│ │ │ ├── rw136.mat
│ │ │ ├── tols90.mat
│ │ │ └── tub100.mat
│ │ ├── CPM
│ │ │ └── cz148.mat
│ │ ├── DIMACS10
│ │ │ └── chesapeake.mat
│ │ ├── FIDAP
│ │ │ └── ex5.mat
│ │ ├── Grund
│ │ │ ├── b1_ss.mat
│ │ │ ├── d_dyn.mat
│ │ │ ├── d_dyn1.mat
│ │ │ └── d_ss.mat
│ │ ├── HB
│ │ │ ├── arc130.mat
│ │ │ ├── ash85.mat
│ │ │ ├── bcspwr01.mat
│ │ │ ├── bcspwr02.mat
│ │ │ ├── bcspwr03.mat
│ │ │ ├── bcsstk01.mat
│ │ │ ├── bcsstk02.mat
│ │ │ ├── bcsstk03.mat
│ │ │ ├── bcsstk04.mat
│ │ │ ├── bcsstk05.mat
│ │ │ ├── bcsstk22.mat
│ │ │ ├── bcsstm01.mat
│ │ │ ├── bcsstm02.mat
│ │ │ ├── bcsstm03.mat
│ │ │ ├── bcsstm04.mat
│ │ │ ├── bcsstm05.mat
│ │ │ ├── bcsstm22.mat
│ │ │ ├── can_144.mat
│ │ │ ├── can_161.mat
│ │ │ ├── can_187.mat
│ │ │ ├── can_24.mat
│ │ │ ├── can_61.mat
│ │ │ ├── can_62.mat
│ │ │ ├── can_73.mat
│ │ │ ├── can_96.mat
│ │ │ ├── curtis54.mat
│ │ │ ├── dwt_162.mat
│ │ │ ├── dwt_193.mat
│ │ │ ├── dwt_59.mat
│ │ │ ├── dwt_66.mat
│ │ │ ├── dwt_72.mat
│ │ │ ├── dwt_87.mat
│ │ │ ├── fs_183_1.mat
│ │ │ ├── fs_183_3.mat
│ │ │ ├── fs_183_4.mat
│ │ │ ├── fs_183_6.mat
│ │ │ ├── gent113.mat
│ │ │ ├── gre_115.mat
│ │ │ ├── gre_185.mat
│ │ │ ├── ibm32.mat
│ │ │ ├── impcol_b.mat
│ │ │ ├── impcol_c.mat
│ │ │ ├── jgl009.mat
│ │ │ ├── jgl011.mat
│ │ │ ├── lap_25.mat
│ │ │ ├── lns_131.mat
│ │ │ ├── lnsp_131.mat
│ │ │ ├── lund_a.mat
│ │ │ ├── lund_b.mat
│ │ │ ├── mcca.mat
│ │ │ ├── nos4.mat
│ │ │ ├── pores_1.mat
│ │ │ ├── rgg010.mat
│ │ │ ├── steam3.mat
│ │ │ ├── west0067.mat
│ │ │ ├── west0132.mat
│ │ │ ├── west0156.mat
│ │ │ ├── west0167.mat
│ │ │ └── will57.mat
│ │ ├── Hamrle
│ │ │ └── Hamrle1.mat
│ │ ├── JGD_BIBD
│ │ │ ├── bibd_9_3.mat
│ │ │ └── bibd_9_5.mat
│ │ ├── JGD_CAG
│ │ │ └── CAG_mat72.mat
│ │ ├── JGD_Forest
│ │ │ └── TF10.mat
│ │ ├── JGD_G5
│ │ │ ├── IG5-6.mat
│ │ │ └── IG5-7.mat
│ │ ├── JGD_GL7d
│ │ │ └── GL7d10.mat
│ │ ├── JGD_Homology
│ │ │ ├── ch3-3-b1.mat
│ │ │ ├── ch3-3-b2.mat
│ │ │ ├── ch4-4-b1.mat
│ │ │ ├── ch4-4-b2.mat
│ │ │ ├── ch4-4-b3.mat
│ │ │ ├── klein-b1.mat
│ │ │ ├── klein-b2.mat
│ │ │ ├── n2c6-b1.mat
│ │ │ ├── n3c4-b1.mat
│ │ │ ├── n3c4-b2.mat
│ │ │ ├── n3c4-b3.mat
│ │ │ ├── n3c4-b4.mat
│ │ │ ├── n3c5-b1.mat
│ │ │ ├── n3c5-b2.mat
│ │ │ ├── n3c5-b7.mat
│ │ │ ├── n3c6-b1.mat
│ │ │ ├── n4c5-b1.mat
│ │ │ └── n4c5-b11.mat
│ │ ├── JGD_Kocay
│ │ │ ├── Trec3.mat
│ │ │ ├── Trec4.mat
│ │ │ ├── Trec5.mat
│ │ │ ├── Trec6.mat
│ │ │ ├── Trec7.mat
│ │ │ └── Trec8.mat
│ │ ├── JGD_Margulies
│ │ │ ├── cat_ears_2_1.mat
│ │ │ ├── flower_4_1.mat
│ │ │ ├── wheel_3_1.mat
│ │ │ ├── wheel_4_1.mat
│ │ │ ├── wheel_5_1.mat
│ │ │ ├── wheel_6_1.mat
│ │ │ └── wheel_7_1.mat
│ │ ├── JGD_Relat
│ │ │ ├── rel3.mat
│ │ │ ├── rel4.mat
│ │ │ ├── relat3.mat
│ │ │ └── relat4.mat
│ │ ├── JGD_Trefethen
│ │ │ ├── Trefethen_150.mat
│ │ │ ├── Trefethen_20.mat
│ │ │ └── Trefethen_20b.mat
│ │ ├── LPnetlib
│ │ │ ├── lp_adlittle.mat
│ │ │ ├── lp_afiro.mat
│ │ │ ├── lp_blend.mat
│ │ │ ├── lp_kb2.mat
│ │ │ ├── lp_sc105.mat
│ │ │ ├── lp_sc50a.mat
│ │ │ ├── lp_sc50b.mat
│ │ │ ├── lp_scagr7.mat
│ │ │ ├── lp_share2b.mat
│ │ │ ├── lp_stocfor1.mat
│ │ │ ├── lpi_bgprtr.mat
│ │ │ ├── lpi_forest6.mat
│ │ │ ├── lpi_galenet.mat
│ │ │ ├── lpi_itest2.mat
│ │ │ ├── lpi_itest6.mat
│ │ │ ├── lpi_klein1.mat
│ │ │ └── lpi_woodinfe.mat
│ │ ├── MathWorks
│ │ │ └── pivtol.mat
│ │ ├── Meszaros
│ │ │ ├── farm.mat
│ │ │ ├── gams10a.mat
│ │ │ ├── gams10am.mat
│ │ │ ├── kleemin.mat
│ │ │ ├── p0033.mat
│ │ │ ├── p0040.mat
│ │ │ ├── problem.mat
│ │ │ ├── refine.mat
│ │ │ └── zed.mat
│ │ ├── Morandini
│ │ │ ├── robot.mat
│ │ │ └── rotor1.mat
│ │ ├── NYPA
│ │ │ └── Maragal_1.mat
│ │ ├── Newman
│ │ │ ├── adjnoun.mat
│ │ │ ├── dolphins.mat
│ │ │ ├── football.mat
│ │ │ ├── karate.mat
│ │ │ ├── lesmis.mat
│ │ │ └── polbooks.mat
│ │ ├── Oberwolfach
│ │ │ ├── LF10.mat
│ │ │ └── LFAT5.mat
│ │ ├── Pajek
│ │ │ ├── Cities.mat
│ │ │ ├── GD01_b.mat
│ │ │ ├── GD01_c.mat
│ │ │ ├── GD02_a.mat
│ │ │ ├── GD02_b.mat
│ │ │ ├── GD06_theory.mat
│ │ │ ├── GD95_a.mat
│ │ │ ├── GD95_b.mat
│ │ │ ├── GD95_c.mat
│ │ │ ├── GD96_b.mat
│ │ │ ├── GD96_c.mat
│ │ │ ├── GD96_d.mat
│ │ │ ├── GD97_a.mat
│ │ │ ├── GD97_b.mat
│ │ │ ├── GD98_a.mat
│ │ │ ├── GD98_b.mat
│ │ │ ├── GD98_c.mat
│ │ │ ├── GD99_b.mat
│ │ │ ├── GD99_c.mat
│ │ │ ├── GlossGT.mat
│ │ │ ├── Journals.mat
│ │ │ ├── Ragusa16.mat
│ │ │ ├── Ragusa18.mat
│ │ │ ├── Sandi_authors.mat
│ │ │ ├── Stranke94.mat
│ │ │ ├── Tina_AskCal.mat
│ │ │ ├── Tina_AskCog.mat
│ │ │ ├── Tina_DisCal.mat
│ │ │ ├── Tina_DisCog.mat
│ │ │ ├── divorce.mat
│ │ │ └── football.mat
│ │ ├── Pothen
│ │ │ ├── mesh1e1.mat
│ │ │ ├── mesh1em1.mat
│ │ │ ├── mesh1em6.mat
│ │ │ └── sphere2.mat
│ │ ├── Rajat
│ │ │ ├── rajat11.mat
│ │ │ └── rajat14.mat
│ │ ├── Rommes
│ │ │ └── ww_36_pmec_36.mat
│ │ ├── UF_Index.mat
│ │ └── vanHeukelum
│ │ │ ├── cage3.mat
│ │ │ ├── cage4.mat
│ │ │ ├── cage5.mat
│ │ │ └── cage6.mat
│ └── matrices
│ │ └── UFstats.csv
├── cs_install.m
├── cs_lsolve_mex.c
├── cs_ltsolve_mex.c
├── cs_make.m
├── cs_mex.c
├── cs_mex.h
└── cs_must_compile.m
└── packages
├── +cdcs_hsde
├── README_HSDE.txt
├── makeADMM.m
├── makeVariables.m
├── preprocess.m
├── printHeader.m
├── private
│ ├── checkConvergence.m
│ ├── factorMatrix.m
│ ├── rescaleData.m
│ ├── updateHatU.m
│ ├── updateU.m
│ └── updateV.m
└── setOutputs.m
├── +cdcs_pd
├── README_PD.txt
├── makeADMM.m
├── makeVariables.m
├── preprocess.m
├── printHeader.m
├── private
│ ├── checkConvergence.m
│ ├── makeProjectors.m
│ ├── rescaleData.m
│ ├── updateX.m
│ ├── updateY.m
│ └── updateZ.m
└── setOutputs.m
├── +cdcs_sos
├── README.txt
├── makeADMM.m
├── makeVariables.m
├── preprocess.m
├── printHeader.m
├── private
│ ├── ConsReorder.m
│ ├── checkConvergence.m
│ ├── factorMatrix.m
│ ├── rescaleData.m
│ ├── updateHatU.m
│ ├── updateU.m
│ └── updateV.m
└── setOutputs.m
└── +cdcs_utils
├── README.txt
├── blockify.m
├── checkInputs.m
├── chordalDecomposition.m
├── clean.m
├── cs_lsolve.m
├── cs_ltsolve.m
├── flatten.m
├── makeADMM.m
├── makeConeVariables.m
├── makeVariables.m
├── preprocess.m
├── printHeader.m
├── private
├── cliquesFromSpMatD.m
├── constructCliqueGraph.m
├── maxSpanningTree.m
├── smat.c
└── svec.c
├── projectK.m
├── psdCompletion.m
├── setOutputs.m
├── setUserOpts.m
├── splitBlocks.m
├── svecData.m
└── vec.m
/cdcsInstall.m:
--------------------------------------------------------------------------------
1 | function cdcsInstall
2 |
3 | % CDCSINSTALL
4 | %
5 | % Install CDCS and compile required binaries.
6 | %
7 | % See also CDCS, CDCSTEST
8 |
9 |
10 | % First, compile some files from CSparse
11 | here = pwd;
12 | cd('include')
13 | cs_install
14 | cd(here);
15 | movefile(['include',filesep,'cs_lsolve.mex*'], ...
16 | [here,filesep,'packages',filesep,'+cdcs_utils']);
17 | movefile(['include',filesep,'cs_ltsolve.mex*'], ...
18 | [here,filesep,'packages',filesep,'+cdcs_utils']);
19 |
20 | % Then compile some mex files from this package
21 | cd(['packages',filesep,'+cdcs_utils',filesep,'private'])
22 | if (~isempty (strfind (computer, '64')))
23 | mexcmd = 'mex -largeArrayDims' ;
24 | else
25 | mexcmd = 'mex' ;
26 | end
27 | eval([mexcmd, ' svec.c']);
28 | eval([mexcmd, ' smat.c']);
29 | cd(here)
30 |
31 | % Finally add to path and save
32 | addpath([here,filesep,'packages']);
33 | addpath(here);
34 | savepath
35 |
36 | fprintf('\nCompilation completed successfully.\n');
37 |
38 | end
39 |
--------------------------------------------------------------------------------
/cdcsOpts.m:
--------------------------------------------------------------------------------
1 | function options = cdcsOpts
2 |
3 | % CDCSOPTS
4 | %
5 | % Default options for CDCS.
6 | %
7 | % Generic solver options
8 | % ----------------------
9 | % options.solver = 'hsde'; % which solver (primal/dual/hsde/sos)
10 | % options.relTol = 1e-4; % tolerance
11 | % options.rescale = true; % scale data to improve convergence
12 | % options.verbose = 1; % print or silent
13 | % options.dispIter = 50; % print every dispIter iterations
14 | % options.maxIter = 1000; % max # iterations
15 | %
16 | % Chordal decomposition options
17 | % -----------------------------
18 | % options.chordalize = 1; % how to decompose the constraints (0/1/2)
19 | % options.yPenalty = true; % add penalty term for Y block to cost
20 | % options.completion = true; % complete the unused entries of the decomposed
21 | % primal variable
22 | %
23 | % ADMM penalty options
24 | % --------------------
25 | % options.rho = 1; % penalty parameter
26 | % options.adaptive = true; % adaptive penalty factor?
27 | % options.tau = 2; % increase factor for adaptive penalty scheme
28 | % (must be > 1)
29 | % options.mu = 10; % ratio of residuals for adaptive penalty scheme
30 | % options.rhoMax = 1e6; % maximum penalty parameter
31 | % options.rhoMin = 1e-6; % minimum penalty parameter
32 | % options.rhoIt = 10; % if pres/dres>mu ( 1)
58 | options.nu = 10; % ratio of residuals for adaptive penalty scheme
59 | options.rhoMax = 1e6; % maximum penalty parameter
60 | options.rhoMin = 1e-6; % minimum penalty parameter
61 | options.rhoIt = 10; % if pres/dres>mu (=0. The optimal solution x* can obviously be found
12 | % with the KKT system
13 | %
14 | % [Q A'] [x] = [0]
15 | % [A 0 ] [y] [b]
16 | %
17 | % so we check that CDCS runs succesfully by comparing the solution to x*.
18 |
19 | % Setup
20 | clear; clc; yalmip ('clear');
21 | opts = sdpsettings('solver','CDCS','verbose',1);
22 |
23 | % Create the problem data
24 | n = 100;
25 | m = max(floor(n/3),1);
26 | A = rand(m,n);
27 | b = rand(m,1);
28 | Q = rand(n); Q = Q+Q'; Q = Q - (min(eig(Q)) - 1)*eye(n);
29 |
30 | % Find the analytical solution
31 | M = Q\(A.');
32 | y = (A*M)\b;
33 | xa = M*y;
34 |
35 | % Setup and solve with YALMIP using CDCS
36 | x = sdpvar(n,1);
37 | optimize(A*x==b,x'*Q*x/2,opts);
38 | xv = value(x);
39 |
40 | % Display solution
41 | fprintf('Analytical objective : %.4e\n',xa'*Q*xa/2);
42 | fprintf('CDCS objective : %.4e\n',xv'*Q*xv/2);
43 | fprintf('||x* - x_cdcs ||_inf: %.4e\n',norm(xa-xv,'inf'))
44 |
45 | end
46 |
--------------------------------------------------------------------------------
/doc/ZFPGW_HSDE_2016.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/doc/ZFPGW_HSDE_2016.pdf
--------------------------------------------------------------------------------
/doc/ZFPGW_Primal&Dual_2016.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/doc/ZFPGW_Primal&Dual_2016.pdf
--------------------------------------------------------------------------------
/examples/ExLyapunov.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/examples/ExLyapunov.mat
--------------------------------------------------------------------------------
/examples/M1000.05.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/examples/M1000.05.mat
--------------------------------------------------------------------------------
/examples/M1000.10.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/examples/M1000.10.mat
--------------------------------------------------------------------------------
/examples/M1000.15.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/examples/M1000.15.mat
--------------------------------------------------------------------------------
/examples/exSOS.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/examples/exSOS.mat
--------------------------------------------------------------------------------
/examples/infd1.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/examples/infd1.mat
--------------------------------------------------------------------------------
/examples/infd2.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/examples/infd2.mat
--------------------------------------------------------------------------------
/examples/infp1.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/examples/infp1.mat
--------------------------------------------------------------------------------
/examples/infp2.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/examples/infp2.mat
--------------------------------------------------------------------------------
/examples/maxG11.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/examples/maxG11.mat
--------------------------------------------------------------------------------
/examples/maxG32.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/examples/maxG32.mat
--------------------------------------------------------------------------------
/examples/mcp250-1.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/examples/mcp250-1.mat
--------------------------------------------------------------------------------
/examples/mcp500-1.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/examples/mcp500-1.mat
--------------------------------------------------------------------------------
/examples/mcp500-2.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/examples/mcp500-2.mat
--------------------------------------------------------------------------------
/examples/qap9.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/examples/qap9.mat
--------------------------------------------------------------------------------
/examples/qpG11.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/examples/qpG11.mat
--------------------------------------------------------------------------------
/examples/qpG51.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/examples/qpG51.mat
--------------------------------------------------------------------------------
/include/Source/cs_dfs.c:
--------------------------------------------------------------------------------
1 | #include "cs.h"
2 | /* depth-first-search of the graph of a matrix, starting at node j */
3 | csi cs_dfs (csi j, cs *G, csi top, csi *xi, csi *pstack, const csi *pinv)
4 | {
5 | csi i, p, p2, done, jnew, head = 0, *Gp, *Gi ;
6 | if (!CS_CSC (G) || !xi || !pstack) return (-1) ; /* check inputs */
7 | Gp = G->p ; Gi = G->i ;
8 | xi [0] = j ; /* initialize the recursion stack */
9 | while (head >= 0)
10 | {
11 | j = xi [head] ; /* get j from the top of the recursion stack */
12 | jnew = pinv ? (pinv [j]) : j ;
13 | if (!CS_MARKED (Gp, j))
14 | {
15 | CS_MARK (Gp, j) ; /* mark node j as visited */
16 | pstack [head] = (jnew < 0) ? 0 : CS_UNFLIP (Gp [jnew]) ;
17 | }
18 | done = 1 ; /* node j done if no unvisited neighbors */
19 | p2 = (jnew < 0) ? 0 : CS_UNFLIP (Gp [jnew+1]) ;
20 | for (p = pstack [head] ; p < p2 ; p++) /* examine all neighbors of j */
21 | {
22 | i = Gi [p] ; /* consider neighbor node i */
23 | if (CS_MARKED (Gp, i)) continue ; /* skip visited node i */
24 | pstack [head] = p ; /* pause depth-first search of node j */
25 | xi [++head] = i ; /* start dfs at node i */
26 | done = 0 ; /* node j is not done */
27 | break ; /* break, to start dfs (i) */
28 | }
29 | if (done) /* depth-first search at node j is done */
30 | {
31 | head-- ; /* remove j from the recursion stack */
32 | xi [--top] = j ; /* and place in the output stack */
33 | }
34 | }
35 | return (top) ;
36 | }
37 |
--------------------------------------------------------------------------------
/include/Source/cs_lsolve.c:
--------------------------------------------------------------------------------
1 | #include "cs.h"
2 | /* solve Lx=b where x and b are dense. x=b on input, solution on output. */
3 | csi cs_lsolve (const cs *L, double *x)
4 | {
5 | csi p, j, n, *Lp, *Li ;
6 | double *Lx ;
7 | if (!CS_CSC (L) || !x) return (0) ; /* check inputs */
8 | n = L->n ; Lp = L->p ; Li = L->i ; Lx = L->x ;
9 | for (j = 0 ; j < n ; j++)
10 | {
11 | x [j] /= Lx [Lp [j]] ;
12 | for (p = Lp [j]+1 ; p < Lp [j+1] ; p++)
13 | {
14 | x [Li [p]] -= Lx [p] * x [j] ;
15 | }
16 | }
17 | return (1) ;
18 | }
19 |
--------------------------------------------------------------------------------
/include/Source/cs_ltsolve.c:
--------------------------------------------------------------------------------
1 | #include "cs.h"
2 | /* solve L'x=b where x and b are dense. x=b on input, solution on output. */
3 | csi cs_ltsolve (const cs *L, double *x)
4 | {
5 | csi p, j, n, *Lp, *Li ;
6 | double *Lx ;
7 | if (!CS_CSC (L) || !x) return (0) ; /* check inputs */
8 | n = L->n ; Lp = L->p ; Li = L->i ; Lx = L->x ;
9 | for (j = n-1 ; j >= 0 ; j--)
10 | {
11 | for (p = Lp [j]+1 ; p < Lp [j+1] ; p++)
12 | {
13 | x [j] -= Lx [p] * x [Li [p]] ;
14 | }
15 | x [j] /= Lx [Lp [j]] ;
16 | }
17 | return (1) ;
18 | }
19 |
--------------------------------------------------------------------------------
/include/Source/cs_malloc.c:
--------------------------------------------------------------------------------
1 | #include "cs.h"
2 | #ifdef MATLAB_MEX_FILE
3 | #define malloc mxMalloc
4 | #define free mxFree
5 | #define realloc mxRealloc
6 | #define calloc mxCalloc
7 | #endif
8 |
9 | /* wrapper for malloc */
10 | void *cs_malloc (csi n, size_t size)
11 | {
12 | return (malloc (CS_MAX (n,1) * size)) ;
13 | }
14 |
15 | /* wrapper for calloc */
16 | void *cs_calloc (csi n, size_t size)
17 | {
18 | return (calloc (CS_MAX (n,1), size)) ;
19 | }
20 |
21 | /* wrapper for free */
22 | void *cs_free (void *p)
23 | {
24 | if (p) free (p) ; /* free p if it is not already NULL */
25 | return (NULL) ; /* return NULL to simplify the use of cs_free */
26 | }
27 |
28 | /* wrapper for realloc */
29 | void *cs_realloc (void *p, csi n, size_t size, csi *ok)
30 | {
31 | void *pnew ;
32 | pnew = realloc (p, CS_MAX (n,1) * size) ; /* realloc the block */
33 | *ok = (pnew != NULL) ; /* realloc fails if pnew is NULL */
34 | return ((*ok) ? pnew : p) ; /* return original p if failure */
35 | }
36 |
--------------------------------------------------------------------------------
/include/Source/cs_reach.c:
--------------------------------------------------------------------------------
1 | #include "cs.h"
2 | /* xi [top...n-1] = nodes reachable from graph of G*P' via nodes in B(:,k).
3 | * xi [n...2n-1] used as workspace */
4 | csi cs_reach (cs *G, const cs *B, csi k, csi *xi, const csi *pinv)
5 | {
6 | csi p, n, top, *Bp, *Bi, *Gp ;
7 | if (!CS_CSC (G) || !CS_CSC (B) || !xi) return (-1) ; /* check inputs */
8 | n = G->n ; Bp = B->p ; Bi = B->i ; Gp = G->p ;
9 | top = n ;
10 | for (p = Bp [k] ; p < Bp [k+1] ; p++)
11 | {
12 | if (!CS_MARKED (Gp, Bi [p])) /* start a dfs at unmarked node i */
13 | {
14 | top = cs_dfs (Bi [p], G, top, xi, xi+n, pinv) ;
15 | }
16 | }
17 | for (p = top ; p < n ; p++) CS_MARK (Gp, xi [p]) ; /* restore G */
18 | return (top) ;
19 | }
20 |
--------------------------------------------------------------------------------
/include/Source/cs_spsolve.c:
--------------------------------------------------------------------------------
1 | #include "cs.h"
2 | /* solve Gx=b(:,k), where G is either upper (lo=0) or lower (lo=1) triangular */
3 | csi cs_spsolve (cs *G, const cs *B, csi k, csi *xi, double *x, const csi *pinv,
4 | csi lo)
5 | {
6 | csi j, J, p, q, px, top, n, *Gp, *Gi, *Bp, *Bi ;
7 | double *Gx, *Bx ;
8 | if (!CS_CSC (G) || !CS_CSC (B) || !xi || !x) return (-1) ;
9 | Gp = G->p ; Gi = G->i ; Gx = G->x ; n = G->n ;
10 | Bp = B->p ; Bi = B->i ; Bx = B->x ;
11 | top = cs_reach (G, B, k, xi, pinv) ; /* xi[top..n-1]=Reach(B(:,k)) */
12 | for (p = top ; p < n ; p++) x [xi [p]] = 0 ; /* clear x */
13 | for (p = Bp [k] ; p < Bp [k+1] ; p++) x [Bi [p]] = Bx [p] ; /* scatter B */
14 | for (px = top ; px < n ; px++)
15 | {
16 | j = xi [px] ; /* x(j) is nonzero */
17 | J = pinv ? (pinv [j]) : j ; /* j maps to col J of G */
18 | if (J < 0) continue ; /* column J is empty */
19 | x [j] /= Gx [lo ? (Gp [J]) : (Gp [J+1]-1)] ;/* x(j) /= G(j,j) */
20 | p = lo ? (Gp [J]+1) : (Gp [J]) ; /* lo: L(j,j) 1st entry */
21 | q = lo ? (Gp [J+1]) : (Gp [J+1]-1) ; /* up: U(j,j) last entry */
22 | for ( ; p < q ; p++)
23 | {
24 | x [Gi [p]] -= Gx [p] * x [j] ; /* x(i) -= G(i,j) * x(j) */
25 | }
26 | }
27 | return (top) ; /* return top of stack */
28 | }
29 |
--------------------------------------------------------------------------------
/include/Source/cs_util.c:
--------------------------------------------------------------------------------
1 | #include "cs.h"
2 | /* allocate a sparse matrix (triplet form or compressed-column form) */
3 | cs *cs_spalloc (csi m, csi n, csi nzmax, csi values, csi triplet)
4 | {
5 | cs *A = cs_calloc (1, sizeof (cs)) ; /* allocate the cs struct */
6 | if (!A) return (NULL) ; /* out of memory */
7 | A->m = m ; /* define dimensions and nzmax */
8 | A->n = n ;
9 | A->nzmax = nzmax = CS_MAX (nzmax, 1) ;
10 | A->nz = triplet ? 0 : -1 ; /* allocate triplet or comp.col */
11 | A->p = cs_malloc (triplet ? nzmax : n+1, sizeof (csi)) ;
12 | A->i = cs_malloc (nzmax, sizeof (csi)) ;
13 | A->x = values ? cs_malloc (nzmax, sizeof (double)) : NULL ;
14 | return ((!A->p || !A->i || (values && !A->x)) ? cs_spfree (A) : A) ;
15 | }
16 |
17 | /* change the max # of entries sparse matrix */
18 | csi cs_sprealloc (cs *A, csi nzmax)
19 | {
20 | csi ok, oki, okj = 1, okx = 1 ;
21 | if (!A) return (0) ;
22 | if (nzmax <= 0) nzmax = (CS_CSC (A)) ? (A->p [A->n]) : A->nz ;
23 | A->i = cs_realloc (A->i, nzmax, sizeof (csi), &oki) ;
24 | if (CS_TRIPLET (A)) A->p = cs_realloc (A->p, nzmax, sizeof (csi), &okj) ;
25 | if (A->x) A->x = cs_realloc (A->x, nzmax, sizeof (double), &okx) ;
26 | ok = (oki && okj && okx) ;
27 | if (ok) A->nzmax = nzmax ;
28 | return (ok) ;
29 | }
30 |
31 | /* free a sparse matrix */
32 | cs *cs_spfree (cs *A)
33 | {
34 | if (!A) return (NULL) ; /* do nothing if A already NULL */
35 | cs_free (A->p) ;
36 | cs_free (A->i) ;
37 | cs_free (A->x) ;
38 | return ((cs *) cs_free (A)) ; /* free the cs struct and return NULL */
39 | }
40 |
41 | /* free a numeric factorization */
42 | csn *cs_nfree (csn *N)
43 | {
44 | if (!N) return (NULL) ; /* do nothing if N already NULL */
45 | cs_spfree (N->L) ;
46 | cs_spfree (N->U) ;
47 | cs_free (N->pinv) ;
48 | cs_free (N->B) ;
49 | return ((csn *) cs_free (N)) ; /* free the csn struct and return NULL */
50 | }
51 |
52 | /* free a symbolic factorization */
53 | css *cs_sfree (css *S)
54 | {
55 | if (!S) return (NULL) ; /* do nothing if S already NULL */
56 | cs_free (S->pinv) ;
57 | cs_free (S->q) ;
58 | cs_free (S->parent) ;
59 | cs_free (S->cp) ;
60 | cs_free (S->leftmost) ;
61 | return ((css *) cs_free (S)) ; /* free the css struct and return NULL */
62 | }
63 |
64 | /* allocate a cs_dmperm or cs_scc result */
65 | csd *cs_dalloc (csi m, csi n)
66 | {
67 | csd *D ;
68 | D = cs_calloc (1, sizeof (csd)) ;
69 | if (!D) return (NULL) ;
70 | D->p = cs_malloc (m, sizeof (csi)) ;
71 | D->r = cs_malloc (m+6, sizeof (csi)) ;
72 | D->q = cs_malloc (n, sizeof (csi)) ;
73 | D->s = cs_malloc (n+6, sizeof (csi)) ;
74 | return ((!D->p || !D->r || !D->q || !D->s) ? cs_dfree (D) : D) ;
75 | }
76 |
77 | /* free a cs_dmperm or cs_scc result */
78 | csd *cs_dfree (csd *D)
79 | {
80 | if (!D) return (NULL) ; /* do nothing if D already NULL */
81 | cs_free (D->p) ;
82 | cs_free (D->q) ;
83 | cs_free (D->r) ;
84 | cs_free (D->s) ;
85 | return ((csd *) cs_free (D)) ; /* free the csd struct and return NULL */
86 | }
87 |
88 | /* free workspace and return a sparse matrix result */
89 | cs *cs_done (cs *C, void *w, void *x, csi ok)
90 | {
91 | cs_free (w) ; /* free workspace */
92 | cs_free (x) ;
93 | return (ok ? C : cs_spfree (C)) ; /* return result if OK, else free it */
94 | }
95 |
96 | /* free workspace and return csi array result */
97 | csi *cs_idone (csi *p, cs *C, void *w, csi ok)
98 | {
99 | cs_spfree (C) ; /* free temporary matrix */
100 | cs_free (w) ; /* free workspace */
101 | return (ok ? p : (csi *) cs_free (p)) ; /* return result, or free it */
102 | }
103 |
104 | /* free workspace and return a numeric factorization (Cholesky, LU, or QR) */
105 | csn *cs_ndone (csn *N, cs *C, void *w, void *x, csi ok)
106 | {
107 | cs_spfree (C) ; /* free temporary matrix */
108 | cs_free (w) ; /* free workspace */
109 | cs_free (x) ;
110 | return (ok ? N : cs_nfree (N)) ; /* return result if OK, else free it */
111 | }
112 |
113 | /* free workspace and return a csd result */
114 | csd *cs_ddone (csd *D, cs *C, void *w, csi ok)
115 | {
116 | cs_spfree (C) ; /* free temporary matrix */
117 | cs_free (w) ; /* free workspace */
118 | return (ok ? D : cs_dfree (D)) ; /* return result if OK, else free it */
119 | }
120 |
--------------------------------------------------------------------------------
/include/UFget/Contents.m:
--------------------------------------------------------------------------------
1 | % UFget: MATLAB interface for the UF Sparse Matrix Collection.
2 | %
3 | % UFget - loads a matrix from the UF Sparse Matrix Collection.
4 | % UFweb - opens the URL for a matrix.
5 | % UFgrep - search for matrices in the UF Sparse Matrix Collection.
6 | % UFkinds - get 'kind' of each problem in the UF collection.
7 | % UFsvd - singular values of a matrix in the UF collection.
8 | %
9 | % Helper functions:
10 | %
11 | % UFget_defaults - returns default parameter settings for UFget.
12 | % UFget_example - a demo for UFget.
13 | % UFget_lookup - gets the group, name, and id of a matrix.
14 | %
15 | % Example:
16 | % help UFget
17 |
18 | % Copyright 2012, Timothy A. Davis
19 |
--------------------------------------------------------------------------------
/include/UFget/Makefile:
--------------------------------------------------------------------------------
1 | UFgui.jar: UFgui.java UFhelp.html
2 | javac UFgui.java
3 | jar cfe UFgui.jar UFgui *.class UFhelp.html
4 | - $(RM) *.class
5 |
6 | run: UFgui.jar
7 | java -jar UFgui.jar
8 |
--------------------------------------------------------------------------------
/include/UFget/README.txt:
--------------------------------------------------------------------------------
1 | UFget: MATLAB and Java interfaces to the UF sparse matrix collection.
2 | Copyright 2005-2012, Timothy A. Davis, http://www.suitesparse.com
3 |
4 | REQUIREMENTS:
5 |
6 | Java JRE 1.6.0 or later is required for the UFgui Java program.
7 | UFget requires MATLAB 7.0. A few of the largest matrices require MATLAB
8 | 7.3 or later.
9 |
10 | See http://www.suitesparse.com
11 | for a single archive file with all the files listed below:
12 |
13 | UFget/README.txt this file
14 | UFget/UFsettings.txt default settings for Java and MATLAB
15 |
16 | for Java:
17 | UFget/UFgui.java a stand-alone Java interface to the collection
18 | UFget/UFgui.jar the compiled UFgui program
19 | UFget/UFhelp.html help for UFgui
20 | UFget/Makefile for compiling UFgui.java into UFgui.jar
21 | UFget/matrices/UFstats.txt matrix statistics file for UFgui.java
22 |
23 | for MATLAB:
24 | UFget/Contents.m help for UFget in MATLAB
25 | UFget/UFget_defaults.m default parameter settings for UFget
26 | UFget/UFget_example.m demo for UFget
27 | UFget/UFget_lookup.m get the group, name, and id of a matrix
28 | UFget/UFget.m primary user interface
29 | UFget/UFgrep.m searches for matrices by name
30 | UFget/UFkinds.m returns the 'kind' for all matrices
31 | UFget/UFweb.m opens the URL for a matrix or collection
32 | UFget/mat/UF_Index.mat index to the UF sparse matrix collection
33 |
34 | download directories:
35 | UFget/MM for Matrix Market files
36 | UFget/RB for Rutherford/Boeing files
37 | UFget/mat for *.mat files
38 | UFget/matrices for *.png icon images of the matrices
39 |
40 | For the Java UFgui program:
41 |
42 | To run the UFgui on Windows or Mac OS X, just double-click the UFgui.jar
43 | file. Or, on any platform, type the following command in your command
44 | window:
45 |
46 | java -jar UFgui.jar
47 |
48 | If that doesn't work, then you need to install the Java JDK or JRE and add
49 | it to your path. See http://java.sun.com/javase/downloads/index.jsp and
50 | http://java.sun.com/javase/6/webnotes/install/index.html for more
51 | information. For Ubuntu, you can install Java by running the Synaptics
52 | package manager.
53 |
54 | The UFgui.jar file is the compiled version of UFgui.java. If you modify
55 | UFgui.java, you can recompile it (for Unix/Linux/Mac/Solaris) by typing
56 | the command:
57 |
58 | make
59 |
60 | To run the UFgui in Linux/Solaris/Unix, your window manager might support
61 | double-clicking the UFgui.jar file as well. If not, type either of
62 | the following commands:
63 |
64 | java -jar UFgui.jar
65 |
66 | or
67 |
68 | make run
69 |
70 |
71 | For the UFget.m MATLAB interface:
72 |
73 | To install the MATLAB package, just add the path containing the UFget
74 | directory to your MATLAB path. Type "pathtool" in MATLAB for more details.
75 |
76 | For a simple example of use, type this command in MATLAB:
77 |
78 | UFget_example
79 |
80 | The MATLAB statement
81 |
82 | Problem = UFget ('HB/arc130')
83 |
84 | (for example), will download a sparse matrix called HB/arc130 (a laser
85 | simulation problem) and load it into MATLAB. You don't need to use your
86 | web browser to load the matrix. The statement
87 |
88 | Problem = UFget (6)
89 |
90 | will also load same the HB/arc130 matrix. Each matrix in the collection
91 | has a unique identifier, in the range 1 to the number of matrices. As new
92 | matrices are added, the id's of existing matrices will not change.
93 |
94 | To view an index of the entire collection, just type
95 |
96 | UFget
97 |
98 | in MATLAB. To modify your download directory, edit the UFget_defaults.m
99 | file (note that this will not modify the download directory for the
100 | UFgui java program, however).
101 |
102 | To open a URL of the entire collection, just type
103 |
104 | UFweb
105 |
106 | To open the URL of a group of matrices in the collection:
107 |
108 | UFweb ('HB')
109 |
110 | To open the web page for one matrix, use either of these formats:
111 |
112 | UFweb ('HB/arc130')
113 | UFweb (6)
114 |
115 | To download a new index, to get access to new matrices:
116 |
117 | UFget ('refresh')
118 |
119 | (by default, using UFget downloads the index every 90 days anyway).
120 |
121 | To search for matrices
122 |
123 | For more information on how the matrix statistics were created, see
124 | http://www.suitesparse.com.
125 |
--------------------------------------------------------------------------------
/include/UFget/UFget_defaults.m:
--------------------------------------------------------------------------------
1 | function params = UFget_defaults
2 | %UFGET_DEFAULTS returns default parameter settings for UFget.
3 | % Usage: params = UFget_defaults ; Returns the default parameter settings for
4 | % UFget. Edit the UFget/UFsettings.txt file to change these settings.
5 | %
6 | % params.url: URL for *.mat files
7 | % params.dir: your local directory for downloaded *.mat files
8 | % params.refresh: how many days should elapse before re-downloading the
9 | % index file (for obtaining access to new matrices in the collection).
10 | % params.topurl: URL for UF Sparse Matrix Collection
11 | % params.topdir: your directory for mat/, matrices/, MM/ and RB/ directories
12 | %
13 | % Example:
14 | % params = UFget_defaults ;
15 | %
16 | % See also UFget.
17 |
18 | % Copyright 2009-2012, Timothy A. Davis, http://www.suitesparse.com
19 |
20 | % decode the current directory for this M-file
21 | s = which (mfilename) ;
22 | i = find (s == filesep) ;
23 | this = s (1:i(end)) ;
24 |
25 | % defaults, if UFsettings.txt is not present
26 | params.topdir = '' ;
27 | params.topurl = 'http://www.cise.ufl.edu/research/sparse' ;
28 | params.refresh = 30 ;
29 |
30 | % open the UFsettings.txt file, if present, and read the default settings
31 |
32 | f = -1 ;
33 | try
34 | f = fopen (sprintf ('%sUFsettings.txt', this), 'r') ;
35 | if (f >= 0)
36 | % get the location of the mat directory
37 | s = fgetl (f) ;
38 | if (ischar (s))
39 | params.topdir = s ;
40 | end
41 | % get the default URL
42 | s = fgetl (f) ;
43 | if (ischar (s))
44 | params.topurl = s ;
45 | end
46 | % get the refresh rate
47 | s = fgetl (f) ;
48 | if (ischar (s) && ~isempty (s))
49 | params.refresh = str2double (s) ;
50 | end
51 | end
52 | catch
53 | end
54 |
55 | try
56 | if (f >= 0)
57 | fclose (f) ;
58 | end
59 | catch
60 | end
61 |
62 | if (isempty (params.topdir))
63 | params.topdir = this ;
64 | end
65 |
66 | if (params.topdir (end) ~= filesep)
67 | params.topdir = [params.topdir filesep] ;
68 | end
69 |
70 | params.url = [params.topurl '/mat'] ;
71 | params.dir = sprintf ('%smat%s', params.topdir, filesep) ;
72 |
--------------------------------------------------------------------------------
/include/UFget/UFget_example.m:
--------------------------------------------------------------------------------
1 | %UFGET_EXAMPLE a demo for UFget.
2 | % This example script gets the index file of the UF sparse matrix collection,
3 | % and then loads in all symmetric non-binary matrices, in increasing order of
4 | % number of rows in the matrix.
5 | %
6 | % Example:
7 | % type UFget_example ; % to see an example of how to use UFget
8 | %
9 | % See also UFget, UFweb, UFgrep.
10 |
11 | % Copyright 2009-2012, Timothy A. Davis, http://www.suitesparse.com
12 |
13 | type UFget_example ;
14 |
15 | index = UFget ;
16 | f = find (index.numerical_symmetry == 1 & ~index.isBinary) ;
17 | [y, j] = sort (index.nrows (f)) ;
18 | f = f (j) ;
19 |
20 | for i = f
21 | fprintf ('Loading %s%s%s, please wait ...\n', ...
22 | index.Group {i}, filesep, index.Name {i}) ;
23 | Problem = UFget (i,index) ;
24 | disp (Problem) ;
25 | spy (Problem.A) ;
26 | title (sprintf ('%s:%s', Problem.name, Problem.title')) ;
27 | UFweb (i) ;
28 | input ('hit enter to continue:') ;
29 | end
30 |
31 |
--------------------------------------------------------------------------------
/include/UFget/UFget_lookup.m:
--------------------------------------------------------------------------------
1 | function [group, name, id] = UFget_lookup (matrix, UF_Index)
2 | %UFGET_LOOKUP gets the group, name, and id of a matrix.
3 | %
4 | % Example:
5 | % [group name id] = UFget_lookup (matrix, UF_Index)
6 | %
7 | % See also UFget.
8 |
9 | % Copyright 2009-2012, Timothy A. Davis, http://www.suitesparse.com
10 |
11 | if (isnumeric (matrix))
12 |
13 | % make sure that the matrix parameter is only one integer value
14 | % this means that if we get an array, just use the first value
15 | id = fix (full (matrix (1))) ;
16 |
17 | % if the index is less than one or bigger than the length of the array,
18 | % then no particular matrix is accessed
19 | if (id > length (UF_Index.nrows) | id < 1) %#ok
20 | id = 0 ;
21 | group = '' ;
22 | name = '' ;
23 | else
24 | % assign the group and name for the given id
25 | group = UF_Index.Group {matrix} ;
26 | name = UF_Index.Name {matrix} ;
27 | end
28 |
29 | elseif (ischar (matrix))
30 |
31 | % the group and matrix name are in the string as in GroupName\MatrixName
32 |
33 | % find the group index for the file separator
34 | % check both types of slashes, and a colon
35 | gi = find (matrix == '/') ;
36 | if (length (gi) == 0) %#ok
37 | gi = find (matrix == '\') ;
38 | end
39 | if (length (gi) == 0) %#ok
40 | gi = find (matrix == ':') ;
41 | end
42 |
43 | % if no name divider is in the string, a whole group is specified
44 | if (length (gi) == 0) %#ok
45 |
46 | id = 0 ;
47 | group = matrix ;
48 | name = '' ;
49 |
50 | else
51 |
52 | % group equals the first part of the string up to the character before
53 | % the last file separator
54 | group = matrix (1:gi(end)-1) ;
55 |
56 | % group equals the last section of the string after the last file
57 | % separator
58 | name = matrix (gi(end)+1:end) ;
59 |
60 | % validate the given name and group by checking the index for a match
61 | refName = strmatch (name, UF_Index.Name) ;
62 | refGroup = strmatch (group, UF_Index.Group) ;
63 | id = intersect (refName, refGroup) ;
64 | if (length (id) >= 1)
65 | id = id (1) ;
66 | else
67 | % the given group/matrix does not exist in the index file
68 | id = 0 ;
69 | end
70 | end
71 |
72 | else
73 |
74 | % there is an error in the argument types passed into the function
75 | error ('invalid input') ;
76 |
77 | end
78 |
--------------------------------------------------------------------------------
/include/UFget/UFgrep.m:
--------------------------------------------------------------------------------
1 | function list = UFgrep (expression, index)
2 | %UFGREP search for matrices in the UF Sparse Matrix Collection.
3 | % UFgrep returns a list of Problem id's whose Problem.name string matches an
4 | % expression. With no output arguments, the list is displayed. Otherwise, it
5 | % is returned as a list of integer id's.
6 | %
7 | % Example:
8 | % UFgrep ('HB') ; % all matrices in the HB group
9 | % UFgrep ('\ 0)
71 |
72 | if (id == 0)
73 |
74 | if (isempty (group))
75 |
76 | % return stats about the whole collection
77 | stats.nmatrices = length (UF_Index.nrows) ;
78 | stats.LastRevisionDate = UF_Index.LastRevisionDate ;
79 | stats.DownloadTime = datestr (UF_Index.DownloadTimeStamp) ;
80 |
81 | else
82 |
83 | % return stats about one matrix group
84 | nmat = length (UF_Index.nrows) ;
85 | ngroup = 0 ;
86 | for i = 1:nmat
87 | if (strcmp (group, UF_Index.Group {i}))
88 | ngroup = ngroup + 1 ;
89 | end
90 | end
91 | stats.nmatrices = ngroup ;
92 | stats.LastRevisionDate = UF_Index.LastRevisionDate ;
93 | stats.DownloadTime = datestr (UF_Index.DownloadTimeStamp) ;
94 |
95 | end
96 | else
97 |
98 | % look up the matrix statistics
99 | stats.Group = group ;
100 | stats.Name = name ;
101 | stats.nrows = UF_Index.nrows (id) ;
102 | stats.ncols = UF_Index.ncols (id) ;
103 | stats.nnz = UF_Index.nnz (id) ;
104 | stats.nzero = UF_Index.nzero (id) ;
105 | stats.pattern_symmetry = UF_Index.pattern_symmetry (id) ;
106 | stats.numerical_symmetry = UF_Index.numerical_symmetry (id) ;
107 | stats.isBinary = UF_Index.isBinary (id) ;
108 | stats.isReal = UF_Index.isReal (id) ;
109 | stats.nnzdiag = UF_Index.nnzdiag (id) ;
110 | stats.posdef = UF_Index.posdef (id) ;
111 | stats.amd_lnz = UF_Index.amd_lnz (id) ;
112 | stats.amd_flops = UF_Index.amd_flops (id) ;
113 | stats.amd_vnz = UF_Index.amd_vnz (id) ;
114 | stats.amd_rnz = UF_Index.amd_rnz (id) ;
115 | stats.nblocks = UF_Index.nblocks (id) ;
116 | stats.sprank = UF_Index.sprank (id) ;
117 | stats.RBtype = UF_Index.RBtype (id,:) ;
118 | stats.cholcand = UF_Index.cholcand (id) ;
119 | stats.ncc = UF_Index.ncc (id) ;
120 | stats.isND = UF_Index.isND (id) ;
121 | stats.isGraph = UF_Index.isGraph (id) ;
122 |
123 | end
124 | end
125 |
--------------------------------------------------------------------------------
/include/UFget/mat/Bai/bfwa62.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Bai/bfwa62.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Bai/bfwb62.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Bai/bfwb62.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Bai/ck104.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Bai/ck104.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Bai/lop163.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Bai/lop163.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Bai/olm100.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Bai/olm100.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Bai/rw136.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Bai/rw136.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Bai/tols90.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Bai/tols90.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Bai/tub100.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Bai/tub100.mat
--------------------------------------------------------------------------------
/include/UFget/mat/CPM/cz148.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/CPM/cz148.mat
--------------------------------------------------------------------------------
/include/UFget/mat/DIMACS10/chesapeake.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/DIMACS10/chesapeake.mat
--------------------------------------------------------------------------------
/include/UFget/mat/FIDAP/ex5.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/FIDAP/ex5.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Grund/b1_ss.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Grund/b1_ss.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Grund/d_dyn.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Grund/d_dyn.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Grund/d_dyn1.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Grund/d_dyn1.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Grund/d_ss.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Grund/d_ss.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/arc130.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/arc130.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/ash85.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/ash85.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/bcspwr01.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/bcspwr01.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/bcspwr02.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/bcspwr02.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/bcspwr03.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/bcspwr03.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/bcsstk01.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/bcsstk01.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/bcsstk02.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/bcsstk02.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/bcsstk03.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/bcsstk03.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/bcsstk04.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/bcsstk04.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/bcsstk05.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/bcsstk05.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/bcsstk22.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/bcsstk22.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/bcsstm01.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/bcsstm01.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/bcsstm02.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/bcsstm02.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/bcsstm03.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/bcsstm03.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/bcsstm04.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/bcsstm04.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/bcsstm05.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/bcsstm05.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/bcsstm22.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/bcsstm22.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/can_144.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/can_144.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/can_161.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/can_161.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/can_187.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/can_187.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/can_24.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/can_24.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/can_61.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/can_61.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/can_62.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/can_62.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/can_73.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/can_73.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/can_96.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/can_96.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/curtis54.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/curtis54.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/dwt_162.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/dwt_162.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/dwt_193.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/dwt_193.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/dwt_59.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/dwt_59.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/dwt_66.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/dwt_66.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/dwt_72.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/dwt_72.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/dwt_87.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/dwt_87.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/fs_183_1.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/fs_183_1.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/fs_183_3.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/fs_183_3.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/fs_183_4.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/fs_183_4.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/fs_183_6.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/fs_183_6.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/gent113.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/gent113.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/gre_115.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/gre_115.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/gre_185.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/gre_185.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/ibm32.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/ibm32.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/impcol_b.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/impcol_b.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/impcol_c.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/impcol_c.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/jgl009.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/jgl009.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/jgl011.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/jgl011.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/lap_25.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/lap_25.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/lns_131.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/lns_131.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/lnsp_131.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/lnsp_131.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/lund_a.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/lund_a.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/lund_b.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/lund_b.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/mcca.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/mcca.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/nos4.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/nos4.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/pores_1.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/pores_1.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/rgg010.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/rgg010.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/steam3.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/steam3.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/west0067.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/west0067.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/west0132.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/west0132.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/west0156.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/west0156.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/west0167.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/west0167.mat
--------------------------------------------------------------------------------
/include/UFget/mat/HB/will57.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/HB/will57.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Hamrle/Hamrle1.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Hamrle/Hamrle1.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_BIBD/bibd_9_3.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_BIBD/bibd_9_3.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_BIBD/bibd_9_5.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_BIBD/bibd_9_5.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_CAG/CAG_mat72.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_CAG/CAG_mat72.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Forest/TF10.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Forest/TF10.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_G5/IG5-6.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_G5/IG5-6.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_G5/IG5-7.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_G5/IG5-7.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_GL7d/GL7d10.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_GL7d/GL7d10.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Homology/ch3-3-b1.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Homology/ch3-3-b1.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Homology/ch3-3-b2.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Homology/ch3-3-b2.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Homology/ch4-4-b1.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Homology/ch4-4-b1.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Homology/ch4-4-b2.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Homology/ch4-4-b2.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Homology/ch4-4-b3.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Homology/ch4-4-b3.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Homology/klein-b1.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Homology/klein-b1.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Homology/klein-b2.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Homology/klein-b2.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Homology/n2c6-b1.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Homology/n2c6-b1.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Homology/n3c4-b1.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Homology/n3c4-b1.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Homology/n3c4-b2.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Homology/n3c4-b2.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Homology/n3c4-b3.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Homology/n3c4-b3.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Homology/n3c4-b4.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Homology/n3c4-b4.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Homology/n3c5-b1.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Homology/n3c5-b1.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Homology/n3c5-b2.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Homology/n3c5-b2.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Homology/n3c5-b7.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Homology/n3c5-b7.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Homology/n3c6-b1.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Homology/n3c6-b1.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Homology/n4c5-b1.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Homology/n4c5-b1.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Homology/n4c5-b11.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Homology/n4c5-b11.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Kocay/Trec3.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Kocay/Trec3.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Kocay/Trec4.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Kocay/Trec4.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Kocay/Trec5.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Kocay/Trec5.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Kocay/Trec6.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Kocay/Trec6.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Kocay/Trec7.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Kocay/Trec7.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Kocay/Trec8.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Kocay/Trec8.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Margulies/cat_ears_2_1.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Margulies/cat_ears_2_1.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Margulies/flower_4_1.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Margulies/flower_4_1.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Margulies/wheel_3_1.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Margulies/wheel_3_1.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Margulies/wheel_4_1.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Margulies/wheel_4_1.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Margulies/wheel_5_1.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Margulies/wheel_5_1.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Margulies/wheel_6_1.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Margulies/wheel_6_1.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Margulies/wheel_7_1.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Margulies/wheel_7_1.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Relat/rel3.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Relat/rel3.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Relat/rel4.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Relat/rel4.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Relat/relat3.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Relat/relat3.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Relat/relat4.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Relat/relat4.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Trefethen/Trefethen_150.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Trefethen/Trefethen_150.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Trefethen/Trefethen_20.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Trefethen/Trefethen_20.mat
--------------------------------------------------------------------------------
/include/UFget/mat/JGD_Trefethen/Trefethen_20b.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/JGD_Trefethen/Trefethen_20b.mat
--------------------------------------------------------------------------------
/include/UFget/mat/LPnetlib/lp_adlittle.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/LPnetlib/lp_adlittle.mat
--------------------------------------------------------------------------------
/include/UFget/mat/LPnetlib/lp_afiro.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/LPnetlib/lp_afiro.mat
--------------------------------------------------------------------------------
/include/UFget/mat/LPnetlib/lp_blend.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/LPnetlib/lp_blend.mat
--------------------------------------------------------------------------------
/include/UFget/mat/LPnetlib/lp_kb2.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/LPnetlib/lp_kb2.mat
--------------------------------------------------------------------------------
/include/UFget/mat/LPnetlib/lp_sc105.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/LPnetlib/lp_sc105.mat
--------------------------------------------------------------------------------
/include/UFget/mat/LPnetlib/lp_sc50a.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/LPnetlib/lp_sc50a.mat
--------------------------------------------------------------------------------
/include/UFget/mat/LPnetlib/lp_sc50b.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/LPnetlib/lp_sc50b.mat
--------------------------------------------------------------------------------
/include/UFget/mat/LPnetlib/lp_scagr7.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/LPnetlib/lp_scagr7.mat
--------------------------------------------------------------------------------
/include/UFget/mat/LPnetlib/lp_share2b.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/LPnetlib/lp_share2b.mat
--------------------------------------------------------------------------------
/include/UFget/mat/LPnetlib/lp_stocfor1.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/LPnetlib/lp_stocfor1.mat
--------------------------------------------------------------------------------
/include/UFget/mat/LPnetlib/lpi_bgprtr.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/LPnetlib/lpi_bgprtr.mat
--------------------------------------------------------------------------------
/include/UFget/mat/LPnetlib/lpi_forest6.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/LPnetlib/lpi_forest6.mat
--------------------------------------------------------------------------------
/include/UFget/mat/LPnetlib/lpi_galenet.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/LPnetlib/lpi_galenet.mat
--------------------------------------------------------------------------------
/include/UFget/mat/LPnetlib/lpi_itest2.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/LPnetlib/lpi_itest2.mat
--------------------------------------------------------------------------------
/include/UFget/mat/LPnetlib/lpi_itest6.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/LPnetlib/lpi_itest6.mat
--------------------------------------------------------------------------------
/include/UFget/mat/LPnetlib/lpi_klein1.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/LPnetlib/lpi_klein1.mat
--------------------------------------------------------------------------------
/include/UFget/mat/LPnetlib/lpi_woodinfe.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/LPnetlib/lpi_woodinfe.mat
--------------------------------------------------------------------------------
/include/UFget/mat/MathWorks/pivtol.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/MathWorks/pivtol.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Meszaros/farm.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Meszaros/farm.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Meszaros/gams10a.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Meszaros/gams10a.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Meszaros/gams10am.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Meszaros/gams10am.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Meszaros/kleemin.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Meszaros/kleemin.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Meszaros/p0033.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Meszaros/p0033.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Meszaros/p0040.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Meszaros/p0040.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Meszaros/problem.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Meszaros/problem.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Meszaros/refine.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Meszaros/refine.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Meszaros/zed.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Meszaros/zed.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Morandini/robot.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Morandini/robot.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Morandini/rotor1.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Morandini/rotor1.mat
--------------------------------------------------------------------------------
/include/UFget/mat/NYPA/Maragal_1.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/NYPA/Maragal_1.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Newman/adjnoun.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Newman/adjnoun.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Newman/dolphins.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Newman/dolphins.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Newman/football.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Newman/football.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Newman/karate.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Newman/karate.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Newman/lesmis.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Newman/lesmis.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Newman/polbooks.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Newman/polbooks.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Oberwolfach/LF10.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Oberwolfach/LF10.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Oberwolfach/LFAT5.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Oberwolfach/LFAT5.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pajek/Cities.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pajek/Cities.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pajek/GD01_b.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pajek/GD01_b.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pajek/GD01_c.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pajek/GD01_c.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pajek/GD02_a.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pajek/GD02_a.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pajek/GD02_b.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pajek/GD02_b.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pajek/GD06_theory.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pajek/GD06_theory.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pajek/GD95_a.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pajek/GD95_a.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pajek/GD95_b.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pajek/GD95_b.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pajek/GD95_c.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pajek/GD95_c.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pajek/GD96_b.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pajek/GD96_b.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pajek/GD96_c.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pajek/GD96_c.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pajek/GD96_d.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pajek/GD96_d.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pajek/GD97_a.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pajek/GD97_a.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pajek/GD97_b.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pajek/GD97_b.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pajek/GD98_a.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pajek/GD98_a.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pajek/GD98_b.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pajek/GD98_b.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pajek/GD98_c.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pajek/GD98_c.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pajek/GD99_b.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pajek/GD99_b.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pajek/GD99_c.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pajek/GD99_c.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pajek/GlossGT.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pajek/GlossGT.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pajek/Journals.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pajek/Journals.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pajek/Ragusa16.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pajek/Ragusa16.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pajek/Ragusa18.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pajek/Ragusa18.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pajek/Sandi_authors.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pajek/Sandi_authors.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pajek/Stranke94.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pajek/Stranke94.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pajek/Tina_AskCal.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pajek/Tina_AskCal.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pajek/Tina_AskCog.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pajek/Tina_AskCog.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pajek/Tina_DisCal.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pajek/Tina_DisCal.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pajek/Tina_DisCog.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pajek/Tina_DisCog.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pajek/divorce.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pajek/divorce.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pajek/football.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pajek/football.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pothen/mesh1e1.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pothen/mesh1e1.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pothen/mesh1em1.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pothen/mesh1em1.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pothen/mesh1em6.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pothen/mesh1em6.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Pothen/sphere2.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Pothen/sphere2.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Rajat/rajat11.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Rajat/rajat11.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Rajat/rajat14.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Rajat/rajat14.mat
--------------------------------------------------------------------------------
/include/UFget/mat/Rommes/ww_36_pmec_36.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/Rommes/ww_36_pmec_36.mat
--------------------------------------------------------------------------------
/include/UFget/mat/UF_Index.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/UF_Index.mat
--------------------------------------------------------------------------------
/include/UFget/mat/vanHeukelum/cage3.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/vanHeukelum/cage3.mat
--------------------------------------------------------------------------------
/include/UFget/mat/vanHeukelum/cage4.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/vanHeukelum/cage4.mat
--------------------------------------------------------------------------------
/include/UFget/mat/vanHeukelum/cage5.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/vanHeukelum/cage5.mat
--------------------------------------------------------------------------------
/include/UFget/mat/vanHeukelum/cage6.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oxfordcontrol/CDCS/172616a2d3a80db9a667c44ce87d1a9fbf828c62/include/UFget/mat/vanHeukelum/cage6.mat
--------------------------------------------------------------------------------
/include/cs_install.m:
--------------------------------------------------------------------------------
1 | function cs_install (do_pause)
2 | %CS_INSTALL: compile and install CSparse for use in MATLAB.
3 | % Your current working directory must be CSparse/MATLAB in order to use this
4 | % function.
5 | %
6 | % The directories
7 | %
8 | % CSparse/MATLAB/CSparse
9 | % CSparse/MATLAB/Demo
10 | % CSparse/MATLAB/UFget
11 | %
12 | % are added to your MATLAB path (see the "pathtool" command to add these to
13 | % your path permanently, for future MATLAB sessions).
14 | %
15 | % Next, the MATLAB CSparse demo program, CSparse/MATLAB/cs_demo is executed.
16 | % To run the demo with pauses so you can see the results, use cs_install(1).
17 | % To run the full MATLAB test programs for CSparse, run testall in the
18 | % Test directory.
19 | %
20 | % Example:
21 | % cs_install % install and run demo with no pauses
22 | % cs_install(1) % install and run demo with pauses
23 | %
24 | % See also: cs_demo
25 | %
26 | % Copyright 2006-2012, Timothy A. Davis, http://www.suitesparse.com
27 |
28 | if (nargin < 1)
29 | do_pause = 0 ;
30 | end
31 |
32 | if (do_pause)
33 | input ('Hit enter to continue: ') ;
34 | end
35 |
36 |
37 | if (verLessThan ('matlab', '7.0'))
38 | fprintf ('UFget not installed (MATLAB 7.0 or later required)\n') ;
39 | else
40 | % install UFget, unless it's already in the path
41 | try
42 | % if this fails, then UFget is not yet installed
43 | index = UFget ;
44 | fprintf ('UFget already installed:\n') ;
45 | which UFget
46 | catch
47 | index = [ ] ;
48 | end
49 | if (isempty (index))
50 | % UFget is not installed. Use ./UFget
51 | fprintf ('Installing ./UFget\n') ;
52 | try
53 | addpath ([pwd,filesep,'UFget']) ;
54 | catch me
55 | disp (me.message) ;
56 | fprintf ('UFget not installed\n') ;
57 | end
58 | end
59 | end
60 |
61 | cs_make (1) ;
62 |
--------------------------------------------------------------------------------
/include/cs_lsolve_mex.c:
--------------------------------------------------------------------------------
1 | #include "cs_mex.h"
2 | /* cs_lsolve: x=L\b. L must be sparse, real, and lower triangular. b must be a
3 | * real full or sparse vector. x is full or sparse, depending on b.
4 | *
5 | * Time taken is O(flop count), which may be less than n if b is sparse,
6 | * depending on L and b.
7 | *
8 | * This function works with MATLAB 7.2, but is not perfectly compatible with
9 | * the requirements of a MATLAB mexFunction when b is sparse. X is returned
10 | * as an unsorted sparse vector. Also, this mexFunction temporarily modifies
11 | * its input, L, by modifying L->p (in the cs_dfs function) and then restoring
12 | * it. This could be corrected by creating a copy of L->p
13 | * (see cs_dmperm_mex.c), but this would take O(n) time, destroying the
14 | * O(flop count) time complexity of this function.
15 | */
16 |
17 | void mexFunction
18 | (
19 | int nargout,
20 | mxArray *pargout [ ],
21 | int nargin,
22 | const mxArray *pargin [ ]
23 | )
24 | {
25 | cs Lmatrix, Bmatrix, *L, *B, *X ;
26 | double *x, *b ;
27 | csi top, nz, p, *xi ;
28 | if (nargout > 1 || nargin != 2)
29 | {
30 | mexErrMsgTxt ("Usage: x = cs_lsolve(L,b)") ;
31 | }
32 | L = cs_mex_get_sparse (&Lmatrix, 1, 1, pargin [0]) ; /* get L */
33 | if (mxIsSparse (pargin [1]))
34 | {
35 | B = cs_mex_get_sparse (&Bmatrix, 0, 1, pargin [1]) ;/* get sparse b */
36 | cs_mex_check (0, L->n, 1, 0, 1, 1, pargin [1]) ;
37 | xi = cs_malloc (2*L->n, sizeof (csi)) ; /* get workspace */
38 | x = cs_malloc (L->n, sizeof (double)) ;
39 | top = cs_spsolve (L, B, 0, xi, x, NULL, 1) ; /* x = L\b */
40 | X = cs_spalloc (L->n, 1, L->n-top, 1, 0) ; /* create sparse x*/
41 | X->p [0] = 0 ;
42 | nz = 0 ;
43 | for (p = top ; p < L->n ; p++)
44 | {
45 | X->i [nz] = xi [p] ;
46 | X->x [nz++] = x [xi [p]] ;
47 | }
48 | X->p [1] = nz ;
49 | pargout [0] = cs_mex_put_sparse (&X) ;
50 | cs_free (x) ;
51 | cs_free (xi) ;
52 | }
53 | else
54 | {
55 | b = cs_mex_get_double (L->n, pargin [1]) ; /* get full b */
56 | x = cs_mex_put_double (L->n, b, &(pargout [0])) ; /* x = b */
57 | cs_lsolve (L, x) ; /* x = L\x */
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/include/cs_ltsolve_mex.c:
--------------------------------------------------------------------------------
1 | #include "cs_mex.h"
2 | /* cs_ltsolve: solve an upper triangular system L'*x=b */
3 | void mexFunction
4 | (
5 | int nargout,
6 | mxArray *pargout [ ],
7 | int nargin,
8 | const mxArray *pargin [ ]
9 | )
10 | {
11 | cs Lmatrix, *L ;
12 | double *x, *b ;
13 | if (nargout > 1 || nargin != 2)
14 | {
15 | mexErrMsgTxt ("Usage: x = cs_ltsolve(L,b)") ;
16 | }
17 | L = cs_mex_get_sparse (&Lmatrix, 1, 1, pargin [0]) ; /* get L */
18 | b = cs_mex_get_double (L->n, pargin [1]) ; /* get b */
19 | x = cs_mex_put_double (L->n, b, &(pargout [0])) ; /* x = b */
20 | cs_ltsolve (L, x) ; /* x = L'\x */
21 | }
22 |
--------------------------------------------------------------------------------
/include/cs_mex.c:
--------------------------------------------------------------------------------
1 | #include "cs_mex.h"
2 | /* check MATLAB input argument */
3 | void cs_mex_check (csi nel, csi m, csi n, csi square, csi sparse, csi values,
4 | const mxArray *A)
5 | {
6 | csi nnel, mm = mxGetM (A), nn = mxGetN (A) ;
7 | if (values)
8 | {
9 | if (mxIsComplex (A))
10 | {
11 | mexErrMsgTxt ("matrix must be real; try CXSparse instead") ;
12 | }
13 | }
14 | if (sparse && !mxIsSparse (A)) mexErrMsgTxt ("matrix must be sparse") ;
15 | if (!sparse)
16 | {
17 | if (mxIsSparse (A)) mexErrMsgTxt ("matrix must be full") ;
18 | if (values && !mxIsDouble (A)) mexErrMsgTxt ("matrix must be double") ;
19 | }
20 | if (nel)
21 | {
22 | /* check number of elements */
23 | nnel = mxGetNumberOfElements (A) ;
24 | if (m >= 0 && n >= 0 && m*n != nnel) mexErrMsgTxt ("wrong length") ;
25 | }
26 | else
27 | {
28 | /* check row and/or column dimensions */
29 | if (m >= 0 && m != mm) mexErrMsgTxt ("wrong dimension") ;
30 | if (n >= 0 && n != nn) mexErrMsgTxt ("wrong dimension") ;
31 | }
32 | if (square && mm != nn) mexErrMsgTxt ("matrix must be square") ;
33 | }
34 |
35 | /* get a MATLAB sparse matrix and convert to cs */
36 | cs *cs_mex_get_sparse (cs *A, csi square, csi values, const mxArray *Amatlab)
37 | {
38 | cs_mex_check (0, -1, -1, square, 1, values, Amatlab) ;
39 | A->m = mxGetM (Amatlab) ;
40 | A->n = mxGetN (Amatlab) ;
41 | A->p = (csi *) mxGetJc (Amatlab) ;
42 | A->i = (csi *) mxGetIr (Amatlab) ;
43 | A->x = values ? mxGetPr (Amatlab) : NULL ;
44 | A->nzmax = mxGetNzmax (Amatlab) ;
45 | A->nz = -1 ; /* denotes a compressed-col matrix, instead of triplet */
46 | return (A) ;
47 | }
48 |
49 | /* return a sparse matrix to MATLAB */
50 | mxArray *cs_mex_put_sparse (cs **Ahandle)
51 | {
52 | cs *A ;
53 | mxArray *Amatlab ;
54 | A = *Ahandle ;
55 | Amatlab = mxCreateSparse (0, 0, 0, mxREAL) ;
56 | mxSetM (Amatlab, A->m) ;
57 | mxSetN (Amatlab, A->n) ;
58 | mxSetNzmax (Amatlab, A->nzmax) ;
59 | cs_free (mxGetJc (Amatlab)) ;
60 | cs_free (mxGetIr (Amatlab)) ;
61 | cs_free (mxGetPr (Amatlab)) ;
62 | mxSetJc (Amatlab, (mwIndex *) A->p) ; /* assign A->p pointer to MATLAB A */
63 | mxSetIr (Amatlab, (mwIndex *) A->i) ;
64 | mxSetPr (Amatlab, A->x) ;
65 | mexMakeMemoryPersistent (A->p) ; /* ensure MATLAB does not free A->p */
66 | mexMakeMemoryPersistent (A->i) ;
67 | mexMakeMemoryPersistent (A->x) ;
68 | cs_free (A) ; /* frees A struct only, not A->p, etc */
69 | *Ahandle = NULL ;
70 | return (Amatlab) ;
71 | }
72 |
73 | /* get a MATLAB dense column vector */
74 | double *cs_mex_get_double (csi n, const mxArray *X)
75 | {
76 | cs_mex_check (0, n, 1, 0, 0, 1, X) ;
77 | return (mxGetPr (X)) ;
78 | }
79 |
80 | /* return a double vector to MATLAB */
81 | double *cs_mex_put_double (csi n, const double *b, mxArray **X)
82 | {
83 | double *x ;
84 | csi k ;
85 | *X = mxCreateDoubleMatrix (n, 1, mxREAL) ; /* create x */
86 | x = mxGetPr (*X) ;
87 | for (k = 0 ; k < n ; k++) x [k] = b [k] ; /* copy x = b */
88 | return (x) ;
89 | }
90 |
91 | /* get a MATLAB flint array and convert to csi */
92 | csi *cs_mex_get_int (csi n, const mxArray *Imatlab, csi *imax, csi lo)
93 | {
94 | double *p ;
95 | csi i, k, *C = cs_malloc (n, sizeof (csi)) ;
96 | cs_mex_check (1, n, 1, 0, 0, 1, Imatlab) ;
97 | p = mxGetPr (Imatlab) ;
98 | *imax = 0 ;
99 | for (k = 0 ; k < n ; k++)
100 | {
101 | i = p [k] ;
102 | C [k] = i - 1 ;
103 | if (i < lo) mexErrMsgTxt ("index out of bounds") ;
104 | *imax = CS_MAX (*imax, i) ;
105 | }
106 | return (C) ;
107 | }
108 |
109 | /* return an csi array to MATLAB as a flint row vector */
110 | mxArray *cs_mex_put_int (csi *p, csi n, csi offset, csi do_free)
111 | {
112 | mxArray *X = mxCreateDoubleMatrix (1, n, mxREAL) ;
113 | double *x = mxGetPr (X) ;
114 | csi k ;
115 | for (k = 0 ; k < n ; k++) x [k] = (p ? p [k] : k) + offset ;
116 | if (do_free) cs_free (p) ;
117 | return (X) ;
118 | }
119 |
--------------------------------------------------------------------------------
/include/cs_mex.h:
--------------------------------------------------------------------------------
1 | #include "cs.h"
2 | #include "mex.h"
3 | cs *cs_mex_get_sparse (cs *A, csi square, csi values, const mxArray *Amatlab) ;
4 | mxArray *cs_mex_put_sparse (cs **A) ;
5 | void cs_mex_check (csi nel, csi m, csi n, csi square, csi sparse, csi values,
6 | const mxArray *A) ;
7 | csi *cs_mex_get_int (csi n, const mxArray *Imatlab, csi *imax, csi lo) ;
8 | mxArray *cs_mex_put_int (csi *p, csi n, csi offset, csi do_free) ;
9 | double *cs_mex_get_double (csi n, const mxArray *X) ;
10 | double *cs_mex_put_double (csi n, const double *b, mxArray **X) ;
11 |
--------------------------------------------------------------------------------
/include/cs_must_compile.m:
--------------------------------------------------------------------------------
1 | function [s, t, tobj] = cs_must_compile (srcdir, f, suffix, obj, hfile, force)
2 | %CS_MUST_COMPILE return 1 if source code f must be compiled, 0 otherwise
3 | % Used by cs_make, and MATLAB/Test/cs_test_make.m.
4 | %
5 | % Example:
6 | % none, not meant for end users.
7 | % See also: CS_MAKE.
8 |
9 | % Copyright 2006-2012, Timothy A. Davis, http://www.suitesparse.com
10 |
11 | dobj = dir ([f obj]) ;
12 | if (force | isempty (dobj)) %#ok
13 | s = 1 ;
14 | t = Inf ;
15 | tobj = -1 ;
16 | return
17 | end
18 | dsrc = dir ([srcdir f suffix '.c']) ;
19 | dh = dir (hfile) ;
20 | t = max (datenum (dsrc.date), datenum (dh.date)) ;
21 | tobj = datenum (dobj.date) ;
22 | s = (tobj < t) ;
23 |
--------------------------------------------------------------------------------
/packages/+cdcs_hsde/README_HSDE.txt:
--------------------------------------------------------------------------------
1 | ================================================================================
2 | ./CDCS/packages/+cdcs_hsde README
3 | ================================================================================
4 |
5 | This folder is a MATLAB package and contains the functions used by the
6 | homogeneous self-dual embedding solvers in CDCS. The package must contain the
7 | functions
8 |
9 | makeADMM.m: constructs the operators for the ADMM steps and to check the
10 | convergence of the ADMM algorithm.
11 |
12 | makeVariables.m: initialize the variables in the ADMM algorithm.
13 |
14 | setOutputs.m: a function to set the output variables in SeDuMi standard format.
15 |
16 | preprocess.m: a function to preprocess the data (chordalize & rescale)
17 |
18 | printHeader.m : a function to set headers & lines for fprintf.
19 |
20 | All other package-specific functions can be put in a private subfolder for better
21 | code organization, although it is not necessary.
--------------------------------------------------------------------------------
/packages/+cdcs_hsde/makeADMM.m:
--------------------------------------------------------------------------------
1 | function [step1,step2,step3,checkConv] = makeADMM(At,b,c,K,Ech,opts)
2 |
3 | % Make ADMM operators
4 |
5 | % factorization
6 | [xi,solInner] = factorMatrix(At,b,c,Ech,opts.scaleFactors.D1,opts.scaleFactors.E2,opts.KKTfact);
7 |
8 | % Update steps
9 | btr = b.';
10 | ctr = c.';
11 | step1 = @(X,Y,Z,rho,others)updateHatU(X,Y,Z,b,c,btr,ctr,xi,solInner,rho,opts.alpha,others); %% projection onto affine set
12 | step2 = @(X,Y,Z,rho,others)updateU(X,Y,Z,others,K,rho); %% projection onto cones
13 | step3 = @(X,Y,Z,rho,others)updateV(X,Y,Z,rho,others); %% update v
14 |
15 | % Convergence check % residuals according to Byod's paper
16 | A = At';
17 | checkConv = @(X,Y,Z,YOld,others,iter,admmtime,opts,log)...
18 | checkConvergence(X,Y,Z,YOld,iter,admmtime,opts,At,A,b,c,btr,ctr,Ech,others,log);
19 |
20 | end
21 |
22 |
23 |
--------------------------------------------------------------------------------
/packages/+cdcs_hsde/makeVariables.m:
--------------------------------------------------------------------------------
1 | function [X,Y,Z,others] = makeVariables(K,initVars,opts)
2 | % [u,v,X] = makeVariables(K,initVars,opts)
3 | % uhat -- X; u --> Y, v --> Z;
4 | % MAKEVARIABLES(K,initVars)
5 | % Make initial variables
6 |
7 | % GF:
8 | % Initialize with all zeros since we know it is a feasible point.
9 | % Initializing kappa=tau=1 gives annoying NaN in first iteration...
10 |
11 |
12 | if isempty(initVars)
13 | %initialize vectorized versions of all variables
14 | X.x = zeros(opts.nX,1)+1; % free variables
15 | X.xh = zeros(opts.nXk,1)+1; % cone variables: vectorized version
16 | X.y = zeros(opts.m,1); % free variables
17 | X.v = zeros(opts.nXk,1); % free variables
18 | X.tau = 0;
19 |
20 | Y.x = zeros(opts.nX,1)+1; % free variables
21 | Y.xh = zeros(opts.nXk,1)+1; % cone variables: vectorized version
22 | Y.y = zeros(opts.m,1); % free variables
23 | Y.v = zeros(opts.nXk,1); % free variables
24 | Y.tau = 0;
25 |
26 | Z.x = zeros(opts.nX,1); % similar to Y
27 | Z.xh = zeros(opts.nXk,1); %
28 | Z.y = zeros(opts.m,1); %
29 | Z.v = zeros(opts.nXk,1); %
30 | Z.kappa = 0;
31 |
32 | others.X = cdcs_utils.makeConeVariables(K);% cone variables: matrix version
33 |
34 | else
35 | % initialized vectorized variables with used input
36 | % TO DO LATER
37 |
38 | end
39 |
40 | end
--------------------------------------------------------------------------------
/packages/+cdcs_hsde/preprocess.m:
--------------------------------------------------------------------------------
1 | function [At,b,c,K,Ech,stuff,opts] = preprocess(At,b,c,K,opts)
2 |
3 | % CDCS/packages/+cdcs_hsde/PREPROCESS
4 | % Chordal decomposition of SDP constraints & rescale data for homogeneous
5 | % self-dual embedding
6 |
7 | % Import functions
8 | import cdcs_utils.svecData
9 | import cdcs_utils.chordalDecomposition
10 |
11 | % Any variables at all?
12 | nonSDP = K.f + K.l + sum(K.q);
13 | if nonSDP + sum(K.s) == 0
14 | error('No variables in your problem?')
15 | end
16 |
17 | %--------------------------------------------
18 | % Chordal decomposition
19 | %--------------------------------------------
20 |
21 | % Returns the submatrix Ats, Cs of data for PSD variables with svec
22 | % instead of vec, which is the standard input. Also return modified
23 | % matrices At,c that account for svec operation.
24 | [At,c,Ats,Cs] = svecData(At,c,K);
25 | totvars = size(At,1);
26 |
27 | % If required and have SDP variables, decompose
28 | if ~isempty(K.s) && any(K.s~=0) && opts.chordalize~=0
29 | [cliques,Ech,Jch,usedvars,s] = chordalDecomposition(Ats,Cs,K);
30 |
31 | else
32 | cliques = [];
33 | Ech = (1:totvars)';
34 | Jch = (1:totvars)';
35 | usedvars = (1:totvars)';
36 | s = K.s;
37 | end
38 |
39 | % original norms, used repeatly in convergence checking
40 | opts.nAt_init = norm(At,'fro');
41 | opts.nb_init = norm(b,'fro');
42 | opts.nc_init = norm(c,'fro');
43 |
44 | %--------------------------------------------
45 | % Rescale data
46 | %--------------------------------------------
47 | [At,b,c,K,opts] = rescaleData(At,b,c,K,Jch,opts);
48 |
49 |
50 | %--------------------------------------------
51 | % Set new At, c, K.s (remove unused variables)
52 | %--------------------------------------------
53 | At = At(usedvars,:);
54 | c = c(usedvars);
55 | K.s = s;
56 |
57 | if opts.rescale == 1
58 | opts.scaleFactors.D1 = opts.scaleFactors.D1(usedvars);
59 | end
60 |
61 | % Check if At,b,C are indeed sparse - if not, make full for speed!
62 | [n,m] = size(At);
63 | densityTol = 0.6;
64 | if nnz(At)/(m*n) > densityTol
65 | At = full(At);
66 | end
67 | if nnz(b)/m > densityTol
68 | b = full(b);
69 | end
70 | if nnz(c)/n > densityTol
71 | c = full(c);
72 | end
73 |
74 |
75 | %--------------------------------------------
76 | % Set stuff
77 | %--------------------------------------------
78 | stuff.cliques = cliques;
79 | stuff.usedvars = usedvars;
80 | stuff.totvars = totvars;
81 |
82 | % norms, used repeatly in convergence checking
83 | opts.nAt = norm(At,'fro');
84 | opts.nb = norm(b,'fro');
85 | opts.nc = norm(c,'fro');
86 |
--------------------------------------------------------------------------------
/packages/+cdcs_hsde/printHeader.m:
--------------------------------------------------------------------------------
1 | function [header,myline1,myline2] = printHeader
2 |
3 | % CDCS/packages/cdcs_pd/PRINTHEADER
4 | % Print header for iterations
5 |
6 | % Set stuff
7 | myline1 = [repmat('=',1,75),'\n'];
8 | myline2 = [repmat('-',1,75),'\n'];
9 | header = [' iter | pres | dres | pcost | dcost | gap ',...
10 | '| time (s) |\n'];
11 |
--------------------------------------------------------------------------------
/packages/+cdcs_hsde/private/checkConvergence.m:
--------------------------------------------------------------------------------
1 | function [stop,info,log,opts] = checkConvergence(hatu,u,v,uold,iter,admmtime,opts,At,A,b,c,btr,ctr,E,others,log)
2 |
3 | % CHECKCONVERGENCE primal/dual infeasible
4 | % Problem codes
5 | %
6 | % 0: converged
7 | % 1: primal infeasible
8 | % 2: dual infeasible
9 | % 3: max number of iterations reached
10 |
11 | stop = false;
12 | info.problem = 3;
13 |
14 | if u.tau > 0 %% feasible problem
15 | x = u.x./u.tau; y = u.y./u.tau;
16 | dcost = (btr*y)/opts.scaleFactors.sc_cost; %% dual cost
17 | pcost = (ctr*x)/opts.scaleFactors.sc_cost; %% primal cost
18 |
19 | % this is based on the scaled data
20 | % presi = norm(A*x - b,'fro')./(1+opts.nb);
21 | % dresi = norm((At*y + accumarray(E,u.v./u.tau)- c),'fro')./(1+opts.nc);
22 | % dresi = norm((At*y + opts.scaleFactors.D1.*accumarray(E,opts.scaleFactors.E2.*u.v./u.tau)- c),'fro')./(1+opts.nc);
23 | % gap = abs(pcost - dcost)/(1 + abs(pcost) + abs(dcost));
24 |
25 | % residual based on unscaled data
26 | % pk = (A*x - b).*opts.scaleFactors.E1;
27 | % presi = ( norm(pk,'fro')./(1+opts.nb_init) ) / opts.scaleFactors.sc_b;
28 | % dk = (At*y + accumarray(E,u.v./u.tau) - c).*opts.scaleFactors.D1;
29 | % dresi = ( norm(dk,'fro')./(1+opts.nc_init) ) / opts.scaleFactors.sc_c;
30 | % gap = abs(pcost - dcost)/(1 + abs(pcost) + abs(dcost));
31 |
32 | pk = (A*x - b)./opts.scaleFactors.E1;
33 | presi = ( norm(pk,'fro')./(1+opts.nb_init) ) / opts.scaleFactors.sc_b;
34 | dk = (At*y + opts.scaleFactors.D1.*accumarray(E,opts.scaleFactors.E2.*u.v./u.tau) - c)./opts.scaleFactors.D1;
35 | dresi = ( norm(dk,'fro')./(1+opts.nc_init) ) / opts.scaleFactors.sc_c;
36 | gap = abs(pcost - dcost)/(1 + abs(pcost) + abs(dcost));
37 |
38 | if max([presi,dresi,gap]) < opts.relTol
39 | info.problem = 0;
40 | stop = true;
41 | end
42 |
43 |
44 | else % infeasible or unbounded problem?
45 | pinfIndex = btr*u.y; % index of certificating primal infesibility
46 | dinfIndex = -ctr*u.x; % index of certificating dual infesibility
47 | if dinfIndex > 0 % dual infeasible
48 | % % scaled variables
49 | pfeas = norm(A*u.x,'fro');
50 | pfeasTol = dinfIndex/opts.nc*opts.relTol;
51 |
52 | % Original variables
53 | % pfeas = norm( opts.scaleFactors.E1.*(A*u.x),'fro');
54 | % %pfeasTol = -dinfIndex/opts.nc_init/opts.scaleFactors.sc_c*opts.relTol;
55 | % pfeasTol = -dinfIndex/norm(opts.scaleFactors.D1.*c,'fro')*opts.relTol;
56 |
57 | if pfeas <= pfeasTol %% a point x that certificates dual infeasiblity
58 | info.problem = 2;
59 | stop = true;
60 | end
61 | end
62 | if pinfIndex > 0 % primal infeasible
63 |
64 | % scaled data
65 | %dfeas1 = norm(At*u.y+ accumarray(E,u.v),'fro');
66 | dfeas = norm(At*u.y+opts.scaleFactors.D1.*accumarray(E,opts.scaleFactors.E2.*u.v),'fro');
67 | dfeasTol = pinfIndex/opts.nb*opts.relTol;
68 |
69 | % unscaled data
70 | %dfeas = norm(opts.scaleFactors.D1.*(At*u.y+opts.scaleFactors.D1.*accumarray(E,opts.scaleFactors.E2.*u.v)),'fro');
71 | %dfeasTol = -pinfIndex/opts.nb_init/opts.scaleFactors.sc_b*opts.relTol;
72 | %dfeasTol = pinfIndex/norm(opts.scaleFactors.E1.*b,'fro')*opts.relTol;
73 | if dfeas <= dfeasTol %% a point y that certificates primal infeasiblity
74 | info.problem = 1;
75 | stop = true;
76 | end
77 | end
78 |
79 | % value
80 | presi = NaN;
81 | dresi = NaN;
82 | pcost = NaN;
83 | dcost = NaN;
84 | gap = NaN;
85 | end
86 |
87 | %progress message
88 | if opts.verbose && (iter == 1 || ~mod(iter,opts.dispIter) || stop)
89 | if ~isnan(presi)
90 | fprintf('%5d | %7.2e | %7.2e | %9.2e | %9.2e | %8.2e | %8.2e |\n',...
91 | iter,presi,dresi,pcost,dcost,gap, toc(admmtime))
92 | else
93 | % for the purpose of alginment
94 | fprintf('%5d | %8d | %8d | %9d | %9d | %8d | %8.2e |\n',...
95 | iter,presi,dresi,pcost,dcost,gap, toc(admmtime))
96 | end
97 | end
98 |
99 | % log information
100 | % Use preallocation for speed
101 | if iter==1
102 | %cc = cell(opts.maxIter,1);
103 | log.dcost = zeros(opts.maxIter,1);
104 | log.gap = zeros(opts.maxIter,1);
105 | %log = struct('pres',cc,'dres',cc,'cost',cc,'dcost',cc);
106 | end
107 | log.pres(iter) = presi;
108 | log.dres(iter) = dresi;
109 | log.cost(iter) = pcost; %% use primal cost
110 | log.dcost(iter) = dcost;
111 | log.gap(iter) = gap;
112 |
113 | % end main
114 | end
115 |
116 |
--------------------------------------------------------------------------------
/packages/+cdcs_hsde/private/factorMatrix.m:
--------------------------------------------------------------------------------
1 | function [xi,solInner] = factorMatrix(At,b,c,E,D1,E2,flag)
2 | % generate projector onto affine constraints
3 | % The modification of H in the scaling process should be considered.
4 |
5 | %tmpE2 = (1 - E2.^2./(1 + E2.^2)).*(E2.^2);
6 | tmpE2 = E2.^2./(1 + E2.^2);
7 | D = D1.*accumarray(E,tmpE2).*D1;
8 | P = 1./(1+D);
9 |
10 | % First factor the matrix (I+APA') where P = inv(I+1/D) diagonal
11 | factors = factorKKT(P,At,flag);
12 |
13 | % Compute a useful vector
14 | z.x = c;
15 | z.xh = sparse(length(E),1);
16 | z.y = -b;
17 | z.v = sparse(length(E),1);
18 | xi = solveInner(factors,E,D1,E2,z);
19 | const = 1+c.'*xi.x - b.'*xi.y;
20 | xi.x = xi.x/const;
21 | xi.xh = xi.xh/const;
22 | xi.y = xi.y/const;
23 | xi.v = xi.v/const;
24 |
25 | % Set function handle
26 | solInner = @(v)solveInner(factors,E,D1,E2,v);
27 |
28 | end
29 |
30 | %----------------------
31 | % solveInner
32 | %----------------------
33 | function u = solveInner(factors,E,D1,E2,v)
34 | % Solve system of form
35 | %
36 | % [ I M1] [u1] = [v1]
37 | % [-M1' I] [u2] [v2]
38 | %
39 | % where u1 = [u11,u12], u2 = [u21,u22] etc. Input v is formatted so that
40 | % v.x = v11
41 | % v.xh = v12
42 | % v.y = v21
43 | % v.v = v22
44 | %
45 | % Output is formatted the same way
46 |
47 | persistent useBuiltin
48 |
49 | if(isempty(useBuiltin))
50 | %default to look for CSparse code
51 | useBuiltin = ~exist(['cs_ltsolve.' mexext],'file');
52 | end
53 |
54 | % Import functions
55 | import cdcs_utils.cs_lsolve
56 | import cdcs_utils.cs_ltsolve
57 |
58 | if strcmpi(factors.flag,'blk')
59 |
60 | % Cholesky factors and original blocks
61 | R = factors.R;
62 | A = factors.A;
63 | At = factors.At;
64 | P = factors.P;
65 | s = factors.s;
66 | si = factors.si;
67 |
68 | % First find v0 to solve system like M*u2 = v0
69 | v01 = v.x + (At*v.y + D1.*accumarray(E,E2.*v.v)); %% first block elimination
70 | v02 = v.xh - E2.*v.v;
71 |
72 | % Solve system M*u2=v0 using factors
73 |
74 | E2square = E2.^2;
75 |
76 | tmpE2 = E2square./(1 + E2square); %% second block elimination
77 | z = P.*(v01 + D1.*accumarray(E,tmpE2.*v02));
78 | d = A*z;
79 | ds= full(d(s,1)); % permute
80 | if(useBuiltin)
81 | p = R'\((R\ds)); % Native matlab version (slow)
82 | else
83 | p = cs_ltsolve(R,cs_lsolve(R,ds)); % Csparse version (avoids transpose)
84 | end
85 | p = p(si,1); % permute back
86 |
87 | % finish solve
88 | u.x = z - P.*(At*p);
89 |
90 | tmp1 = 1+E2square;
91 | tmp2 = D1.*u.x;
92 | tmp3 = tmp2(E);
93 |
94 | u.xh = (v02 + E2square.*tmp3)./tmp1;
95 | u.y = v.y - A*u.x;
96 | u.v = v.v + (u.xh - tmp3).*E2;
97 | else
98 | error('Unknown method')
99 | end
100 | end
101 |
102 |
103 | %----------------------
104 | % factorKKT
105 | %----------------------
106 | function factors = factorKKT(P,At,flag)
107 |
108 | if(nargin < 2)
109 | At = [];
110 | flag = 'blk';
111 | end
112 |
113 | if(nargin < 3)
114 | flag = 'blk';
115 | end
116 |
117 | %[n,~] = size(At);
118 |
119 | if strcmpi(flag,'ldl')
120 | % TO DO
121 | % I don't think ldl decomposition is a good choice for hsde.
122 | error('Unknown method')
123 |
124 | elseif strcmpi(flag,'inv')
125 | % TO DO
126 | error('Unknown method')
127 | else
128 | [n,m] = size(At);
129 | B = spdiags(sqrt(P),0,n,n)*At; % slow with sparse type with few nonzeros?
130 | M = speye(m) + sparse(B'*B); % = I + A*P*A'
131 | [R,p,s] = chol(M,'lower','vector');
132 |
133 | if p==0
134 | %For maximum efficiency in projection, store both
135 | %the permutation s and its inverse permutation
136 | factors.flag = 'blk';
137 | factors.R = R;
138 | factors.A = At';
139 | factors.At = At;
140 | factors.P = P;
141 | factors.s = s;
142 | tmp = 1:length(s);
143 | factors.si(s) = tmp; %inverse permutation
144 | else
145 | error('Cholesky decomposition fails ... ')
146 | % not definite - use LDL
147 | % M = [spdiags(1./P,0,n,n), sparse(At)
148 | % sparse(m,n), sparse(m,m)];
149 | % [U,D,s] = ldl(M,'upper','vector');
150 | % factors.flag = 'ldl';
151 | % factors.L = U';
152 | % factors.D = D;
153 | % factors.s = s;
154 | % tmp = 1:length(s);
155 | % factors.si(s) = tmp; %inverse permutation
156 | end
157 | end
158 |
159 | end
160 |
--------------------------------------------------------------------------------
/packages/+cdcs_hsde/private/updateHatU.m:
--------------------------------------------------------------------------------
1 | function [hatu,others] = updateHatU(X,u,v,b,c,btr,ctr,xi,solInner,rho,alpha,others)
2 | % update hat{u} = (I+Q)^{-1}(u+v)
3 |
4 | % Projection to affine set
5 |
6 | %% v = u + v; v = u+v/rho?
7 | % v.x = u.x + (v.x)./rho;
8 | % v.xh = u.xh +(v.xh)./rho;
9 | % v.y = u.y + (v.y)./rho;
10 | % v.v = u.v + (v.v)./rho;
11 | % v.kappa = u.tau+v.kappa./rho;
12 |
13 | v.x = u.x + v.x;
14 | v.xh = u.xh + v.xh;
15 | v.y = u.y + v.y;
16 | v.v = u.v + v.v;
17 | v.kappa = u.tau+v.kappa;
18 |
19 | %% solving (I+Q)w = v
20 | v.x = v.x - (v.kappa).*c;
21 | v.y = v.y + (v.kappa).*b;
22 |
23 | w = solInner(v);
24 |
25 | const = ctr*w.x - btr*w.y; % this is a scalar!
26 | hatu.x = w.x - xi.x.*const;
27 | hatu.xh = w.xh - xi.xh.*const;
28 | hatu.y = w.y - xi.y.*const;
29 | hatu.v = w.v - xi.v.*const;
30 | hatu.tau = v.kappa + ctr*hatu.x - btr*hatu.y;
31 |
32 | %% over-relaxation; see section 3.3 in the paper by O'Donoghue
33 | if alpha~=1
34 | beta = 1-alpha;
35 | hatu.x = alpha.*hatu.x + beta.*u.x;
36 | hatu.xh = alpha.*hatu.xh + beta.*u.xh;
37 | hatu.y = alpha.*hatu.y + beta.*u.y;
38 | hatu.v = alpha.*hatu.v + beta.*u.v;
39 | hatu.tau = alpha.*hatu.tau + beta.*u.tau;
40 | end
41 |
42 |
43 | end
44 |
45 |
--------------------------------------------------------------------------------
/packages/+cdcs_hsde/private/updateU.m:
--------------------------------------------------------------------------------
1 | function [u,others] =updateU(hatu,Y,v,others,K,rho)
2 | %u = updateU(hatu,v,X,K,rho)
3 | % projection to cones
4 |
5 | % cone variables: projection
6 | X = others.X;
7 | %X = cdcs_utils.blockify(X,hatu.xh-v.xh./rho,K); % blockxified variables
8 | X = cdcs_utils.blockify(X,hatu.xh-v.xh,K); % blockxified variables
9 | X = cdcs_utils.projectK(X,K,0);
10 | u.xh = cdcs_utils.flatten(v.xh,X);
11 |
12 | % free variables
13 | u.x = hatu.x - v.x;%./rho;
14 | u.y = hatu.y - v.y;%./rho;
15 | u.v = hatu.v - v.v;%./rho;
16 |
17 | % non-neggative variables
18 | u.tau = hatu.tau - v.kappa;%./rho;
19 | if u.tau < 0;
20 | u.tau = 0;
21 | end
22 |
23 | end
24 |
25 |
--------------------------------------------------------------------------------
/packages/+cdcs_hsde/private/updateV.m:
--------------------------------------------------------------------------------
1 | function [v_n,others]=updateV(hatu,u,v,rho,others)
2 | % v_n = updateV(v,hatu,u,rho)
3 | % The third step in ADMM, update the multipliers
4 |
5 | % v_n.x = v.x - rho.*(hatu.x - u.x); %rho*(hatu.x - u.x);
6 | % v_n.xh = v.xh - rho.*(hatu.xh - u.xh); %rho*(hatu.xh - u.xh);
7 | % v_n.y = v.y - rho.*(hatu.y - u.y); %rho*(hatu.y - u.y);
8 | % v_n.v = v.v - rho.*(hatu.v - u.v); %rho*(hatu.v - u.v);
9 | % v_n.kappa = v.kappa - rho.*(hatu.tau - u.tau);%rho*(hatu.kappa - u.kappa);
10 |
11 | v_n.x = v.x - hatu.x + u.x;
12 | v_n.xh = v.xh - hatu.xh + u.xh;
13 | v_n.y = v.y - hatu.y + u.y;
14 | v_n.v = v.v - hatu.v + u.v;
15 | v_n.kappa = v.kappa - hatu.tau + u.tau;
16 |
17 | end
18 |
19 |
--------------------------------------------------------------------------------
/packages/+cdcs_hsde/setOutputs.m:
--------------------------------------------------------------------------------
1 | function [x,y,z,info,opts] = setOutputs(X,Y,Z,others,K,c,E,chstuff,info,opts)
2 |
3 | % SETOUTPUTS.M
4 | %
5 | % Set outputs in sedumi format using positive semidefinite completion algorithms
6 |
7 | % Import functions
8 | import cdcs_utils.makeConeVariables
9 | import cdcs_utils.flatten
10 | import cdcs_utils.blockify
11 | import cdcs_utils.psdCompletion
12 |
13 | % Intialize outputs with correct dimensions
14 | x = zeros(opts.n_init,1);
15 | y = zeros(opts.m_init,1);
16 | z = zeros(opts.n_init,1);
17 |
18 |
19 | % Create some useful variables. xsvec is initialized so it is obvious which
20 | % entries have not been computed if psdCompletion is not called upon user
21 | % request. This is also good for compatibility with YALMIP: used variables are
22 | % set to NaN!
23 | xtemp = zeros(opts.n,1);
24 | ztemp = zeros(opts.n,1);
25 | xsvec = NaN(chstuff.totvars,1); % svec format
26 | zsvec = zeros(chstuff.totvars,1); % svec format
27 | [xmat,zmat] = makeConeVariables(K); % blockified
28 |
29 | % Extract variables & scale solution back
30 | y(:) = (Y.y./Y.tau.*opts.scaleFactors.E1)./opts.scaleFactors.sc_c;
31 | %zsvec(chstuff.usedvars) = accumarray(E,Y.v./Y.tau);
32 | zsvec(chstuff.usedvars) = accumarray(E,opts.scaleFactors.E2.*Y.v./Y.tau);
33 | zsvec(chstuff.usedvars) = zsvec(chstuff.usedvars)./opts.scaleFactors.sc_c;
34 | %zsvec(chstuff.usedvars) = (zsvec(chstuff.usedvars)./opts.scaleFactors.D1)./opts.scaleFactors.sc_c;
35 | zmat = blockify(zmat,zsvec,K);
36 | ztemp = flatten(ztemp,zmat,0);
37 |
38 | % Positive semidefinite completion of x variable
39 | % Only complete if problem successfully solved!
40 |
41 | tmpScale = max(opts.scaleFactors.D1)./opts.scaleFactors.sc_b; % keep the unscaled variables for completion
42 | xsvec(chstuff.usedvars) = (Y.x./Y.tau.*opts.scaleFactors.D1)./opts.scaleFactors.sc_b./tmpScale;
43 | xmat = blockify(xmat,xsvec,K);
44 | xtemp = flatten(xtemp,xmat,0); % in sedumi format for psdCompletion
45 | if info.problem==0 && opts.completion==1 && opts.chordalize~=0
46 | try
47 | % This will give an error if one PSD cone can in fact be split into multiple
48 | % separate cones
49 | xtemp = psdCompletion(xtemp,K,chstuff.cliques); % psdComplete!
50 | catch
51 | warning('CDCS:psdCompletion',...
52 | ['Aborting matrix completion algorithm due to a problem.\n'...
53 | 'Variables in the positive semidefinite cones will be ',...
54 | 'returned without completion.']);
55 | info.problem = 4;
56 | end
57 | elseif info.problem==3
58 | warning('CDCS:psdCompletion',...
59 | ['CDCS reached the maximum number of iterations, and will not attempt\n',...
60 | 'to complete the positive semidefinite variable. Your output will most\n',...
61 | 'likely contain NaNs!']);
62 | end
63 |
64 | % scale back the solutions
65 |
66 |
67 | % Assign solution to used variables
68 | x(opts.usedvars) = xtemp.*tmpScale;
69 | z(opts.usedvars) = ztemp;
70 |
71 |
72 | % END FUNCTION
73 | end
--------------------------------------------------------------------------------
/packages/+cdcs_pd/README_PD.txt:
--------------------------------------------------------------------------------
1 | ================================================================================
2 | ./CDCS/packages/+cdcs_pd README
3 | ================================================================================
4 |
5 | This folder is a MATLAB package and contains the functions used by the
6 | primal-only and dual-only solvers in CDCS. The package must contain the functions
7 |
8 | makeADMM.m: constructs the operators for the ADMM steps and to check the
9 | convergence of the ADMM algorithm.
10 |
11 | makeVariables.m: initialize the variables in the ADMM algorithm.
12 |
13 | setOutputs.m: a function to set the output variables in SeDuMi standard format.
14 |
15 | preprocess.m: a function to preprocess the data (chordalize & rescale)
16 |
17 | printHeader.m : a function to set headers & lines for fprintf.
18 |
19 | All other package-specific functions can be put in a private subfolder for better
20 | code organization, although it is not necessary.
--------------------------------------------------------------------------------
/packages/+cdcs_pd/makeADMM.m:
--------------------------------------------------------------------------------
1 | function [step1,step2,step3,checkConv] = makeADMM(At,b,c,K,Ech,opts)
2 |
3 | % Make ADMM operators
4 |
5 | % Decompose cost vector
6 | if opts.chordalize == 0
7 | % Do nothing!
8 | cd = c;
9 | elseif opts.chordalize == 1
10 | % Decompose equally
11 | IA = accumarray(Ech,1);
12 | cd = c./IA; cd = cd(Ech);
13 | elseif opts.chordalize == 2
14 | % Decompose using only last entry
15 | nv = length(Ech);
16 | cd = zeros(nv,1);
17 | [U,IA] = unique(Ech,'last');
18 | cd(IA,:) = c(U,:);
19 | else
20 | error('Unknown chordal decomposition method.')
21 | end
22 |
23 | % Useful stuff
24 | [projAffine,projCone] = makeProjectors(At,b,c,K,cd,Ech,opts);
25 |
26 | % Update steps
27 | step1 = @(X,Y,Z,rho,others)updateX(X,Y,Z,rho,others,Ech,K,projAffine,opts);
28 | step2 = @(X,Y,Z,rho,others)updateY(X,Y,Z,rho,others,projCone);
29 | step3 = @(X,Y,Z,rho,others)updateZ(X,Y,Z,rho,others,K);
30 |
31 | % Convergence check
32 | checkConv = @(X,Y,Z,YOld,others,iter,admmtime,opts,log)...
33 | checkConvergence(X,Y,Z,YOld,others,b,c,Ech,iter,opts,admmtime,log);
34 |
35 |
36 |
37 | end
38 |
39 |
40 |
--------------------------------------------------------------------------------
/packages/+cdcs_pd/makeVariables.m:
--------------------------------------------------------------------------------
1 | function [X,Y,Z,others] = makeVariables(K,initVars,opts)
2 |
3 | % MAKEVARIABLES(initVars,K)
4 | % Make initial variables
5 | %
6 | % X.vec: vectorized variable for affine constraints
7 | % Y.vec: list of vectorized sub-variables for conic projections
8 | % Z.vec: vectorized Lagrange multipliers
9 | % X.blk: blockified variable for affine constraints - must match Y.blk
10 | % Y.blk: blockified subvariables, ready for projection onto cones
11 | % Z.blk: blockified Lagrange multipliers
12 |
13 |
14 | if isempty(initVars)
15 | %initialize vectorized versions of all variables
16 | if strcmpi(opts.solver,'primal')
17 | X.vec = sparse(opts.nX,1);
18 | others.dual = sparse(opts.m,1);
19 | elseif strcmpi(opts.solver,'dual')
20 | X.vec = sparse(opts.m+opts.nXk,1);
21 | others.dual = sparse(opts.nX,1);
22 | end
23 | Y.vec = sparse(opts.nXk,1);
24 | Z.vec = sparse(opts.nXk,1);
25 |
26 | %initialize blockified versions of all variables
27 | [X.blk,Y.blk,Z.blk] = cdcs_utils.makeConeVariables(K);
28 |
29 | else
30 | % initialized vectorized variables with used input
31 | X.vec = initVars.X.vec;
32 | Y.vec = initVars.Y.vec;
33 | Z.vec = initVars.Z.vec;
34 | X.blk = initVars.X.blk;
35 | Y.blk = initVars.Y.blk;
36 | Z.blk = initVars.Z.blk;
37 |
38 | end
39 |
40 |
41 |
42 |
43 | end
--------------------------------------------------------------------------------
/packages/+cdcs_pd/preprocess.m:
--------------------------------------------------------------------------------
1 | function [At,b,c,K,Ech,stuff,opts] = preprocess(At,b,c,K,opts)
2 |
3 | % CDCS/packages/+cdcs_pd/PREPROCESS.m
4 | %
5 | % Preprocess data: chordalize and rescale. Method for primal-only and dual-only
6 | % solvers.
7 |
8 | % Import functions
9 | import cdcs_utils.svecData
10 | import cdcs_utils.chordalDecomposition
11 |
12 | % Any variables at all?
13 | nonSDP = K.f + K.l + sum(K.q);
14 | if nonSDP + sum(K.s) == 0
15 | error('No variables in your problem?')
16 | end
17 |
18 | %--------------------------------------------
19 | % Rescale data
20 | %--------------------------------------------
21 | [At,b,c,K,opts] = rescaleData(At,b,c,K,opts);
22 |
23 | %--------------------------------------------
24 | % Chordal decomposition
25 | %--------------------------------------------
26 | % Returns the submatrix Ats, Cs of data for PSD variables with svec
27 | % instead of vec, which is the standard input. Also return modified
28 | % matrices At,c that account for svec operation.
29 | [At,c,Ats,Cs] = svecData(At,c,K);
30 | totvars = size(At,1);
31 |
32 | % If required and have SDP variables, decompose
33 | if ~isempty(K.s) && any(K.s~=0) && opts.chordalize~=0
34 | [cliques,Ech,Jch,usedvars,s] = chordalDecomposition(Ats,Cs,K);
35 |
36 | else
37 | cliques = [];
38 | Ech = (1:totvars)';
39 | Jch = (1:totvars)';
40 | usedvars = (1:totvars)';
41 | s = K.s;
42 |
43 | end
44 |
45 | % Set new At, c, K.s (remove unused variables)
46 | At = At(usedvars,:);
47 | c = c(usedvars);
48 | K.s = s;
49 |
50 | % Check if At,b,C are indeed sparse - if not, make full for speed!
51 | [n,m] = size(At);
52 | densityTol = 0.6;
53 | if nnz(At)/(m*n) > densityTol
54 | At = full(At);
55 | end
56 | if nnz(b)/m > densityTol
57 | b = full(b);
58 | end
59 | if nnz(c)/n > densityTol
60 | c = full(c);
61 | end
62 |
63 |
64 | %--------------------------------------------
65 | % Set stuff
66 | %--------------------------------------------
67 | stuff.cliques = cliques;
68 | stuff.usedvars = usedvars;
69 | stuff.totvars = totvars;
--------------------------------------------------------------------------------
/packages/+cdcs_pd/printHeader.m:
--------------------------------------------------------------------------------
1 | function [header,myline1,myline2] = printHeader
2 |
3 | % CDCS/packages/cdcs_pd/PRINTHEADER
4 | % Print header for iterations
5 |
6 | % Set stuff
7 | myline1 = [repmat('=',1,64),'\n'];
8 | myline2 = [repmat('-',1,64),'\n'];
9 | header = ' iter | pres | dres | cost | rho | time (s) |\n';
10 |
--------------------------------------------------------------------------------
/packages/+cdcs_pd/private/checkConvergence.m:
--------------------------------------------------------------------------------
1 | function [stop,info,log,opts] = checkConvergence(X,Y,Z,YOld,others,b,c,E,iter,opts,admmtime,log)
2 |
3 | % CHECKCONVERGENCE
4 | % Use the basic convergence test in the Boyd survey paper
5 | % Primal/dual solver cannot detect infeasibility so error codes can only be
6 | % 0: problem successfully solved
7 | % 3: max number of iterations reached
8 |
9 |
10 | persistent itPinf itDinf
11 | if iter == 1
12 | % initialize persistent iteration counters when entering for the first
13 | % time (persistent variables are empty and not zero when declared)
14 | itPinf = 0; % number of iterations for which pinf/dinf <= eta
15 | itDinf = 0; % number of iterations for which pinf/dinf > eta
16 | end
17 |
18 | % Import functions
19 | import cdcs_utils.flatten
20 |
21 | % Extract some variables
22 | Ex = flatten(Y.vec,X.blk);
23 | y = Y.vec;
24 | yOld = YOld.vec;
25 | z = Z.vec;
26 | rho = opts.rho;
27 |
28 | % primal residual
29 | r = norm(Ex-y,'fro');
30 | pres = r./max(norm(Ex,'fro'),norm(y,'fro'));
31 |
32 | if strcmpi(opts.solver,'primal')
33 | % cost
34 | x = X.vec;
35 | cost = full(c.'*x)/opts.scaleFactors.sc_cost;
36 |
37 | % dual residual
38 | s = rho.*(norm( accumarray(E,(y-yOld)) ,'fro'));
39 | dres = s./norm(accumarray(E,z),'fro');
40 |
41 | elseif strcmpi(opts.solver,'dual')
42 | % cost
43 | x = X.vec(1:opts.m);
44 | cost = full(b.'*x)/opts.scaleFactors.sc_cost;
45 |
46 | % dual residual
47 | s = rho.*(norm(y-yOld,'fro'));
48 | dres = s./norm(z,'fro');
49 | end
50 |
51 | % Costs
52 |
53 |
54 | %stopping criteria
55 | if(max(pres,dres)= opts.nu
74 | itPinf = itPinf+1;
75 | itDinf = 0;
76 | if itPinf >= opts.rhoIt
77 | % ratio of pinf and dinf remained large for long => rescale rho
78 | itPinf = 0;
79 | opts.rho = min(opts.rho*opts.mu, opts.rhoMax);
80 | end
81 | elseif 1/resRat >= opts.nu
82 | itDinf = itDinf+1;
83 | itPinf = 0;
84 | if itDinf >= opts.rhoIt
85 | % ratio of pinf and dinf remained small for long => rescale rho
86 | itDinf = 0;
87 | opts.rho = max(opts.rho/opts.mu, opts.rhoMin);
88 | end
89 | end
90 | end
91 |
92 | % Log errors
93 | log.pres(iter) = pres;
94 | log.dres(iter) = dres;
95 | log.cost(iter) = cost;
96 |
97 | %=======
98 | % Use preallocation for speed
99 | %if iter==1
100 | % cc = cell(opts.maxIter,1);
101 | % log = struct('pres',cc,'dres',cc,'cost',cc);
102 | %end
103 | %log(iter).pres = pres;
104 | %log(iter).dres = dres;
105 | %log(iter).cost = cost;
106 | %>>>>>>> master
107 |
108 | end
--------------------------------------------------------------------------------
/packages/+cdcs_pd/private/rescaleData.m:
--------------------------------------------------------------------------------
1 | function [At,b,c,K,opts] = rescaleData(At,b,c,K,opts)
2 |
3 | % CDCS/packages/+cdcs_pd/RESCALEDATA.m
4 | % Try to rescale data to get nicer convergence properties.
5 | % Assumes no zero columns in At, otherwise will fail.
6 |
7 | % Parameters
8 | [n,m] = size(At);
9 | min_scale = 1e-3;
10 | max_scale = 1e+3;
11 | minScaleRowAt = min_scale .*sqrt(m);
12 | maxScaleRowAt = max_scale .*sqrt(m);
13 | minScaleColAt = min_scale .*sqrt(n);
14 | maxScaleColAt = max_scale .*sqrt(n);
15 |
16 | if opts.rescale
17 |
18 | % Similar scaling strategy to SCS
19 |
20 | % Scale rows of At
21 | % must take mean over cone to preserve cone membership
22 | D = full(sqrt(sum(At.*At,2))); % norm of cols of A (col vec)
23 | count = 0;
24 | if K.f>0
25 | nvars = K.f;
26 | D(count+1:count+nvars) = mean(D(count+1:count+nvars));
27 | count = count + nvars;
28 | end
29 | if K.l>0
30 | nvars = K.l;
31 | D(count+1:count+nvars) = mean(D(count+1:count+nvars));
32 | count = count + nvars;
33 | end
34 | if sum(K.q)>0
35 | for i = 1:length(K.q)
36 | nvars = K.q(i);
37 | D(count+1:count+nvars) = mean(D(count+1:count+nvars));
38 | count = count + nvars;
39 | end
40 | end
41 | if sum(K.s)>0
42 | for i = 1:length(K.s)
43 | nvars = K.s(i)^2;
44 | D(count+1:count+nvars) = mean(D(count+1:count+nvars));
45 | count = count + nvars;
46 | end
47 | end
48 |
49 | D(D>maxScaleRowAt) = maxScaleRowAt; % set upper bound
50 | D(DmaxScaleColAt) = maxScaleColAt; % set upper bound
56 | E(E Y, v --> Z;
4 | % MAKEVARIABLES(K,initVars)
5 | % Make initial variables
6 |
7 |
8 | if isempty(initVars)
9 | %initialize vectorized versions of all variables
10 | X.x = zeros(opts.n,1); % cone variables
11 | X.y = zeros(opts.m,1); % free variables
12 | X.tau = sqrt(opts.n+opts.m+1); % set as sqrt(n+m+1) in SCS?
13 |
14 |
15 | Y.x = zeros(opts.n,1); % cone variables
16 | Y.y = zeros(opts.m,1); % free variables
17 | Y.tau = sqrt(opts.n+opts.m+1);
18 |
19 | Z.x = zeros(opts.n,1); % similar to Y
20 | Z.y = zeros(opts.m,1); %
21 | Z.kappa = 0;
22 |
23 | others.X = cdcs_utils.makeConeVariables(K);% cone variables: matrix version
24 |
25 | else
26 | % initialized vectorized variables with used input
27 | % TO DO LATER
28 |
29 | end
30 |
31 | end
--------------------------------------------------------------------------------
/packages/+cdcs_sos/preprocess.m:
--------------------------------------------------------------------------------
1 | function [At,b,c,K,Ech,stuff,opts] = preprocess(At,b,c,K,opts)
2 |
3 | % CDCS/packages/+cdcs_sos/PREPROCESS
4 | % rescale data for homogeneous self-dual embedding
5 |
6 | % Import functions
7 | import cdcs_utils.svecData
8 | import cdcs_utils.chordalDecomposition
9 |
10 | % Any variables at all?
11 | nonSDP = K.f + K.l + sum(K.q);
12 | if nonSDP + sum(K.s) == 0
13 | error('No variables in your problem?')
14 | end
15 |
16 | % no chordal decompositon
17 | Ech = [];
18 | stuff = [];
19 |
20 | % svec form
21 | [At,c,~,~] = svecData(At,c,K);
22 | [opts.n,opts.m] = size(At);
23 |
24 | % original norms, used repeatly in convergence checking
25 | opts.nAt_init = norm(At,'fro');
26 | opts.nb_init = norm(b,'fro');
27 | opts.nc_init = norm(c,'fro');
28 |
29 |
30 | %--------------------------------------------
31 | % Reorder the PSD cones
32 | %--------------------------------------------
33 | % reorder the variables, such that A = [A1 A2], A2*A2' is diagonal
34 | reorder = 1;
35 | if reorder == 1
36 | [At,c,K,opts] = ConsReorder(At,c,K,opts);
37 | end
38 |
39 | %--------------------------------------------
40 | % Rescale data
41 | %--------------------------------------------
42 | % Rescale
43 | [At,b,c,K,opts] = rescaleData(At,b,c,K,opts); % doesn't work well!
44 |
45 |
46 | % Check if At,b,C are indeed sparse - if not, make full for speed!
47 | [n,m] = size(At);
48 | densityTol = 0.6;
49 | if nnz(At)/(m*n) > densityTol
50 | At = full(At);
51 | end
52 | if nnz(b)/m > densityTol
53 | b = full(b);
54 | end
55 | if nnz(c)/n > densityTol
56 | c = full(c);
57 | end
58 |
59 | % norms, used repeatly in convergence checking
60 | opts.nAt = norm(At,'fro');
61 | opts.nb = norm(b,'fro');
62 | opts.nc = norm(c,'fro');
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/packages/+cdcs_sos/printHeader.m:
--------------------------------------------------------------------------------
1 | function [header,myline1,myline2] = printHeader
2 |
3 | % CDCS/packages/cdcs_pd/PRINTHEADER
4 | % Print header for iterations
5 |
6 | % Set stuff
7 | myline1 = [repmat('=',1,76),'\n'];
8 | myline2 = [repmat('-',1,76),'\n'];
9 | header = [' iter | pres | dres | pcost | dcost | gap ',...
10 | '| time (s) |\n'];
11 |
--------------------------------------------------------------------------------
/packages/+cdcs_sos/private/ConsReorder.m:
--------------------------------------------------------------------------------
1 | function [At,c,K,opts] = ConsReorder(At,c,K,opts)
2 | % Reorder the constraints such that A = [A1 A2]. A2*A2' is diagonal
3 | % Only handle the PSD cone, and leave the free and second-order cone
4 | % unchanged
5 |
6 | %% find the diagonal part
7 | nCone = length(K.s);
8 | % GF on 24 July 2017: how about linear variables?
9 | nConeVars = cumsum([K.f+K.l+K.q, K.s.*(K.s+1)/2]);
10 | OrthFlag = zeros(nCone,1);
11 | OrthNum = 0;
12 | for i = 1:nCone %% focusing on PSD cones
13 | tmpAt = At(nConeVars(i)+1:nConeVars(i+1),:);
14 | if isdiag(tmpAt'*tmpAt) %% diagonal part
15 | OrthFlag(i) = 1;
16 | OrthNum = OrthNum+ nConeVars(i+1) - nConeVars(i);
17 | end
18 | end
19 | opts.sos.OrthFlag = OrthFlag;
20 | opts.sos.Orth = OrthNum; %% number of orthogonal constraints
21 | opts.sos.NonOrth = nConeVars(end) - OrthNum;
22 |
23 | [~,ReOrder] = sort(OrthFlag); %% reorder the variables x
24 | K.s = K.s(ReOrder);
25 | opts.sos.ReOrder = ReOrder;
26 |
27 | %% reorder the data
28 | Index = 1;
29 | ReOrderData = zeros(nConeVars(end)-nConeVars(1),1);
30 | for i = 1:nCone
31 | Num = nConeVars(ReOrder(i)+1) - nConeVars(ReOrder(i));
32 | ReOrderData(Index:Index+Num-1) = nConeVars(ReOrder(i))+1:nConeVars(ReOrder(i)+1);
33 | Index = Index+Num;
34 | end
35 | ReOrderData = [(1:nConeVars(1))';ReOrderData];
36 | c = c(ReOrderData);
37 | At = At(ReOrderData,:);
38 |
39 | %% sparsify
40 | if ~issparse(At) || ~issparse(c)
41 | c = sparse(c);
42 | At = sparse(At);
43 | end
44 | end
45 |
46 |
--------------------------------------------------------------------------------
/packages/+cdcs_sos/private/checkConvergence.m:
--------------------------------------------------------------------------------
1 | function [stop,info,log,opts] = checkConvergence(hatu,u,v,uold,iter,admmtime,opts,At,b,c,others,log)
2 | % CHECKCONVERGENCE primal/dual infeasible
3 | %
4 | % Problem codes
5 | % 0: converged
6 | % 1: primal infeasible
7 | % 2: dual infeasible
8 | % 3: max number of iterations reached
9 |
10 | stop = false;
11 | info.problem = 3;
12 |
13 | if u.tau > 0 %% feasible problem
14 | x = u.x./u.tau;
15 | y = u.y./u.tau;
16 | dcost = (b.'*y)/opts.scaleFactors.sc_cost; %% dual cost
17 | pcost = (c.'*x)/opts.scaleFactors.sc_cost; %% primal cost
18 |
19 | % Residuals before rescaling (O'Donoghue et al, Section 5)
20 | % Use same normalization as O'Donoghue et al
21 | pk = (At.'*x - b).*opts.scaleFactors.E;
22 | presi = ( norm(pk,'fro')./(1+opts.nb_init) ) / opts.scaleFactors.sc_b;
23 | dk = (At*y + (v.x./u.tau) - c).*opts.scaleFactors.D;
24 | dresi = ( norm(dk,'fro')./(1+opts.nc_init) ) / opts.scaleFactors.sc_c;
25 | gap = abs(pcost - dcost)/(1 + abs(pcost) + abs(dcost));
26 |
27 | if max([presi,dresi,gap]) < opts.relTol
28 | info.problem = 0;
29 | stop = true;
30 | end
31 |
32 | else % infeasible or unbounded problem?
33 | pinfIndex = b.'*u.y; % index of certificating primal infesibility
34 | dinfIndex = -c.'*u.x; % index of certificating dual infesibility
35 | if dinfIndex > 0 % dual infeasible
36 | % Scaled variables
37 | % pfeas = norm(At'*u.x,'fro');
38 | % pfeasTol = dinfIndex/opts.nc*opts.relTol;
39 | % Original variables
40 | pfeas = norm( (At'*u.x).*opts.scaleFactors.E ,'fro');
41 | pfeasTol = dinfIndex/opts.nc_init/opts.scaleFactors.sc_c*opts.relTol;
42 | if pfeas <= pfeasTol %% a point x that certificates dual infeasiblity
43 | info.problem = 2;
44 | stop = true;
45 | end
46 | end
47 | if pinfIndex > 0 % primal infeasible
48 | % Original variables
49 | dfeas = norm( (At*u.y+v.x).*opts.scaleFactors.D ,'fro');
50 | dfeasTol = pinfIndex/opts.nb_init/opts.scaleFactors.sc_b*opts.relTol;
51 | if dfeas <= dfeasTol %% a point y that certificates primal infeasiblity
52 | info.problem = 1;
53 | stop = true;
54 | end
55 | end
56 |
57 | % value
58 | presi = NaN;
59 | dresi = NaN;
60 | pcost = NaN;
61 | dcost = NaN;
62 | gap = NaN;
63 | end
64 |
65 | %progress message
66 | if opts.verbose && (iter == 1 || ~mod(iter,opts.dispIter) || stop)
67 | if ~isnan(presi)
68 | fprintf('%5d | %7.2e | %7.2e | %9.2e | %9.2e | %8.2e | %8.2e |\n',...
69 | iter,presi,dresi,pcost,dcost,gap, toc(admmtime))
70 | else
71 | % for the purpose of alginment
72 | fprintf('%5d | %8d | %8d | %9d | %9d | %8d | %8.2e |\n',...
73 | iter,presi,dresi,pcost,dcost,gap, toc(admmtime))
74 | end
75 |
76 | end
77 |
78 | % log information
79 | % Use preallocation for speed
80 | if iter==1
81 | % Much faster preallocation method
82 | log.dcost = zeros(opts.maxIter,1);
83 | log.gap = zeros(opts.maxIter,1);
84 | end
85 |
86 | log.pres(iter) = presi;
87 | log.dres(iter) = dresi;
88 | log.cost(iter) = pcost; %% use primal cost
89 | log.dcost(iter) = dcost;
90 | log.gap(iter) = gap;
91 |
92 | % end main
93 | end
94 |
95 |
--------------------------------------------------------------------------------
/packages/+cdcs_sos/private/rescaleData.m:
--------------------------------------------------------------------------------
1 | function [At,b,c,K,opts] = rescaleData(At,b,c,K,opts)
2 |
3 | % CDCS/packages/+cdcs_sos/RESCALEDATA.m
4 | % Try to rescale data to get nicer convergence properties.
5 | % Assumes no zero columns in At, otherwise will fail.
6 |
7 | % Parameters
8 | [n,m] = size(At);
9 | min_scale = 1e-3;
10 | max_scale = 1e+3;
11 | minScaleRowAt = min_scale .*sqrt(m);
12 | maxScaleRowAt = max_scale .*sqrt(m);
13 | minScaleColAt = min_scale .*sqrt(n);
14 | maxScaleColAt = max_scale .*sqrt(n);
15 |
16 | if opts.rescale
17 |
18 | % Similar scaling strategy to SCS, but scale columns of A (rows of At) to
19 | % have unit norm. So, flip order of operations compared to SCS!
20 |
21 | % Scale rows of At
22 | % must take mean over cone to preserve cone membership
23 | % But not true for free and linear blocks: can scale individual variables!
24 | D = full(sqrt(sum(At.*At,2))); % norm of cols of A (col vec)
25 | count = 0;
26 | if K.f>0
27 | nvars = K.f;
28 | % No need for mean in free cone!
29 | % D(count+1:count+nvars) = mean(D(count+1:count+nvars));
30 | count = count + nvars;
31 | end
32 | if K.l>0
33 | nvars = K.l;
34 | % No need for mean in linear cone!
35 | % D(count+1:count+nvars) = mean(D(count+1:count+nvars));
36 | count = count + nvars;
37 | end
38 | if sum(K.q)>0
39 | for i = 1:length(K.q)
40 | nvars = K.q(i);
41 | D(count+1:count+nvars) = mean(D(count+1:count+nvars));
42 | count = count + nvars;
43 | end
44 | end
45 | if sum(K.s)>0
46 | for i = 1:length(K.s)
47 | % use svec'ed variables
48 | nvars = K.s(i)*(K.s(i)+1)/2;
49 | D(count+1:count+nvars) = mean(D(count+1:count+nvars));
50 | count = count + nvars;
51 | end
52 | end
53 |
54 | D(D>maxScaleRowAt) = maxScaleRowAt; % set upper bound
55 | D(DmaxScaleColAt) = maxScaleColAt; % set upper bound
67 | E(E use v as the scaled multiplier
8 | % in algorithm by O'Donoghue et at
9 | % v.x = u.x + (v.x)./rho;
10 | % v.y = u.y + (v.y)./rho;
11 | % v.kappa = u.tau+v.kappa./rho;
12 | v.x = u.x + v.x;
13 | v.y = u.y + v.y;
14 | v.kappa = u.tau + v.kappa;
15 |
16 |
17 | %% solving (I+Q)w = v
18 | v.x = v.x - (v.kappa).*c;
19 | v.y = v.y + (v.kappa).*b;
20 |
21 | w = solInner(v);
22 |
23 | % Compute transpose only once per iteration (could use persistent variable)
24 | ctr = c.';
25 | btr = b.';
26 |
27 | const = ctr*w.x - btr*w.y; % this is a scalar!
28 | hatu.x = w.x - xi.x.*const;
29 | hatu.y = w.y - xi.y.*const;
30 | hatu.tau = v.kappa + ctr*hatu.x - btr*hatu.y;
31 |
32 | %% over-relaxation; see section 3.3 in the paper by O'Donoghue
33 | if alpha~=1
34 | beta = 1-alpha;
35 | hatu.x = alpha.*hatu.x + beta.*u.x;
36 | hatu.y = alpha.*hatu.y + beta.*u.y;
37 | hatu.tau = alpha.*hatu.tau + beta.*u.tau;
38 | end
39 |
40 |
41 | end
42 |
43 |
--------------------------------------------------------------------------------
/packages/+cdcs_sos/private/updateU.m:
--------------------------------------------------------------------------------
1 | function [u,others] =updateU(hatu,Y,v,others,K,rho)
2 | %u = updateU(hatu,v,X,K,rho)
3 | % projection to cones
4 |
5 | % cone variables: projection
6 | X = others.X;
7 | % GF: make v scaled multiplier
8 | % X = cdcs_utils.blockify(X,hatu.x-v.x./rho,K);
9 | X = cdcs_utils.blockify(X,hatu.x-v.x,K); % blockified variables
10 | X = cdcs_utils.projectK(X,K,0);
11 | u.x = cdcs_utils.flatten(v.x,X);
12 |
13 | % free variables
14 | % u.y = hatu.y - v.y./rho;
15 | u.y = hatu.y - v.y;
16 |
17 | % non-neggative variables
18 | % u.tau = hatu.tau - v.kappa./rho;
19 | u.tau = hatu.tau - v.kappa;
20 | if u.tau < 0
21 | u.tau = 0;
22 | end
23 |
24 | end
25 |
26 |
--------------------------------------------------------------------------------
/packages/+cdcs_sos/private/updateV.m:
--------------------------------------------------------------------------------
1 | function [v_n,others]=updateV(hatu,u,v,rho,others)
2 | % v_n = updateV(v,hatu,u,rho)
3 | % The third step in ADMM, update the multipliers
4 |
5 | % v_n.x = v.x - rho.*(hatu.x - u.x); %rho*(hatu.x - u.x);
6 | % v_n.y = v.y - rho.*(hatu.y - u.y); %rho*(hatu.y - u.y);
7 | % v_n.kappa = v.kappa - rho.*(hatu.tau - u.tau);%rho*(hatu.kappa - u.kappa);
8 |
9 | % GF: v is already scaled multiplier
10 | v_n.x = v.x - hatu.x + u.x;
11 | v_n.y = v.y - hatu.y + u.y;
12 | v_n.kappa = v.kappa - hatu.tau + u.tau;
13 |
14 |
15 | end
16 |
17 |
--------------------------------------------------------------------------------
/packages/+cdcs_sos/setOutputs.m:
--------------------------------------------------------------------------------
1 | function [x,y,z,info,opts] = setOutputs(X,Y,Z,K,info,opts)
2 |
3 | % SETOUTPUTS.M
4 | %
5 | % Set outputs in sedumi format using positive semidefinite completion algorithms
6 |
7 | % Import functions
8 | import cdcs_utils.makeConeVariables
9 | import cdcs_utils.flatten
10 | import cdcs_utils.blockify
11 |
12 | x = zeros(opts.n_init,1);
13 | y = zeros(opts.m_init,1);
14 | z = zeros(opts.n_init,1);
15 |
16 |
17 | %% vector value
18 | xtmp = Y.x/Y.tau;
19 | ytmp = Y.y/Y.tau;
20 | ztmp = Z.x/X.tau;
21 |
22 | % Scale solution
23 | % Scale before blockify because rescaling was done after svec operation in
24 | % rescaleData.m
25 | xtmp = (xtmp./opts.scaleFactors.D)./opts.scaleFactors.sc_b;
26 | ytmp = (ytmp./opts.scaleFactors.E)./opts.scaleFactors.sc_c;
27 | ztmp = (ztmp.*opts.scaleFactors.D)./opts.scaleFactors.sc_c;
28 |
29 |
30 |
31 | % Reorder the variables x, z back to match the original data
32 | % becasue we reordered the data into the prepcosseing step
33 | Kreorder.s = K.s(opts.sos.ReOrder); % This is the PSD cone after reordering
34 | nConeVars = cumsum([K.f+K.l+K.q, Kreorder.s.*(Kreorder.s+1)/2]);
35 | [~,ReOrder] = sort(opts.sos.ReOrder); %% reorder the variables x
36 | Index = 1;
37 | ReOrderVariables = zeros(nConeVars(end)-nConeVars(1),1);
38 | for i = 1:length(K.s)
39 | Num = nConeVars(ReOrder(i)+1) - nConeVars(ReOrder(i));
40 | ReOrderVariables(Index:Index+Num-1) = nConeVars(ReOrder(i))+1:nConeVars(ReOrder(i)+1);
41 | Index = Index + Num;
42 | end
43 | ReOrderVariables = [(1:nConeVars(1))';ReOrderVariables];
44 | xtmp = xtmp(ReOrderVariables);
45 | ztmp = ztmp(ReOrderVariables);
46 |
47 |
48 | % block value
49 | [xmat,zmat] = makeConeVariables(K); % blockified
50 | xmat = blockify(xmat,xtmp,K);
51 | zmat = blockify(zmat,ztmp,K);
52 | xtmp = flatten(xmat,xmat,0);
53 | ztmp = flatten(zmat,zmat,0);
54 |
55 | % % Scale solution
56 | % xtmp = (xtmp./opts.scaleFactors.D)./opts.scaleFactors.sc_b;
57 | % ytmp = (ytmp./opts.scaleFactors.E)./opts.scaleFactors.sc_c;
58 | % ztmp = (ztmp.*opts.scaleFactors.D)./opts.scaleFactors.sc_c;
59 |
60 | % Assign solution to used variables
61 | x(opts.usedvars) = xtmp;
62 | z(opts.usedvars) = ztmp;
63 | y = ytmp;
64 |
65 | % END FUNCTION
66 | end
--------------------------------------------------------------------------------
/packages/+cdcs_utils/README.txt:
--------------------------------------------------------------------------------
1 | ================================================================================
2 | ./CDCS/packages/+cdcs_utils README
3 | ================================================================================
4 |
5 | This folder is a MATLAB package and contains the functions that are used by all
6 | algorithms included in CDCS. Algorithm-specific functions should go in their
7 | dedicated folder.
8 |
--------------------------------------------------------------------------------
/packages/+cdcs_utils/blockify.m:
--------------------------------------------------------------------------------
1 | function X = blockify(X,x,K)
2 |
3 | %Turn portions of x into the matrices X_i
4 | %that must satisfy X_i \succeq 0
5 |
6 | %NB: X is both the input and output, since this
7 | %enables a sort-of call by reference in matlab,
8 | %and no copies are made (seemingly)
9 |
10 | % Free variables
11 | if(isfield(K,'f') && K.f > 0)
12 | X{1}(:) = x(1:K.f);
13 | shift = 1;
14 | count = K.f;
15 | else
16 | shift = 0;
17 | count = 0;
18 | end
19 |
20 | % Zero variables
21 | if(isfield(K,'z') && K.z > 0)
22 | X{1+shift}(:) = x(count+(1:K.z));
23 | shift = shift+1;
24 | count = count + K.z;
25 | end
26 |
27 | % R+ variables
28 | if(isfield(K,'l') && K.l > 0)
29 | X{1+shift}(:) = x(count+(1:K.l));
30 | shift = shift+1;
31 | count = count + K.l;
32 | end
33 |
34 | % SOC variables
35 | if isfield(K,'q') && sum(K.q) > 0
36 | for ii = 1:length(K.q)
37 | X{ii+shift}(:) = x( count+(1:K.q(ii)) );
38 | count = count + K.q(ii);
39 | end
40 | shift = shift+length(K.q);
41 | end
42 |
43 | % SDP variables
44 | if isfield(K,'s') && sum(K.s) > 0
45 | for ii = 1:length(K.s)
46 | d = K.s(ii); %dimension of this SDP cone
47 | if d>0
48 | % X{ii+shift}(:) = x((count+1):(count+d^2),1);
49 | % count = count + d^2;
50 | coneDim = d*(d+1)/2;
51 | X{ii+shift} = smat(x((count+1):(count+coneDim),1));
52 | count = count + coneDim;
53 | end
54 | end
55 | end
56 |
57 | end
58 |
59 |
--------------------------------------------------------------------------------
/packages/+cdcs_utils/checkInputs.m:
--------------------------------------------------------------------------------
1 | function [At,b,c,K,opts] = checkInputs(At,b,c,K,opts)
2 |
3 | %sparsify and vectorize everything
4 | At = sparse(At);
5 | b = sparse(b(:));
6 |
7 | if(isstruct(c))
8 | c.cx = sparse(c.cx(:));
9 | c.cz = sparse(c.cz(:));
10 | else
11 | c = sparse(c(:));
12 | end
13 |
14 |
15 | %check that only free, zero, non-negative, quadratic cone and SDP variables
16 | %are included
17 | if(~all(ismember(fieldnames(K),{'f','l','q','s'})))
18 | error('Unsupported cone constraint types.');
19 | end
20 |
21 | %basic problem dimensions
22 | [n,m] = size(At);
23 | opts.n_init = n;
24 | opts.m_init = m;
25 |
26 | % Set cone
27 | nConeVars = 0;
28 | if(isfield(K,'f') && ~isempty(K.f) && K.f > 0)
29 | nConeVars = nConeVars + K.f;
30 | else
31 | K.f = 0;
32 | end
33 |
34 | if(isfield(K,'l') && ~isempty(K.l) && K.l > 0)
35 | nConeVars = nConeVars + K.l;
36 | else
37 | K.l = 0;
38 | end
39 |
40 | if (isfield(K,'q') && ~isempty(K.q) && max(K.q) > 0)
41 | K.q = K.q(K.q~=0);
42 | nConeVars = nConeVars + sum(K.q);
43 | else
44 | K.q = 0;
45 | end
46 |
47 | if (isfield(K,'s') && ~isempty(K.s) && max(K.s) > 0)
48 | K.s = K.s(K.s~=0);
49 | nConeVars = nConeVars + sum(K.s.^2);
50 | else
51 | K.s = 0;
52 | end
53 |
54 | % Check if cone dimensions match with data
55 | assert(nConeVars == opts.n_init);
56 |
--------------------------------------------------------------------------------
/packages/+cdcs_utils/chordalDecomposition.m:
--------------------------------------------------------------------------------
1 | function [cliques,Ech,Jch,usedvars,s] = chordalDecomposition(Ats,Cs,K)
2 |
3 |
4 | % CDCS/packages/+cdcs_utils/CHORDALDECOMPOSITION.m
5 | %
6 | % Compute chordal decomposition of SDP cones.
7 |
8 | %--------------------------------------------
9 | % Non SDP variables
10 | %--------------------------------------------
11 | nonSDP = K.f + K.l + sum(K.q);
12 | nonSDPind = (1:nonSDP)';
13 |
14 |
15 | %--------------------------------------------
16 | % Sparsity pattern, choral extension and maximal cliques
17 | %--------------------------------------------
18 | SP = spones(spones(Cs) + sparse(sum(spones(Ats),2))); % vector of 1s and 0s
19 |
20 | % Decompose each block
21 | nCones = length(K.s);
22 | count = 0;
23 | countE = 0;
24 | usedvars = [];
25 | s = cell(nCones,1);
26 | cliques = cell(nCones,1);
27 | Ech = {};
28 | Jch = {};
29 | for i = 1:nCones
30 |
31 | % make block
32 | % n = K.s(i)^2;
33 | % Blk = reshape(SP(count+1:count+n),K.s(i),K.s(i));
34 | n = K.s(i)*(K.s(i)+1)/2;
35 | Blk = smat(SP(count+1:count+n));
36 |
37 | % Chordal decomposition
38 | cliques{i} = cliquesFromSpMatD(Blk);
39 | P = cliques{i}.NoC;
40 | Blk = spones(cliques{i}.idxMatrix+cliques{i}.idxMatrix'); %% chordal sparsity
41 | ri = cliques{i}.Elem;
42 | ci = zeros(length(ri),1);
43 | tmp = 0;
44 | for k = 1:P
45 | ci( tmp+1 : tmp+cliques{i}.NoElem(k) ) = k;
46 | tmp = tmp + cliques{i}.NoElem(k);
47 | end
48 | MCO = sparse(ri,ci,1,K.s(i),P);
49 |
50 | % Find variables to keep
51 | nnzind = find(svec(Blk));
52 | usedvars = [usedvars; nnzind+nonSDP+count];
53 |
54 |
55 | % Indexing to extract local submatrices & split cone
56 | E = cell(P,1);
57 | ind = cell(P,1);
58 | s{i} = zeros(1,P);
59 | for j = 1:P
60 |
61 | %indices in global variable X (including zero entries)
62 | Position = find(MCO(:,j));
63 | s{i}(j) = length(Position); % size of clique cone
64 | Position = repmat(Position,1,s{i}(j));
65 | rw = Position(:);
66 | cl = Position'; cl = cl(:);
67 | lti = rw>=cl; % lower triangular indices
68 | rw = rw(lti);
69 | cl = cl(lti);
70 | ind{j} = rw+(K.s(i)-cl./2).*(cl-1); % linear indices in svec(X)
71 |
72 | % Which entry of list of nonzero elements in global variable?
73 | [LIA,LOCB] = ismember(ind{j},nnzind);
74 | E{j} = LOCB + nonSDP + countE;
75 | ind{j} = ind{j} + nonSDP + count;
76 | end
77 |
78 | Ech = [Ech; E];
79 | Jch = [Jch; ind];
80 | count = count + n;
81 | countE = countE + length(nnzind);
82 | end
83 |
84 |
85 |
86 | %--------------------------------------------
87 | % Concatenate mapping indices
88 | %--------------------------------------------
89 | Ech = [nonSDPind; vertcat(Ech{:})];
90 | Jch = [nonSDPind; vertcat(Jch{:})];
91 | s = horzcat(s{:});
92 | usedvars = [nonSDPind; usedvars];
--------------------------------------------------------------------------------
/packages/+cdcs_utils/clean.m:
--------------------------------------------------------------------------------
1 | function varargout = clean(varargin)
2 |
3 | %clean out small values in a vector.
4 | %
5 | % Usage : x = clean(x), or
6 | % x = clean(x,tol), or
7 | % clean(x,tol);
8 |
9 | if(nargin<2)
10 | level = 1e-10;
11 | nClean = 1;
12 | else
13 | level = varargin{end};
14 | nClean = nargin-1;
15 | end
16 |
17 | %eliminate spurious values.
18 | %nested indexing is to avoid
19 | %creating extremely dense
20 | %indices from sparse matrices
21 |
22 | %old usage
23 | if(nargout >= 1)
24 | for i = 1:nClean
25 | varargout{i} = cleanIt(varargin{i},level);
26 | end
27 | end
28 |
29 | %super clever matlab-y amazement
30 | if(nargout == 0)
31 | for i = 1:nClean
32 | theName = inputname(i);
33 | assignin('caller',theName,cleanIt(varargin{i},level));
34 | end
35 | varargout = {};
36 | end
37 |
38 |
39 | function x = cleanIt(x,level)
40 |
41 | %actual cleaning function. careful indexing
42 | %to avoid dense indices
43 |
44 | idx1 = find(x);
45 | idx2 = abs(x(idx1)) < level;
46 | x(idx1(idx2)) = 0;
47 |
48 |
49 |
--------------------------------------------------------------------------------
/packages/+cdcs_utils/cs_lsolve.m:
--------------------------------------------------------------------------------
1 | function x = cs_lsolve (L,b) %#ok
2 | %CS_LSOLVE solve a sparse lower triangular system L*x=b.
3 | % x = cs_lsolve(L,b) computes x = L\b, L must be lower triangular with a
4 | % zero-free diagonal. b must be a column vector. x is full if b is full.
5 | % If b is sparse, x is sparse but the nonzero pattern of x is NOT sorted (it
6 | % is returned in topological order).
7 | %
8 | % Example:
9 | % Prob = UFget ('HB/bcsstk01') ; L = cs_chol (Prob.A) ; n = size (L,1) ;
10 | % b = rand (n,1) ; x = cs_lsolve (L,b) ; norm (L*x-b)
11 | %
12 | % See also CS_LTSOLVE, CS_USOLVE, CS_UTSOLVE, MLDIVIDE.
13 |
14 | % Copyright 2006-2012, Timothy A. Davis, http://www.suitesparse.com
15 |
16 | error ('cs_lsolve mexFunction not found') ;
17 |
--------------------------------------------------------------------------------
/packages/+cdcs_utils/cs_ltsolve.m:
--------------------------------------------------------------------------------
1 | function x = cs_ltsolve (L,b) %#ok
2 | %CS_LTSOLVE solve a sparse upper triangular system L'*x=b.
3 | % x = cs_ltsolve(L,b) computes x = L'\b, L must be lower triangular with a
4 | % zero-free diagonal. b must be a full vector.
5 | %
6 | % Example:
7 | % Prob = UFget ('HB/bcsstk01') ; L = cs_chol (Prob.A) ; n = size (L,1) ;
8 | % b = rand (n,1) ; x = cs_ltsolve (L,b) ; norm (L'*x-b)
9 | %
10 | % See also CS_LSOLVE, CS_USOLVE, CS_UTSOLVE, MLDIVIDE.
11 |
12 | % Copyright 2006-2012, Timothy A. Davis, http://www.suitesparse.com
13 |
14 | error ('cs_ltsolve mexFunction not found') ;
15 |
--------------------------------------------------------------------------------
/packages/+cdcs_utils/flatten.m:
--------------------------------------------------------------------------------
1 | function z = flatten(z,Z,svecFlag)
2 |
3 | %flatten a cell array in a long vector
4 | %For matrix cells, assume symmetric by default and use symmetric vectorization.
5 | %To disable this behaviour and use normal matrix vectorization, set the input
6 | %flag svecFlag to false (or 0).
7 |
8 | if nargin>2 && svecFlag==0
9 | Zvec = cellfun(@(x)x(:),Z,'UniformOutput',false);
10 | else
11 | Zvec = cellfun(@(x)svec(x),Z,'UniformOutput',false);
12 | end
13 | z = vertcat(Zvec{:});
14 |
15 | end
16 |
--------------------------------------------------------------------------------
/packages/+cdcs_utils/makeADMM.m:
--------------------------------------------------------------------------------
1 | function [updateX,updateY,updateZ,checkConvergence] = makeADMM(At,b,c,K,Ech,opts)
2 |
3 | % CDCS/packages/+cdcs_utils/MAKEADMM.m
4 | %
5 | % Initialize ADMM operators for CDCS. Call the correct initialization routine
6 | % according to the method specified in opts.solver.
7 |
8 | switch lower(opts.solver)
9 |
10 | case {'primal', 'dual'}
11 | [updateX,updateY,updateZ,checkConvergence] = ...
12 | cdcs_pd.makeADMM(At,b,c,K,Ech,opts);
13 |
14 | case {'hsde'}
15 | [updateX,updateY,updateZ,checkConvergence] = ...
16 | cdcs_hsde.makeADMM(At,b,c,K,Ech,opts);
17 |
18 | case {'sos'}
19 | [updateX,updateY,updateZ,checkConvergence] = ...
20 | cdcs_sos.makeADMM(At,b,c,K,opts);
21 |
22 | otherwise
23 | error('Unknown value for ''options.solver''.')
24 |
25 | end
26 |
27 |
--------------------------------------------------------------------------------
/packages/+cdcs_utils/makeConeVariables.m:
--------------------------------------------------------------------------------
1 | function [varargout] = makeConeVariables(K)
2 |
3 | % Make conic variables
4 | varargout = repmat({{}},[1 nargout]);
5 | shift = 0;
6 |
7 | %populate the free variables
8 | if(isfield(K,'f') && K.f > 0)
9 | for j = 1:nargout
10 | varargout{j}{1+shift} = zeros(K.f,1);
11 | end
12 | shift = 1;
13 | end
14 |
15 | %populate the zero variables
16 | if(isfield(K,'z') && K.z > 0)
17 | for j = 1:nargout
18 | varargout{j}{1+shift} = zeros(K.z,1);
19 | end
20 | shift = shift+1;
21 | end
22 |
23 | %populate the linear cone variables
24 | if(isfield(K,'l') && K.l > 0)
25 | for j = 1:nargout
26 | varargout{j}{1+shift} = zeros(K.l,1);
27 | end
28 | shift = shift+1;
29 | end
30 |
31 | %populate the second order cone variables
32 | if isfield(K,'q') && sum(K.q) > 0
33 | nqCones = length(K.q);
34 | for i = 1:nqCones
35 | for j = 1:nargout
36 | varargout{j}{end+1} = zeros(K.q(i),1);
37 | end
38 | end
39 | end
40 |
41 | %populate the semidefinite cones
42 | if isfield(K,'s') && sum(K.s) > 0
43 | nsCones = length(K.s);
44 | for i = 1:nsCones
45 | for j = 1:nargout
46 | varargout{j}{end+1} = zeros(K.s(i),K.s(i));
47 | end
48 | end
49 | end
50 |
--------------------------------------------------------------------------------
/packages/+cdcs_utils/makeVariables.m:
--------------------------------------------------------------------------------
1 | function [X,Y,Z,others] = makeVariables(K,initVars,opts)
2 |
3 | % CDCS/packages/+cdcs_utils/MAKEVARIABLES.m
4 | %
5 | % Initialize variables for CDCS. Call the correct variable initialization
6 | % routine according to the method specified in opts.solver.
7 |
8 | switch lower(opts.solver)
9 |
10 | case {'primal', 'dual'}
11 | [X,Y,Z,others] = cdcs_pd.makeVariables(K,initVars,opts);
12 |
13 | case {'hsde'}
14 | [X,Y,Z,others] = cdcs_hsde.makeVariables(K,initVars,opts);
15 |
16 | case {'sos'}
17 | [X,Y,Z,others] = cdcs_sos.makeVariables(K,initVars,opts);
18 |
19 | otherwise
20 | error('Unknown value for ''options.solver''.')
21 |
22 | end
--------------------------------------------------------------------------------
/packages/+cdcs_utils/preprocess.m:
--------------------------------------------------------------------------------
1 | function [At,b,c,K,Ech,chstuff,opts] = preprocess(At,b,c,K,opts)
2 |
3 | % CDCS/packages/+cdcs_utils/PREPROCESS.m
4 | %
5 | % Preprocess data: chordalize and rescale. Call functions according to their
6 | % method (homogeneous self-dual method uses different rescaling!)
7 |
8 | switch lower(opts.solver)
9 |
10 | case {'primal', 'dual'}
11 | [At,b,c,K,Ech,chstuff,opts] = cdcs_pd.preprocess(At,b,c,K,opts);
12 |
13 | case {'hsde'}
14 | [At,b,c,K,Ech,chstuff,opts] = cdcs_hsde.preprocess(At,b,c,K,opts);
15 |
16 | case {'sos'}
17 | [At,b,c,K,Ech,chstuff,opts] = cdcs_sos.preprocess(At,b,c,K,opts);
18 |
19 | otherwise
20 | error('Unknown value for ''options.solver''.')
21 | end
22 |
23 |
--------------------------------------------------------------------------------
/packages/+cdcs_utils/printHeader.m:
--------------------------------------------------------------------------------
1 | function [header,myline1,myline2] = printHeader(opts)
2 |
3 | % CDCS/packages/+cdcs_utils/PRINTHEADER.m
4 | %
5 | % Print header for solver
6 |
7 | switch lower(opts.solver)
8 |
9 | case {'primal', 'dual'}
10 | [header,myline1,myline2] = cdcs_pd.printHeader;
11 |
12 | case {'hsde'}
13 | [header,myline1,myline2] = cdcs_hsde.printHeader;
14 |
15 | case {'sos'}
16 | [header,myline1,myline2] = cdcs_sos.printHeader;
17 |
18 | otherwise
19 | error('Unknown value for ''options.solver''.')
20 |
21 | end
22 |
23 |
--------------------------------------------------------------------------------
/packages/+cdcs_utils/private/constructCliqueGraph.m:
--------------------------------------------------------------------------------
1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 | function [adjacencyMatrixC,noOfEdges,edgeCostVectC,incidenceMatrixC] ...
3 | = constructCliqueGraph(clique)
4 | %
5 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 | % This file is a component of SparseCoLO
7 | % Copyright (C) 2009
8 | % Masakazu Kojima Group
9 | % Department of Mathematical and Computing Sciences
10 | % Tokyo Institute of Technology
11 | %
12 | % This program is free software; you can redistribute it and/or modify
13 | % it under the terms of the GNU General Public License as published by
14 | % the Free Software Foundation; either version 2 of the License, or
15 | % (at your option) any later version.
16 | %
17 | % This program is distributed in the hope that it will be useful,
18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | % GNU General Public License for more details.
21 | %
22 | % You should have received a copy of the GNU General Public License
23 | % along with this program; if not, write to the Free Software
24 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 | %
26 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27 | %
28 |
29 | % adjacensy matrix --->
30 | % startingTime = cputime;
31 | % adjacencyMatrixC = sparse(clique.NoC,clique.NoC);
32 | % for p=1:clique.NoC-1
33 | % for q=p+1:clique.NoC
34 | % tempSet = intersect(clique.Set{p},clique.Set{q});
35 | % if ~isempty(tempSet)
36 | % adjacencyMatrixC(p,q) = length(tempSet);
37 | % end
38 | % end
39 | % end
40 | cliqueMat = sparse(clique.NoC,clique.NoC);
41 | for p=1:clique.NoC
42 | cliqueMat(p,clique.Set{p}) = 1;
43 | end
44 | % idx = 0;
45 | % for p=1:clique.NoC
46 | % sDimE = clique.NoElem(p);
47 | % cliqueMat(p,clique.Elem(idx+(1:sDimE))) = 1;
48 | % idx + sDimE;
49 | % end
50 | adjacencyMatrixC = triu(cliqueMat*cliqueMat',1);
51 | % fprintf('Part A: cputime = %6.2f\n',cputime-startingTime);
52 | % <--- adjacensy matrix
53 | % edgeCostVectC --->
54 | % startingTime = cputime;
55 | edgeCostVectC = reshape(adjacencyMatrixC',1,clique.NoC*clique.NoC);
56 | nzIdx = find(edgeCostVectC);
57 | edgeCostVectC = full(edgeCostVectC(nzIdx));
58 | % fprintf('Part B: cputime = %6.2f\n',cputime-startingTime);
59 | %edgeCostVectC
60 | % <--- edgeCostVectC
61 | % the number of edges --->
62 | noOfEdges = nnz(adjacencyMatrixC);
63 | % <--- the number of edges
64 | % incidence matrix --->
65 | % startingTime = cputime;
66 | % incidenceMatrixC = [];
67 | % edgePointer = 0;
68 | % identityMat = speye(clique.NoC,clique.NoC);
69 | % for p=1:clique.NoC-1
70 | % nzIdx = find(adjacencyMatrixC(p,:) > 0);
71 | % if ~isempty(nzIdx)
72 | % ll = length(nzIdx);
73 | % addMatrix = sparse(clique.NoC,ll);
74 | % addMatrix(p,:) = 1;
75 | % addMatrix = addMatrix - identityMat(:,nzIdx);
76 | % incidenceMatrixC = [incidenceMatrixC,addMatrix];
77 | % end
78 | % end
79 | idxNz = find(adjacencyMatrixC');
80 | idx1 = ceil(idxNz/clique.NoC)';
81 | idx2 = mod(idxNz,clique.NoC)';
82 | idxZero = find(idx2==0);
83 | idx2(idxZero) = clique.NoC;
84 | identityMat = speye(clique.NoC,clique.NoC);
85 | incidenceMatrixC = identityMat(:,idx1) - identityMat(:,idx2);
86 | % fprintf('Part C: cputime = %6.2f\n',cputime-startingTime);
87 | % <--- incidentce matrix
88 | % Ordering columns according to edge costs --->
89 | [edgeCostVectC,permutation] = sort(edgeCostVectC,'descend');
90 | incidenceMatrixC = incidenceMatrixC(:,permutation);
91 | %
92 | % edgeCostVectC
93 | %
94 | % XXXX
95 | % <--- Ordering columns according to edge costs
96 | return
97 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
98 |
--------------------------------------------------------------------------------
/packages/+cdcs_utils/private/maxSpanningTree.m:
--------------------------------------------------------------------------------
1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 | function [treeValue,adjacencyMatrixT,edgeCostVectT,incidenceMatrixT,basisIdx,BInv] ...
3 | = maxSpanningTree(clique,adjacencyMatrixC,edgeCostVectC,incidenceMatrixC,randSeed)
4 |
5 | %
6 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7 | % This file is a component of SparseCoLO
8 | % Copyright (C) 2009
9 | % Masakazu Kojima Group
10 | % Department of Mathematical and Computing Sciences
11 | % Tokyo Institute of Technology
12 | %
13 | % This program is free software; you can redistribute it and/or modify
14 | % it under the terms of the GNU General Public License as published by
15 | % the Free Software Foundation; either version 2 of the License, or
16 | % (at your option) any later version.
17 | %
18 | % This program is distributed in the hope that it will be useful,
19 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | % GNU General Public License for more details.
22 | %
23 | % You should have received a copy of the GNU General Public License
24 | % along with this program; if not, write to the Free Software
25 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 | %
27 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
28 | %
29 |
30 | rand('state',randSeed);
31 | edgeCostVect = edgeCostVectC;
32 | noOfEdges = length(edgeCostVect);
33 | BInv = speye(clique.NoC-1,clique.NoC-1);
34 | edgeDegree = zeros(1,noOfEdges);
35 | edgeDegreeMinus = zeros(1,noOfEdges);
36 | nodeDegree = zeros(clique.NoC,1);
37 | noOfTreeEdges = 0;
38 | basisIdx = zeros(clique.NoC-1,1);
39 | dterminedRows = []; % find(basisIdx');
40 | treeValue = 0;
41 | controlSW = 1;
42 | edgeCostPointer = 0;
43 | iteration = 0;
44 |
45 | while controlSW == 1
46 | iteration = iteration + 1;
47 | if isempty(edgeCostVect)
48 | % fprintf('## iteration = %d at maxSpanningTree4\n',iteration);
49 | error('## the conversion fails because the clique graph is not connected!');
50 | end
51 | currentEdgeCost = edgeCostVect(1);
52 | j = find(edgeCostVect < currentEdgeCost,1);
53 | if isempty(j)
54 | maxIdx = [edgeCostPointer+1:noOfEdges];
55 | edgeCostPointer = [];
56 | edgeCostVect = [];
57 | else
58 | maxIdx = [edgeCostPointer+1:edgeCostPointer+j-1];
59 | edgeCostVect = edgeCostVect(j:noOfEdges-edgeCostPointer);
60 | edgeCostPointer = edgeCostPointer+j-1;
61 | end
62 | while (~isempty(maxIdx)) && (controlSW == 1)
63 | ll = length(maxIdx);
64 | if ll == 1
65 | i = maxIdx(1);
66 | maxIdx = [];
67 | else
68 | [value,j] = min(edgeDegree(maxIdx));
69 | i = maxIdx(j);
70 | maxIdx = setdiff(maxIdx,[i]);
71 | end
72 | pivotCol = BInv * incidenceMatrixC(1:clique.NoC-1,i);
73 | pivRowIdx = find(pivotCol' ~= 0);
74 | pivRowIdx = setdiff(pivRowIdx,dterminedRows);
75 | if ~isempty(pivRowIdx)
76 | ll = length(pivRowIdx);
77 | if ll == 1
78 | q = pivRowIdx(1);
79 | else
80 | [value,j] = max(rand(1,ll));
81 | q = pivRowIdx(j);
82 | end
83 | basisIdx(q,1) = i;
84 | dterminedRows = find(basisIdx');
85 | addDegreeIdx = find(incidenceMatrixC(:,i)');
86 | nodeDegree(addDegreeIdx) = nodeDegree(addDegreeIdx) + 1;
87 | idxPlus = find(incidenceMatrixC(:,i)' == 1);
88 | idxMinus = find(incidenceMatrixC(:,i)' == -1);
89 | edgeDegree = edgeDegree + abs(incidenceMatrixC(idxPlus,:));
90 | edgeDegree = edgeDegree + abs(incidenceMatrixC(idxMinus,:));
91 | treeValue = treeValue + edgeCostVectC(i);
92 | pivotMatrix = speye(clique.NoC-1,clique.NoC-1);
93 | pivotMatrix(:,q) = -pivotCol/pivotCol(q,1);
94 | pivotMatrix(q,q) = 1/pivotCol(q,1);
95 | BInv = pivotMatrix*BInv;
96 | end
97 | if length(dterminedRows) == clique.NoC-1
98 | controlSW = 0;
99 | end
100 | end
101 | end
102 |
103 | edgeCostVectT = edgeCostVectC(1,basisIdx');
104 | incidenceMatrixT = incidenceMatrixC(:,basisIdx');
105 |
106 | adjacencyMatrixT=sparse(clique.NoC,clique.NoC);
107 | for p=1:clique.NoC-1
108 | idx = find(incidenceMatrixT(:,p)');
109 | adjacencyMatrixT(idx(1),idx(2)) = edgeCostVectT(p);
110 | end
111 |
112 | return
113 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
114 |
115 |
--------------------------------------------------------------------------------
/packages/+cdcs_utils/private/smat.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | * mexsmat.c : C mex file
3 | *
4 | * M = smat(x);
5 | *
6 | * Input: x = n(n+1)/2 vector
7 | *
8 | * Based on code from SDPT3.4
9 | ***********************************************************************/
10 |
11 | #include
12 | #include
13 | #include
14 |
15 |
16 | /**********************************************************
17 | * form Q using the lower triangular part
18 | **********************************************************/
19 | void sym(double *Q, int n)
20 | {
21 | int j, k, jn, kn;
22 |
23 | for (j=0; jn-j-1) { /*if i not a valid row index*/
71 | idxj+= n-j; /*update index*/
72 | }
73 | else {
74 | break;
75 | }
76 | }
77 | /* which column? */
78 | j2=j;
79 |
80 | /*Set entry*/
81 | if (i==0) {
82 | irB[count] = i+j;
83 | B[count] = hf*A[k];
84 | ++jcB[j+1];
85 | }
86 | else {
87 | irB[count] = i+j;
88 | B[count] = ir2*A[k];
89 | ++jcB[j+1];
90 | }
91 | count++;
92 | }
93 |
94 | /*cumsum of jcB*/
95 | for (j=0; j1){
124 | mexErrMsgTxt("smat: requires 1 output argument."); }
125 |
126 |
127 | /***** assign pointers *****/
128 | A = mxGetPr(prhs[0]);
129 | m1 = mxGetM(prhs[0]);
130 | n1 = mxGetN(prhs[0]);
131 | if (n1==1) {
132 | n = ( sqrt(8*m1+1)-1 )/2;
133 | }
134 | else if (m1==1) {
135 | n = ( sqrt(8*n1+1)-1 )/2;
136 | }
137 | else {
138 | mexErrMsgTxt("smat: is only defined for vector arguments!");
139 | }
140 |
141 |
142 | isspA = mxIsSparse(prhs[0]);
143 | if (isspA) {
144 | irA = mxGetIr(prhs[0]);
145 | jcA = mxGetJc(prhs[0]);
146 | }
147 |
148 | /***** create return argument *****/
149 | if (isspA) {
150 | NZmax = jcA[1]-jcA[0];
151 | rhs[0] = mxCreateSparse(n,n,2*NZmax,mxREAL);
152 | B = mxGetPr(rhs[0]);
153 | irB = mxGetIr(rhs[0]);
154 | jcB = mxGetJc(rhs[0]);
155 | }
156 | else {
157 | plhs[0] = mxCreateDoubleMatrix(n,n,mxREAL);
158 | B = mxGetPr(plhs[0]);
159 | }
160 |
161 | /***** Do the computations in a subroutine *****/
162 | smat1(n,ir2,A,irA,jcA,isspA,B,irB,jcB,isspA);
163 | if (isspA) {
164 | /*** if isspB, (actual B) = B+B' ****/
165 | mexCallMATLAB(1, &rhs[1], 1, &rhs[0], "ctranspose");
166 | mexCallMATLAB(1, &plhs[0],2, rhs, "+");
167 | mxDestroyArray(*rhs);
168 | }
169 |
170 |
171 | return;
172 | }
173 | /**********************************************************/
174 |
175 |
--------------------------------------------------------------------------------
/packages/+cdcs_utils/private/svec.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | * mexsvec.c : C mex file
3 | *
4 | * x = svec(A);
5 | *
6 | * Input: A = nxn matrix
7 | *
8 | * Based on code from SDPT3.4
9 | ***********************************************************************/
10 |
11 | #include
12 | #include
13 | #include
14 |
15 |
16 | /**********************************************************
17 | * Stack lower triangular part of A row-wise into a column vector
18 | **********************************************************/
19 | void svec1(int n, double r2,
20 | double *A, mwIndex *irA, mwIndex *jcA, int isspA,
21 | double *B, mwIndex *irB, mwIndex *jcB, int isspB)
22 |
23 | { int idx, rowidx, i, j, jn, k, kstart, kend;
24 |
25 | /* Dense input, dense output */
26 | if (!isspB & !isspA) {
27 | idx = 0;
28 | for (j=0; j j) {
48 | irB[idx] = i + n*j - ((j+1)*j)/2;
49 | B[idx] = A[k]*r2;
50 | idx++; }
51 | else if (i==j) {
52 | irB[idx] = i + n*j - ((j+1)*j)/2;
53 | B[idx] = A[k];
54 | idx++;
55 | }
56 | }
57 | }
58 | jcB[1] = idx;
59 | }
60 | return;
61 | }
62 |
63 | /**********************************************************
64 | * Stack lower triangular part of A row-wise into a column vector
65 | **********************************************************/
66 | void copyvec(int n,
67 | double *A, mwIndex *irA, mwIndex *jcA, int isspA,
68 | double *B, mwIndex *irB, mwIndex *jcB, int isspB)
69 |
70 | { int idx, rowidx, i, j, jn, k, kstart, kend;
71 |
72 | /* Dense input, dense output */
73 | if (!isspB & !isspA) {
74 | idx = 0;
75 | for (j=0; j 1){
115 | mexErrMsgTxt("svec: requires 1 output argument."); }
116 |
117 | /* CHECK THE DIMENSIONS */
118 |
119 | m = mxGetM(prhs[0]);
120 | n = mxGetN(prhs[0]);
121 | if (n==1) {
122 | isvecA = 1;
123 | n2 = m;
124 | }
125 | else if (m == n) {
126 | isvecA = 0;
127 | /* Find size of svectorized variable */
128 | n2 = n*(n+1)/2;
129 | }
130 | else {
131 | mexErrMsgTxt("svec: matrix must be square.");
132 | }
133 |
134 |
135 |
136 |
137 | /***** assign pointers *****/
138 | A = mxGetPr(prhs[0]);
139 | isspA = mxIsSparse(prhs[0]);
140 | if (isspA) {
141 | irA = mxGetIr(prhs[0]); /* get row indices */
142 | jcA = mxGetJc(prhs[0]); /* get col indices */
143 | NZmax = mxGetNzmax(prhs[0]); /* # allocated nonzero elements */
144 | }
145 | else {
146 | NZmax = n2;
147 | }
148 |
149 |
150 | /***** create return argument *****/
151 | if (isspA) {
152 | plhs[0] = mxCreateSparse(n2,1,n2,mxREAL);
153 | B = mxGetPr(plhs[0]);
154 | irB = mxGetIr(plhs[0]);
155 | jcB = mxGetJc(plhs[0]);
156 | jcB[0] = 0;
157 | }
158 | else {
159 | plhs[0] = mxCreateDoubleMatrix(n2,1,mxREAL);
160 | B = mxGetPr(plhs[0]);
161 | }
162 |
163 | /***** Do the computations in a subroutine *****/
164 | if (isvecA) {
165 | copyvec(m,A,irA,jcA,isspA,B,irB,jcB,isspA);
166 | }
167 | else {
168 |
169 | svec1(n,r2,A,irA,jcA,isspA,B,irB,jcB,isspA);
170 | }
171 | return;
172 | }
173 | /**********************************************************/
174 |
--------------------------------------------------------------------------------
/packages/+cdcs_utils/projectK.m:
--------------------------------------------------------------------------------
1 | function X = projectK(X,K,useDual)
2 |
3 | %project a vector onto a cone K defined in SEDUMI format
4 |
5 | if(nargin < 3)
6 | useDual = 0;
7 | end
8 |
9 | if(useDual)
10 | dual = 1; primal = 0;
11 | else
12 | primal = 1; dual = 0;
13 | end
14 |
15 | assert(xor(primal,dual));
16 |
17 | blockIdx = 1;
18 |
19 | % FREE CONE PROJECTION (R^n)
20 | if(isfield(K,'f') && K.f > 0)
21 | if(primal)
22 | X{blockIdx} = projectRn(X{blockIdx});
23 | end
24 | if(dual)
25 | X{blockIdx} = projectZero(X{blockIdx});
26 | end
27 | blockIdx = blockIdx + 1;
28 | end
29 |
30 | % ZERO CONE PROJECTION ({0}^n)
31 | if(isfield(K,'z') && K.z > 0)
32 | if(primal)
33 | X{blockIdx} = projectZero(X{blockIdx});
34 | end
35 | if(dual)
36 | X{blockIdx} = projectRn(X{blockIdx});
37 | end
38 | blockIdx = blockIdx + 1;
39 | end
40 |
41 | % POSITIVE ORTHANT PROJECTION (R^n_+)
42 | if(isfield(K,'l') && K.l > 0)
43 | X{blockIdx} = projectPosOrthant(X{blockIdx}); %self dual cone
44 | blockIdx = blockIdx + 1;
45 | end
46 |
47 | % SOC PROJECTION
48 | if (isfield(K,'q') && any(K.q))
49 | for i = (1:length(K.q))
50 | X{blockIdx} = projectSOC(X{blockIdx}); %self dual cone
51 | blockIdx = blockIdx + 1;
52 | end
53 | end
54 |
55 | % PSD CONE PROJECTION (S_+^n)
56 | %project everything onto the PSD cone (self-dual)
57 | nPosEigs = 0;
58 | if (isfield(K,'s') && any(K.s))
59 | for i = (1:length(K.s))
60 | [X{blockIdx},temp] = projectPSD(X{blockIdx}); %self dual cone
61 | nPosEigs = nPosEigs + temp;
62 | blockIdx = blockIdx + 1;
63 | end
64 | end
65 |
66 | % fprintf('Number of positive eigenvalues = %i\n',nPosEigs);
67 |
68 | end
69 |
70 |
71 | %------------------------------------
72 | % ACTUAL PROJECTION FUNCTIONS
73 | %------------------------------------
74 |
75 | % ZERO CONE
76 | function X = projectZero(X)
77 | X(:) = 0;
78 | end
79 |
80 | % FREE CONE
81 | function X = projectRn(X)
82 | return;
83 | end
84 |
85 | % POSITIVE ORTHANT
86 | function X = projectPosOrthant(X)
87 | X = max(X,0);
88 | end
89 |
90 | % SECOND ORDER CONE
91 | function X = projectSOC(X)
92 | s = X(1);
93 | x = X(2:end);
94 | normx = norm(x,2);
95 |
96 | if(normx <= s)
97 | X = X;
98 | elseif(normx <= -s)
99 | X = X.*0;
100 | else
101 | t = (normx + s)/2;
102 | X = [t;(t/normx).*x];
103 | end
104 | end
105 |
106 | % POSITIVE SEMIDEFINITE CONE
107 | function [S,nPosEigs] = projectPSD(S)
108 | %scalar case
109 | if(numel(S) == 1)
110 | nPosEigs = double(S > 0);
111 | S = max(0,S);
112 | return;
113 | end
114 | % matrix case
115 | S = S./2;
116 | S = S+S.';
117 | [U,E] = eig(S);
118 | ind = diag(E)>0;
119 | UsE = U(:,ind)*sqrt(E(ind,ind));
120 | S = UsE*UsE.';
121 | nPosEigs = nnz(ind);
122 | end
123 |
--------------------------------------------------------------------------------
/packages/+cdcs_utils/setOutputs.m:
--------------------------------------------------------------------------------
1 | function [x,y,z,info,opts] = setOutputs(X,Y,Z,others,Kold,c,Ech,chstuff,info,opts)
2 |
3 | % CDCS/packages/+cdcs_utils/SETOUTPUTS.m
4 | %
5 | % Set output for CDCS. Call the correct routine according to the method
6 | % specified in opts.solver.
7 |
8 | switch lower(opts.solver)
9 |
10 | case {'primal', 'dual'}
11 | [x,y,z,info,opts] = cdcs_pd.setOutputs(X,Y,Z,others,Kold,c,Ech,chstuff,info,opts);
12 |
13 | case {'hsde'}
14 | [x,y,z,info,opts] = cdcs_hsde.setOutputs(X,Y,Z,others,Kold,c,Ech,chstuff,info,opts);
15 |
16 | case {'sos'}
17 | [x,y,z,info,opts] = cdcs_sos.setOutputs(X,Y,Z,Kold,info,opts);
18 |
19 | otherwise
20 | error('Unknown value for ''options.solver''.')
21 |
22 | end
--------------------------------------------------------------------------------
/packages/+cdcs_utils/setUserOpts.m:
--------------------------------------------------------------------------------
1 | function opts = setUserOpts(opts,userOpts)
2 |
3 | % SETUSEROPTS
4 | %
5 | % Set user options
6 |
7 | if ~isstruct(userOpts)
8 | error('Input ''options'' must be a structure.');
9 | else
10 | fnames = fieldnames(userOpts);
11 | for n=1:length(fnames)
12 | if isfield(opts,fnames{n})
13 | opts.(fnames{n}) = userOpts.(fnames{n});
14 | else
15 | warning('Option ''%s'' is unknown and will be ignored.',fnames{n})
16 | end
17 | end
18 | end
19 |
20 | % make solver lowercase
21 | opts.solver = lower(opts.solver);
--------------------------------------------------------------------------------
/packages/+cdcs_utils/splitBlocks.m:
--------------------------------------------------------------------------------
1 | function [At,b,c,K,opts] = splitBlocks(At,b,c,K,opts)
2 |
3 | % Try to split semidefinite blocks into smaller connected components
4 | % Return updated data with split cones and a vector of indices opts.sort such
5 | % that
6 | %
7 | % x_new = x_old(opts.sort)
8 | %
9 | % Given x_new, the original variable x_old can be reconstructed with
10 | %
11 | % >> x_old = zeros(,1);
12 | % >> x_old(opts.sort) = x_new;
13 |
14 | % Some variables
15 | cnt = K.f + K.l + sum(K.q);
16 | nBlk = length(K.s);
17 |
18 | % Sparsity pattern of semidefinite blocks
19 | csdp = c(cnt+1:end);
20 | Atsdp = At(cnt+1:end,:);
21 | SP = spones(spones(csdp) + sparse(sum(spones(Atsdp),2)));
22 |
23 | % Loop over blocks
24 | R = []; rowcnt = 0;
25 | C = []; colcnt = 0;
26 | s = [];
27 | for i = 1:nBlk
28 |
29 | % Find connected components of block
30 | m = K.s(i);
31 | B = reshape(SP(rowcnt+1:rowcnt+m^2),m,m);
32 | [tags,nComponents] = connectedComponents(B);
33 |
34 | % If more than one component, split.
35 | if nComponents>1
36 |
37 | % Find component dimensions, permutation matrix and indices for block
38 | % pattern
39 | p = zeros(m,1);
40 | count = 0;
41 | I = []; J = [];
42 | for j = 1:nComponents
43 | % Dimension and permutation vector
44 | ind = find(tags==j);
45 | dim = numel(ind);
46 | s = [s, dim];
47 | lind = count+1:count+dim;
48 | p(lind) = ind;
49 |
50 | % Find indices for block pattern
51 | [row,col] = meshgrid(lind);
52 | I = [I; row(:)];
53 | J = [J; col(:)];
54 |
55 | % Update counter
56 | count = count+dim;
57 |
58 | end
59 |
60 |
61 | % Project onto connected components
62 | P = sparse(p,1:m,1,m,m); % permutation of cone
63 | B = sparse(I,J,1,m,m); % permuted connected components
64 | e = find(B); ne = length(e);
65 | E = sparse(e,1:ne,1,m^2,ne); % projection onto component blocks
66 | [Ri,Ci] = find(kron(P,P)*E);
67 |
68 | % Store indices
69 | R = [R; Ri+rowcnt];
70 | C = [C; Ci+colcnt];
71 |
72 | % Update counters
73 | rowcnt = rowcnt + m^2;
74 | colcnt = colcnt + ne;
75 |
76 | else
77 | % Nothing to do
78 | s = [s, m];
79 | Ri = (1:m^2)';
80 | R = [R; Ri+rowcnt];
81 | C = [C; Ri+colcnt];
82 | rowcnt = rowcnt + m^2;
83 | colcnt = colcnt + m^2;
84 | end
85 |
86 | end
87 |
88 |
89 | % Update problem data
90 | M = sparse(C,R,1,colcnt,rowcnt); % since work with transpose At!
91 | At = [At(1:cnt,:); M*Atsdp];
92 | c = [c(1:cnt); M*csdp];
93 | K.s = s;
94 |
95 | % Find used variables
96 | opts.usedvars = [(1:cnt)'; R+cnt];
97 |
98 |
99 |
100 | % END MAIN
101 | end
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 | % ============================================================================ %
111 | % NESTED FUNCTION %
112 | % ============================================================================ %
113 |
114 | function [tags,nComponents] = connectedComponents(B)
115 |
116 | % Find connected components of sparsity pattern matrix B
117 |
118 | L = size(B,1); % number of vertex
119 |
120 | % Breadth-first search:
121 | tags = zeros(1,L); % all vertex unexplored at the begining
122 | rts = [];
123 | ccc = 0; % connected components counter
124 | while true
125 | ind = find(tags==0);
126 | if ~isempty(ind)
127 | fue = ind(1); % first unexplored vertex
128 | rts = [rts fue];
129 | list = [fue];
130 | ccc = ccc+1;
131 | tags(fue) = ccc;
132 | while true
133 | list_new = [];
134 | for lc=1:length(list)
135 | p = list(lc); % point
136 | cp = find(B(p,:)); % points connected to p
137 | cp1 = cp(tags(cp)==0); % get only unexplored vertecies
138 | tags(cp1) = ccc;
139 | list_new =[list_new cp1];
140 | end
141 | list = list_new;
142 | if isempty(list)
143 | break;
144 | end
145 | end
146 | else
147 | break;
148 | end
149 | end
150 |
151 | % set number of components
152 | nComponents = max(tags);
153 | end
--------------------------------------------------------------------------------
/packages/+cdcs_utils/svecData.m:
--------------------------------------------------------------------------------
1 | function [At,C,Ats,Cs] = svecData(At,C,K)
2 |
3 | % SVECDATA.m
4 | %
5 | % Transform data from vectorize format to svectorized format for semidefinite
6 | % variables according to the cone K.
7 |
8 | %--------------------------------------------
9 | % Some variables
10 | %--------------------------------------------
11 | nSDP = sum(K.s.^2);
12 | nonSDP = K.f + K.l + sum(K.q);
13 |
14 | if nSDP > 0
15 | %--------------------------------------------
16 | % Build matrix Q such that svec(X)=Q*vec(X).
17 | % Consider each block separately.
18 | %--------------------------------------------
19 | nBlk = length(K.s);
20 | isr2 = 1./sqrt(2);
21 | I = zeros(nSDP,1);
22 | J = zeros(nSDP,1);
23 | V = zeros(nSDP,1);
24 | count = 0;
25 | bdrow = 0;
26 | bdcol = 0;
27 |
28 | % Loop over blocks
29 | for blk = 1:nBlk
30 | n = K.s(blk);
31 | rowcnt = 0;
32 |
33 | % Loop over columns
34 | for j=1:n
35 |
36 | % Find indices
37 | nels = n-j+1;
38 | rws = repmat(1:nels,2,1);
39 | rws = rws(:);
40 | cls = [n*(j-1)+(j+1:n); n*((j+1:n)-1)+j];
41 | I(count+1:count+2*nels-1) = rowcnt + rws(2:end) + bdrow;
42 | J(count+1:count+2*nels-1) = [n*(j-1)+j; cls(:)] + bdcol;
43 | V(count+1:count+2*nels-1) = [1; repmat(isr2,2*nels-2,1)];
44 |
45 | % update counters
46 | rowcnt = rowcnt + nels;
47 | count = count + 2*nels-1;
48 | end
49 |
50 | % Update block diagonal counter
51 | bdrow = bdrow + n*(n+1)/2;
52 | bdcol = bdcol + n^2;
53 | end
54 |
55 | % Build sparse Q
56 | Q = sparse(I,J,V,bdrow,nSDP);
57 |
58 | % svec the data
59 | Ats = Q*At(nonSDP+1:end,:);
60 | Cs = Q*C(nonSDP+1:end,:);
61 |
62 | else
63 | Ats = [];
64 | Cs = [];
65 |
66 | end
67 |
68 | %--------------------------------------------
69 | % Modify At and c
70 | %--------------------------------------------
71 | At = [At(1:nonSDP,:); Ats];
72 | C = [ C(1:nonSDP); Cs];
73 |
74 |
75 | end
--------------------------------------------------------------------------------
/packages/+cdcs_utils/vec.m:
--------------------------------------------------------------------------------
1 | function x = vec(X)
2 |
3 | % VEC
4 | % Vectorize matrix. x = vec(X) is equivalent to x = X(:).
5 |
6 | x = X(:);
7 |
8 | end
--------------------------------------------------------------------------------