Subversion Repositories slepc-dev

Rev

Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
525 dsic.upv.es!antodo 1
/*
545 dsic.upv.es!jroman 2
      EPS routines related to monitors.
1376 slepc 3
 
4
   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1672 slepc 5
   SLEPc - Scalable Library for Eigenvalue Problem Computations
2116 eromero 6
   Copyright (c) 2002-2010, Universidad Politecnica de Valencia, Spain
1376 slepc 7
 
1672 slepc 8
   This file is part of SLEPc.
9
 
10
   SLEPc is free software: you can redistribute it and/or modify it under  the
11
   terms of version 3 of the GNU Lesser General Public License as published by
12
   the Free Software Foundation.
13
 
14
   SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
15
   WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
16
   FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
17
   more details.
18
 
19
   You  should have received a copy of the GNU Lesser General  Public  License
20
   along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
1376 slepc 21
   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
525 dsic.upv.es!antodo 22
*/
1376 slepc 23
 
2283 jroman 24
#include <private/epsimpl.h>   /*I "slepceps.h" I*/
525 dsic.upv.es!antodo 25
 
26
#undef __FUNCT__  
2313 jroman 27
#define __FUNCT__ "EPSMonitor"
28
/*
29
   Runs the user provided monitor routines, if any.
30
*/
31
PetscErrorCode EPSMonitor(EPS eps,PetscInt it,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest)
32
{
33
  PetscErrorCode ierr;
34
  PetscInt       i,n = eps->numbermonitors;
35
 
36
  PetscFunctionBegin;
37
  for (i=0;i<n;i++) {
38
    ierr = (*eps->monitor[i])(eps,it,nconv,eigr,eigi,errest,nest,eps->monitorcontext[i]);CHKERRQ(ierr);
39
  }
40
  PetscFunctionReturn(0);
41
}
42
 
