virtual typename VectorType::value_type criterion(const VectorType &r,
const VectorType &d) const;
- /**
- * Residual. Temporary vector allocated through the VectorMemory object at
- * the start of the actual solution process and deallocated at the end.
- */
- VectorType *Vr;
- /**
- * Preconditioned residual. Temporary vector allocated through the
- * VectorMemory object at the start of the actual solution process and
- * deallocated at the end.
- */
- VectorType *Vd;
-
/**
* Control parameters.
*/
const AdditionalData &data)
:
Solver<VectorType> (cn,mem),
- Vr(nullptr),
- Vd(nullptr),
additional_data(data)
{}
const AdditionalData &data)
:
Solver<VectorType> (cn),
- Vr(nullptr),
- Vd(nullptr),
additional_data(data)
{}
unsigned int iter = 0;
- // Memory allocation
- Vr = this->memory.alloc();
+ // Memory allocation.
+ // 'Vr' holds the residual, 'Vd' the preconditioned residual
+ typename VectorMemory<VectorType>::Pointer Vr (this->memory);
+ typename VectorMemory<VectorType>::Pointer Vd (this->memory);
+
VectorType &r = *Vr;
r.reinit(x);
- Vd = this->memory.alloc();
+
VectorType &d = *Vd;
d.reinit(x);
}
catch (...)
{
- this->memory.free(Vr);
- this->memory.free(Vd);
deallog.pop();
throw;
}
- // Deallocate Memory
- this->memory.free(Vr);
- this->memory.free(Vd);
+
deallog.pop();
// in case of failure: throw exception
}
+
template <class VectorType>
template <typename MatrixType, typename PreconditionerType>
void
unsigned int iter = 0;
- // Memory allocation
- Vr = this->memory.alloc();
+ // Memory allocation.
+ // 'Vr' holds the residual, 'Vd' the preconditioned residual
+ typename VectorMemory<VectorType>::Pointer Vr (this->memory);
+ typename VectorMemory<VectorType>::Pointer Vd (this->memory);
+
VectorType &r = *Vr;
r.reinit(x);
- Vd = this-> memory.alloc();
+
VectorType &d = *Vd;
d.reinit(x);
}
catch (...)
{
- this->memory.free(Vr);
- this->memory.free(Vd);
deallog.pop();
throw;
}
- // Deallocate Memory
- this->memory.free(Vr);
- this->memory.free(Vd);
deallog.pop();
// in case of failure: throw exception
if (conv != SolverControl::success)