<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>DSDP: src/solver/dsdpschurmat.c Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.7.4 --> <div id="top"> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">DSDP</div> </td> </tr> </tbody> </table> </div> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="annotated.html"><span>Data Structures</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li><a href="dirs.html"><span>Directories</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>Globals</span></a></li> </ul> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="dir_23046874d7fed141927c769a66d8e3a5.html">src</a> </li> <li class="navelem"><a class="el" href="dir_03c647d51c93e018646ff83aa2eeb169.html">solver</a> </li> </ul> </div> </div> <div class="header"> <div class="headertitle"> <div class="title">dsdpschurmat.c</div> </div> </div> <div class="contents"> <a href="dsdpschurmat_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#include "<a class="code" href="dsdpschurmat__impl_8h.html" title="Function pointers that a Schur complement matrix (dense, sparse, parallel dense) must provide...">dsdpschurmat_impl.h</a>"</span> <a name="l00002"></a>00002 <span class="preprocessor">#include "<a class="code" href="dsdpschurmat_8h.html" title="Methods of a Schur Matrix.">dsdpschurmat.h</a>"</span> <a name="l00003"></a>00003 <span class="preprocessor">#include "<a class="code" href="dsdpbasictypes_8h.html" title="Solver, solution types, termination codes,.">dsdpbasictypes.h</a>"</span> <a name="l00004"></a>00004 <span class="preprocessor">#include "<a class="code" href="dsdpsys_8h.html" title="Error handling, printing, and profiling.">dsdpsys.h</a>"</span> <a name="l00005"></a>00005 <a name="l00011"></a>00011 <span class="keyword">static</span> <span class="keywordtype">int</span> hfactorevent=0,hsolveevent=0; <a name="l00012"></a>00012 <a name="l00013"></a>00013 <span class="preprocessor">#define DSDPNoOperationError(a); { DSDPSETERR1(10,"Schur matrix type: %s, Operation not defined\n",(a).dsdpops->matname); }</span> <a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor">#define DSDPChkMatError(a,b); { if (b){ DSDPSETERR1(b,"Schur matrix type: %s,\n",(a).dsdpops->matname);} }</span> <a name="l00015"></a>00015 <span class="preprocessor"></span> <a name="l00016"></a>00016 <span class="keyword">static</span> <span class="keywordtype">int</span> DSDPApplySMW(<a class="code" href="structDSDPSchurMat__C.html" title="Schur complement matrix whose solution is the Newton direction.">DSDPSchurMat</a>, <a class="code" href="dsdpvec_8h.html#a421243d35437ad44ded3c1e34198e8e9" title="This object hold m+2 variables: a scaling of C, the y variables, and r.">DSDPVec</a>, <a class="code" href="dsdpvec_8h.html#a421243d35437ad44ded3c1e34198e8e9" title="This object hold m+2 variables: a scaling of C, the y variables, and r.">DSDPVec</a>); <a name="l00017"></a>00017 <span class="keyword">static</span> <span class="keywordtype">int</span> DSDPSchurMatSolveM(<a class="code" href="structDSDPSchurMat__C.html" title="Schur complement matrix whose solution is the Newton direction.">DSDPSchurMat</a>, <a class="code" href="dsdpvec_8h.html#a421243d35437ad44ded3c1e34198e8e9" title="This object hold m+2 variables: a scaling of C, the y variables, and r.">DSDPVec</a>, <a class="code" href="dsdpvec_8h.html#a421243d35437ad44ded3c1e34198e8e9" title="This object hold m+2 variables: a scaling of C, the y variables, and r.">DSDPVec</a>); <a name="l00018"></a>00018 <a name="l00019"></a>00019 <span class="preprocessor">#undef __FUNCT__</span> <a name="l00020"></a>00020 <span class="preprocessor"></span><span class="preprocessor">#define __FUNCT__ "DSDPSchurMatSetData"</span> <a name="l00021"></a>00021 <span class="preprocessor"></span> <a name="l00028"></a><a class="code" href="dsdpschurmat_8h.html#a07de8558d63b3365cf274417b82ee31b">00028</a> <span class="keywordtype">int</span> <a class="code" href="dsdpschurmat_8c.html#ab3f83dfa4e65816b57c0a58ec4e8ba4c" title="Set the Schur matrix with an opaque pointer and structure of function pointers.">DSDPSchurMatSetData</a>(<a class="code" href="structDSDPSchurMat__C.html" title="Schur complement matrix whose solution is the Newton direction.">DSDPSchurMat</a> *M, <span class="keyword">struct</span> DSDPSchurMat_Ops* ops, <span class="keywordtype">void</span>*data){ <a name="l00029"></a>00029 DSDPFunctionBegin; <a name="l00030"></a>00030 (*M).dsdpops=ops; <a name="l00031"></a>00031 (*M).data=data; <a name="l00032"></a>00032 DSDPFunctionReturn(0); <a name="l00033"></a>00033 } <a name="l00034"></a>00034 <a name="l00035"></a>00035 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* schurmatname=<span class="stringliteral">"NOT NAMED YET"</span>; <a name="l00036"></a>00036 <a name="l00037"></a>00037 <span class="preprocessor">#undef __FUNCT__</span> <a name="l00038"></a>00038 <span class="preprocessor"></span><span class="preprocessor">#define __FUNCT__ "DSDPSchurMatOpsInitialize"</span> <a name="l00039"></a>00039 <span class="preprocessor"></span> <a name="l00044"></a><a class="code" href="dsdpschurmat__impl_8h.html#a308f47c83d9a28407a9e128ec92b464f">00044</a> <span class="keywordtype">int</span> <a class="code" href="dsdpschurmat_8c.html#adb7cfe252525b4f617fc276f2c665f6b" title="Initialize function pointers to 0.">DSDPSchurMatOpsInitialize</a>(<span class="keyword">struct</span> DSDPSchurMat_Ops* dops){ <a name="l00045"></a>00045 DSDPFunctionBegin; <a name="l00046"></a>00046 <span class="keywordflow">if</span> (dops==NULL) <span class="keywordflow">return</span> 0; <a name="l00047"></a>00047 dops->matzero=0; <a name="l00048"></a>00048 dops->matrownonzeros=0; <a name="l00049"></a>00049 dops->mataddrow=0; <a name="l00050"></a>00050 dops->mataddelement=0; <a name="l00051"></a>00051 dops->matadddiagonal=0; <a name="l00052"></a>00052 dops->matshiftdiagonal=0; <a name="l00053"></a>00053 dops->matassemble=0; <a name="l00054"></a>00054 dops->matscaledmultiply=0; <a name="l00055"></a>00055 dops->matmultr=0; <a name="l00056"></a>00056 dops->matfactor=0; <a name="l00057"></a>00057 dops->matsolve=0; <a name="l00058"></a>00058 dops->pmatonprocessor=0; <a name="l00059"></a>00059 dops->pmatwhichdiag=0; <a name="l00060"></a>00060 dops->pmatdistributed=0; <a name="l00061"></a>00061 dops->matdestroy=0; <a name="l00062"></a>00062 dops->matview=0; <a name="l00063"></a>00063 dops->matsetup=0; <a name="l00064"></a>00064 dops->id=0; <a name="l00065"></a>00065 dops->matname=schurmatname; <a name="l00066"></a>00066 DSDPFunctionReturn(0); <a name="l00067"></a>00067 } <a name="l00068"></a>00068 <a name="l00069"></a>00069 <span class="keyword">static</span> <span class="keyword">struct </span>DSDPSchurMat_Ops dsdpmops; <a name="l00070"></a>00070 <a name="l00071"></a>00071 <a name="l00072"></a>00072 <span class="preprocessor">#undef __FUNCT__</span> <a name="l00073"></a>00073 <span class="preprocessor"></span><span class="preprocessor">#define __FUNCT__ "DSDPSchurMatOpsInitialize"</span> <a name="l00074"></a>00074 <span class="preprocessor"></span> <a name="l00079"></a><a class="code" href="dsdpschurmat_8h.html#adb5330cbbb6d322a41e41ca264d3bd9d">00079</a> <span class="keywordtype">int</span> <a class="code" href="dsdpschurmat_8c.html#a9af8b9c907f86d73e44a21de79daeef3" title="Initialize pointers to null.">DSDPSchurMatInitialize</a>(<a class="code" href="structDSDPSchurMat__C.html" title="Schur complement matrix whose solution is the Newton direction.">DSDPSchurMat</a> *M){ <a name="l00080"></a>00080 <span class="keywordtype">int</span> info; <a name="l00081"></a>00081 DSDPFunctionBegin; <a name="l00082"></a>00082 info=<a class="code" href="dsdpschurmat_8c.html#adb7cfe252525b4f617fc276f2c665f6b" title="Initialize function pointers to 0.">DSDPSchurMatOpsInitialize</a>(&dsdpmops); DSDPCHKERR(info); <a name="l00083"></a>00083 info=<a class="code" href="dsdpschurmat_8c.html#ab3f83dfa4e65816b57c0a58ec4e8ba4c" title="Set the Schur matrix with an opaque pointer and structure of function pointers.">DSDPSchurMatSetData</a>(M,&dsdpmops,0); DSDPCHKERR(info); <a name="l00084"></a>00084 DSDPCALLOC1(&M->schur,DSDPSchurInfo,&info);DSDPCHKERR(info); <a name="l00085"></a>00085 M->schur->m=0; M->schur->r=0; M->schur->dd=0; <a name="l00086"></a>00086 info=DSDPInitializeFixedVariable(&M->schur->fv);DSDPCHKERR(info); <a name="l00087"></a>00087 DSDPFunctionReturn(0); <a name="l00088"></a>00088 } <a name="l00089"></a>00089 <a name="l00090"></a>00090 <span class="preprocessor">#undef __FUNCT__</span> <a name="l00091"></a>00091 <span class="preprocessor"></span><span class="preprocessor">#define __FUNCT__ "DSDPSchurMatZeroEntries"</span> <a name="l00092"></a>00092 <span class="preprocessor"></span> <a name="l00097"></a><a class="code" href="dsdpschurmat_8h.html#a53362ac7f8c4ab6ee431fba98c45373b">00097</a> <span class="keywordtype">int</span> <a class="code" href="dsdpschurmat_8c.html#a5d7b6f5a9e43140f0a55eca37d897fb7" title="Zero all element in the matrix.">DSDPSchurMatZeroEntries</a>(<a class="code" href="structDSDPSchurMat__C.html" title="Schur complement matrix whose solution is the Newton direction.">DSDPSchurMat</a> M){ <a name="l00098"></a>00098 <span class="keywordtype">int</span> info; <a name="l00099"></a>00099 DSDPFunctionBegin; <a name="l00100"></a>00100 <span class="keywordflow">if</span> (M.dsdpops->matzero){ <a name="l00101"></a>00101 info=(M.dsdpops->matzero)(M.data); DSDPChkMatError(M,info); <a name="l00102"></a>00102 } <span class="keywordflow">else</span> { <a name="l00103"></a>00103 DSDPNoOperationError(M); <a name="l00104"></a>00104 } <a name="l00105"></a>00105 DSDPFunctionReturn(0); <a name="l00106"></a>00106 } <a name="l00107"></a>00107 <a name="l00108"></a>00108 <a name="l00109"></a>00109 <span class="preprocessor">#undef __FUNCT__</span> <a name="l00110"></a>00110 <span class="preprocessor"></span><span class="preprocessor">#define __FUNCT__ "DSDPSchurMatShiftDiagonal"</span> <a name="l00111"></a>00111 <span class="preprocessor"></span> <a name="l00120"></a><a class="code" href="dsdpschurmat_8h.html#a0b1ffcfbb122a4d95a6cdbb1b7c118a9">00120</a> <span class="keywordtype">int</span> <a class="code" href="dsdpschurmat_8c.html#ae641b4fb6efcb0794593d1719a7c3845" title="Add a scalar to each diagonal element of the matrix.">DSDPSchurMatShiftDiagonal</a>(<a class="code" href="structDSDPSchurMat__C.html" title="Schur complement matrix whose solution is the Newton direction.">DSDPSchurMat</a> M, <span class="keywordtype">double</span> dd){ <a name="l00121"></a>00121 <span class="keywordtype">int</span> info; <a name="l00122"></a>00122 DSDPFunctionBegin; <a name="l00123"></a>00123 <span class="keywordflow">if</span> (dd==0){DSDPFunctionReturn(0);} <a name="l00124"></a>00124 M.schur->dd=dd; <a name="l00125"></a>00125 <span class="keywordflow">if</span> (M.dsdpops->matshiftdiagonal){ <a name="l00126"></a>00126 <span class="comment">/* if(M.schur->r){info=DSDPVecAddR(M.schur->rhs3,dd);DSDPCHKERR(info);} */</span> <a name="l00127"></a>00127 info=(M.dsdpops->matshiftdiagonal)(M.data,dd); DSDPChkMatError(M,info); <a name="l00128"></a>00128 DSDPLogInfo(0,2,<span class="stringliteral">"Add %4.4e to the Diagonal of Schur Matrix\n"</span>,dd); <a name="l00129"></a>00129 } <span class="keywordflow">else</span> { <a name="l00130"></a>00130 DSDPNoOperationError(M); <a name="l00131"></a>00131 } <a name="l00132"></a>00132 DSDPFunctionReturn(0); <a name="l00133"></a>00133 } <a name="l00134"></a>00134 <a name="l00135"></a>00135 <a name="l00136"></a>00136 <span class="preprocessor">#undef __FUNCT__</span> <a name="l00137"></a>00137 <span class="preprocessor"></span><span class="preprocessor">#define __FUNCT__ "DSDPSchurMatInParallel"</span> <a name="l00138"></a>00138 <span class="preprocessor"></span> <a name="l00149"></a><a class="code" href="dsdpschurmat_8h.html#a011b150fd4f258cc37fc4b75d116d579">00149</a> <span class="keywordtype">int</span> <a class="code" href="dsdpschurmat_8c.html#a8d6a10df0c60e0c2721b93839bc0ded8" title="Determine whether M is computed in parallel.">DSDPSchurMatInParallel</a>(<a class="code" href="structDSDPSchurMat__C.html" title="Schur complement matrix whose solution is the Newton direction.">DSDPSchurMat</a> M, <a class="code" href="dsdpbasictypes_8h.html#ae667f2bff3ab5ab0bc109fa76dc4ed65" title="Boolean variables.">DSDPTruth</a> *flag){ <a name="l00150"></a>00150 <span class="keywordtype">int</span> info,flg; <a name="l00151"></a>00151 DSDPFunctionBegin; <a name="l00152"></a>00152 <span class="keywordflow">if</span> (M.dsdpops->pmatdistributed){ <a name="l00153"></a>00153 info=(M.dsdpops->pmatdistributed)(M.data,&flg); DSDPChkMatError(M,info); <a name="l00154"></a>00154 <span class="keywordflow">if</span> (flg) *flag=<a class="code" href="dsdpbasictypes_8h.html#ae667f2bff3ab5ab0bc109fa76dc4ed65ae6b2e53e51e94a5fa7204ceac78f824f">DSDP_TRUE</a>; <span class="keywordflow">else</span> *flag=<a class="code" href="dsdpbasictypes_8h.html#ae667f2bff3ab5ab0bc109fa76dc4ed65a74385569aa7a59059a8847e2d39b754c">DSDP_FALSE</a>; <a name="l00155"></a>00155 } <span class="keywordflow">else</span> { <a name="l00156"></a>00156 *flag=<a class="code" href="dsdpbasictypes_8h.html#ae667f2bff3ab5ab0bc109fa76dc4ed65a74385569aa7a59059a8847e2d39b754c">DSDP_FALSE</a>; <a name="l00157"></a>00157 } <a name="l00158"></a>00158 DSDPFunctionReturn(0); <a name="l00159"></a>00159 } <a name="l00160"></a>00160 <a name="l00161"></a>00161 <a name="l00162"></a>00162 <a name="l00163"></a>00163 <span class="preprocessor">#undef __FUNCT__</span> <a name="l00164"></a>00164 <span class="preprocessor"></span><span class="preprocessor">#define __FUNCT__ "DSDPSchurMatAssemble"</span> <a name="l00165"></a>00165 <span class="preprocessor"></span> <a name="l00174"></a><a class="code" href="dsdpschurmat_8h.html#adc9a7cee88ae453a0f0b4e6965ca3837">00174</a> <span class="keywordtype">int</span> <a class="code" href="dsdpschurmat_8c.html#aa0f35c05985382f83c15658f38f07464" title="Final assembly of M.">DSDPSchurMatAssemble</a>(<a class="code" href="structDSDPSchurMat__C.html" title="Schur complement matrix whose solution is the Newton direction.">DSDPSchurMat</a> M){ <a name="l00175"></a>00175 <span class="keywordtype">int</span> info; <a name="l00176"></a>00176 DSDPFunctionBegin; <a name="l00177"></a>00177 <span class="keywordflow">if</span> (M.dsdpops->matassemble){ <a name="l00178"></a>00178 info=(M.dsdpops->matassemble)(M.data); DSDPChkMatError(M,info); <a name="l00179"></a>00179 } <span class="keywordflow">else</span> { <a name="l00180"></a>00180 DSDPNoOperationError(M); <a name="l00181"></a>00181 } <a name="l00182"></a>00182 DSDPFunctionReturn(0); <a name="l00183"></a>00183 } <a name="l00184"></a>00184 <a name="l00185"></a>00185 <span class="preprocessor">#undef __FUNCT__</span> <a name="l00186"></a>00186 <span class="preprocessor"></span><span class="preprocessor">#define __FUNCT__ "DSDPSchurMatFactor"</span> <a name="l00187"></a>00187 <span class="preprocessor"></span> <a name="l00196"></a><a class="code" href="dsdpschurmat_8h.html#aaca1d13a1ed20b56ee58370d551e5927">00196</a> <span class="keywordtype">int</span> <a class="code" href="dsdpschurmat_8c.html#ab3c5bcf162b2e5923c5428cb1764ed57" title="Factor M.">DSDPSchurMatFactor</a>(<a class="code" href="structDSDPSchurMat__C.html" title="Schur complement matrix whose solution is the Newton direction.">DSDPSchurMat</a> M, <a class="code" href="dsdpbasictypes_8h.html#ae667f2bff3ab5ab0bc109fa76dc4ed65" title="Boolean variables.">DSDPTruth</a> *successful){ <a name="l00197"></a>00197 <span class="keywordtype">int</span> info,flag=0; <a name="l00198"></a>00198 <a class="code" href="dsdpvec_8h.html#a421243d35437ad44ded3c1e34198e8e9" title="This object hold m+2 variables: a scaling of C, the y variables, and r.">DSDPVec</a> rhs3=M.schur->rhs3,dy3=M.schur->dy3; <a name="l00199"></a>00199 DSDPFunctionBegin; <a name="l00200"></a>00200 *successful=<a class="code" href="dsdpbasictypes_8h.html#ae667f2bff3ab5ab0bc109fa76dc4ed65ae6b2e53e51e94a5fa7204ceac78f824f">DSDP_TRUE</a>; <a name="l00201"></a>00201 DSDPEventLogBegin(hfactorevent); <a name="l00202"></a>00202 <span class="keywordflow">if</span> (M.dsdpops->matfactor){ <a name="l00203"></a>00203 info=(M.dsdpops->matfactor)(M.data,&flag); DSDPChkMatError(M,info); <a name="l00204"></a>00204 <span class="keywordflow">if</span> (flag){ <a name="l00205"></a>00205 *successful=<a class="code" href="dsdpbasictypes_8h.html#ae667f2bff3ab5ab0bc109fa76dc4ed65a74385569aa7a59059a8847e2d39b754c">DSDP_FALSE</a>; <a name="l00206"></a>00206 DSDPLogInfo(0,2,<span class="stringliteral">"Indefinite Schur Matrix -- Bad Factorization\n"</span>); <a name="l00207"></a>00207 } <a name="l00208"></a>00208 } <span class="keywordflow">else</span> { <a name="l00209"></a>00209 DSDPNoOperationError(M); <a name="l00210"></a>00210 } <a name="l00211"></a>00211 DSDPEventLogEnd(hfactorevent); <a name="l00212"></a>00212 <span class="keywordflow">if</span> (M.schur->r){ <a name="l00213"></a>00213 info=DSDPSchurMatSolveM(M,rhs3,dy3);DSDPCHKERR(info);} <a name="l00214"></a>00214 <span class="keywordflow">else</span> {info=DSDPVecZero(dy3);DSDPCHKERR(info);} <a name="l00215"></a>00215 DSDPFunctionReturn(0); <a name="l00216"></a>00216 } <a name="l00217"></a>00217 <a name="l00218"></a>00218 <a name="l00219"></a>00219 <span class="preprocessor">#undef __FUNCT__</span> <a name="l00220"></a>00220 <span class="preprocessor"></span><span class="preprocessor">#define __FUNCT__ "DSDPSchurMatMultiply"</span> <a name="l00221"></a>00221 <span class="preprocessor"></span> <a name="l00231"></a><a class="code" href="dsdpschurmat_8h.html#a5d77b3c4f421843dea361302073af061">00231</a> <span class="keywordtype">int</span> <a class="code" href="dsdpschurmat_8c.html#a3ac77a7f5f31d116197d0dc07bef782f" title="Multiply M by a vector. y = M x.">DSDPSchurMatMultiply</a>(<a class="code" href="structDSDPSchurMat__C.html" title="Schur complement matrix whose solution is the Newton direction.">DSDPSchurMat</a> M, <a class="code" href="dsdpvec_8h.html#a421243d35437ad44ded3c1e34198e8e9" title="This object hold m+2 variables: a scaling of C, the y variables, and r.">DSDPVec</a> x, <a class="code" href="dsdpvec_8h.html#a421243d35437ad44ded3c1e34198e8e9" title="This object hold m+2 variables: a scaling of C, the y variables, and r.">DSDPVec</a> y){ <a name="l00232"></a>00232 <span class="keywordtype">int</span> info,n; <a name="l00233"></a>00233 <span class="keywordtype">double</span> *xx,*yy,r=M.schur->r; <a name="l00234"></a>00234 <span class="keywordtype">double</span> r1,r2,dd; <a name="l00235"></a>00235 <a class="code" href="dsdpvec_8h.html#a421243d35437ad44ded3c1e34198e8e9" title="This object hold m+2 variables: a scaling of C, the y variables, and r.">DSDPVec</a> rhs3; <a name="l00236"></a>00236 DSDPFunctionBegin; <a name="l00237"></a>00237 <a name="l00238"></a>00238 <span class="keywordflow">if</span> (M.dsdpops->matscaledmultiply){ <a name="l00239"></a>00239 info=DSDPVecGetSize(x,&n); DSDPCHKERR(info); <a name="l00240"></a>00240 info=DSDPVecGetArray(x,&xx); DSDPCHKERR(info); <a name="l00241"></a>00241 info=DSDPVecGetArray(y,&yy); DSDPCHKERR(info); <a name="l00242"></a>00242 info=(M.dsdpops->matscaledmultiply)(M.data,xx+1,yy+1,n-2); DSDPChkMatError(M,info); <a name="l00243"></a>00243 yy[0]=0; <a name="l00244"></a>00244 yy[n-1]=0; <a name="l00245"></a>00245 info=DSDPVecRestoreArray(y,&yy); DSDPCHKERR(info); <a name="l00246"></a>00246 info=DSDPVecRestoreArray(x,&xx); DSDPCHKERR(info); <a name="l00247"></a>00247 } <span class="keywordflow">else</span> { <a name="l00248"></a>00248 DSDPNoOperationError(M); <a name="l00249"></a>00249 } <a name="l00250"></a>00250 <span class="keywordflow">if</span> (r){ <a name="l00251"></a>00251 rhs3=M.schur->rhs3; <a name="l00252"></a>00252 info=DSDPVecGetR(rhs3,&r2);DSDPCHKERR(info); <a name="l00253"></a>00253 info=DSDPVecGetR(x,&r1);DSDPCHKERR(info); <a name="l00254"></a>00254 info=DSDPVecAXPY(r1,rhs3,y);DSDPCHKERR(info); <a name="l00255"></a>00255 info=DSDPVecDot(rhs3,x,&dd);DSDPCHKERR(info); <a name="l00256"></a>00256 info=DSDPVecAddR(y,dd-r1*r2);DSDPCHKERR(info); <a name="l00257"></a>00257 } <a name="l00258"></a>00258 DSDPFunctionReturn(0); <a name="l00259"></a>00259 } <a name="l00260"></a>00260 <a name="l00261"></a>00261 <span class="preprocessor">#undef __FUNCT__</span> <a name="l00262"></a>00262 <span class="preprocessor"></span><span class="preprocessor">#define __FUNCT__ "DSDPSchurMatMultR"</span> <a name="l00263"></a>00263 <span class="preprocessor"></span><span class="keywordtype">int</span> DSDPSchurMatMultR(<a class="code" href="structDSDPSchurMat__C.html" title="Schur complement matrix whose solution is the Newton direction.">DSDPSchurMat</a> M, <a class="code" href="dsdpvec_8h.html#a421243d35437ad44ded3c1e34198e8e9" title="This object hold m+2 variables: a scaling of C, the y variables, and r.">DSDPVec</a> x, <a class="code" href="dsdpvec_8h.html#a421243d35437ad44ded3c1e34198e8e9" title="This object hold m+2 variables: a scaling of C, the y variables, and r.">DSDPVec</a> y){ <a name="l00264"></a>00264 <span class="keywordtype">int</span> info,n; <a name="l00265"></a>00265 <span class="keywordtype">double</span> *xx,*yy,r=M.schur->r; <a name="l00266"></a>00266 <span class="keywordtype">double</span> r1,r2,dd; <a name="l00267"></a>00267 <a class="code" href="dsdpvec_8h.html#a421243d35437ad44ded3c1e34198e8e9" title="This object hold m+2 variables: a scaling of C, the y variables, and r.">DSDPVec</a> rhs3; <a name="l00268"></a>00268 DSDPFunctionBegin; <a name="l00269"></a>00269 <a name="l00270"></a>00270 <span class="keywordflow">if</span> (M.dsdpops->matmultr){ <a name="l00271"></a>00271 info=DSDPVecGetSize(x,&n); DSDPCHKERR(info); <a name="l00272"></a>00272 info=DSDPVecGetArray(x,&xx); DSDPCHKERR(info); <a name="l00273"></a>00273 info=DSDPVecGetArray(y,&yy); DSDPCHKERR(info); <a name="l00274"></a>00274 info=(M.dsdpops->matmultr)(M.data,xx+1,yy+1,n-2); DSDPChkMatError(M,info); <a name="l00275"></a>00275 yy[0]=0; <a name="l00276"></a>00276 yy[n-1]=0; <a name="l00277"></a>00277 info=DSDPVecRestoreArray(y,&yy); DSDPCHKERR(info); <a name="l00278"></a>00278 info=DSDPVecRestoreArray(x,&xx); DSDPCHKERR(info); <a name="l00279"></a>00279 <span class="keywordflow">if</span> (r){ <a name="l00280"></a>00280 rhs3=M.schur->rhs3; <a name="l00281"></a>00281 info=DSDPVecGetR(rhs3,&r2);DSDPCHKERR(info); <a name="l00282"></a>00282 info=DSDPVecGetR(x,&r1);DSDPCHKERR(info); <a name="l00283"></a>00283 info=DSDPVecAXPY(r1,rhs3,y);DSDPCHKERR(info); <a name="l00284"></a>00284 info=DSDPVecDot(rhs3,x,&dd);DSDPCHKERR(info); <a name="l00285"></a>00285 info=DSDPVecAddR(y,dd-r1*r2);DSDPCHKERR(info); <a name="l00286"></a>00286 } <a name="l00287"></a>00287 } <span class="keywordflow">else</span> { <a name="l00288"></a>00288 info=DSDPVecZero(y);DSDPCHKERR(info); <a name="l00289"></a>00289 <span class="comment">/* DSDPNoOperationError(M); */</span> <a name="l00290"></a>00290 } <a name="l00291"></a>00291 DSDPFunctionReturn(0); <a name="l00292"></a>00292 } <a name="l00293"></a>00293 <a name="l00294"></a>00294 <span class="preprocessor">#undef __FUNCT__</span> <a name="l00295"></a>00295 <span class="preprocessor"></span><span class="preprocessor">#define __FUNCT__ "DSDPSchurMatReducePVec"</span> <a name="l00296"></a>00296 <span class="preprocessor"></span> <a name="l00307"></a><a class="code" href="dsdpschurmat_8h.html#af6979949b35620f3e6af738dbceec493">00307</a> <span class="keywordtype">int</span> <a class="code" href="dsdpschurmat_8c.html#a0b48fd50cf0b15fc018cfb5addbf132c" title="Collect elements of the vector.">DSDPSchurMatReducePVec</a>(<a class="code" href="structDSDPSchurMat__C.html" title="Schur complement matrix whose solution is the Newton direction.">DSDPSchurMat</a> M, <a class="code" href="dsdpvec_8h.html#a421243d35437ad44ded3c1e34198e8e9" title="This object hold m+2 variables: a scaling of C, the y variables, and r.">DSDPVec</a> x){ <a name="l00308"></a>00308 <span class="keywordtype">int</span> info,n; <a name="l00309"></a>00309 <span class="keywordtype">double</span> *xx; <a name="l00310"></a>00310 <a class="code" href="dsdpbasictypes_8h.html#ae667f2bff3ab5ab0bc109fa76dc4ed65" title="Boolean variables.">DSDPTruth</a> flag; <a name="l00311"></a>00311 DSDPFunctionBegin; <a name="l00312"></a>00312 <a name="l00313"></a>00313 <span class="keywordflow">if</span> (M.dsdpops->pmatreduction){ <a name="l00314"></a>00314 info=DSDPVecGetSize(x,&n); DSDPCHKERR(info); <a name="l00315"></a>00315 info=DSDPVecGetArray(x,&xx); DSDPCHKERR(info); <a name="l00316"></a>00316 info=(M.dsdpops->pmatreduction)(M.data,xx+1,n-2); DSDPChkMatError(M,info); <a name="l00317"></a>00317 info=DSDPVecRestoreArray(x,&xx); DSDPCHKERR(info); <a name="l00318"></a>00318 } <span class="keywordflow">else</span> { <a name="l00319"></a>00319 info=<a class="code" href="dsdpschurmat_8c.html#a8d6a10df0c60e0c2721b93839bc0ded8" title="Determine whether M is computed in parallel.">DSDPSchurMatInParallel</a>(M,&flag);DSDPChkMatError(M,info); <a name="l00320"></a>00320 <span class="keywordflow">if</span> (flag==<a class="code" href="dsdpbasictypes_8h.html#ae667f2bff3ab5ab0bc109fa76dc4ed65ae6b2e53e51e94a5fa7204ceac78f824f">DSDP_TRUE</a>){ <a name="l00321"></a>00321 DSDPNoOperationError(M); <a name="l00322"></a>00322 } <a name="l00323"></a>00323 } <a name="l00324"></a>00324 info=DSDPZeroFixedVariables(M,x);DSDPCHKERR(info); <a name="l00325"></a>00325 DSDPFunctionReturn(0); <a name="l00326"></a>00326 } <a name="l00327"></a>00327 <a name="l00328"></a>00328 <a name="l00329"></a>00329 <a name="l00330"></a>00330 <span class="preprocessor">#undef __FUNCT__</span> <a name="l00331"></a>00331 <span class="preprocessor"></span><span class="preprocessor">#define __FUNCT__ "DSDPSchurMatSetR"</span> <a name="l00332"></a>00332 <span class="preprocessor"></span> <a name="l00338"></a><a class="code" href="dsdpschurmat_8h.html#ac910c72c8e9ae032ffd85de78a907336">00338</a> <span class="keywordtype">int</span> <a class="code" href="dsdpschurmat_8c.html#a50ec9f401f7a0b426e6cfca3b5eedaa5" title="Set up the data structure.">DSDPSchurMatSetR</a>(<a class="code" href="structDSDPSchurMat__C.html" title="Schur complement matrix whose solution is the Newton direction.">DSDPSchurMat</a> M, <span class="keywordtype">double</span> rr){ <a name="l00339"></a>00339 DSDPFunctionBegin; <a name="l00340"></a>00340 M.schur->r=rr; <a name="l00341"></a>00341 DSDPFunctionReturn(0); <a name="l00342"></a>00342 } <a name="l00343"></a>00343 <a name="l00344"></a>00344 <span class="preprocessor">#undef __FUNCT__</span> <a name="l00345"></a>00345 <span class="preprocessor"></span><span class="preprocessor">#define __FUNCT__ "DSDPSchurMatSetup"</span> <a name="l00346"></a>00346 <span class="preprocessor"></span> <a name="l00352"></a><a class="code" href="dsdpschurmat_8h.html#a4da487048d5cb28fd72b679de3406300">00352</a> <span class="keywordtype">int</span> <a class="code" href="dsdpschurmat_8c.html#a332298433d360d6b5a2b5d09ec2c4d52" title="Set up the data structure.">DSDPSchurMatSetup</a>(<a class="code" href="structDSDPSchurMat__C.html" title="Schur complement matrix whose solution is the Newton direction.">DSDPSchurMat</a> M, <a class="code" href="dsdpvec_8h.html#a421243d35437ad44ded3c1e34198e8e9" title="This object hold m+2 variables: a scaling of C, the y variables, and r.">DSDPVec</a> Y){ <a name="l00353"></a>00353 <span class="keywordtype">int</span> info,m; <a name="l00354"></a>00354 DSDPFunctionBegin; <a name="l00355"></a>00355 info=DSDPVecDuplicate(Y,&M.schur->rhs3); <a name="l00356"></a>00356 info=DSDPVecDuplicate(Y,&M.schur->dy3); <a name="l00357"></a>00357 info=DSDPVecGetSize(Y,&m);DSDPCHKERR(info); <a name="l00358"></a>00358 <span class="keywordflow">if</span> (M.dsdpops->matsetup){ <a name="l00359"></a>00359 info=(M.dsdpops->matsetup)(M.data,m-2); DSDPChkMatError(M,info); <a name="l00360"></a>00360 } <span class="keywordflow">else</span> { <a name="l00361"></a>00361 DSDPNoOperationError(M); <a name="l00362"></a>00362 } <a name="l00363"></a>00363 DSDPEventLogRegister(<span class="stringliteral">"Factor Newton Eq."</span>,&hfactorevent); <a name="l00364"></a>00364 DSDPEventLogRegister(<span class="stringliteral">"Solve Newton Eq."</span>,&hsolveevent); <a name="l00365"></a>00365 DSDPFunctionReturn(0); <a name="l00366"></a>00366 } <a name="l00367"></a>00367 <a name="l00368"></a>00368 <a name="l00369"></a>00369 <span class="preprocessor">#undef __FUNCT__</span> <a name="l00370"></a>00370 <span class="preprocessor"></span><span class="preprocessor">#define __FUNCT__ "DSDPSchurMatView"</span> <a name="l00371"></a>00371 <span class="preprocessor"></span> <a name="l00376"></a><a class="code" href="dsdpschurmat_8h.html#a9e0c020190f8e8a6769080fdc8e015e8">00376</a> <span class="keywordtype">int</span> <a class="code" href="dsdpschurmat_8c.html#ac2532ec3ba1a780409e4c22b599a4c4e" title="Print the matrix.">DSDPSchurMatView</a>(<a class="code" href="structDSDPSchurMat__C.html" title="Schur complement matrix whose solution is the Newton direction.">DSDPSchurMat</a> M){ <a name="l00377"></a>00377 <span class="keywordtype">int</span> info; <a name="l00378"></a>00378 DSDPFunctionBegin; <a name="l00379"></a>00379 <span class="keywordflow">if</span> (M.dsdpops->matview){ <a name="l00380"></a>00380 info=(M.dsdpops->matview)(M.data); DSDPChkMatError(M,info); <a name="l00381"></a>00381 } <span class="keywordflow">else</span> { <a name="l00382"></a>00382 DSDPNoOperationError(M); <a name="l00383"></a>00383 } <a name="l00384"></a>00384 info=DSDPVecView(M.schur->rhs3);DSDPCHKERR(info); <a name="l00385"></a>00385 DSDPFunctionReturn(0); <a name="l00386"></a>00386 } <a name="l00387"></a>00387 <a name="l00388"></a>00388 <a name="l00389"></a>00389 <span class="preprocessor">#undef __FUNCT__</span> <a name="l00390"></a>00390 <span class="preprocessor"></span><span class="preprocessor">#define __FUNCT__ "DSDPSchurMatRowScaling"</span> <a name="l00391"></a>00391 <span class="preprocessor"></span> <a name="l00399"></a><a class="code" href="dsdpschurmat_8h.html#a93b4c05694183a0362c79d63035d2d40">00399</a> <span class="keywordtype">int</span> <a class="code" href="dsdpschurmat_8c.html#ae26fbbe6ae18b7a1bae605540e94e7a1" title="Identify which rows on on this processor.">DSDPSchurMatRowScaling</a>(<a class="code" href="structDSDPSchurMat__C.html" title="Schur complement matrix whose solution is the Newton direction.">DSDPSchurMat</a> M, <a class="code" href="dsdpvec_8h.html#a421243d35437ad44ded3c1e34198e8e9" title="This object hold m+2 variables: a scaling of C, the y variables, and r.">DSDPVec</a> D){ <a name="l00400"></a>00400 <span class="keywordtype">int</span> info; <a name="l00401"></a>00401 DSDPFunctionBegin; <a name="l00402"></a>00402 info=<a class="code" href="dsdpschurmat_8h.html#afa6d59fd28e2666d6fbeae8abf370dda" title="Get the scaling and nonzero pattern of each diagonal element of the matrix.">DSDPSchurMatDiagonalScaling</a>(M,D);DSDPCHKERR(info); <a name="l00403"></a>00403 info=DSDPZeroFixedVariables(M,D);DSDPCHKERR(info); <a name="l00404"></a>00404 DSDPFunctionReturn(0); <a name="l00405"></a>00405 } <a name="l00406"></a>00406 <a name="l00407"></a>00407 <span class="preprocessor">#undef __FUNCT__</span> <a name="l00408"></a>00408 <span class="preprocessor"></span><span class="preprocessor">#define __FUNCT__ "DSDPSchurMatDestroy"</span> <a name="l00409"></a>00409 <span class="preprocessor"></span> <a name="l00414"></a><a class="code" href="dsdpschurmat_8h.html#ade84963aba7d3cc4c580fae97a61cc9e">00414</a> <span class="keywordtype">int</span> <a class="code" href="dsdpschurmat_8c.html#aa070672b861d36b1cc4fbc8b2950824c" title="Free the memory in the data structure.">DSDPSchurMatDestroy</a>(<a class="code" href="structDSDPSchurMat__C.html" title="Schur complement matrix whose solution is the Newton direction.">DSDPSchurMat</a> *M){ <a name="l00415"></a>00415 <span class="keywordtype">int</span> info; <a name="l00416"></a>00416 DSDPFunctionBegin; <a name="l00417"></a>00417 <span class="keywordflow">if</span> ((*M).dsdpops->matdestroy){ <a name="l00418"></a>00418 info=((*M).dsdpops->matdestroy)((*M).data); DSDPChkMatError(*M,info); <a name="l00419"></a>00419 } <span class="keywordflow">else</span> { <a name="l00420"></a>00420 <span class="comment">/*</span> <a name="l00421"></a>00421 <span class="comment"> DSDPNoOperationError(*M);</span> <a name="l00422"></a>00422 <span class="comment"> */</span> <a name="l00423"></a>00423 } <a name="l00424"></a>00424 info=DSDPVecDestroy(&M->schur->rhs3);DSDPCHKERR(info); <a name="l00425"></a>00425 info=DSDPVecDestroy(&M->schur->dy3);DSDPCHKERR(info); <a name="l00426"></a>00426 <span class="comment">/* info=DSDPSchurMatSetData(M,0,0); DSDPCHKERR(info); */</span> <a name="l00427"></a>00427 info=<a class="code" href="dsdpschurmat_8c.html#adb7cfe252525b4f617fc276f2c665f6b" title="Initialize function pointers to 0.">DSDPSchurMatOpsInitialize</a>(&dsdpmops); DSDPCHKERR(info); <a name="l00428"></a>00428 info=<a class="code" href="dsdpschurmat_8c.html#ab3f83dfa4e65816b57c0a58ec4e8ba4c" title="Set the Schur matrix with an opaque pointer and structure of function pointers.">DSDPSchurMatSetData</a>(M,&dsdpmops,0); DSDPCHKERR(info); <a name="l00429"></a>00429 DSDPFREE(&M->schur,&info);DSDPCHKERR(info); <a name="l00430"></a>00430 DSDPFunctionReturn(0); <a name="l00431"></a>00431 } <a name="l00432"></a>00432 <a name="l00433"></a>00433 <span class="preprocessor">#undef __FUNCT__</span> <a name="l00434"></a>00434 <span class="preprocessor"></span><span class="preprocessor">#define __FUNCT__ "DSDPSchurMatSolveM"</span> <a name="l00435"></a>00435 <span class="preprocessor"></span><span class="keyword">static</span> <span class="keywordtype">int</span> DSDPSchurMatSolveM(<a class="code" href="structDSDPSchurMat__C.html" title="Schur complement matrix whose solution is the Newton direction.">DSDPSchurMat</a> M, <a class="code" href="dsdpvec_8h.html#a421243d35437ad44ded3c1e34198e8e9" title="This object hold m+2 variables: a scaling of C, the y variables, and r.">DSDPVec</a> b, <a class="code" href="dsdpvec_8h.html#a421243d35437ad44ded3c1e34198e8e9" title="This object hold m+2 variables: a scaling of C, the y variables, and r.">DSDPVec</a> x){ <a name="l00436"></a>00436 <span class="keywordtype">int</span> info,n; <a name="l00437"></a>00437 <span class="keywordtype">double</span> *xx,*bb; <a name="l00438"></a>00438 DSDPFunctionBegin; <a name="l00439"></a>00439 info=DSDPEventLogBegin(hsolveevent); <a name="l00440"></a>00440 <span class="keywordflow">if</span> (M.dsdpops->matsolve){ <a name="l00441"></a>00441 info=DSDPVecGetArray(b,&bb); DSDPCHKERR(info); <a name="l00442"></a>00442 info=DSDPVecGetSize(x,&n); DSDPCHKERR(info); <a name="l00443"></a>00443 info=DSDPVecZero(x);DSDPCHKERR(info); <a name="l00444"></a>00444 info=DSDPVecGetArray(x,&xx); DSDPCHKERR(info); <a name="l00445"></a>00445 info=(M.dsdpops->matsolve)(M.data,bb+1,xx+1,n-2); DSDPChkMatError(M,info); <a name="l00446"></a>00446 info=DSDPVecRestoreArray(b,&bb); DSDPCHKERR(info); <a name="l00447"></a>00447 info=DSDPVecRestoreArray(x,&xx); DSDPCHKERR(info); <a name="l00448"></a>00448 } <span class="keywordflow">else</span> { <a name="l00449"></a>00449 DSDPNoOperationError(M); <a name="l00450"></a>00450 } <a name="l00451"></a>00451 info=DSDPVecSetR(x,0.0);DSDPCHKERR(info); <a name="l00452"></a>00452 info=DSDPVecSetC(x,0.0);DSDPCHKERR(info); <a name="l00453"></a>00453 info=DSDPEventLogEnd(hsolveevent); <a name="l00454"></a>00454 DSDPFunctionReturn(0); <a name="l00455"></a>00455 } <a name="l00456"></a>00456 <a name="l00457"></a>00457 <span class="preprocessor">#undef __FUNCT__</span> <a name="l00458"></a>00458 <span class="preprocessor"></span><span class="preprocessor">#define __FUNCT__ "DSDPSchurMatSolve"</span> <a name="l00459"></a>00459 <span class="preprocessor"></span> <a name="l00466"></a><a class="code" href="dsdpschurmat_8h.html#a515f6bfc386956b74c35451056d15293">00466</a> <span class="keywordtype">int</span> <a class="code" href="dsdpschurmat_8c.html#a4d6f4dcdea100c12545aac3890eb0b9b" title="Solve the linear system.">DSDPSchurMatSolve</a>(<a class="code" href="structDSDPSchurMat__C.html" title="Schur complement matrix whose solution is the Newton direction.">DSDPSchurMat</a> M, <a class="code" href="dsdpvec_8h.html#a421243d35437ad44ded3c1e34198e8e9" title="This object hold m+2 variables: a scaling of C, the y variables, and r.">DSDPVec</a> b, <a class="code" href="dsdpvec_8h.html#a421243d35437ad44ded3c1e34198e8e9" title="This object hold m+2 variables: a scaling of C, the y variables, and r.">DSDPVec</a> x){ <a name="l00467"></a>00467 <span class="keywordtype">int</span> info; <a name="l00468"></a>00468 DSDPFunctionBegin; <a name="l00469"></a>00469 info=DSDPSchurMatSolveM(M,b,x);DSDPCHKERR(info); <a name="l00470"></a>00470 info=DSDPApplySMW(M,b,x);DSDPCHKERR(info); <a name="l00471"></a>00471 info=DSDPZeroFixedVariables(M,x);DSDPCHKERR(info); <a name="l00472"></a>00472 DSDPFunctionReturn(0); <a name="l00473"></a>00473 } <a name="l00474"></a>00474 <a name="l00475"></a>00475 <span class="preprocessor">#undef __FUNCT__ </span> <a name="l00476"></a>00476 <span class="preprocessor"></span><span class="preprocessor">#define __FUNCT__ "DSDPApplySMW"</span> <a name="l00477"></a>00477 <span class="preprocessor"></span><span class="keyword">static</span> <span class="keywordtype">int</span> DSDPApplySMW(<a class="code" href="structDSDPSchurMat__C.html" title="Schur complement matrix whose solution is the Newton direction.">DSDPSchurMat</a> M, <a class="code" href="dsdpvec_8h.html#a421243d35437ad44ded3c1e34198e8e9" title="This object hold m+2 variables: a scaling of C, the y variables, and r.">DSDPVec</a> rhs, <a class="code" href="dsdpvec_8h.html#a421243d35437ad44ded3c1e34198e8e9" title="This object hold m+2 variables: a scaling of C, the y variables, and r.">DSDPVec</a> dy){ <a name="l00478"></a>00478 <span class="keywordtype">int</span> info; <a name="l00479"></a>00479 <span class="keywordtype">double</span> r=M.schur->r,rr,dr,rhsr,rssr; <a name="l00480"></a>00480 <span class="keywordtype">double</span> rhsnorm,rhsnorm3,rhs1mrhs3=0,rhs3mrhs3=0; <a name="l00481"></a>00481 <a class="code" href="dsdpvec_8h.html#a421243d35437ad44ded3c1e34198e8e9" title="This object hold m+2 variables: a scaling of C, the y variables, and r.">DSDPVec</a> rhs3=M.schur->rhs3,dy3=M.schur->dy3; <a name="l00482"></a>00482 DSDPFunctionBegin; <a name="l00483"></a>00483 <a name="l00484"></a>00484 info=DSDPVecNormInfinity(rhs,&rhsnorm);DSDPCHKERR(info); <a name="l00485"></a>00485 info=DSDPVecNormInfinity(rhs3,&rhsnorm3);DSDPCHKERR(info); <a name="l00486"></a>00486 <span class="keywordflow">if</span> (r==0 || rhsnorm==0){ <a name="l00487"></a>00487 info=DSDPVecSetR(dy,0); DSDPCHKERR(info); <a name="l00488"></a>00488 info=DSDPVecSetR(rhs,0); DSDPCHKERR(info); <a name="l00489"></a>00489 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (0 && rhsnorm3==0){ <span class="comment">/* dsdp->UsePenalty==DSDPNever */</span> <a name="l00490"></a>00490 info=DSDPVecGetR(rhs,&rr); DSDPCHKERR(info); <a name="l00491"></a>00491 info=DSDPVecSetR(dy,rr); DSDPCHKERR(info); <a name="l00492"></a>00492 } <span class="keywordflow">else</span> { <a name="l00493"></a>00493 <span class="comment">/* Use bigM penalty method and Sherman-Morrison-Woodbury */</span> <a name="l00494"></a>00494 info=DSDPVecGetR(rhs,&rhsr); DSDPCHKERR(info); <a name="l00495"></a>00495 info=DSDPVecGetR(rhs3,&rssr); DSDPCHKERR(info); <a name="l00496"></a>00496 info=DSDPVecDot(rhs3,dy,&rhs1mrhs3); DSDPCHKERR(info); <a name="l00497"></a>00497 info=DSDPVecDot(rhs3,dy3,&rhs3mrhs3); DSDPCHKERR(info); <a name="l00498"></a>00498 <span class="keywordflow">if</span> (rssr-rhs3mrhs3==0) rssr*=(1.00001); <a name="l00499"></a>00499 dr=-(rhs1mrhs3-rhsr )/(rssr-rhs3mrhs3); <a name="l00500"></a>00500 info=DSDPVecAXPY(-dr,dy3,dy);DSDPCHKERR(info); <a name="l00501"></a>00501 info=DSDPVecSetR(dy,dr); DSDPCHKERR(info); <a name="l00502"></a>00502 info=DSDPVecSetR(rhs,rhsr); DSDPCHKERR(info); <a name="l00503"></a>00503 info=DSDPVecDot(rhs,dy,&rhs3mrhs3); DSDPCHKERR(info); <a name="l00504"></a>00504 <span class="keywordflow">if</span> (rhs3mrhs3 <=0){ <a name="l00505"></a>00505 DSDPLogInfo(0,3,<span class="stringliteral">"DSDP Step Direction Not Descent, Adjusting. \n"</span>); <a name="l00506"></a>00506 info=DSDPVecAddR(rhs3,rssr*0.1);DSDPCHKERR(info); <a name="l00507"></a>00507 info=DSDPVecAXPY(dr,dy3,dy);DSDPCHKERR(info); <a name="l00508"></a>00508 info=DSDPVecSetR(dy,0); DSDPCHKERR(info); <a name="l00509"></a>00509 info=DSDPApplySMW(M,rhs,dy);DSDPCHKERR(info); <a name="l00510"></a>00510 } <a name="l00511"></a>00511 } <a name="l00512"></a>00512 DSDPFunctionReturn(0); <a name="l00513"></a>00513 } <a name="l00514"></a>00514 <a name="l00515"></a>00515 <span class="preprocessor">#undef __FUNCT__ </span> <a name="l00516"></a>00516 <span class="preprocessor"></span><span class="preprocessor">#define __FUNCT__ "DSDPZeroFixedVariables"</span> <a name="l00517"></a>00517 <span class="preprocessor"></span><span class="keywordtype">int</span> DSDPZeroFixedVariables( <a class="code" href="structDSDPSchurMat__C.html" title="Schur complement matrix whose solution is the Newton direction.">DSDPSchurMat</a> M, <a class="code" href="dsdpvec_8h.html#a421243d35437ad44ded3c1e34198e8e9" title="This object hold m+2 variables: a scaling of C, the y variables, and r.">DSDPVec</a> dy){ <a name="l00518"></a>00518 <span class="keywordtype">int</span> i,info; <a name="l00519"></a>00519 FixedVariables *fv=&M.schur->fv; <a name="l00520"></a>00520 DSDPFunctionBegin; <a name="l00521"></a>00521 <span class="keywordflow">for</span> (i=0;i<fv->nvars;i++){ <a name="l00522"></a>00522 info=DSDPVecSetElement(dy,fv->var[i],0.0);DSDPCHKERR(info); <a name="l00523"></a>00523 } <a name="l00524"></a>00524 DSDPFunctionReturn(0); <a name="l00525"></a>00525 } <a name="l00526"></a>00526 <a name="l00527"></a>00527 <span class="preprocessor">#undef __FUNCT__ </span> <a name="l00528"></a>00528 <span class="preprocessor"></span><span class="preprocessor">#define __FUNCT__ "DSDPApplyFixedVariables"</span> <a name="l00529"></a>00529 <span class="preprocessor"></span><span class="keywordtype">int</span> DSDPApplyFixedVariables( <a class="code" href="structDSDPSchurMat__C.html" title="Schur complement matrix whose solution is the Newton direction.">DSDPSchurMat</a> M, <a class="code" href="dsdpvec_8h.html#a421243d35437ad44ded3c1e34198e8e9" title="This object hold m+2 variables: a scaling of C, the y variables, and r.">DSDPVec</a> y){ <a name="l00530"></a>00530 <span class="keywordtype">int</span> i,jj,info; <a name="l00531"></a>00531 <span class="keywordtype">double</span> vv,scl; <a name="l00532"></a>00532 FixedVariables *fv=&M.schur->fv; <a name="l00533"></a>00533 info=DSDPVecGetC(y,&scl);DSDPCHKERR(info); <a name="l00534"></a>00534 DSDPFunctionBegin; <a name="l00535"></a>00535 <span class="keywordflow">for</span> (i=0;i<fv->nvars;i++){ <a name="l00536"></a>00536 vv=fv->fval[i]*fabs(scl); <a name="l00537"></a>00537 jj=fv->var[i]; <a name="l00538"></a>00538 info=DSDPVecSetElement(y,jj,vv);DSDPCHKERR(info); <a name="l00539"></a>00539 } <a name="l00540"></a>00540 DSDPFunctionReturn(0); <a name="l00541"></a>00541 } <a name="l00542"></a>00542 <a name="l00543"></a>00543 <span class="preprocessor">#undef __FUNCT__ </span> <a name="l00544"></a>00544 <span class="preprocessor"></span><span class="preprocessor">#define __FUNCT__ "DSDPFixedVariableNorm"</span> <a name="l00545"></a>00545 <span class="preprocessor"></span><span class="keywordtype">int</span> DSDPFixedVariablesNorm( <a class="code" href="structDSDPSchurMat__C.html" title="Schur complement matrix whose solution is the Newton direction.">DSDPSchurMat</a> M, <a class="code" href="dsdpvec_8h.html#a421243d35437ad44ded3c1e34198e8e9" title="This object hold m+2 variables: a scaling of C, the y variables, and r.">DSDPVec</a> y){ <a name="l00546"></a>00546 <span class="keywordtype">int</span> i,jj,info; <a name="l00547"></a>00547 <span class="keywordtype">double</span> vv; <a name="l00548"></a>00548 FixedVariables *fv=&M.schur->fv; <a name="l00549"></a>00549 DSDPFunctionBegin; <a name="l00550"></a>00550 <span class="keywordflow">for</span> (i=0;i<fv->nvars;i++){ <a name="l00551"></a>00551 jj=fv->var[i]; vv=fv->fval[i]; <a name="l00552"></a>00552 info=DSDPVecAddC(y,1.0);DSDPCHKERR(info); <a name="l00553"></a>00553 info=DSDPVecAddElement(y,jj,vv*vv);DSDPCHKERR(info); <a name="l00554"></a>00554 } <a name="l00555"></a>00555 DSDPFunctionReturn(0); <a name="l00556"></a>00556 } <a name="l00557"></a>00557 <a name="l00558"></a>00558 <span class="preprocessor">#undef __FUNCT__ </span> <a name="l00559"></a>00559 <span class="preprocessor"></span><span class="preprocessor">#define __FUNCT__ "DSDPComputeFixedYX"</span> <a name="l00560"></a>00560 <span class="preprocessor"></span><span class="keywordtype">int</span> DSDPComputeFixedYX( <a class="code" href="structDSDPSchurMat__C.html" title="Schur complement matrix whose solution is the Newton direction.">DSDPSchurMat</a> M, <a class="code" href="dsdpvec_8h.html#a421243d35437ad44ded3c1e34198e8e9" title="This object hold m+2 variables: a scaling of C, the y variables, and r.">DSDPVec</a> berr){ <a name="l00561"></a>00561 <span class="keywordtype">int</span> i,jj,info; <a name="l00562"></a>00562 <span class="keywordtype">double</span> vv; <a name="l00563"></a>00563 FixedVariables *fv=&M.schur->fv; <a name="l00564"></a>00564 DSDPFunctionBegin; <a name="l00565"></a>00565 <span class="keywordflow">for</span> (i=0;i<fv->nvars;i++){ <a name="l00566"></a>00566 jj=fv->var[i]; <a name="l00567"></a>00567 info=DSDPVecGetElement(berr,jj,&vv);DSDPCHKERR(info); <a name="l00568"></a>00568 info=DSDPVecSetElement(berr,jj,0);DSDPCHKERR(info); <a name="l00569"></a>00569 info=DSDPVecAddC(berr,-vv*fv->fval[i]);DSDPCHKERR(info); <a name="l00570"></a>00570 info=DSDPVecAddR(berr,fabs(vv));DSDPCHKERR(info); <a name="l00571"></a>00571 fv->fdual[i]=-vv; <a name="l00572"></a>00572 <span class="keywordflow">if</span> (fv->xout) fv->xout[i]=-vv; <a name="l00573"></a>00573 DSDPLogInfo(0,2,<span class="stringliteral">"FIXED VAR DUAL: %d %4.4f, ADD %4.4f to objective.\n"</span>,jj,vv,-vv*fv->fval[i]); <a name="l00574"></a>00574 } <a name="l00575"></a>00575 DSDPFunctionReturn(0); <a name="l00576"></a>00576 } <a name="l00577"></a>00577 <a name="l00578"></a>00578 <span class="preprocessor">#undef __FUNCT__ </span> <a name="l00579"></a>00579 <span class="preprocessor"></span><span class="preprocessor">#define __FUNCT__ "DSDPIsFixed"</span> <a name="l00580"></a>00580 <span class="preprocessor"></span><span class="keywordtype">int</span> DSDPIsFixed( <a class="code" href="structDSDPSchurMat__C.html" title="Schur complement matrix whose solution is the Newton direction.">DSDPSchurMat</a> M, <span class="keywordtype">int</span> vari, <a class="code" href="dsdpbasictypes_8h.html#ae667f2bff3ab5ab0bc109fa76dc4ed65" title="Boolean variables.">DSDPTruth</a> *flag){ <a name="l00581"></a>00581 <span class="keywordtype">int</span> i; <a name="l00582"></a>00582 FixedVariables *fv=&M.schur->fv; <a name="l00583"></a>00583 DSDPFunctionBegin; <a name="l00584"></a>00584 *flag=<a class="code" href="dsdpbasictypes_8h.html#ae667f2bff3ab5ab0bc109fa76dc4ed65a74385569aa7a59059a8847e2d39b754c">DSDP_FALSE</a>; <a name="l00585"></a>00585 <span class="keywordflow">for</span> (i=0;i<fv->nvars;i++){ <a name="l00586"></a>00586 <span class="keywordflow">if</span> (fv->var[i]==vari){ <a name="l00587"></a>00587 *flag=<a class="code" href="dsdpbasictypes_8h.html#ae667f2bff3ab5ab0bc109fa76dc4ed65ae6b2e53e51e94a5fa7204ceac78f824f">DSDP_TRUE</a>; <a name="l00588"></a>00588 <span class="keywordflow">break</span>; <a name="l00589"></a>00589 } <a name="l00590"></a>00590 } <a name="l00591"></a>00591 DSDPFunctionReturn(0); <a name="l00592"></a>00592 } <a name="l00593"></a>00593 <span class="preprocessor">#undef __FUNCT__ </span> <a name="l00594"></a>00594 <span class="preprocessor"></span><span class="preprocessor">#define __FUNCT__ "DSDPInitializeFixedVariables"</span> <a name="l00595"></a>00595 <span class="preprocessor"></span><span class="keywordtype">int</span> DSDPInitializeFixedVariable( FixedVariables *fv){ <a name="l00596"></a>00596 DSDPFunctionBegin; <a name="l00597"></a>00597 fv->nmaxvars=0; <a name="l00598"></a>00598 fv->nvars=0; <a name="l00599"></a>00599 fv->fval=0; <a name="l00600"></a>00600 fv->var=0; <a name="l00601"></a>00601 fv->fdual=0; <a name="l00602"></a>00602 DSDPFunctionReturn(0); <a name="l00603"></a>00603 } <a name="l00604"></a>00604 <a name="l00605"></a>00605 <span class="preprocessor">#undef __FUNCT__ </span> <a name="l00606"></a>00606 <span class="preprocessor"></span><span class="preprocessor">#define __FUNCT__ "DSDPAddFixedVariables"</span> <a name="l00607"></a>00607 <span class="preprocessor"></span><span class="keywordtype">int</span> DSDPAddFixedVariable( <a class="code" href="structDSDPSchurMat__C.html" title="Schur complement matrix whose solution is the Newton direction.">DSDPSchurMat</a> M, <span class="keywordtype">int</span> vari, <span class="keywordtype">double</span> val){ <a name="l00608"></a>00608 <span class="keywordtype">int</span> i,t,*iinew,info,nvars; <a name="l00609"></a>00609 <span class="keywordtype">double</span> *ddnew,*vvnew; <a name="l00610"></a>00610 FixedVariables *fv=&M.schur->fv; <a name="l00611"></a>00611 DSDPFunctionBegin; <a name="l00612"></a>00612 nvars=fv->nvars; <a name="l00613"></a>00613 <span class="keywordflow">if</span> (nvars>=fv->nmaxvars){ <a name="l00614"></a>00614 t=2*nvars + 2; <a name="l00615"></a>00615 DSDPCALLOC2(&iinew,<span class="keywordtype">int</span>,t,&info); <a name="l00616"></a>00616 DSDPCALLOC2(&ddnew,<span class="keywordtype">double</span>,t,&info); <a name="l00617"></a>00617 DSDPCALLOC2(&vvnew,<span class="keywordtype">double</span>,t,&info); <a name="l00618"></a>00618 <span class="keywordflow">for</span> (i=0;i<nvars;i++){ <a name="l00619"></a>00619 iinew[i]=fv->var[i]; <a name="l00620"></a>00620 ddnew[i]=fv->fval[i]; <a name="l00621"></a>00621 vvnew[i]=fv->fdual[i]; <a name="l00622"></a>00622 } <a name="l00623"></a>00623 DSDPFREE(&fv->var,&info);DSDPCHKERR(info); <a name="l00624"></a>00624 DSDPFREE(&fv->fval,&info);DSDPCHKERR(info); <a name="l00625"></a>00625 DSDPFREE(&fv->fdual,&info);DSDPCHKERR(info); <a name="l00626"></a>00626 fv->var=iinew; <a name="l00627"></a>00627 fv->fval=ddnew; <a name="l00628"></a>00628 fv->fdual=vvnew; <a name="l00629"></a>00629 fv->nmaxvars=t; <a name="l00630"></a>00630 } <a name="l00631"></a>00631 fv->var[fv->nvars]=vari; <a name="l00632"></a>00632 fv->fval[fv->nvars]=val; <a name="l00633"></a>00633 fv->nvars++; <a name="l00634"></a>00634 DSDPFunctionReturn(0); <a name="l00635"></a>00635 } <a name="l00636"></a>00636 <a name="l00637"></a>00637 <span class="preprocessor">#include "<a class="code" href="dsdp_8h.html" title="Internal data structure for the DSDP solver.">dsdp.h</a>"</span> <a name="l00638"></a>00638 <a name="l00639"></a>00639 <span class="preprocessor">#undef __FUNCT__</span> <a name="l00640"></a>00640 <span class="preprocessor"></span><span class="preprocessor">#define __FUNCT__ "DSDPSparsityInSchurMat"</span> <a name="l00641"></a>00641 <span class="preprocessor"></span> <a name="l00649"></a><a class="code" href="dsdpschurmat__impl_8h.html#a678ceeb410d7f137d3fc1e516d24156a">00649</a> <span class="keywordtype">int</span> <a class="code" href="dsdpschurmat_8c.html#a5d1bb7af407a05ae65c63e9d40146644" title="Identify nonzero elements in a row of the Schur complement.">DSDPSparsityInSchurMat</a>(<a class="code" href="structDSDP__C.html" title="Internal structures for the DSDP solver.">DSDP</a> dsdp, <span class="keywordtype">int</span> row, <span class="keywordtype">int</span> rnnz[], <span class="keywordtype">int</span> mm){ <a name="l00650"></a>00650 <span class="keywordtype">int</span> info,*iptr,m=mm+2; <a name="l00651"></a>00651 <span class="keywordtype">double</span> *dd; <a name="l00652"></a>00652 <a class="code" href="dsdpvec_8h.html#a421243d35437ad44ded3c1e34198e8e9" title="This object hold m+2 variables: a scaling of C, the y variables, and r.">DSDPVec</a> R=dsdp->M.schur->rhs3; <a name="l00653"></a>00653 DSDPFunctionBegin; <a name="l00654"></a>00654 info=DSDPVecZero(R);DSDPCHKERR(info); <a name="l00655"></a>00655 info=DSDPVecGetArray(R,&dd);DSDPCHKERR(info); <a name="l00656"></a>00656 iptr=(<span class="keywordtype">int</span>*)dd; <a name="l00657"></a>00657 info=<a class="code" href="dsdp_8h.html#a4116515642c1eb1c843b90aee3909cec" title="Each cone should print its state.">DSDPSchurSparsity</a>(dsdp,row+1,iptr,m);DSDPCHKERR(info); <a name="l00658"></a>00658 memcpy((<span class="keywordtype">void</span>*)rnnz,(<span class="keywordtype">void</span>*)(iptr+1),(mm)*<span class="keyword">sizeof</span>(<span class="keywordtype">int</span>)); <a name="l00659"></a>00659 info=DSDPVecRestoreArray(R,&dd);DSDPCHKERR(info); <a name="l00660"></a>00660 DSDPFunctionReturn(0); <a name="l00661"></a>00661 } <a name="l00662"></a>00662 <a name="l00663"></a>00663 <span class="preprocessor">#include "<a class="code" href="dsdp5_8h.html" title="The API to DSDP for those applications using DSDP as a subroutine library.">dsdp5.h</a>"</span> <a name="l00664"></a>00664 <span class="preprocessor">#undef __FUNCT__</span> <a name="l00665"></a>00665 <span class="preprocessor"></span><span class="preprocessor">#define __FUNCT__ "DSDPSetFixedVariable"</span> <a name="l00666"></a>00666 <span class="preprocessor"></span> <a name="l00675"></a><a class="code" href="group__DSDPSolver.html#ga4654614850ec5fc42e9350854f560fd1">00675</a> <span class="keywordtype">int</span> <a class="code" href="group__DSDPSolver.html#ga4654614850ec5fc42e9350854f560fd1" title="Fix variable y to exact value.">DSDPSetFixedVariable</a>(<a class="code" href="structDSDP__C.html" title="Internal structures for the DSDP solver.">DSDP</a> dsdp, <span class="keywordtype">int</span> vari, <span class="keywordtype">double</span> val){ <a name="l00676"></a>00676 <span class="keywordtype">int</span> info; <a name="l00677"></a>00677 DSDPFunctionBegin; <a name="l00678"></a>00678 DSDPLogInfo(0,2,<span class="stringliteral">"Set Fixed Variable: %d, %12.8f\n"</span>,vari,val); <a name="l00679"></a>00679 info= DSDPAddFixedVariable(dsdp->M,vari,val);DSDPCHKERR(info); <a name="l00680"></a>00680 DSDPFunctionReturn(0); <a name="l00681"></a>00681 } <a name="l00682"></a>00682 <a name="l00683"></a>00683 <span class="preprocessor">#undef __FUNCT__</span> <a name="l00684"></a>00684 <span class="preprocessor"></span><span class="preprocessor">#define __FUNCT__ "DSDPSetFixedVariables"</span> <a name="l00685"></a>00685 <span class="preprocessor"></span> <a name="l00695"></a><a class="code" href="group__DSDPSolver.html#gabaa520cba1ca164175fb45cff1b2d6e3">00695</a> <span class="keywordtype">int</span> <a class="code" href="group__DSDPSolver.html#gabaa520cba1ca164175fb45cff1b2d6e3" title="Fix variable y to exact values.">DSDPSetFixedVariables</a>(<a class="code" href="structDSDP__C.html" title="Internal structures for the DSDP solver.">DSDP</a> dsdp, <span class="keywordtype">double</span> vars[], <span class="keywordtype">double</span> vals[], <span class="keywordtype">double</span> xout[], <span class="keywordtype">int</span> nvars){ <a name="l00696"></a>00696 <span class="keywordtype">int</span> i,info; <a name="l00697"></a>00697 DSDPFunctionBegin; <a name="l00698"></a>00698 <span class="keywordflow">for</span> (i=0;i<nvars;i++){ <a name="l00699"></a>00699 info=<a class="code" href="group__DSDPSolver.html#ga4654614850ec5fc42e9350854f560fd1" title="Fix variable y to exact value.">DSDPSetFixedVariable</a>(dsdp,(<span class="keywordtype">int</span>)vars[i],vals[i]); <a name="l00700"></a>00700 dsdp->M.schur->fv.xout=xout; <a name="l00701"></a>00701 } <a name="l00702"></a>00702 DSDPFunctionReturn(0); <a name="l00703"></a>00703 } <a name="l00704"></a>00704 <a name="l00705"></a>00705 <span class="preprocessor">#undef __FUNCT__ </span> <a name="l00706"></a>00706 <span class="preprocessor"></span><span class="preprocessor">#define __FUNCT__ "DSDPGetFixedYX"</span> <a name="l00707"></a>00707 <span class="preprocessor"></span><span class="keywordtype">int</span> DSDPGetFixedYX( <a class="code" href="structDSDP__C.html" title="Internal structures for the DSDP solver.">DSDP</a> dsdp, <span class="keywordtype">int</span> vari, <span class="keywordtype">double</span> *dd){ <a name="l00708"></a>00708 <span class="keywordtype">int</span> i; <a name="l00709"></a>00709 FixedVariables *fv=&dsdp->M.schur->fv; <a name="l00710"></a>00710 DSDPFunctionBegin; <a name="l00711"></a>00711 <span class="keywordflow">for</span> (i=0;i<fv->nvars;i++){ <a name="l00712"></a>00712 <span class="keywordflow">if</span> (vari==fv->var[i]){ <a name="l00713"></a>00713 *dd=fv->fdual[i]; <span class="keywordflow">break</span>; <a name="l00714"></a>00714 } <a name="l00715"></a>00715 } <a name="l00716"></a>00716 DSDPFunctionReturn(0); <a name="l00717"></a>00717 } </pre></div></div> </div> <hr class="footer"/><address class="footer"><small>Generated on Wed Jun 8 2011 for DSDP by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address> </body> </html>