43
#undef __FUNCT__  
1331 slepc 44
#define __FUNCT__ "EPSMonitorSet"
525 dsic.upv.es!antodo 45
/*@C
1331 slepc 46
   EPSMonitorSet - Sets an ADDITIONAL function to be called at every
525 dsic.upv.es!antodo 47
   iteration to monitor the error estimates for each requested eigenpair.
48
 
2328 jroman 49
   Logically Collective on EPS
525 dsic.upv.es!antodo 50
 
51
   Input Parameters:
52
+  eps     - eigensolver context obtained from EPSCreate()
1021 slepc 53
.  monitor - pointer to function (if this is PETSC_NULL, it turns off monitoring)
1287 slepc 54
.  mctx    - [optional] context for private data for the
525 dsic.upv.es!antodo 55
             monitor routine (use PETSC_NULL if no context is desired)
1287 slepc 56
-  monitordestroy - [optional] routine that frees monitor context
57
          (may be PETSC_NULL)
525 dsic.upv.es!antodo 58
 
59
   Calling Sequence of monitor:
617 dsic.upv.es!antodo 60
$     monitor (EPS eps, int its, int nconv, PetscScalar *eigr, PetscScalar *eigi, PetscReal* errest, int nest, void *mctx)
525 dsic.upv.es!antodo 61
 
62
+  eps    - eigensolver context obtained from EPSCreate()
63
.  its    - iteration number
64
.  nconv  - number of converged eigenpairs
617 dsic.upv.es!antodo 65
.  eigr   - real part of the eigenvalues
66
.  eigi   - imaginary part of the eigenvalues
663 dsic.upv.es!antodo 67
.  errest - relative error estimates for each eigenpair
525 dsic.upv.es!antodo 68
.  nest   - number of error estimates
1331 slepc 69
-  mctx   - optional monitoring context, as set by EPSMonitorSet()
525 dsic.upv.es!antodo 70
 
71
   Options Database Keys:
2048 eromero 72
+    -eps_monitor          - print only the first error estimate
73
.    -eps_monitor_all      - print error estimates at each iteration
74
.    -eps_monitor_conv     - print the eigenvalue approximations only when
1811 jroman 75
      convergence has been reached
2048 eromero 76
.    -eps_monitor_draw     - sets line graph monitor for the first unconverged
77
      approximate eigenvalue
78
.    -eps_monitor_draw_all - sets line graph monitor for all unconverged
79
      approximate eigenvalue
80
-    -eps_monitor_cancel   - cancels all monitors that have been hardwired into
1331 slepc 81
      a code by calls to EPSMonitorSet(), but does not cancel those set via
525 dsic.upv.es!antodo 82
      the options database.
83
 
84
   Notes:  
85
   Several different monitoring routines may be set by calling
1331 slepc 86
   EPSMonitorSet() multiple times; all will be called in the
525 dsic.upv.es!antodo 87
   order in which they were set.
88
 
89
   Level: intermediate
90
 
2134 eromero 91
.seealso: EPSMonitorFirst(), EPSMonitorAll(), EPSMonitorLG(), EPSMonitorLGAll(), EPSMonitorCancel()
525 dsic.upv.es!antodo 92
@*/
2351 jroman 93
PetscErrorCode EPSMonitorSet(EPS eps,PetscErrorCode (*monitor)(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*),void *mctx,PetscErrorCode (*monitordestroy)(void**))
525 dsic.upv.es!antodo 94
{
95
  PetscFunctionBegin;
2213 jroman 96
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
525 dsic.upv.es!antodo 97
  if (eps->numbermonitors >= MAXEPSMONITORS) {
2214 jroman 98
    SETERRQ(((PetscObject)eps)->comm,PETSC_ERR_ARG_OUTOFRANGE,"Too many EPS monitors set");
525 dsic.upv.es!antodo 99
  }
100
  eps->monitor[eps->numbermonitors]           = monitor;
1287 slepc 101
  eps->monitorcontext[eps->numbermonitors]    = (void*)mctx;
102
  eps->monitordestroy[eps->numbermonitors++]  = monitordestroy;
525 dsic.upv.es!antodo 103
  PetscFunctionReturn(0);
104
}
105
 
106
#undef __FUNCT__  
1331 slepc 107
#define __FUNCT__ "EPSMonitorCancel"
1021 slepc 108
/*@
1331 slepc 109
   EPSMonitorCancel - Clears all monitors for an EPS object.
525 dsic.upv.es!antodo 110
 
2328 jroman 111
   Logically Collective on EPS
525 dsic.upv.es!antodo 112
 
113
   Input Parameters:
114
.  eps - eigensolver context obtained from EPSCreate()
115
 
116
   Options Database Key:
1331 slepc 117
.    -eps_monitor_cancel - Cancels all monitors that have been hardwired
118
      into a code by calls to EPSMonitorSet(),
525 dsic.upv.es!antodo 119
      but does not cancel those set via the options database.
120
 
121
   Level: intermediate
122
 
1331 slepc 123
.seealso: EPSMonitorSet()
525 dsic.upv.es!antodo 124
@*/
1331 slepc 125
PetscErrorCode EPSMonitorCancel(EPS eps)
525 dsic.upv.es!antodo 126
{
1287 slepc 127
  PetscErrorCode ierr;
128
  PetscInt       i;
129
 
525 dsic.upv.es!antodo 130
  PetscFunctionBegin;
2213 jroman 131
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
1287 slepc 132
  for (i=0; i<eps->numbermonitors; i++) {
133
    if (eps->monitordestroy[i]) {
2311 jroman 134
      ierr = (*eps->monitordestroy[i])(&eps->monitorcontext[i]);CHKERRQ(ierr);
1287 slepc 135
    }
136
  }
525 dsic.upv.es!antodo 137
  eps->numbermonitors = 0;
138
  PetscFunctionReturn(0);
139
}
140
 
