TQpLinSolverDens.cxx

Go to the documentation of this file.
00001 // @(#)root/quadp:$Id: TQpLinSolverDens.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 // TQpLinSolverDens                                                     //
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 "TQpLinSolverDens.h"
00054 
00055 ClassImp(TQpLinSolverDens)
00056 
00057 //______________________________________________________________________________
00058 TQpLinSolverDens::TQpLinSolverDens(TQpProbDens *factory,TQpDataDens *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    data->PutQIntoAt(fKkt,0,      0);
00067    if (fMy > 0) data->PutAIntoAt(fKkt,fNx,    0);
00068    if (fMz > 0) data->PutCIntoAt(fKkt,fNx+fMy,0);
00069    for (Int_t ix = fNx; ix < fNx+fMy+fMz; ix++) {
00070       for (Int_t iy = fNx; iy < fNx+fMy+fMz; iy++)
00071          fKkt(ix,iy) = 0.0;
00072    }
00073 
00074    fSolveLU = TDecompLU(n);
00075 }
00076 
00077 
00078 //______________________________________________________________________________
00079 TQpLinSolverDens::TQpLinSolverDens(const TQpLinSolverDens &another) : TQpLinSolverBase(another)
00080 {
00081 // Copy constructor
00082 
00083    *this = another;
00084 }
00085 
00086 
00087 //______________________________________________________________________________
00088 void TQpLinSolverDens::Factor(TQpDataBase *prob,TQpVar *vars)
00089 {
00090 // Sets up the matrix for the main linear system in "augmented system" form.
00091 
00092    TQpLinSolverBase::Factor(prob,vars);
00093    fSolveLU.SetMatrix(fKkt);
00094 }
00095 
00096 
00097 //______________________________________________________________________________
00098 void TQpLinSolverDens::PutXDiagonal(TVectorD &xdiag)
00099 {
00100 // Places the diagonal resulting from the bounds on x into the augmented system matrix
00101 
00102    TMatrixDDiag diag(fKkt);
00103    for (Int_t i = 0; i < xdiag.GetNrows(); i++)
00104       diag[i] = xdiag[i];
00105 }
00106 
00107 
00108 //______________________________________________________________________________
00109 void TQpLinSolverDens::PutZDiagonal(TVectorD &zdiag)
00110 {
00111 // Places the diagonal resulting from the bounds on Cx into the augmented system matrix
00112 
00113    TMatrixDDiag diag(fKkt);
00114    for (Int_t i = 0; i < zdiag.GetNrows(); i++)
00115       diag[i+fNx+fMy] = zdiag[i];
00116 }
00117 
00118 
00119 //______________________________________________________________________________
00120 void TQpLinSolverDens::SolveCompressed(TVectorD &compressedRhs)
00121 {
00122 // Perform the actual solve using the factors produced in factor. 
00123 // rhs on input contains the aggregated right-hand side of the augmented system;
00124 //  on output contains the solution in aggregated form .
00125 
00126    fSolveLU.Solve(compressedRhs);
00127 }
00128 
00129 
00130 //______________________________________________________________________________
00131 TQpLinSolverDens &TQpLinSolverDens::operator=(const TQpLinSolverDens &source)
00132 {
00133 // Assignment operator
00134 
00135    if (this != &source) {
00136       TQpLinSolverBase::operator=(source);
00137       fKkt.ResizeTo(source.fKkt); fKkt = source.fKkt;
00138       fSolveLU = source.fSolveLU;
00139    }
00140    return *this;
00141 }

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