TQpLinSolverSparse.cxx

Go to the documentation of this file.
00001 // @(#)root/quadp:$Id: TQpLinSolverSparse.cxx 20882 2007-11-19 11:31:26Z rdm $
00002 // Author: Eddy Offermann   May 2004
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 /*************************************************************************
00013  * Parts of this file are copied from the OOQP distribution and          *
00014  * are subject to the following license:                                 *
00015  *                                                                       *
00016  * COPYRIGHT 2001 UNIVERSITY OF CHICAGO                                  *
00017  *                                                                       *
00018  * The copyright holder hereby grants you royalty-free rights to use,    *
00019  * reproduce, prepare derivative works, and to redistribute this software*
00020  * to others, provided that any changes are clearly documented. This     *
00021  * software was authored by:                                             *
00022  *                                                                       *
00023  *   E. MICHAEL GERTZ      gertz@mcs.anl.gov                             *
00024  *   Mathematics and Computer Science Division                           *
00025  *   Argonne National Laboratory                                         *
00026  *   9700 S. Cass Avenue                                                 *
00027  *   Argonne, IL 60439-4844                                              *
00028  *                                                                       *
00029  *   STEPHEN J. WRIGHT     swright@cs.wisc.edu                           *
00030  *   Computer Sciences Department                                        *
00031  *   University of Wisconsin                                             *
00032  *   1210 West Dayton Street                                             *
00033  *   Madison, WI 53706   FAX: (608)262-9777                              *
00034  *                                                                       *
00035  * Any questions or comments may be directed to one of the authors.      *
00036  *                                                                       *
00037  * ARGONNE NATIONAL LABORATORY (ANL), WITH FACILITIES IN THE STATES OF   *
00038  * ILLINOIS AND IDAHO, IS OWNED BY THE UNITED STATES GOVERNMENT, AND     *
00039  * OPERATED BY THE UNIVERSITY OF CHICAGO UNDER PROVISION OF A CONTRACT   *
00040  * WITH THE DEPARTMENT OF ENERGY.                                        *
00041  *************************************************************************/
00042 
00043 //////////////////////////////////////////////////////////////////////////
00044 //                                                                      //
00045 // TQpLinSolverSparse                                                   //
00046 //                                                                      //
00047 // Implements the aspects of the solvers for dense general QP           //
00048 // formulation that are specific to the dense case.                     //
00049 //                                                                      //
00050 //////////////////////////////////////////////////////////////////////////
00051 
00052 #include "Riostream.h"
00053 #include "TQpLinSolverSparse.h"
00054 
00055 ClassImp(TQpLinSolverSparse)
00056 
00057 //______________________________________________________________________________
00058 TQpLinSolverSparse::TQpLinSolverSparse(TQpProbSparse *factory,TQpDataSparse *data) :
00059                     TQpLinSolverBase(factory,data)
00060 {
00061 // Constructor
00062 
00063    const Int_t n = factory->fNx+factory->fMy+factory->fMz;
00064    fKkt.ResizeTo(n,n);
00065 
00066    if (fMy > 0) data->PutAIntoAt(fKkt,fNx,    0);
00067    if (fMz > 0) data->PutCIntoAt(fKkt,fNx+fMy,0);
00068 
00069    // trick to make sure that A and C are inserted symmetrically
00070    if (fMy > 0 || fMz > 0) {
00071       TMatrixDSparse tmp(TMatrixDSparse::kTransposed,fKkt);
00072       fKkt += tmp;
00073    }
00074 
00075    data->PutQIntoAt(fKkt,0,0);
00076 }
00077 
00078 
00079 //______________________________________________________________________________
00080 TQpLinSolverSparse::TQpLinSolverSparse(const TQpLinSolverSparse &another) :
00081 TQpLinSolverBase(another)
00082 {
00083 // Copy constructor
00084 
00085    *this = another;
00086 }
00087 
00088 
00089 //______________________________________________________________________________
00090 void TQpLinSolverSparse::Factor(TQpDataBase *prob,TQpVar *vars)
00091 {
00092 // Sets up the matrix for the main linear system in "augmented system" form.
00093 
00094    TQpLinSolverBase::Factor(prob,vars);
00095    fSolveSparse.SetMatrix(fKkt);
00096 }
00097 
00098 
00099 //______________________________________________________________________________
00100 void TQpLinSolverSparse::PutXDiagonal(TVectorD &xdiag)
00101 {
00102 // Places the diagonal resulting from the bounds on x into the augmented system matrix
00103 
00104    TMatrixDSparseDiag diag(fKkt);
00105    for (Int_t i = 0; i < xdiag.GetNrows(); i++)
00106       diag[i] = xdiag[i];
00107 }
00108 
00109 
00110 //______________________________________________________________________________
00111 void TQpLinSolverSparse::PutZDiagonal(TVectorD &zdiag)
00112 {
00113 // Places the diagonal resulting from the bounds on Cx into the augmented system matrix
00114 
00115    TMatrixDSparseDiag diag(fKkt);
00116    for (Int_t i = 0; i < zdiag.GetNrows(); i++)
00117       diag[i+fNx+fMy] = zdiag[i];
00118 }
00119 
00120 
00121 //______________________________________________________________________________
00122 void TQpLinSolverSparse::SolveCompressed(TVectorD &compressedRhs)
00123 {
00124 // Perform the actual solve using the factors produced in factor.
00125 // rhs on input contains the aggregated right-hand side of the augmented system;
00126 //  on output contains the solution in aggregated form .
00127 
00128    fSolveSparse.Solve(compressedRhs);
00129 }
00130 
00131 
00132 //______________________________________________________________________________
00133 TQpLinSolverSparse &TQpLinSolverSparse::operator=(const TQpLinSolverSparse &source)
00134 {
00135 // Assignment operator
00136 
00137    if (this != &source) {
00138       TQpLinSolverBase::operator=(source);
00139       fKkt.ResizeTo(source.fKkt); fKkt = source.fKkt;
00140       fSolveSparse = source.fSolveSparse;
00141    }
00142    return *this;
00143 }

Generated on Tue Jul 5 14:37:59 2011 for ROOT_528-00b_version by  doxygen 1.5.1