141
#undef __FUNCT__  
142
#define __FUNCT__ "EPSGetMonitorContext"
143
/*@C
1021 slepc 144
   EPSGetMonitorContext - Gets the monitor context, as set by
2242 jroman 145
   EPSMonitorSet() for the FIRST monitor only.
525 dsic.upv.es!antodo 146
 
147
   Not Collective
148
 
149
   Input Parameter:
150
.  eps - eigensolver context obtained from EPSCreate()
151
 
152
   Output Parameter:
153
.  ctx - monitor context
154
 
155
   Level: intermediate
156
 
2242 jroman 157
.seealso: EPSMonitorSet()
525 dsic.upv.es!antodo 158
@*/
2331 jroman 159
PetscErrorCode EPSGetMonitorContext(EPS eps,void **ctx)
525 dsic.upv.es!antodo 160
{
161
  PetscFunctionBegin;
2213 jroman 162
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
2317 jroman 163
  *ctx = eps->monitorcontext[0];
525 dsic.upv.es!antodo 164
  PetscFunctionReturn(0);
165
}
166
 
167
#undef __FUNCT__  
2041 eromero 168
#define __FUNCT__ "EPSMonitorAll"
525 dsic.upv.es!antodo 169
/*@C
2041 eromero 170
   EPSMonitorAll - Print the current approximate values and
525 dsic.upv.es!antodo 171
   error estimates at each iteration of the eigensolver.
172
 
173
   Collective on EPS
174
 
175
   Input Parameters:
176
+  eps    - eigensolver context
177
.  its    - iteration number
178
.  nconv  - number of converged eigenpairs so far
179
.  eigr   - real part of the eigenvalues
180
.  eigi   - imaginary part of the eigenvalues
181
.  errest - error estimates
182
.  nest   - number of error estimates to display
183
-  dummy  - unused monitor context
184
 
185
   Level: intermediate
186
 
2328 jroman 187
.seealso: EPSMonitorSet(), EPSMonitorFirst(), EPSMonitorConverged()
525 dsic.upv.es!antodo 188
@*/
2041 eromero 189
PetscErrorCode EPSMonitorAll(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *dummy)
525 dsic.upv.es!antodo 190
{
1532 slepc 191
  PetscErrorCode          ierr;
192
  PetscInt                i;
2054 eromero 193
  PetscScalar             er,ei;
1532 slepc 194
  PetscViewerASCIIMonitor viewer = (PetscViewerASCIIMonitor) dummy;
525 dsic.upv.es!antodo 195
 
196
  PetscFunctionBegin;
1220 slepc 197
  if (its) {
1532 slepc 198
    if (!dummy) {ierr = PetscViewerASCIIMonitorCreate(((PetscObject)eps)->comm,"stdout",0,&viewer);CHKERRQ(ierr);}
2394 jroman 199
    ierr = PetscViewerASCIIMonitorPrintf(viewer,"%3D EPS nconv=%D Values (Errors)",its,nconv);CHKERRQ(ierr);
1220 slepc 200
    for (i=0;i<nest;i++) {
2054 eromero 201
      er = eigr[i]; ei = eigi[i];
2331 jroman 202
      ierr = STBackTransform(eps->OP,1,&er,&ei);CHKERRQ(ierr);
525 dsic.upv.es!antodo 203
#if defined(PETSC_USE_COMPLEX)
2394 jroman 204
      ierr = PetscViewerASCIIMonitorPrintf(viewer," %G%+Gi",PetscRealPart(er),PetscImaginaryPart(er));CHKERRQ(ierr);
525 dsic.upv.es!antodo 205
#else
2394 jroman 206
      ierr = PetscViewerASCIIMonitorPrintf(viewer," %G",er);CHKERRQ(ierr);
207
      if (ei!=0.0) { ierr = PetscViewerASCIIMonitorPrintf(viewer,"%+Gi",ei);CHKERRQ(ierr); }
525 dsic.upv.es!antodo 208
#endif
2394 jroman 209
      ierr = PetscViewerASCIIMonitorPrintf(viewer," (%10.8e)",(double)errest[i]);CHKERRQ(ierr);
1220 slepc 210
    }
1532 slepc 211
    ierr = PetscViewerASCIIMonitorPrintf(viewer,"\n");CHKERRQ(ierr);
2305 jroman 212
    if (!dummy) {ierr = PetscViewerASCIIMonitorDestroy(&viewer);CHKERRQ(ierr);}
525 dsic.upv.es!antodo 213
  }
214
  PetscFunctionReturn(0);
215
}
623 dsic.upv.es!antodo 216
 
