Iterative Template Library
Encyclopedia
The Iterative Template Library (ITL) is a generic component library that provides iterative methods for solving linear systems. ITL also provides numerous preconditioners which is for MTL
Matrix Template Library
The Matrix Template Library is a linear algebra library for C++ programs.The MTL uses template programming, which considerably reduces the code length. All matrices and vectors are available in all classical numerical formats: float, double, complex or complex.Furthermore, generic programming...

. The ITL was written at the Open Systems Lab of Indiana University
Indiana University
Indiana University is a multi-campus public university system in the state of Indiana, United States. Indiana University has a combined student body of more than 100,000 students, including approximately 42,000 students enrolled at the Indiana University Bloomington campus and approximately 37,000...

 by Andrew Lumsdaine, Lie-Quan Lee, Jeremy Seik, and others.

ITL uses the abstract interface of matrix–vector, vector–vector, and vector–scalar operations MTL is default to serve those operations. ITL is able to use other packages such as Blitz++
Blitz++
Blitz++ is a high-performance vector mathematics library written in C++. This library is intended for use in scientific applications that might otherwise be implemented with Fortran or MATLAB....

 and BLAS
Basic Linear Algebra Subprograms
Basic Linear Algebra Subprograms is a de facto application programming interface standard for publishing libraries to perform basic linear algebra operations such as vector and matrix multiplication. They were first published in 1979, and are used to build larger packages such as LAPACK...

 with the same abstract interface provided.

Because generic programming encourages simplifying interfaces to only what is required by the logic they support, the ITL algorithms resemble pseudocode, at least when compared with other implementations of the same algorithms. For example, ITL's conjugate gradient follows:
/* required operations: mult,copy,dot_conj,add,scaled */
template < class Matrix, class VectorX, class VectorB,
class Preconditioner, class Iteration >
int cg(const Matrix& A, VectorX& x, const VectorB& b,
const Preconditioner& M, Iteration& iter)
{
typedef VectorX TmpVec;
typename itl_traits::value_type rho(0), rho_1(0), alpha(0), beta(0);
TmpVec p(size(x)), q(size(x)), r(size(x)), z(size(x));

itl::mult(A, itl::scaled(x, -1.0), b, r);

while (! iter.finished(r))
{
itl::solve(M, r, z);
rho = itl::dot_conj(r, z);
if (iter.first)
itl::copy(z, p);
else
{
beta = rho / rho_1;
itl::add(z, itl::scaled(p, beta), p);
}

itl::mult(A, p, q);

alpha = rho / itl::dot_conj(p, q);

itl::add(x, itl::scaled(p, alpha), x);
itl::add(r, itl::scaled(q, -alpha), r);

rho_1 = rho;

++iter;
}

return iter.error_code;
}
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK