Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TQpLinSolverDens.cxx
Go to the documentation of this file.
1 // @(#)root/quadp:$Id$
2 // Author: Eddy Offermann May 2004
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 /*************************************************************************
13  * Parts of this file are copied from the OOQP distribution and *
14  * are subject to the following license: *
15  * *
16  * COPYRIGHT 2001 UNIVERSITY OF CHICAGO *
17  * *
18  * The copyright holder hereby grants you royalty-free rights to use, *
19  * reproduce, prepare derivative works, and to redistribute this software*
20  * to others, provided that any changes are clearly documented. This *
21  * software was authored by: *
22  * *
23  * E. MICHAEL GERTZ gertz@mcs.anl.gov *
24  * Mathematics and Computer Science Division *
25  * Argonne National Laboratory *
26  * 9700 S. Cass Avenue *
27  * Argonne, IL 60439-4844 *
28  * *
29  * STEPHEN J. WRIGHT swright@cs.wisc.edu *
30  * Computer Sciences Department *
31  * University of Wisconsin *
32  * 1210 West Dayton Street *
33  * Madison, WI 53706 FAX: (608)262-9777 *
34  * *
35  * Any questions or comments may be directed to one of the authors. *
36  * *
37  * ARGONNE NATIONAL LABORATORY (ANL), WITH FACILITIES IN THE STATES OF *
38  * ILLINOIS AND IDAHO, IS OWNED BY THE UNITED STATES GOVERNMENT, AND *
39  * OPERATED BY THE UNIVERSITY OF CHICAGO UNDER PROVISION OF A CONTRACT *
40  * WITH THE DEPARTMENT OF ENERGY. *
41  *************************************************************************/
42 
43 ////////////////////////////////////////////////////////////////////////////////
44 ///
45 /// \class TQpLinSolverDens
46 ///
47 /// Implements the aspects of the solvers for dense general QP
48 /// formulation that are specific to the dense case.
49 ///
50 ////////////////////////////////////////////////////////////////////////////////
51 
52 #include "Riostream.h"
53 #include "TQpLinSolverDens.h"
54 
55 ClassImp(TQpLinSolverDens);
56 
57 ////////////////////////////////////////////////////////////////////////////////
58 /// Constructor
59 
60 TQpLinSolverDens::TQpLinSolverDens(TQpProbDens *factory,TQpDataDens *data) :
61  TQpLinSolverBase(factory,data)
62 {
63  const Int_t n = factory->fNx+factory->fMy+factory->fMz;
64  fKkt.ResizeTo(n,n);
65 
66  data->PutQIntoAt(fKkt,0, 0);
67  if (fMy > 0) data->PutAIntoAt(fKkt,fNx, 0);
68  if (fMz > 0) data->PutCIntoAt(fKkt,fNx+fMy,0);
69  for (Int_t ix = fNx; ix < fNx+fMy+fMz; ix++) {
70  for (Int_t iy = fNx; iy < fNx+fMy+fMz; iy++)
71  fKkt(ix,iy) = 0.0;
72  }
73 
74  fSolveLU = TDecompLU(n);
75 }
76 
77 
78 ////////////////////////////////////////////////////////////////////////////////
79 /// Copy constructor
80 
81 TQpLinSolverDens::TQpLinSolverDens(const TQpLinSolverDens &another) : TQpLinSolverBase(another)
82 {
83  *this = another;
84 }
85 
86 
87 ////////////////////////////////////////////////////////////////////////////////
88 /// Sets up the matrix for the main linear system in "augmented system" form.
89 
90 void TQpLinSolverDens::Factor(TQpDataBase *prob,TQpVar *vars)
91 {
92  TQpLinSolverBase::Factor(prob,vars);
93  fSolveLU.SetMatrix(fKkt);
94 }
95 
96 
97 ////////////////////////////////////////////////////////////////////////////////
98 /// Places the diagonal resulting from the bounds on x into the augmented system matrix
99 
100 void TQpLinSolverDens::PutXDiagonal(TVectorD &xdiag)
101 {
102  TMatrixDDiag diag(fKkt);
103  for (Int_t i = 0; i < xdiag.GetNrows(); i++)
104  diag[i] = xdiag[i];
105 }
106 
107 
108 ////////////////////////////////////////////////////////////////////////////////
109 /// Places the diagonal resulting from the bounds on Cx into the augmented system matrix
110 
111 void TQpLinSolverDens::PutZDiagonal(TVectorD &zdiag)
112 {
113  TMatrixDDiag diag(fKkt);
114  for (Int_t i = 0; i < zdiag.GetNrows(); i++)
115  diag[i+fNx+fMy] = zdiag[i];
116 }
117 
118 
119 ////////////////////////////////////////////////////////////////////////////////
120 /// Perform the actual solve using the factors produced in factor.
121 /// rhs on input contains the aggregated right-hand side of the augmented system;
122 /// on output contains the solution in aggregated form .
123 
124 void TQpLinSolverDens::SolveCompressed(TVectorD &compressedRhs)
125 {
126  fSolveLU.Solve(compressedRhs);
127 }
128 
129 
130 ////////////////////////////////////////////////////////////////////////////////
131 /// Assignment operator
132 
133 TQpLinSolverDens &TQpLinSolverDens::operator=(const TQpLinSolverDens &source)
134 {
135  if (this != &source) {
136  TQpLinSolverBase::operator=(source);
137  fKkt.ResizeTo(source.fKkt); fKkt = source.fKkt;
138  fSolveLU = source.fSolveLU;
139  }
140  return *this;
141 }