217
#undef __FUNCT__  
1721 antodo 218
#define __FUNCT__ "EPSMonitorFirst"
219
/*@C
220
   EPSMonitorFirst - Print the first approximate value and
221
   error estimate at each iteration of the eigensolver.
222
 
223
   Collective on EPS
224
 
225
   Input Parameters:
226
+  eps    - eigensolver context
227
.  its    - iteration number
228
.  nconv  - number of converged eigenpairs so far
229
.  eigr   - real part of the eigenvalues
230
.  eigi   - imaginary part of the eigenvalues
231
.  errest - error estimates
232
.  nest   - number of error estimates to display
233
-  dummy  - unused monitor context
234
 
235
   Level: intermediate
236
 
2328 jroman 237
.seealso: EPSMonitorSet(), EPSMonitorAll(), EPSMonitorConverged()
1721 antodo 238
@*/
239
PetscErrorCode EPSMonitorFirst(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *dummy)
240
{
241
  PetscErrorCode          ierr;
2054 eromero 242
  PetscScalar             er,ei;
1721 antodo 243
  PetscViewerASCIIMonitor viewer = (PetscViewerASCIIMonitor) dummy;
244
 
245
  PetscFunctionBegin;
246
  if (its && nconv<nest) {
247
    if (!dummy) {ierr = PetscViewerASCIIMonitorCreate(((PetscObject)eps)->comm,"stdout",0,&viewer);CHKERRQ(ierr);}
2394 jroman 248
    ierr = PetscViewerASCIIMonitorPrintf(viewer,"%3D EPS nconv=%D first unconverged value (error)",its,nconv);CHKERRQ(ierr);
2054 eromero 249
    er = eigr[nconv]; ei = eigi[nconv];
2331 jroman 250
    ierr = STBackTransform(eps->OP,1,&er,&ei);CHKERRQ(ierr);
1721 antodo 251
#if defined(PETSC_USE_COMPLEX)
2394 jroman 252
    ierr = PetscViewerASCIIMonitorPrintf(viewer," %G%+Gi",PetscRealPart(er),PetscImaginaryPart(er));CHKERRQ(ierr);
1721 antodo 253
#else
2394 jroman 254
    ierr = PetscViewerASCIIMonitorPrintf(viewer," %G",er);CHKERRQ(ierr);
255
    if (ei!=0.0) { ierr = PetscViewerASCIIMonitorPrintf(viewer,"%+Gi",ei);CHKERRQ(ierr); }
1721 antodo 256
#endif
2394 jroman 257
    ierr = PetscViewerASCIIMonitorPrintf(viewer," (%10.8e)\n",(double)errest[nconv]);CHKERRQ(ierr);
2305 jroman 258
    if (!dummy) {ierr = PetscViewerASCIIMonitorDestroy(&viewer);CHKERRQ(ierr);}
1721 antodo 259
  }
260
  PetscFunctionReturn(0);
261
}
262
 
