void Mehrotra ( const DistSparseMatrix<Real>& A, const DistMultiVec<Real>& b, const DistMultiVec<Real>& c, const DistMultiVec<Int>& orders, const DistMultiVec<Int>& firstInds, DistMultiVec<Real>& x, DistMultiVec<Real>& y, DistMultiVec<Real>& z, const MehrotraCtrl<Real>& ctrl ) { EL_DEBUG_CSE const Int n = c.Height(); const Grid& grid = A.Grid(); DistSparseMatrix<Real> G(grid); Identity( G, n, n ); G *= -1; DistMultiVec<Real> h(grid); Zeros( h, n, 1 ); MehrotraCtrl<Real> affineCtrl = ctrl; affineCtrl.primalInit = false; affineCtrl.dualInit = false; DistMultiVec<Real> s(grid); socp::affine::Mehrotra(A,G,b,c,h,orders,firstInds,x,y,z,s,affineCtrl); }
void RowMaxNorms( const DistMultiVec<F>& A, DistMultiVec<Base<F>>& norms ) { DEBUG_CSE norms.SetComm( A.Comm() ); norms.Resize( A.Height(), 1 ); RowMaxNorms( A.LockedMatrix(), norms.Matrix() ); }
void SOCSquareRoot ( const DistMultiVec<Real>& x, DistMultiVec<Real>& xRoot, const DistMultiVec<Int>& orders, const DistMultiVec<Int>& firstInds, Int cutoff ) { DEBUG_ONLY(CSE cse("SOCSquareRoot")) DistMultiVec<Real> d(x.Comm()); SOCDets( x, d, orders, firstInds ); ConeBroadcast( d, orders, firstInds ); auto roots = x; ConeBroadcast( roots, orders, firstInds ); const Int localHeight = x.LocalHeight(); xRoot.SetComm( x.Comm() ); Zeros( xRoot, x.Height(), 1 ); for( Int iLoc=0; iLoc<localHeight; ++iLoc ) { const Int i = x.GlobalRow(iLoc); const Real x0 = roots.GetLocal(iLoc,0); const Real det = d.GetLocal(iLoc,0); const Real eta0 = Sqrt(x0+Sqrt(det))/Sqrt(Real(2)); if( i == firstInds.GetLocal(iLoc,0) ) xRoot.SetLocal( iLoc, 0, eta0 ); else xRoot.SetLocal( iLoc, 0, x.GetLocal(iLoc,0)/(2*eta0) ); } }
void EntrywiseMap ( const DistMultiVec<S>& A, DistMultiVec<T>& B, function<T(S)> func ) { DEBUG_CSE B.SetComm( A.Comm() ); B.Resize( A.Height(), A.Width() ); EntrywiseMap( A.LockedMatrix(), B.Matrix(), func ); }
void NesterovTodd ( const DistMultiVec<Real>& s, const DistMultiVec<Real>& z, DistMultiVec<Real>& w ) { DEBUG_CSE w.SetComm( s.Comm() ); w.Resize( s.Height(), 1 ); const Real* sBuf = s.LockedMatrix().LockedBuffer(); const Real* zBuf = z.LockedMatrix().LockedBuffer(); Real* wBuf = w.Matrix().Buffer(); const Int localHeight = w.LocalHeight(); for( Int iLoc=0; iLoc<localHeight; ++iLoc ) wBuf[iLoc] = Sqrt(sBuf[iLoc]/zBuf[iLoc]); }
inline void DistNodalMultiVec<F>::Pull ( const DistMap& inverseMap, const DistSymmInfo& info, const DistMultiVec<F>& X ) { DEBUG_ONLY(CallStackEntry cse("DistNodalMultiVec::Pull")) height_ = X.Height(); width_ = X.Width(); // Traverse our part of the elimination tree to see how many indices we need int numRecvInds=0; const int numLocal = info.localNodes.size(); for( int s=0; s<numLocal; ++s ) numRecvInds += info.localNodes[s].size; const int numDist = info.distNodes.size(); for( int s=1; s<numDist; ++s ) numRecvInds += info.distNodes[s].multiVecMeta.localSize; // Fill the set of indices that we need to map to the original ordering int off=0; std::vector<int> mappedInds( numRecvInds ); for( int s=0; s<numLocal; ++s ) { const SymmNodeInfo& nodeInfo = info.localNodes[s]; for( int t=0; t<nodeInfo.size; ++t ) mappedInds[off++] = nodeInfo.off+t; } for( int s=1; s<numDist; ++s ) { const DistSymmNodeInfo& nodeInfo = info.distNodes[s]; const Grid& grid = *nodeInfo.grid; const int gridSize = grid.Size(); const int gridRank = grid.VCRank(); const int alignment = 0; const int shift = Shift( gridRank, alignment, gridSize ); for( int t=shift; t<nodeInfo.size; t+=gridSize ) mappedInds[off++] = nodeInfo.off+t; } DEBUG_ONLY( if( off != numRecvInds ) LogicError("mappedInds was filled incorrectly"); )