ROL
ROL_Sketch.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ************************************************************************
3 //
4 // Rapid Optimization Library (ROL) Package
5 // Copyright (2014) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact lead developers:
38 // Drew Kouri (dpkouri@sandia.gov) and
39 // Denis Ridzal (dridzal@sandia.gov)
40 //
41 // ************************************************************************
42 // @HEADER
43 
44 #ifndef ROL_SKETCH_H
45 #define ROL_SKETCH_H
46 
47 #include "ROL_Vector.hpp"
48 #include "ROL_LinearAlgebra.hpp"
49 #include "ROL_LAPACK.hpp"
50 #include "ROL_UpdateType.hpp"
51 #include "ROL_Types.hpp"
52 #include <random>
53 #include <chrono>
54 
62 namespace ROL {
63 
64 template <class Real>
65 class Sketch {
66 private:
67  // Sketch storage
68  std::vector<Ptr<Vector<Real>>> Y_;
69  LA::Matrix<Real> X_, Z_, C_;
70 
71  // Random dimension reduction maps
72  std::vector<Ptr<Vector<Real>>> Upsilon_, Phi_;
73  LA::Matrix<Real> Omega_, Psi_;
74 
76 
77  const Real orthTol_;
78  const int orthIt_;
79 
80  const bool truncate_;
81 
82  LAPACK<int,Real> lapack_;
83 
85 
86  Ptr<std::ostream> out_;
87 
88  Ptr<Elementwise::NormalRandom<Real>> nrand_;
89  Ptr<std::mt19937_64> gen_;
90  Ptr<std::normal_distribution<Real>> dist_;
91 
92  void mgs2(std::vector<Ptr<Vector<Real>>> &Y) const {
93  const int nvec(Y.size());
94  const Real zero(0), one(1);
95  Real rjj(0), rij(0);
96  std::vector<Real> normQ(nvec,0);
97  bool flag(true);
98  for (int j = 0; j < nvec; ++j) {
99  rjj = Y[j]->norm();
100  if (rjj > ROL_EPSILON<Real>()) { // Ignore update if Y[i] is zero.
101  for (int k = 0; k < orthIt_; ++k) {
102  for (int i = 0; i < j; ++i) {
103  rij = Y[i]->dot(*Y[j]);
104  Y[j]->axpy(-rij,*Y[i]);
105  }
106  normQ[j] = Y[j]->norm();
107  flag = true;
108  for (int i = 0; i < j; ++i) {
109  rij = std::abs(Y[i]->dot(*Y[j]));
110  if (rij > orthTol_*normQ[j]*normQ[i]) {
111  flag = false;
112  break;
113  }
114  }
115  if (flag) break;
116  }
117  }
118  rjj = normQ[j];
119  if (rjj > zero) Y[j]->scale(one/rjj);
120  }
121  }
122 
123  int LSsolver(LA::Matrix<Real> &A, LA::Matrix<Real> &B, bool trans = false) const {
124  int flag(0);
125  char TRANS = (trans ? 'T' : 'N');
126  int M = A.numRows();
127  int N = A.numCols();
128  int NRHS = B.numCols();
129  int LDA = M;
130  int LDB = std::max(M,N);
131  std::vector<Real> WORK(1);
132  int LWORK = -1;
133  int INFO;
134  lapack_.GELS(TRANS,M,N,NRHS,A.values(),LDA,B.values(),LDB,&WORK[0],LWORK,&INFO);
135  flag += INFO;
136  LWORK = static_cast<int>(WORK[0]);
137  WORK.resize(LWORK);
138  lapack_.GELS(TRANS,M,N,NRHS,A.values(),LDA,B.values(),LDB,&WORK[0],LWORK,&INFO);
139  flag += INFO;
140  return flag;
141  }
142 
143  int lowRankApprox(LA::Matrix<Real> &A, int r) const {
144  const Real zero(0);
145  char JOBU = 'S';
146  char JOBVT = 'S';
147  int M = A.numRows();
148  int N = A.numCols();
149  int K = std::min(M,N);
150  int LDA = M;
151  std::vector<Real> S(K);
152  LA::Matrix<Real> U(M,K);
153  int LDU = M;
154  LA::Matrix<Real> VT(K,N);
155  int LDVT = K;
156  std::vector<Real> WORK(1), WORK0(1);
157  int LWORK = -1;
158  int INFO;
159  lapack_.GESVD(JOBU,JOBVT,M,N,A.values(),LDA,&S[0],U.values(),LDU,VT.values(),LDVT,&WORK[0],LWORK,&WORK0[0],&INFO);
160  LWORK = static_cast<int>(WORK[0]);
161  WORK.resize(LWORK);
162  lapack_.GESVD(JOBU,JOBVT,M,N,A.values(),LDA,&S[0],U.values(),LDU,VT.values(),LDVT,&WORK[0],LWORK,&WORK0[0],&INFO);
163  for (int i = 0; i < M; ++i) {
164  for (int j = 0; j < N; ++j) {
165  A(i,j) = zero;
166  for (int k = 0; k < r; ++k) {
167  A(i,j) += S[k] * U(i,k) * VT(k,j);
168  }
169  }
170  }
171  return INFO;
172  }
173 
174  int computeP(void) {
175  int INFO(0);
176  if (!flagP_) {
177  // Solve least squares problem using LAPACK
178  int M = ncol_;
179  int N = k_;
180  int K = std::min(M,N);
181  int LDA = M;
182  std::vector<Real> TAU(K);
183  std::vector<Real> WORK(1);
184  int LWORK = -1;
185  // Compute QR factorization of X
186  lapack_.GEQRF(M,N,X_.values(),LDA,&TAU[0],&WORK[0],LWORK,&INFO);
187  LWORK = static_cast<int>(WORK[0]);
188  WORK.resize(LWORK);
189  lapack_.GEQRF(M,N,X_.values(),LDA,&TAU[0],&WORK[0],LWORK,&INFO);
190  // Generate Q
191  LWORK = -1;
192  lapack_.ORGQR(M,N,K,X_.values(),LDA,&TAU[0],&WORK[0],LWORK,&INFO);
193  LWORK = static_cast<int>(WORK[0]);
194  WORK.resize(LWORK);
195  lapack_.ORGQR(M,N,K,X_.values(),LDA,&TAU[0],&WORK[0],LWORK,&INFO);
196  flagP_ = true;
197  }
198  return INFO;
199  }
200 
201  int computeQ(void) {
202  if (!flagQ_) {
203  mgs2(Y_);
204  flagQ_ = true;
205  }
206  return 0;
207  }
208 
209  int computeC(void) {
210  int infoP(0), infoQ(0), infoLS1(0), infoLS2(0), infoLRA(0);
211  infoP = computeP();
212  infoQ = computeQ();
213  if (!flagC_) {
214  const Real zero(0);
215  LA::Matrix<Real> L(s_,k_), R(s_,k_);
216  for (int i = 0; i < s_; ++i) {
217  for (int j = 0; j < k_; ++j) {
218  L(i,j) = Phi_[i]->dot(*Y_[j]);
219  R(i,j) = zero;
220  for (int k = 0; k < ncol_; ++k) R(i,j) += Psi_(k,i) * X_(k,j);
221  }
222  }
223  // Solve least squares problems using LAPACK
224  infoLS1 = LSsolver(L,Z_,false);
225  LA::Matrix<Real> Zmat(s_,k_);
226  for (int i = 0; i < k_; ++i) {
227  for (int j = 0; j < s_; ++j) Zmat(j,i) = Z_(i,j);
228  }
229  infoLS2 = LSsolver(R,Zmat,false);
230  for (int i = 0; i < k_; ++i) {
231  for (int j = 0; j < k_; ++j) C_(j,i) = Zmat(i,j);
232  }
233  // Compute best rank r approximation
234  if (truncate_) infoLRA = lowRankApprox(C_,rank_);
235  // Set flag
236  flagC_ = true;
237  }
238  return std::abs(infoP)+std::abs(infoQ)+std::abs(infoLS1)
239  +std::abs(infoLS2)+std::abs(infoLRA);
240  }
241 
242 public:
243  virtual ~Sketch(void) {}
244 
245  Sketch(const Vector<Real> &x, int ncol, int rank,
246  Real orthTol = 1e-8, int orthIt = 2, bool truncate = false,
247  unsigned dom_seed = 0, unsigned rng_seed = 0)
248  : ncol_(ncol), orthTol_(orthTol), orthIt_(orthIt), truncate_(truncate),
249  flagP_(false), flagQ_(false), flagC_(false),
250  out_(nullPtr) {
251  Real mu(0), sig(1);
252  nrand_ = makePtr<Elementwise::NormalRandom<Real>>(mu,sig,dom_seed);
253  unsigned seed = rng_seed;
254  if (seed == 0) seed = std::chrono::system_clock::now().time_since_epoch().count();
255  gen_ = makePtr<std::mt19937_64>(seed);
256  dist_ = makePtr<std::normal_distribution<Real>>(mu,sig);
257  // Compute reduced dimensions
258  maxRank_ = std::min(ncol_, x.dimension());
259  rank_ = std::min(rank, maxRank_);
260  k_ = std::min(2*rank_+1, maxRank_);
261  s_ = std::min(2*k_ +1, maxRank_);
262  // Initialize matrix storage
263  Upsilon_.resize(k_); Phi_.resize(s_); Omega_.reshape(ncol_,k_); Psi_.reshape(ncol_,s_);
264  X_.reshape(ncol_,k_); Y_.resize(k_); Z_.reshape(s_,s_); C_.reshape(k_,k_);
265  for (int i = 0; i < k_; ++i) {
266  Y_[i] = x.clone();
267  Upsilon_[i] = x.clone();
268  }
269  for (int i = 0; i < s_; ++i) Phi_[i] = x.clone();
270  reset(true);
271  }
272 
273  void setStream(Ptr<std::ostream> &out) {
274  out_ = out;
275  }
276 
277  void reset(bool randomize = true) {
278  const Real zero(0);
279  X_.putScalar(zero); Z_.putScalar(zero); C_.putScalar(zero);
280  for (int i = 0; i < k_; ++i) Y_[i]->zero();
281  flagP_ = false; flagQ_ = false; flagC_ = false;
282  if (randomize) {
283  for (int i = 0; i < s_; ++i) {
284  Phi_[i]->applyUnary(*nrand_);
285  for (int j = 0; j < ncol_; ++j) Psi_(j,i) = (*dist_)(*gen_);
286  }
287  for (int i = 0; i < k_; ++i) {
288  Upsilon_[i]->applyUnary(*nrand_);
289  for (int j = 0; j < ncol_; ++j) Omega_(j,i) = (*dist_)(*gen_);
290  }
291  }
292  }
293 
294  void setRank(int rank) {
295  rank_ = std::min(rank, maxRank_);
296  // Compute reduced dimensions
297  int sold = s_, kold = k_;
298  k_ = std::min(2*rank_+1, maxRank_);
299  s_ = std::min(2*k_ +1, maxRank_);
300  Omega_.reshape(ncol_,k_); Psi_.reshape(ncol_,s_);
301  X_.reshape(ncol_,k_); Z_.reshape(s_,s_); C_.reshape(k_,k_);
302  if (s_ > sold) {
303  for (int i = sold; i < s_; ++i) Phi_.push_back(Phi_[0]->clone());
304  }
305  if (k_ > kold) {
306  for (int i = kold; i < k_; ++i) {
307  Y_.push_back(Y_[0]->clone());
308  Upsilon_.push_back(Upsilon_[0]->clone());
309  }
310  }
311  reset(true);
312  if ( out_ != nullPtr ) {
313  *out_ << std::string(80,'=') << std::endl;
314  *out_ << " ROL::Sketch::setRank" << std::endl;
315  *out_ << " **** Rank = " << rank_ << std::endl;
316  *out_ << " **** k = " << k_ << std::endl;
317  *out_ << " **** s = " << s_ << std::endl;
318  *out_ << std::string(80,'=') << std::endl;
319  }
320  }
321 
322  void update(void) {
323  reset(true);
324  }
325 
326  int advance(Real nu, const Vector<Real> &h, int col, Real eta = 1.0) {
327  // Check to see if col is less than ncol_
328  if ( col >= ncol_ || col < 0 ) return 1; // Input column index out of range!
329  if (!flagP_ && !flagQ_ && !flagC_) {
330  for (int i = 0; i < k_; ++i) {
331  // Update X
332  for (int j = 0; j < ncol_; ++j) X_(j,i) *= eta;
333  X_(col,i) += nu*h.dot(*Upsilon_[i]);
334  // Update Y
335  Y_[i]->scale(eta);
336  Y_[i]->axpy(nu*Omega_(col,i),h);
337  }
338  // Update Z
339  Real hphi(0);
340  for (int i = 0; i < s_; ++i) {
341  hphi = h.dot(*Phi_[i]);
342  for (int j = 0; j < s_; ++j) {
343  Z_(i,j) *= eta;
344  Z_(i,j) += nu*Psi_(col,j)*hphi;
345  }
346  }
347  if ( out_ != nullPtr ) {
348  *out_ << std::string(80,'=') << std::endl;
349  *out_ << " ROL::Sketch::advance" << std::endl;
350  *out_ << " **** col = " << col << std::endl;
351  *out_ << " **** norm(h) = " << h.norm() << std::endl;
352  *out_ << std::string(80,'=') << std::endl;
353  }
354  }
355  else {
356  // Reconstruct has already been called!
357  return 1;
358  }
359  return 0;
360  }
361 
362  int reconstruct(Vector<Real> &a, const int col) {
363  // Check to see if col is less than ncol_
364  if ( col >= ncol_ || col < 0 ) return 2; // Input column index out of range!
365  const Real zero(0);
366  int flag(0);
367  // Compute QR factorization of X store in X
368  flag = computeP();
369  if (flag > 0 ) return 3;
370  // Compute QR factorization of Y store in Y
371  flag = computeQ();
372  if (flag > 0 ) return 4;
373  // Compute (Phi Q)\Z/(Psi P)* store in C
374  flag = computeC();
375  if (flag > 0 ) return 5;
376  // Recover sketch
377  a.zero();
378  Real coeff(0);
379  for (int i = 0; i < k_; ++i) {
380  coeff = zero;
381  for (int j = 0; j < k_; ++j) coeff += C_(i,j) * X_(col,j);
382  a.axpy(coeff,*Y_[i]);
383  }
384  if ( out_ != nullPtr ) {
385  *out_ << std::string(80,'=') << std::endl;
386  *out_ << " ROL::Sketch::reconstruct" << std::endl;
387  *out_ << " **** col = " << col << std::endl;
388  *out_ << " **** norm(a) = " << a.norm() << std::endl;
389  *out_ << std::string(80,'=') << std::endl;
390  }
391  return 0;
392  }
393 
394  bool test(const int rank, std::ostream &outStream = std::cout, const int verbosity = 0) {
395  const Real one(1), tol(std::sqrt(ROL_EPSILON<Real>()));
396  using seed_type = std::mt19937_64::result_type;
397  seed_type const seed = 123;
398  std::mt19937_64 eng{seed};
399  std::uniform_real_distribution<Real> dist(static_cast<Real>(0),static_cast<Real>(1));
400  // Initialize low rank factors
401  std::vector<Ptr<Vector<Real>>> U(rank);
402  LA::Matrix<Real> V(ncol_,rank);
403  for (int i = 0; i < rank; ++i) {
404  U[i] = Y_[0]->clone();
405  U[i]->randomize(-one,one);
406  for (int j = 0; j < ncol_; ++j) V(j,i) = dist(eng);
407  }
408  // Initialize A and build sketch
409  update();
410  std::vector<Ptr<Vector<Real>>> A(ncol_);
411  for (int i = 0; i < ncol_; ++i) {
412  A[i] = Y_[0]->clone(); A[i]->zero();
413  for (int j = 0; j < rank; ++j) {
414  A[i]->axpy(V(i,j),*U[j]);
415  }
416  advance(one,*A[i],i,one);
417  }
418  // Test QR decomposition of X
419  bool flagP = testP(outStream, verbosity);
420  // Test QR decomposition of Y
421  bool flagQ = testQ(outStream, verbosity);
422  // Test reconstruction of A
423  Real nerr(0), maxerr(0);
424  Ptr<Vector<Real>> err = Y_[0]->clone();
425  for (int i = 0; i < ncol_; ++i) {
426  reconstruct(*err,i);
427  err->axpy(-one,*A[i]);
428  nerr = err->norm();
429  maxerr = (nerr > maxerr ? nerr : maxerr);
430  }
431  if (verbosity > 0) {
432  std::ios_base::fmtflags oflags(outStream.flags());
433  outStream << std::scientific << std::setprecision(3) << std::endl;
434  outStream << " TEST RECONSTRUCTION: Max Error = "
435  << std::setw(12) << std::right << maxerr
436  << std::endl << std::endl;
437  outStream.flags(oflags);
438  }
439  return flagP & flagQ & (maxerr < tol ? true : false);
440  }
441 
442 private:
443 
444  // Test functions
445  bool testQ(std::ostream &outStream = std::cout, const int verbosity = 0) {
446  const Real one(1), tol(std::sqrt(ROL_EPSILON<Real>()));
447  computeQ();
448  Real qij(0), err(0), maxerr(0);
449  std::ios_base::fmtflags oflags(outStream.flags());
450  if (verbosity > 0) outStream << std::scientific << std::setprecision(3);
451  if (verbosity > 1) {
452  outStream << std::endl
453  << " Printing Q'Q...This should be approximately equal to I"
454  << std::endl << std::endl;
455  }
456  for (int i = 0; i < k_; ++i) {
457  for (int j = 0; j < k_; ++j) {
458  qij = Y_[i]->dot(*Y_[j]);
459  err = (i==j ? std::abs(qij-one) : std::abs(qij));
460  maxerr = (err > maxerr ? err : maxerr);
461  if (verbosity > 1) outStream << std::setw(12) << std::right << qij;
462  }
463  if (verbosity > 1) outStream << std::endl;
464  if (maxerr > tol) break;
465  }
466  if (verbosity > 0) {
467  outStream << std::endl << " TEST ORTHOGONALIZATION: Max Error = "
468  << std::setw(12) << std::right << maxerr
469  << std::endl;
470  outStream.flags(oflags);
471  }
472  return (maxerr < tol ? true : false);
473  }
474 
475  bool testP(std::ostream &outStream = std::cout, const int verbosity = 0) {
476  const Real zero(0), one(1), tol(std::sqrt(ROL_EPSILON<Real>()));
477  computeP();
478  Real qij(0), err(0), maxerr(0);
479  std::ios_base::fmtflags oflags(outStream.flags());
480  if (verbosity > 0) outStream << std::scientific << std::setprecision(3);
481  if (verbosity > 1) {
482  outStream << std::endl
483  << " Printing P'P...This should be approximately equal to I"
484  << std::endl << std::endl;
485  }
486  for (int i = 0; i < k_; ++i) {
487  for (int j = 0; j < k_; ++j) {
488  qij = zero;
489  for (int k = 0; k < ncol_; ++k) qij += X_(k,i) * X_(k,j);
490  err = (i==j ? std::abs(qij-one) : std::abs(qij));
491  maxerr = (err > maxerr ? err : maxerr);
492  if (verbosity > 1) outStream << std::setw(12) << std::right << qij;
493  }
494  if (verbosity > 1) outStream << std::endl;
495  if (maxerr > tol) break;
496  }
497  if (verbosity > 0) {
498  outStream << std::endl << " TEST ORTHOGONALIZATION: Max Error = "
499  << std::setw(12) << std::right << maxerr
500  << std::endl;
501  outStream.flags(oflags);
502  }
503  return (maxerr < tol ? true : false);
504  }
505 
506 }; // class Sketch
507 
508 } // namespace ROL
509 
510 #endif
int computeC(void)
Definition: ROL_Sketch.hpp:209
void setStream(Ptr< std::ostream > &out)
Definition: ROL_Sketch.hpp:273
Ptr< std::normal_distribution< Real > > dist_
Definition: ROL_Sketch.hpp:90
const bool truncate_
Definition: ROL_Sketch.hpp:80
std::vector< Ptr< Vector< Real > > > Y_
Definition: ROL_Sketch.hpp:68
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
virtual int dimension() const
Return dimension of the vector space.
Definition: ROL_Vector.hpp:196
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
Definition: ROL_Vector.hpp:153
const Real orthTol_
Definition: ROL_Sketch.hpp:77
int computeP(void)
Definition: ROL_Sketch.hpp:174
int reconstruct(Vector< Real > &a, const int col)
Definition: ROL_Sketch.hpp:362
Ptr< std::mt19937_64 > gen_
Definition: ROL_Sketch.hpp:89
Contains definitions of custom data types in ROL.
Provides an interface for randomized sketching.
Definition: ROL_Sketch.hpp:65
int LSsolver(LA::Matrix< Real > &A, LA::Matrix< Real > &B, bool trans=false) const
Definition: ROL_Sketch.hpp:123
std::vector< Ptr< Vector< Real > > > Upsilon_
Definition: ROL_Sketch.hpp:72
virtual void zero()
Set to zero vector.
Definition: ROL_Vector.hpp:167
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:80
Ptr< Elementwise::NormalRandom< Real > > nrand_
Definition: ROL_Sketch.hpp:88
void update(void)
Definition: ROL_Sketch.hpp:322
virtual Real dot(const Vector &x) const =0
Compute where .
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0_ zero()
Vector< Real > V
Sketch(const Vector< Real > &x, int ncol, int rank, Real orthTol=1e-8, int orthIt=2, bool truncate=false, unsigned dom_seed=0, unsigned rng_seed=0)
Definition: ROL_Sketch.hpp:245
bool testQ(std::ostream &outStream=std::cout, const int verbosity=0)
Definition: ROL_Sketch.hpp:445
LA::Matrix< Real > Psi_
Definition: ROL_Sketch.hpp:73
void reset(bool randomize=true)
Definition: ROL_Sketch.hpp:277
void mgs2(std::vector< Ptr< Vector< Real >>> &Y) const
Definition: ROL_Sketch.hpp:92
LA::Matrix< Real > C_
Definition: ROL_Sketch.hpp:69
int computeQ(void)
Definition: ROL_Sketch.hpp:201
LA::Matrix< Real > Z_
Definition: ROL_Sketch.hpp:69
bool testP(std::ostream &outStream=std::cout, const int verbosity=0)
Definition: ROL_Sketch.hpp:475
bool test(const int rank, std::ostream &outStream=std::cout, const int verbosity=0)
Definition: ROL_Sketch.hpp:394
LAPACK< int, Real > lapack_
Definition: ROL_Sketch.hpp:82
LA::Matrix< Real > Omega_
Definition: ROL_Sketch.hpp:73
int advance(Real nu, const Vector< Real > &h, int col, Real eta=1.0)
Definition: ROL_Sketch.hpp:326
Ptr< std::ostream > out_
Definition: ROL_Sketch.hpp:86
LA::Matrix< Real > X_
Definition: ROL_Sketch.hpp:69
virtual Real norm() const =0
Returns where .
std::vector< Ptr< Vector< Real > > > Phi_
Definition: ROL_Sketch.hpp:72
virtual ~Sketch(void)
Definition: ROL_Sketch.hpp:243
void setRank(int rank)
Definition: ROL_Sketch.hpp:294
const int orthIt_
Definition: ROL_Sketch.hpp:78
int lowRankApprox(LA::Matrix< Real > &A, int r) const
Definition: ROL_Sketch.hpp:143