263
#undef __FUNCT__  
264
#define __FUNCT__ "EPSMonitorConverged"
265
/*@C
266
   EPSMonitorConverged - Print the approximate values and
267
   error estimates as they converge.
268
 
269
   Collective on EPS
270
 
271
   Input Parameters:
272
+  eps    - eigensolver context
273
.  its    - iteration number
274
.  nconv  - number of converged eigenpairs so far
275
.  eigr   - real part of the eigenvalues
276
.  eigi   - imaginary part of the eigenvalues
277
.  errest - error estimates
278
.  nest   - number of error estimates to display
279
-  dummy  - unused monitor context
280
 
281
   Level: intermediate
282
 
2328 jroman 283
.seealso: EPSMonitorSet(), EPSMonitorFirst(), EPSMonitorAll()
1721 antodo 284
@*/
285
PetscErrorCode EPSMonitorConverged(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *dummy)
286
{
2311 jroman 287
  PetscErrorCode   ierr;
288
  PetscInt         i;
289
  PetscScalar      er,ei;
290
  SlepcConvMonitor ctx = (SlepcConvMonitor) dummy;
1721 antodo 291
 
292
  PetscFunctionBegin;
293
  if (!its) {
1950 jroman 294
    ctx->oldnconv = 0;
1721 antodo 295
  } else {
1950 jroman 296
    for (i=ctx->oldnconv;i<nconv;i++) {
2394 jroman 297
      ierr = PetscViewerASCIIMonitorPrintf(ctx->viewer,"%3D EPS converged value (error) #%D",its,i);CHKERRQ(ierr);
2054 eromero 298
      er = eigr[i]; ei = eigi[i];
2331 jroman 299
      ierr = STBackTransform(eps->OP,1,&er,&ei);CHKERRQ(ierr);
1721 antodo 300
#if defined(PETSC_USE_COMPLEX)
2394 jroman 301
      ierr = PetscViewerASCIIMonitorPrintf(ctx->viewer," %G%+Gi",PetscRealPart(er),PetscImaginaryPart(er));CHKERRQ(ierr);
1721 antodo 302
#else
2394 jroman 303
      ierr = PetscViewerASCIIMonitorPrintf(ctx->viewer," %G",er);CHKERRQ(ierr);
304
      if (ei!=0.0) { ierr = PetscViewerASCIIMonitorPrintf(ctx->viewer,"%+Gi",ei);CHKERRQ(ierr); }
1721 antodo 305
#endif
2394 jroman 306
      ierr = PetscViewerASCIIMonitorPrintf(ctx->viewer," (%10.8e)\n",(double)errest[i]);CHKERRQ(ierr);
1721 antodo 307
    }
1950 jroman 308
    ctx->oldnconv = nconv;
1721 antodo 309
  }
310
  PetscFunctionReturn(0);
311
}
312
 
