Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TQpProbDens.cxx
Go to the documentation of this file.
1// @(#)root/matrix:$Id$
2// Authors: Fons Rademakers, Eddy Offermann Mar 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#include "TQpProbDens.h"
44#include "TMatrixD.h"
45#include "TQpLinSolverDens.h"
46
47////////////////////////////////////////////////////////////////////////////////
48///
49/// \class TQpProbDens
50///
51/// dense matrix problem formulation
52///
53////////////////////////////////////////////////////////////////////////////////
54
55
56////////////////////////////////////////////////////////////////////////////////
57/// Constructor
58
61{
62 // We do not want more constrains than variables
63 R__ASSERT(nx-my-mz > 0);
64}
65
66
67////////////////////////////////////////////////////////////////////////////////
68/// Copy constructor
69
74
75
76////////////////////////////////////////////////////////////////////////////////
77/// Setup the data
78
80 Double_t *Q,
81 Double_t *xlo,Bool_t *ixlo,
82 Double_t *xup,Bool_t *ixup,
83 Double_t *A, Double_t *bA,
84 Double_t *C,
87{
88 TVectorD vc ; vc .Use(fNx,c);
89 TMatrixDSym mQ ; mQ .Use(fNx,Q);
90 TVectorD vxlo; vxlo.Use(fNx,xlo);
91 TVectorD vxup; vxup.Use(fNx,xup);
92 TMatrixD mA ;
94 if (fMy > 0) {
95 mA .Use(fMy,fNx,A);
96 vbA .Use(fMy,bA);
97 }
98 TMatrixD mC ;
101 if (fMz > 0) {
102 mC .Use(fMz,fNx,C);
103 vclo.Use(fMz,clo);
104 vcup.Use(fMz,cup);
105 }
106
109 for (Int_t ix = 0; ix < fNx; ix++) {
110 vixlo[ix] = (ixlo[ix]) ? 1.0 : 0.0;
111 vixup[ix] = (ixup[ix]) ? 1.0 : 0.0;
112 }
113
116 for (Int_t ic = 0; ic < fMz; ic++) {
117 viclo[ic] = (iclo[ic]) ? 1.0 : 0.0;
118 vicup[ic] = (icup[ic]) ? 1.0 : 0.0;
119 }
120
123
124 return data;
125}
126
127
128////////////////////////////////////////////////////////////////////////////////
129/// Setup the data
130
133 TVectorD &xlo, TVectorD &ixlo,
134 TVectorD &xup, TVectorD &ixup,
139{
141 TMatrixD &mA = (TMatrixD &) A_in;
142 TMatrixD &mC = (TMatrixD &) C_in;
143
144 R__ASSERT(mQ.GetNrows() == fNx && mQ.GetNcols() == fNx);
145 if (fMy > 0) R__ASSERT(mA.GetNrows() == fMy && mA.GetNcols() == fNx);
146 else R__ASSERT(mA.GetNrows() == fMy);
147 if (fMz > 0) R__ASSERT(mC.GetNrows() == fMz && mC.GetNcols() == fNx);
148 else R__ASSERT(mC.GetNrows() == fMz);
149
150 R__ASSERT(c.GetNrows() == fNx);
151 R__ASSERT(xlo.GetNrows() == fNx);
152 R__ASSERT(ixlo.GetNrows() == fNx);
153 R__ASSERT(xup.GetNrows() == fNx);
154 R__ASSERT(ixup.GetNrows() == fNx);
155
156 R__ASSERT(bA.GetNrows() == fMy);
157 R__ASSERT(clo.GetNrows() == fMz);
158 R__ASSERT(iclo.GetNrows() == fMz);
159 R__ASSERT(cup.GetNrows() == fMz);
160 R__ASSERT(icup.GetNrows() == fMz);
161
163
164 return data;
165}
166
167
168////////////////////////////////////////////////////////////////////////////////
169/// Setup the residuals
170
172{
174 return new TQpResidual(fNx,fMy,fMz,data->fXloIndex,data->fXupIndex,data->fCloIndex,data->fCupIndex);
175}
176
177
178////////////////////////////////////////////////////////////////////////////////
179/// Setup the variables
180
182{
184
185 return new TQpVar(fNx,fMy,fMz,data->fXloIndex,data->fXupIndex,data->fCloIndex,data->fCupIndex);
186}
187
188
189////////////////////////////////////////////////////////////////////////////////
190/// Setup the linear solver
191
197
198
199////////////////////////////////////////////////////////////////////////////////
200/// Assembles a single vector object from three given vectors .
201/// rhs_out (output) final joined vector
202/// rhs1_in (input) first part of rhs
203/// rhs2_in (input) middle part of rhs
204/// rhs3_in (input) last part of rhs .
205
207{
208 rhs.SetSub(0,rhs1_in);
209 if (fMy > 0) rhs.SetSub(fNx, rhs2_in);
210 if (fMz > 0) rhs.SetSub(fNx+fMy,rhs3_in);
211}
212
213
214////////////////////////////////////////////////////////////////////////////////
215/// Extracts three component vectors from a given aggregated vector.
216/// vars_in (input) aggregated vector
217/// x_in (output) first part of vars
218/// y_in (output) middle part of vars
219/// z_in (output) last part of vars
220
222{
223 x_in = vars_in.GetSub(0,fNx-1);
224 if (fMy > 0) y_in = vars_in.GetSub(fNx, fNx+fMy-1);
225 if (fMz > 0) z_in = vars_in.GetSub(fNx+fMy,fNx+fMy+fMz-1);
226}
227
228
229////////////////////////////////////////////////////////////////////////////////
230/// Create a random QP problem
231
233{
234 data = new TQpDataDens(fNx,fMy,fMz);
235 soln = this->MakeVariables(data);
236 data->DataRandom(soln->fX,soln->fY,soln->fZ,soln->fS);
237}
238
239
240////////////////////////////////////////////////////////////////////////////////
241/// Assignment operator
242
244{
245 if (this != &source) {
247 }
248 return *this;
249}
#define c(i)
Definition RSha256.hxx:101
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Definition TError.h:125
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Data for the general QP formulation.
Definition TQpDataBase.h:61
Data for the dense QP formulation.
Definition TQpDataDens.h:63
Implementation of main solver for linear systems.
Implements the aspects of the solvers for dense general QP formulation that are specific to the dense...
default general problem formulation:
Definition TQpProbBase.h:89
TQpProbBase & operator=(const TQpProbBase &source)
Assignment operator.
dense matrix problem formulation
Definition TQpProbDens.h:61
TQpVar * MakeVariables(const TQpDataBase *data) override
Setup the variables.
void JoinRHS(TVectorD &rhs_in, TVectorD &rhs1_in, TVectorD &rhs2_in, TVectorD &rhs3_in) override
Assembles a single vector object from three given vectors .
virtual TQpDataBase * MakeData(Double_t *c, Double_t *Q, Double_t *xlo, Bool_t *ixlo, Double_t *xup, Bool_t *ixup, Double_t *A, Double_t *bA, Double_t *C, Double_t *clo, Bool_t *iclo, Double_t *cup, Bool_t *icup)
Setup the data.
TQpProbDens & operator=(const TQpProbDens &source)
Assignment operator.
void MakeRandomData(TQpDataDens *&data, TQpVar *&soln, Int_t nnzQ, Int_t nnzA, Int_t nnzC)
Create a random QP problem.
TQpLinSolverBase * MakeLinSys(const TQpDataBase *data) override
Setup the linear solver.
void SeparateVars(TVectorD &x_in, TVectorD &y_in, TVectorD &z_in, TVectorD &vars_in) override
Extracts three component vectors from a given aggregated vector.
TQpResidual * MakeResiduals(const TQpDataBase *data) override
Setup the residuals.
The Residuals class calculates and stores the quantities that appear on the right-hand side of the li...
Definition TQpResidual.h:62
Class containing the variables for the general QP formulation.
Definition TQpVar.h:60
Int_t GetNrows() const
Definition TVectorT.h:75