Boost LA

Views

Overloads of operator| are used to access vector and matrix elements, as well as to provide different views of matrix and vector types. The example below multiplies column 1 (Boost LA indexes are always zero-based) of the matrix m by a scalar:

void
multiply_column1( float33 & m, float scalar )
    {
    m|col<1> *= scalar;
    }

The expression m|col<1> returns a reference of an unspecified 3D vector type that accessses column 1 of m. Note however that this does not create any temporary objects; instead operator*= above works directly with a reference to m.

Here is another example, multiplying a transposed view of a matrix by a vector of the user-defined type float3:

float3 v = {0,0,7};
float3 vrot = (rotx_matrix<3>(3.14159f) | transpose) * v;

In general, the various view functions return references of unspecified, non-copyable types that refer to the original object. They can be assigned from or converted to any compatible vector or matrix type.

For more details, see View Proxies.