void IPM ( const Matrix<Real>& A, const Matrix<Real>& b, Real lambda, Matrix<Real>& x, const qp::affine::Ctrl<Real>& ctrl ) { DEBUG_CSE const Int m = A.Height(); const Int n = A.Width(); const Range<Int> uInd(0,n), vInd(n,2*n), rInd(2*n,2*n+m); Matrix<Real> Q, c, AHat, G, h; // Q := | 0 0 0 | // | 0 0 0 | // | 0 0 I | // ============== Zeros( Q, 2*n+m, 2*n+m ); auto Qrr = Q( rInd, rInd ); FillDiagonal( Qrr, Real(1) ); // c := lambda*[1;1;0] // =================== Zeros( c, 2*n+m, 1 ); auto cuv = c( IR(0,2*n), ALL ); Fill( cuv, lambda ); // \hat A := [A, -A, I] // ==================== Zeros( AHat, m, 2*n+m ); auto AHatu = AHat( IR(0,m), uInd ); auto AHatv = AHat( IR(0,m), vInd ); auto AHatr = AHat( IR(0,m), rInd ); AHatu = A; AHatv -= A; FillDiagonal( AHatr, Real(1) ); // G := | -I 0 0 | // | 0 -I 0 | // ================ Zeros( G, 2*n, 2*n+m ); FillDiagonal( G, Real(-1) ); // h := 0 // ====== Zeros( h, 2*n, 1 ); // Solve the affine QP // =================== Matrix<Real> xHat, y, z, s; QP( Q, AHat, G, b, c, h, xHat, y, z, s, ctrl ); // x := u - v // ========== x = xHat( uInd, ALL ); x -= xHat( vInd, ALL ); }
void LAV ( const AbstractDistMatrix<Real>& A, const AbstractDistMatrix<Real>& b, AbstractDistMatrix<Real>& xPre, const lp::affine::Ctrl<Real>& ctrl ) { EL_DEBUG_CSE DistMatrixWriteProxy<Real,Real,MC,MR> xProx( xPre ); auto& x = xProx.Get(); const Int m = A.Height(); const Int n = A.Width(); const Grid& g = A.Grid(); const Range<Int> xInd(0,n), uInd(n,n+m), vInd(n+m,n+2*m); DistMatrix<Real> c(g), AHat(g), G(g), h(g); // c := [0;1;1] // ============ Zeros( c, n+2*m, 1 ); auto cuv = c( IR(n,n+2*m), ALL ); Fill( cuv, Real(1) ); // \hat A := [A, I, -I] // ==================== Zeros( AHat, m, n+2*m ); auto AHatx = AHat( IR(0,m), xInd ); auto AHatu = AHat( IR(0,m), uInd ); auto AHatv = AHat( IR(0,m), vInd ); AHatx = A; FillDiagonal( AHatu, Real( 1) ); FillDiagonal( AHatv, Real(-1) ); // G := | 0 -I 0 | // | 0 0 -I | // ================ Zeros( G, 2*m, n+2*m ); auto Guv = G( IR(0,2*m), IR(n,n+2*m) ); FillDiagonal( Guv, Real(-1) ); // h := | 0 | // | 0 | // ========== Zeros( h, 2*m, 1 ); // Solve the affine linear program // =============================== DistMatrix<Real> xHat(g), y(g), z(g), s(g); LP( AHat, G, b, c, h, xHat, y, z, s, ctrl ); // Extract x // ========= x = xHat( xInd, ALL ); }
void LAV ( const Matrix<Real>& A, const Matrix<Real>& b, Matrix<Real>& x, const lp::affine::Ctrl<Real>& ctrl ) { EL_DEBUG_CSE const Int m = A.Height(); const Int n = A.Width(); const Range<Int> xInd(0,n), uInd(n,n+m), vInd(n+m,n+2*m); Matrix<Real> c, AHat, G, h; // c := [0;1;1] // ============ Zeros( c, n+2*m, 1 ); auto cuv = c( IR(n,n+2*m), ALL ); Fill( cuv, Real(1) ); // \hat A := [A, I, -I] // ==================== Zeros( AHat, m, n+2*m ); auto AHatx = AHat( IR(0,m), xInd ); auto AHatu = AHat( IR(0,m), uInd ); auto AHatv = AHat( IR(0,m), vInd ); AHatx = A; FillDiagonal( AHatu, Real( 1) ); FillDiagonal( AHatv, Real(-1) ); // G := | 0 -I 0 | // | 0 0 -I | // ================ Zeros( G, 2*m, n+2*m ); auto Guv = G( IR(0,2*m), IR(n,n+2*m) ); FillDiagonal( Guv, Real(-1) ); // h := | 0 | // | 0 | // ========== Zeros( h, 2*m, 1 ); // Solve the affine linear program // =============================== Matrix<Real> xHat, y, z, s; LP( AHat, G, b, c, h, xHat, y, z, s, ctrl ); // Extract x // ========== x = xHat( xInd, ALL ); }
void LAV ( const DistSparseMatrix<Real>& A, const DistMultiVec<Real>& b, DistMultiVec<Real>& x, const lp::affine::Ctrl<Real>& ctrl ) { EL_DEBUG_CSE const Int m = A.Height(); const Int n = A.Width(); const Grid& grid = A.Grid(); DistSparseMatrix<Real> AHat(grid), G(grid); DistMultiVec<Real> c(grid), h(grid); // c := [0;1;1] // ============ Zeros( c, n+2*m, 1 ); for( Int iLoc=0; iLoc<c.LocalHeight(); ++iLoc ) if( c.GlobalRow(iLoc) >= n ) c.SetLocal( iLoc, 0, Real(1) ); // \hat A := [A, I, -I] // ==================== Zeros( AHat, m, n+2*m ); const Int numLocalEntriesA = A.NumLocalEntries(); AHat.Reserve( numLocalEntriesA + 2*AHat.LocalHeight() ); for( Int e=0; e<numLocalEntriesA; ++e ) AHat.QueueUpdate( A.Row(e), A.Col(e), A.Value(e) ); for( Int iLoc=0; iLoc<AHat.LocalHeight(); ++iLoc ) { const Int i = AHat.GlobalRow(iLoc); AHat.QueueLocalUpdate( iLoc, i+n, Real( 1) ); AHat.QueueLocalUpdate( iLoc, i+n+m, Real(-1) ); } AHat.ProcessLocalQueues(); // G := | 0 -I 0 | // | 0 0 -I | // ================ Zeros( G, 2*m, n+2*m ); G.Reserve( G.LocalHeight() ); for( Int iLoc=0; iLoc<G.LocalHeight(); ++iLoc ) G.QueueLocalUpdate( iLoc, G.GlobalRow(iLoc)+n, Real(-1) ); G.ProcessLocalQueues(); // h := | 0 | // | 0 | // ========== Zeros( h, 2*m, 1 ); // Solve the affine QP // =================== DistMultiVec<Real> xHat(grid), y(grid), z(grid), s(grid); LP( AHat, G, b, c, h, xHat, y, z, s, ctrl ); // Extract x // ========= x = xHat( IR(0,n), ALL ); }
void QP ( const DistSparseMatrix<Real>& A, const DistMultiVec<Real>& B, DistMultiVec<Real>& X, const qp::direct::Ctrl<Real>& ctrl ) { DEBUG_CSE const Int m = A.Height(); const Int n = A.Width(); const Int k = B.Width(); mpi::Comm comm = A.Comm(); DistSparseMatrix<Real> Q(comm), AHat(comm); DistMultiVec<Real> bHat(comm), c(comm); Herk( LOWER, ADJOINT, Real(1), A, Q ); MakeHermitian( LOWER, Q ); Zeros( AHat, 0, n ); Zeros( bHat, 0, 1 ); Zeros( X, n, k ); DistMultiVec<Real> q(comm), y(comm), z(comm); auto& qLoc = q.Matrix(); auto& XLoc = X.Matrix(); auto& BLoc = B.LockedMatrix(); for( Int j=0; j<k; ++j ) { auto xLoc = XLoc( ALL, IR(j) ); auto bLoc = BLoc( ALL, IR(j) ); Zeros( c, n, 1 ); Zeros( q, m, 1 ); qLoc = bLoc; Multiply( ADJOINT, Real(-1), A, q, Real(0), c ); Zeros( q, n, 1 ); qLoc = xLoc; El::QP( Q, AHat, bHat, c, q, y, z, ctrl ); xLoc = qLoc; } }
void QP ( const ElementalMatrix<Real>& APre, const ElementalMatrix<Real>& BPre, ElementalMatrix<Real>& XPre, const qp::direct::Ctrl<Real>& ctrl ) { DEBUG_CSE DistMatrixReadProxy<Real,Real,MC,MR> AProx( APre ), BProx( BPre ); DistMatrixWriteProxy<Real,Real,MC,MR> XProx( XPre ); auto& A = AProx.GetLocked(); auto& B = BProx.GetLocked(); auto& X = XProx.Get(); const Int n = A.Width(); const Int k = B.Width(); const Grid& g = A.Grid(); DistMatrix<Real> Q(g), AHat(g), bHat(g), c(g); Herk( LOWER, ADJOINT, Real(1), A, Q ); Zeros( AHat, 0, n ); Zeros( bHat, 0, 1 ); Zeros( X, n, k ); DistMatrix<Real> y(g), z(g); for( Int j=0; j<k; ++j ) { auto x = X( ALL, IR(j) ); auto b = B( ALL, IR(j) ); Zeros( c, n, 1 ); Gemv( ADJOINT, Real(-1), A, b, Real(0), c ); El::QP( Q, AHat, bHat, c, x, y, z, ctrl ); } }
void IPM ( const DistSparseMatrix<Real>& A, const DistMultiVec<Real>& b, Real lambda, DistMultiVec<Real>& x, const qp::affine::Ctrl<Real>& ctrl ) { DEBUG_CSE const Int m = A.Height(); const Int n = A.Width(); mpi::Comm comm = A.Comm(); DistSparseMatrix<Real> Q(comm), AHat(comm), G(comm); DistMultiVec<Real> c(comm), h(comm); // Q := | 0 0 0 | // | 0 0 0 | // | 0 0 I | // ============== Zeros( Q, 2*n+m, 2*n+m ); { Int numLocalUpdates = 0; for( Int iLoc=0; iLoc<Q.LocalHeight(); ++iLoc ) if( Q.GlobalRow(iLoc) >= 2*n ) ++numLocalUpdates; Q.Reserve( numLocalUpdates ); for( Int iLoc=0; iLoc<Q.LocalHeight(); ++iLoc ) if( Q.GlobalRow(iLoc) >= 2*n ) Q.QueueLocalUpdate( iLoc, Q.GlobalRow(iLoc), Real(1) ); Q.ProcessLocalQueues(); } // c := lambda*[1;1;0] // =================== Zeros( c, 2*n+m, 1 ); auto& cLoc = c.Matrix(); for( Int iLoc=0; iLoc<c.LocalHeight(); ++iLoc ) if( c.GlobalRow(iLoc) < 2*n ) cLoc(iLoc) = lambda; // \hat A := [A, -A, I] // ==================== // NOTE: Since A and \hat A are the same height and each distributed within // columns, it is possible to form \hat A from A without communication const Int numLocalEntriesA = A.NumLocalEntries(); Zeros( AHat, m, 2*n+m ); AHat.Reserve( 2*numLocalEntriesA+AHat.LocalHeight() ); for( Int e=0; e<numLocalEntriesA; ++e ) { AHat.QueueUpdate( A.Row(e), A.Col(e), A.Value(e) ); AHat.QueueUpdate( A.Row(e), A.Col(e)+n, -A.Value(e) ); } for( Int iLoc=0; iLoc<AHat.LocalHeight(); ++iLoc ) { const Int i = AHat.GlobalRow(iLoc); AHat.QueueLocalUpdate( iLoc, i+2*n, Real(1) ); } AHat.ProcessLocalQueues(); // G := | -I 0 0 | // | 0 -I 0 | // ================ Zeros( G, 2*n, 2*n+m ); G.Reserve( G.LocalHeight() ); for( Int iLoc=0; iLoc<G.LocalHeight(); ++iLoc ) { const Int i = G.GlobalRow(iLoc); G.QueueLocalUpdate( iLoc, i, Real(-1) ); } G.ProcessLocalQueues(); // h := 0 // ====== Zeros( h, 2*n, 1 ); // Solve the affine QP // =================== DistMultiVec<Real> xHat(comm), y(comm), z(comm), s(comm); QP( Q, AHat, G, b, c, h, xHat, y, z, s, ctrl ); // x := u - v // ========== Zeros( x, n, 1 ); Int numRemoteUpdates = 0; for( Int iLoc=0; iLoc<xHat.LocalHeight(); ++iLoc ) if( xHat.GlobalRow(iLoc) < 2*n ) ++numRemoteUpdates; else break; x.Reserve( numRemoteUpdates ); auto& xHatLoc = xHat.LockedMatrix(); for( Int iLoc=0; iLoc<xHat.LocalHeight(); ++iLoc ) { const Int i = xHat.GlobalRow(iLoc); if( i < n ) x.QueueUpdate( i, 0, xHatLoc(iLoc) ); else if( i < 2*n ) x.QueueUpdate( i-n, 0, -xHatLoc(iLoc) ); else break; } x.ProcessQueues(); }
void IPM ( const AbstractDistMatrix<Real>& A, const AbstractDistMatrix<Real>& d, Real lambda, AbstractDistMatrix<Real>& x, const qp::affine::Ctrl<Real>& ctrl ) { EL_DEBUG_CSE const Int m = A.Height(); const Int n = A.Width(); const Grid& g = A.Grid(); const Range<Int> wInd(0,n), betaInd(n,n+1), zInd(n+1,n+m+1); DistMatrix<Real> Q(g), c(g), AHat(g), b(g), G(g), h(g); // Q := | I 0 0 | // | 0 0 0 | // | 0 0 0 | // ============== Zeros( Q, n+m+1, n+m+1 ); auto Qww = Q( wInd, wInd ); FillDiagonal( Qww, Real(1) ); // c := [0;0;lambda] // ================ Zeros( c, n+m+1, 1 ); auto cz = c( zInd, ALL ); Fill( cz, lambda ); // AHat = [] // ========= Zeros( AHat, 0, n+m+1 ); // b = [] // ====== Zeros( b, 0, 1 ); // G := |-diag(d) A, -d, -I| // | 0, 0, -I| // ========================= Zeros( G, 2*m, n+m+1 ); auto G0w = G( IR(0,m), wInd ); auto G0beta = G( IR(0,m), betaInd ); auto G0z = G( IR(0,m), zInd ); auto G1z = G( IR(m,2*m), zInd ); G0w = A; G0w *= -1; DiagonalScale( LEFT, NORMAL, d, G0w ); G0beta = d; G0beta *= -1; FillDiagonal( G0z, Real(-1) ); FillDiagonal( G1z, Real(-1) ); // h := [-ones(m,1); zeros(m,1)] // ============================= Zeros( h, 2*m, 1 ); auto h0 = h( IR(0,m), ALL ); Fill( h0, Real(-1) ); // Solve the affine QP // =================== DistMatrix<Real> y(g), z(g), s(g); QP( Q, AHat, G, b, c, h, x, y, z, s, ctrl ); }
void IPM ( const DistSparseMatrix<Real>& A, const DistMultiVec<Real>& d, Real lambda, DistMultiVec<Real>& x, const qp::affine::Ctrl<Real>& ctrl ) { EL_DEBUG_CSE const Int m = A.Height(); const Int n = A.Width(); mpi::Comm comm = A.Comm(); DistSparseMatrix<Real> Q(comm), AHat(comm), G(comm); DistMultiVec<Real> c(comm), b(comm), h(comm); auto& dLoc = d.LockedMatrix(); auto& cLoc = c.Matrix(); auto& hLoc = h.Matrix(); // Q := | I 0 0 | // | 0 0 0 | // | 0 0 0 | // ============== Zeros( Q, n+m+1, n+m+1 ); { // Count the number of local entries in the top-left I // --------------------------------------------------- Int numLocalUpdates = 0; for( Int iLoc=0; iLoc<Q.LocalHeight(); ++iLoc ) if( Q.GlobalRow(iLoc) < n ) ++numLocalUpdates; else break; Q.Reserve( numLocalUpdates ); for( Int iLoc=0; iLoc<Q.LocalHeight(); ++iLoc ) if( Q.GlobalRow(iLoc) < n ) Q.QueueLocalUpdate( iLoc, Q.GlobalRow(iLoc), Real(1) ); Q.ProcessLocalQueues(); } // c := [0;0;lambda] // ================= Zeros( c, n+m+1, 1 ); for( Int iLoc=0; iLoc<c.LocalHeight(); ++iLoc ) if( c.GlobalRow(iLoc) > n ) cLoc(iLoc) = lambda; // AHat = [] // ========= Zeros( AHat, 0, n+m+1 ); // b = [] // ====== Zeros( b, 0, 1 ); // G := |-diag(d) A, -d, -I| // | 0, 0, -I| // ========================= Zeros( G, 2*m, n+m+1 ); G.Reserve ( A.NumLocalEntries()+d.LocalHeight()+G.LocalHeight(), A.NumLocalEntries()+d.LocalHeight() ); for( Int e=0; e<A.NumLocalEntries(); ++e ) { const Int i = A.Row(e); const Int j = A.Col(e); const Int iLoc = A.LocalRow(i); const Real value = -dLoc(iLoc)*A.Value(e); G.QueueUpdate( i, j, value ); } for( Int iLoc=0; iLoc<d.LocalHeight(); ++iLoc ) { const Int i = d.GlobalRow(iLoc); G.QueueUpdate( i, n, -dLoc(iLoc) ); } for( Int iLoc=0; iLoc<G.LocalHeight(); ++iLoc ) { const Int i = G.GlobalRow(iLoc); if( i < m ) G.QueueLocalUpdate( iLoc, i+n+1, Real(-1) ); else G.QueueLocalUpdate( iLoc, (i-m)+n+1, Real(-1) ); } G.ProcessQueues(); // h := [-ones(m,1); zeros(m,1)] // ============================= Zeros( h, 2*m, 1 ); for( Int iLoc=0; iLoc<h.LocalHeight(); ++iLoc ) if( h.GlobalRow(iLoc) < m ) hLoc(iLoc) = Real(-1); else break; // Solve the affine QP // =================== DistMultiVec<Real> y(comm), z(comm), s(comm); QP( Q, AHat, G, b, c, h, x, y, z, s, ctrl ); }
void IPM ( const AbstractDistMatrix<Real>& APre, const AbstractDistMatrix<Real>& b, Real lambda, AbstractDistMatrix<Real>& xPre, const qp::affine::Ctrl<Real>& ctrl ) { EL_DEBUG_CSE DistMatrixReadProxy<Real,Real,MC,MR> AProx( APre ); const auto& A = AProx.GetLocked(); DistMatrixWriteProxy<Real,Real,MC,MR> xProx( xPre ); auto& x = xProx.Get(); const Int m = A.Height(); const Int n = A.Width(); const Grid& g = A.Grid(); const Range<Int> uInd(0,n), vInd(n,2*n), rInd(2*n,2*n+m); DistMatrix<Real> Q(g), c(g), AHat(g), G(g), h(g); // Q := | 0 0 0 | // | 0 0 0 | // | 0 0 I | // ============== Zeros( Q, 2*n+m, 2*n+m ); auto Qrr = Q( rInd, rInd ); FillDiagonal( Qrr, Real(1) ); // c := lambda*[1;1;0] // =================== Zeros( c, 2*n+m, 1 ); auto cuv = c( IR(0,2*n), ALL ); Fill( cuv, lambda ); // \hat A := [A, -A, I] // ==================== Zeros( AHat, m, 2*n+m ); auto AHatu = AHat( IR(0,m), uInd ); auto AHatv = AHat( IR(0,m), vInd ); auto AHatr = AHat( IR(0,m), rInd ); AHatu = A; AHatv -= A; FillDiagonal( AHatr, Real(1) ); // G := | -I 0 0 | // | 0 -I 0 | // ================ Zeros( G, 2*n, 2*n+m ); FillDiagonal( G, Real(-1) ); // h := 0 // ====== Zeros( h, 2*n, 1 ); // Solve the affine QP // =================== DistMatrix<Real> xHat(g), y(g), z(g), s(g); QP( Q, AHat, G, b, c, h, xHat, y, z, s, ctrl ); // x := u - v // ========== x = xHat( uInd, ALL ); x -= xHat( vInd, ALL ); }
void RLS ( const DistSparseMatrix<Real>& A, const DistMultiVec<Real>& b, Real rho, DistMultiVec<Real>& x, const socp::affine::Ctrl<Real>& ctrl ) { DEBUG_CSE const Int m = A.Height(); const Int n = A.Width(); mpi::Comm comm = A.Comm(); DistMultiVec<Int> orders(comm), firstInds(comm); Zeros( orders, m+n+3, 1 ); Zeros( firstInds, m+n+3, 1 ); { const Int localHeight = orders.LocalHeight(); for( Int iLoc=0; iLoc<localHeight; ++iLoc ) { const Int i = orders.GlobalRow(iLoc); if( i < m+1 ) { orders.SetLocal( iLoc, 0, m+1 ); firstInds.SetLocal( iLoc, 0, 0 ); } else { orders.SetLocal( iLoc, 0, n+2 ); firstInds.SetLocal( iLoc, 0, m+1 ); } } } // G := | -1 0 0 | // | 0 0 A | // | 0 -1 0 | // | 0 0 -I | // | 0 0 0 | DistSparseMatrix<Real> G(comm); { Zeros( G, m+n+3, n+2 ); // Count the number of entries of G to reserve // ------------------------------------------- Int numLocalUpdates = 0; const Int localHeight = G.LocalHeight(); for( Int iLoc=0; iLoc<localHeight; ++iLoc ) { const Int i = G.GlobalRow(iLoc); if( i == 0 || i == m+1 || (i>m+1 && i<m+n+2) ) ++numLocalUpdates; } const Int numEntriesA = A.NumLocalEntries(); G.Reserve( numLocalUpdates+numEntriesA, numEntriesA ); // Queue the local updates // ----------------------- for( Int iLoc=0; iLoc<localHeight; ++iLoc ) { const Int i = G.GlobalRow(iLoc); if( i == 0 ) G.QueueLocalUpdate( iLoc, 0, -1 ); else if( i == m+1 ) G.QueueLocalUpdate( iLoc, 1, -1 ); else if( i > m+1 && i < m+n+2 ) G.QueueLocalUpdate( iLoc, i-m, -1 ); } // Queue the remote updates // ------------------------ for( Int e=0; e<numEntriesA; ++e ) G.QueueUpdate( A.Row(e)+1, A.Col(e)+2, A.Value(e) ); G.ProcessQueues(); } // h := | 0 | // | b | // | 0 | // | 0 | // | 1 | DistMultiVec<Real> h(comm); Zeros( h, m+n+3, 1 ); auto& bLoc = b.LockedMatrix(); { const Int bLocalHeight = b.LocalHeight(); h.Reserve( bLocalHeight ); for( Int iLoc=0; iLoc<bLocalHeight; ++iLoc ) h.QueueUpdate( b.GlobalRow(iLoc)+1, 0, bLoc(iLoc) ); h.ProcessQueues(); } h.Set( END, 0, 1 ); // c := [1; rho; 0] DistMultiVec<Real> c(comm); Zeros( c, n+2, 1 ); c.Set( 0, 0, 1 ); c.Set( 1, 0, rho ); DistSparseMatrix<Real> AHat(comm); Zeros( AHat, 0, n+2 ); DistMultiVec<Real> bHat(comm); Zeros( bHat, 0, 1 ); DistMultiVec<Real> xHat(comm), y(comm), z(comm), s(comm); SOCP( AHat, G, bHat, c, h, orders, firstInds, xHat, y, z, s, ctrl ); x = xHat( IR(2,END), ALL ); }
void RLS ( const ElementalMatrix<Real>& APre, const ElementalMatrix<Real>& bPre, Real rho, ElementalMatrix<Real>& xPre, const socp::affine::Ctrl<Real>& ctrl ) { DEBUG_CSE DistMatrixReadProxy<Real,Real,MC,MR> AProx( APre ), bProx( bPre ); DistMatrixWriteProxy<Real,Real,MC,MR> xProx( xPre ); auto& A = AProx.GetLocked(); auto& b = bProx.GetLocked(); auto& x = xProx.Get(); const Int m = A.Height(); const Int n = A.Width(); const Grid& g = A.Grid(); DistMatrix<Int,VC,STAR> orders(g), firstInds(g); Zeros( orders, m+n+3, 1 ); Zeros( firstInds, m+n+3, 1 ); { const Int localHeight = orders.LocalHeight(); for( Int iLoc=0; iLoc<localHeight; ++iLoc ) { const Int i = orders.GlobalRow(iLoc); if( i < m+1 ) { orders.SetLocal( iLoc, 0, m+1 ); firstInds.SetLocal( iLoc, 0, 0 ); } else { orders.SetLocal( iLoc, 0, n+2 ); firstInds.SetLocal( iLoc, 0, m+1 ); } } } // G := | -1 0 0 | // | 0 0 A | // | 0 -1 0 | // | 0 0 -I | // | 0 0 0 | DistMatrix<Real> G(g); { Zeros( G, m+n+3, n+2 ); G.Set( 0, 0, -1 ); auto GA = G( IR(1,m+1), IR(2,n+2) ); GA = A; G.Set( m+1, 1, -1 ); auto GI = G( IR(m+2,m+n+2), IR(2,n+2) ); Identity( GI, n, n ); GI *= -1; } // h := | 0 | // | b | // | 0 | // | 0 | // | 1 | DistMatrix<Real> h(g); Zeros( h, m+n+3, 1 ); auto hb = h( IR(1,m+1), ALL ); hb = b; h.Set( END, 0, 1 ); // c := [1; rho; 0] DistMatrix<Real> c(g); Zeros( c, n+2, 1 ); c.Set( 0, 0, 1 ); c.Set( 1, 0, rho ); DistMatrix<Real> AHat(g), bHat(g); Zeros( AHat, 0, n+2 ); Zeros( bHat, 0, 1 ); DistMatrix<Real> xHat(g), y(g), z(g), s(g); SOCP( AHat, G, bHat, c, h, orders, firstInds, xHat, y, z, s, ctrl ); x = xHat( IR(2,END), ALL ); }