diff --git a/doc/operations_overview.htm b/doc/operations_overview.htm index cb6cc7d2..48f19633 100644 --- a/doc/operations_overview.htm +++ b/doc/operations_overview.htm @@ -207,8 +207,40 @@ in preference to iterator's for the same reason. For the more darin can be completely turned off in uBLAS by defining the configuration macro BOOST_UBLAS_NO_ELEMENT_PROXIES.

+ +

Controlling the complexity of nested products

+ +

What is the complexity (the number of add and multiply operations) required to compute the following? +

+
+ R = prod(A, prod(B,C)); 
+
+

Firstly the complexity depends on matrix size. Also since prod is transitive (not commutative) +the bracket order affects the complexity. +

+

uBLAS evaluates expressions without matrix or vector temporaries and honours +the bracketing structure. However avoiding temporaries for nested product unnecessarly increases the complexity. +Conversly by explictly using temporary matrices the complexity of a nested product can be reduced. +

+

uBLAS provides 3 alternative syntaxes for this purpose: +

+
+ temp_type T = prod(B,C); R = prod(A,T);   // Preferable if T is preallocated
+
+
+ prod(A, temp_type(prod(B,C));
+
+
+ prod(A, prod<temp_type>(B,C));
+
+

The 'temp_type' is important. Given A,B,C are all of the same type. Say +matrix<float>, the choice is easy. However if the value_type is mixed (int with float or double) +or the matrix type is mixed (sparse with symmetric) the best solution is not so obvious. It is up to you! It +depends on numerical properties of A and the result of the prod(B,C). +

+
-

Copyright (©) 2000-2004 Joerg Walter, Mathias Koch, Gunter +

Copyright (©) 2000-2007 Joerg Walter, Mathias Koch, Gunter Winkler, Michael Stevens
Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies.