/* ------------------------------------------------------------- This file is a component of SDPA Copyright (C) 2004-2013 SDPA Project This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ------------------------------------------------------------- */ #include "sdpa_dataset.h" #include "sdpa_parts.h" #include "sdpa_linear.h" #include "sdpa_newton.h" namespace sdpa { Solutions::Solutions() { initialize(); } Solutions::~Solutions() { finalize(); } void Solutions::initialize() { nDim = 0; mDim = 0; } void Solutions::initialize(int m, BlockStruct& bs) { mDim = m; nDim = 0; for (int l=0; l \n"); cholmodSpace.display(fpout, printFormat); fprintf(fpout, "order =========> \n"); order.display(fpout, printFormat); rMessage("Solutions @ end @@@@@@@@@@@@@@@@@@@@@@"); } void Solutions::makeFinalSolution(bool Xmake, bool Zmake, BlockStruct& bs) { if (Xmake == true) { cholmodSpace.getCholesky(order); finalX.initialize(bs); for (int l=0; l ret) { ret = tmp; } } return ret; } double Residuals::computeMaxNorm(cholmod_sparse* rD) { double ret = 0.0; for (int index1=0; index1nzmax; ++index1) { const double tmp = fabs(((double*)rD->x)[index1]); if (tmp > ret) { ret = tmp; } } return ret; } void Residuals::update(CholmodSpace& cholmodSpace) { // p[k] = b[k] - A[k].X; normPrimal = computeMaxNorm(cholmodSpace.rp); double tmpNorm = 0.0; for (int l = 0; l < cholmodSpace.LP_nBlock; ++l) { double tmp2 = fabs(cholmodSpace.LP_rD[l]); if (tmp2 > tmpNorm) { tmpNorm = tmp2; } } for (int l = 0; l < cholmodSpace.SDP_nBlock; ++l) { double tmp2 = computeMaxNorm(cholmodSpace.SDP_block[l].rD); if (tmp2 > tmpNorm) { tmpNorm = tmp2; } } normDual = tmpNorm; } void Residuals::copyToInit() { initNormPrimal = normPrimal; initNormDual = normDual; centerNorm = 0.0; } void Residuals::display(FILE* fpout) { if (fpout == NULL) { return; } fprintf(fpout," initial.normPrimal = %8.3e\n", initNormPrimal); fprintf(fpout," initial.normDual = %8.3e\n", initNormDual); fprintf(fpout," currentRes.normPrimal = %8.3e\n", normPrimal); fprintf(fpout," currentRes.normDual = %8.3e\n", normDual); } } // end of namespace 'sdpa'