2311 jroman 313
#undef __FUNCT__  
1331 slepc 314
#define __FUNCT__ "EPSMonitorLG"
1509 slepc 315
PetscErrorCode EPSMonitorLG(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *monctx)
623 dsic.upv.es!antodo 316
{
626 dsic.upv.es!antodo 317
  PetscViewer    viewer = (PetscViewer) monctx;
2041 eromero 318
  PetscDraw      draw,draw1;
319
  PetscDrawLG    lg,lg1;
623 dsic.upv.es!antodo 320
  PetscErrorCode ierr;
2041 eromero 321
  PetscReal      x,y,myeigr,p;
2054 eromero 322
  PetscScalar    er,ei;
623 dsic.upv.es!antodo 323
 
324
  PetscFunctionBegin;
1422 slepc 325
  if (!viewer) { viewer = PETSC_VIEWER_DRAW_(((PetscObject)eps)->comm); }
626 dsic.upv.es!antodo 326
  ierr = PetscViewerDrawGetDraw(viewer,0,&draw);CHKERRQ(ierr);
327
  ierr = PetscViewerDrawGetDrawLG(viewer,0,&lg);CHKERRQ(ierr);
328
  if (!its) {
628 dsic.upv.es!antodo 329
    ierr = PetscDrawSetTitle(draw,"Error estimates");CHKERRQ(ierr);
626 dsic.upv.es!antodo 330
    ierr = PetscDrawSetDoubleBuffer(draw);CHKERRQ(ierr);
2041 eromero 331
    ierr = PetscDrawLGSetDimension(lg,1);CHKERRQ(ierr);
332
    ierr = PetscDrawLGReset(lg);CHKERRQ(ierr);
333
    ierr = PetscDrawLGSetLimits(lg,0,1.0,log10(eps->tol)-2,0.0);CHKERRQ(ierr);
334
  }
335
 
336
  /* In the hermitian case, the eigenvalues are real and can be plotted */
337
  if (eps->ishermitian) {
338
    ierr = PetscViewerDrawGetDraw(viewer,1,&draw1);CHKERRQ(ierr);
339
    ierr = PetscViewerDrawGetDrawLG(viewer,1,&lg1);CHKERRQ(ierr);
340
    if (!its) {
341
      ierr = PetscDrawSetTitle(draw1,"Approximate eigenvalues");CHKERRQ(ierr);
342
      ierr = PetscDrawSetDoubleBuffer(draw1);CHKERRQ(ierr);
343
      ierr = PetscDrawLGSetDimension(lg1,1);CHKERRQ(ierr);
344
      ierr = PetscDrawLGReset(lg1);CHKERRQ(ierr);
345
      ierr = PetscDrawLGSetLimits(lg1,0,1.0,1.e20,-1.e20);CHKERRQ(ierr);
346
    }
347
  }
348
 
349
  x = (PetscReal) its;
350
  if (errest[nconv] > 0.0) y = log10(errest[nconv]); else y = 0.0;
351
  ierr = PetscDrawLGAddPoint(lg,&x,&y);CHKERRQ(ierr);
352
  if (eps->ishermitian) {
2054 eromero 353
    er = eigr[nconv]; ei = eigi[nconv];
2331 jroman 354
    ierr = STBackTransform(eps->OP,1,&er,&ei);CHKERRQ(ierr);
2054 eromero 355
    myeigr = PetscRealPart(er);
2041 eromero 356
    ierr = PetscDrawLGAddPoint(lg1,&x,&myeigr);CHKERRQ(ierr);
357
    ierr = PetscDrawGetPause(draw1,&p);CHKERRQ(ierr);
358
    ierr = PetscDrawSetPause(draw1,0);CHKERRQ(ierr);    
359
    ierr = PetscDrawLGDraw(lg1);CHKERRQ(ierr);
360
    ierr = PetscDrawSetPause(draw1,p);CHKERRQ(ierr);    
361
  }
362
  ierr = PetscDrawLGDraw(lg);CHKERRQ(ierr);
363
  PetscFunctionReturn(0);
364
}
365
 
366
#undef __FUNCT__  
367
#define __FUNCT__ "EPSMonitorLGAll"
368
PetscErrorCode EPSMonitorLGAll(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *monctx)
369
{
370
  PetscViewer    viewer = (PetscViewer) monctx;
371
  PetscDraw      draw,draw1;
372
  PetscDrawLG    lg,lg1;
373
  PetscErrorCode ierr;
374
  PetscReal      *x,*y,*myeigr,p;
375
  PetscInt       i,n = PetscMin(eps->nev,255);
2054 eromero 376
  PetscScalar    er,ei;
2041 eromero 377
 
378
  PetscFunctionBegin;
379
  if (!viewer) { viewer = PETSC_VIEWER_DRAW_(((PetscObject)eps)->comm); }
380
  ierr = PetscViewerDrawGetDraw(viewer,0,&draw);CHKERRQ(ierr);
381
  ierr = PetscViewerDrawGetDrawLG(viewer,0,&lg);CHKERRQ(ierr);
382
  if (!its) {
383
    ierr = PetscDrawSetTitle(draw,"Error estimates");CHKERRQ(ierr);
384
    ierr = PetscDrawSetDoubleBuffer(draw);CHKERRQ(ierr);
626 dsic.upv.es!antodo 385
    ierr = PetscDrawLGSetDimension(lg,n);CHKERRQ(ierr);
386
    ierr = PetscDrawLGReset(lg);CHKERRQ(ierr);
387
    ierr = PetscDrawLGSetLimits(lg,0,1.0,log10(eps->tol)-2,0.0);CHKERRQ(ierr);
388
  }
389
 
2041 eromero 390
  /* In the hermitian case, the eigenvalues are real and can be plotted */
626 dsic.upv.es!antodo 391
  if (eps->ishermitian) {
392
    ierr = PetscViewerDrawGetDraw(viewer,1,&draw1);CHKERRQ(ierr);
393
    ierr = PetscViewerDrawGetDrawLG(viewer,1,&lg1);CHKERRQ(ierr);
623 dsic.upv.es!antodo 394
    if (!its) {
628 dsic.upv.es!antodo 395
      ierr = PetscDrawSetTitle(draw1,"Approximate eigenvalues");CHKERRQ(ierr);
626 dsic.upv.es!antodo 396
      ierr = PetscDrawSetDoubleBuffer(draw1);CHKERRQ(ierr);
397
      ierr = PetscDrawLGSetDimension(lg1,n);CHKERRQ(ierr);
398
      ierr = PetscDrawLGReset(lg1);CHKERRQ(ierr);
399
      ierr = PetscDrawLGSetLimits(lg1,0,1.0,1.e20,-1.e20);CHKERRQ(ierr);
623 dsic.upv.es!antodo 400
    }
401
  }
402
 
403
  ierr = PetscMalloc(sizeof(PetscReal)*n,&x);CHKERRQ(ierr);
404
  ierr = PetscMalloc(sizeof(PetscReal)*n,&y);CHKERRQ(ierr);
405
  for (i=0;i<n;i++) {
406
    x[i] = (PetscReal) its;
2048 eromero 407
    if (i < nest && errest[i] > 0.0) y[i] = log10(errest[i]);
408
    else y[i] = 0.0;
623 dsic.upv.es!antodo 409
  }
410
  ierr = PetscDrawLGAddPoint(lg,x,y);CHKERRQ(ierr);
626 dsic.upv.es!antodo 411
  if (eps->ishermitian) {
2041 eromero 412
    ierr = PetscMalloc(sizeof(PetscReal)*n,&myeigr);CHKERRQ(ierr);
2048 eromero 413
    for(i=0;i<n;i++) {
2054 eromero 414
      er = eigr[i]; ei = eigi[i];
2331 jroman 415
      ierr = STBackTransform(eps->OP,1,&er,&ei);CHKERRQ(ierr);
2054 eromero 416
      if (i < nest) myeigr[i] = PetscRealPart(er);
2048 eromero 417
      else myeigr[i] = 0.0;
418
    }
2041 eromero 419
    ierr = PetscDrawLGAddPoint(lg1,x,myeigr);CHKERRQ(ierr);
1004 slepc 420
    ierr = PetscDrawGetPause(draw1,&p);CHKERRQ(ierr);
626 dsic.upv.es!antodo 421
    ierr = PetscDrawSetPause(draw1,0);CHKERRQ(ierr);    
422
    ierr = PetscDrawLGDraw(lg1);CHKERRQ(ierr);
1004 slepc 423
    ierr = PetscDrawSetPause(draw1,p);CHKERRQ(ierr);    
2041 eromero 424
    ierr = PetscFree(myeigr);CHKERRQ(ierr);
626 dsic.upv.es!antodo 425
  }
705 dsic.upv.es!antodo 426
  ierr = PetscDrawLGDraw(lg);CHKERRQ(ierr);
623 dsic.upv.es!antodo 427
  ierr = PetscFree(x);CHKERRQ(ierr);
428
  ierr = PetscFree(y);CHKERRQ(ierr);  
429
  PetscFunctionReturn(0);
430
}
1021 slepc 431