_Linear Algebra with C++ Template Metaprograms_ by Todd Veldhuizen and Kumaraswamy Ponnambalam Example 1: (a) // Four vectors with 1000 elements of double Vector y(1000), a(1000), b(1000), c(1000) y = a + b + c; (b) for (int i=0; i < 1000; ++i) y[i] = a[i] + c[i]; (c) // Temporary vector __t1 allocated, which receives (a + b) Vector __t1(1000); for (int i=0; i < 1000; ++i) __t1[i] = a[i] + b[i]; // Temporary vector __t2 allocated, which receives (__t1 + c) Vector __t2(1000); for (int i=0; i < 1000; ++i) __t2[i] = __t1[i] + c[i]; // Result is copied into y for (int i = 0; i < 1000; ++i) y[i] = __t2[i]; Example 2: (a) Vector y, a, b, c; y = a + b + c; (b) double y[3], a[3], b[3], c[3]; y[0] = a[0] + b[0] + c[0]; y[1] = a[1] + b[1] + c[1]; y[2] = a[2] + b[2] + c[2]; Example 3: (a) Vector a, b; double result = dot(a,b); // Dot product of two vectors (b) double a[3], b[3]; double result = a[0]*b[0] + a[1]*b[1] + a[2]*b[2];