/[escript]/trunk/paso/src/GMRES2.cpp
ViewVC logotype

Diff of /trunk/paso/src/GMRES2.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4261 by jfenwick, Wed Feb 27 06:09:33 2013 UTC revision 4291 by jfenwick, Thu Mar 7 08:57:58 2013 UTC
# Line 48  err_t Paso_Solver_GMRES2( Line 48  err_t Paso_Solver_GMRES2(
48    /*        /*    
49     *  allocate memory:     *  allocate memory:
50     */     */
51    h=TMPMEMALLOC(l*l,double);    h=new double[l*l];
52    v=TMPMEMALLOC(l,double*);    v=new double*[l];
53    c=TMPMEMALLOC(l,double);    c=new double[l];
54    s=TMPMEMALLOC(l,double);    s=new double[l];
55    g=TMPMEMALLOC(l,double);    g=new double[l];
56    work=TMPMEMALLOC(n,double);    work=new double[n];
57    
58    if (h==NULL || v ==NULL || c== NULL || s == NULL || g== NULL || work==NULL) {    if (h==NULL || v ==NULL || c== NULL || s == NULL || g== NULL || work==NULL) {
59       Status=SOLVER_MEMORY_ERROR;       Status=SOLVER_MEMORY_ERROR;
# Line 69  err_t Paso_Solver_GMRES2( Line 69  err_t Paso_Solver_GMRES2(
69        if (! convergeFlag) {        if (! convergeFlag) {
70            abs_tol=rel_tol*normf0;            abs_tol=rel_tol*normf0;
71            printf("GMRES2 initial residual norm %e (rel. tol=%e)\n",normf0,rel_tol);            printf("GMRES2 initial residual norm %e (rel. tol=%e)\n",normf0,rel_tol);
72            v[0]=TMPMEMALLOC(n,double);            v[0]=new double[n];
73            if (v[0]==NULL) {            if (v[0]==NULL) {
74               Status=SOLVER_MEMORY_ERROR;               Status=SOLVER_MEMORY_ERROR;
75            } else {            } else {
# Line 79  err_t Paso_Solver_GMRES2( Line 79  err_t Paso_Solver_GMRES2(
79            }            }
80            while( (! (breakFlag || maxIterFlag || convergeFlag)) && (Status ==SOLVER_NO_ERROR) ) {            while( (! (breakFlag || maxIterFlag || convergeFlag)) && (Status ==SOLVER_NO_ERROR) ) {
81                 k++;                 k++;
82                 v[k]=TMPMEMALLOC(n,double);                 v[k]=new double[n];
83                 if (v[k]==NULL) {                 if (v[k]==NULL) {
84                    Status=SOLVER_MEMORY_ERROR;                    Status=SOLVER_MEMORY_ERROR;
85                 } else {                 } else {
# Line 168  err_t Paso_Solver_GMRES2( Line 168  err_t Paso_Solver_GMRES2(
168    *  clean up:    *  clean up:
169    */    */
170    if ( v !=NULL) {    if ( v !=NULL) {
171      for (i=0;i<iter_max;i++) TMPMEMFREE(v[i]);      for (i=0;i<iter_max;i++) delete[] v[i];
172    }    }
173    TMPMEMFREE(h);    delete[] h;
174    TMPMEMFREE(v);    delete[] v;
175    TMPMEMFREE(c);    delete[] c;
176    TMPMEMFREE(s);    delete[] s;
177    TMPMEMFREE(g);    delete[] g;
178    TMPMEMFREE(work);    delete[] work;
179    *iter=k;    *iter=k;
180    *tolerance=norm_of_residual;    *tolerance=norm_of_residual;
181    return Status;    return Status;

Legend:
Removed from v.4261  
changed lines
  Added in v.4291

  ViewVC Help
Powered by ViewVC 1.1.26