$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r73615 - in sandbox/maps/boost: . maps maps/generic maps/math maps/support
From: bjs3141_at_[hidden]
Date: 2011-08-08 19:51:34
Author: brian.smith
Date: 2011-08-08 19:51:30 EDT (Mon, 08 Aug 2011)
New Revision: 73615
URL: http://svn.boost.org/trac/boost/changeset/73615
Log:
Initial commit.
Added:
   sandbox/maps/boost/
   sandbox/maps/boost/maps/
   sandbox/maps/boost/maps.hpp   (contents, props changed)
   sandbox/maps/boost/maps/generic/
   sandbox/maps/boost/maps/generic/array.hpp   (contents, props changed)
   sandbox/maps/boost/maps/generic/array_.hpp   (contents, props changed)
   sandbox/maps/boost/maps/generic/pointer.hpp   (contents, props changed)
   sandbox/maps/boost/maps/generic/view.hpp   (contents, props changed)
   sandbox/maps/boost/maps/generic/view_.hpp   (contents, props changed)
   sandbox/maps/boost/maps/math/
   sandbox/maps/boost/maps/math/matrix.hpp   (contents, props changed)
   sandbox/maps/boost/maps/math/matrix_matrix.hpp   (contents, props changed)
   sandbox/maps/boost/maps/math/matrix_scalar.hpp   (contents, props changed)
   sandbox/maps/boost/maps/math/matrix_vector.hpp   (contents, props changed)
   sandbox/maps/boost/maps/math/scalar.hpp   (contents, props changed)
   sandbox/maps/boost/maps/math/scalar_matrix.hpp   (contents, props changed)
   sandbox/maps/boost/maps/math/scalar_scalar.hpp   (contents, props changed)
   sandbox/maps/boost/maps/math/scalar_vector.hpp   (contents, props changed)
   sandbox/maps/boost/maps/math/vector.hpp   (contents, props changed)
   sandbox/maps/boost/maps/math/vector_matrix.hpp   (contents, props changed)
   sandbox/maps/boost/maps/math/vector_scalar.hpp   (contents, props changed)
   sandbox/maps/boost/maps/math/vector_vector.hpp   (contents, props changed)
   sandbox/maps/boost/maps/support/
   sandbox/maps/boost/maps/support/assigner.hpp   (contents, props changed)
   sandbox/maps/boost/maps/support/bounds.hpp   (contents, props changed)
   sandbox/maps/boost/maps/support/expression.hpp   (contents, props changed)
   sandbox/maps/boost/maps/support/generic.hpp   (contents, props changed)
   sandbox/maps/boost/maps/support/includes.hpp   (contents, props changed)
   sandbox/maps/boost/maps/support/math.hpp   (contents, props changed)
   sandbox/maps/boost/maps/support/preprocessor_bounds.hpp   (contents, props changed)
   sandbox/maps/boost/maps/support/preprocessor_ranges.hpp   (contents, props changed)
Added: sandbox/maps/boost/maps.hpp
==============================================================================
--- (empty file)
+++ sandbox/maps/boost/maps.hpp	2011-08-08 19:51:30 EDT (Mon, 08 Aug 2011)
@@ -0,0 +1,15 @@
+//--
+// Copyright (c) 2010-2011 Brian Smith
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/maps for documentation.
+//--
+#if !defined( BOOST_MAPS_HPP_ )
+#define BOOST_MAPS_HPP_
+
+#include <boost/maps/support/includes.hpp>
+
+
+#endif BOOST_MAPS_HPP_
\ No newline at end of file
Added: sandbox/maps/boost/maps/generic/array.hpp
==============================================================================
--- (empty file)
+++ sandbox/maps/boost/maps/generic/array.hpp	2011-08-08 19:51:30 EDT (Mon, 08 Aug 2011)
@@ -0,0 +1,1078 @@
+//--
+// Copyright (c) 2010-2011 Brian Smith
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/maps for documentation.
+//--
+#if !defined( BOOST_MAPS_GENERIC_ARRAY_HPP )
+#define BOOST_MAPS_GENERIC_ARRAY_HPP
+
+#include <boost/maps/support/preprocessor_bounds.hpp>
+#include <boost/maps/support/includes.hpp>
+
+#ifdef BOOST_MSVC
+# pragma warning( disable : 4996 ) // std::copy and its relatives deprecated by microsoft
+#endif
+
+namespace boost { namespace maps {
+
+//--
+
+    template< class T, std::size_t N, class B, class C, std::size_t S, class A >
+    struct array_allocate
+    {    
+        typedef typename array_type< T,N,B,A >::type type;
+        typedef typename array_type< T,N-1,C,A >::type value_type;
+        typedef typename A::template rebind< value_type >::other allocator;
+
+        void operator()( type& p ) 
+        {    
+            allocator a; 
+            p = a.allocate( S );
+        }
+    };
+
+//--
+
+    template< class T, std::size_t N, class B, class C, std::size_t S, class A >
+    struct array_deallocate
+    {    
+        typedef typename array_type< T,N,B,A >::type type;
+        typedef typename array_type< T,N-1,C,A >::type value_type;
+        typedef typename A::template rebind< value_type >::other allocator;
+
+        void operator()( type& p ) 
+        {    
+            allocator a; 
+            a.deallocate( p, S ); p = 0;
+        }
+    };
+
+//--
+
+    template< class T, std::size_t N, class B, class C, std::size_t S, bool I, class A >
+    struct array_construct
+    {    
+        typedef typename array_type< T,N,B,A >::type type;
+        typedef typename array_type< T,N-1,C,A >::type value_type;
+        typedef typename A::template rebind< value_type >::other allocator;
+
+        void operator()( type& p ) 
+        {    
+            type f = p, l = p+S;
+            allocator a;
+            try
+            {   T t = T();
+                while( f != l ) { a.construct( f, t ); ++f; }
+            }catch( ... )
+            {   type n = p;
+                while( n != f ) { a.destroy( n ); ++n; }
+                throw;
+            }
+        }
+    };
+
+    template< class T, std::size_t N, class B, class C, std::size_t S, class A >
+    struct array_construct< T,N,B,C,S,false,A >
+    {    
+        typedef typename array_type< T,N,B,A >::type type;
+
+        void operator()( type& ) 
+        {}
+    };
+
+//--
+
+    template< class T, std::size_t N, class B, class C, std::size_t S, bool I, class A >
+    struct array_destroy
+    {    
+        typedef typename array_type< T,N,B,A >::type type;
+        typedef typename array_type< T,N-1,C,A >::type value_type;
+        typedef typename A::template rebind< value_type >::other allocator;
+
+        void operator()( type& p ) 
+        {    
+            allocator a; 
+            for( std::size_t i = 0; i != S; ++i ) a.destroy( p+i );
+        }
+    };
+
+    template< class T, std::size_t N, class B, class C, std::size_t S, class A >
+    struct array_destroy< T,N,B,C,S,true,A >
+    {    
+        typedef typename array_type< T,N,B,A >::type type;
+
+        void operator()( type& ) 
+        {}
+    };
+
+//--
+
+    template< class T, std::size_t N, class B, std::size_t S, bool I, class A >
+    struct array_constructor
+    {
+        typedef typename array_type< T,N,B,A >::type type;
+        typedef typename mpl::next< B >::type C;
+        typedef typename mpl::deref< C >::type D;
+
+        void operator()( type& p ) 
+        {   
+            if( S == 0 ) throw std::invalid_argument( "invalid array<> dimension" );
+            array_allocate< T,N,B,C,S,A >()( p );
+            try { array_constructor< T,N-1,C,S*D::value,I,A >()( p[0] ); }
+            catch( ... ) { array_deallocate< T,N,B,C,S,A >()( p ); throw; }
+            for( std::size_t j = 1, k = D::value; j != S; ++j ) p[j] = p[j-1] + k;
+        }
+    };
+
+    template< class T, class B, std::size_t S, bool I, class A >
+    struct array_constructor< T,1,B,S,I,A >
+    {
+        typedef typename array_type< T,1,B,A >::type type;
+        typedef typename mpl::next< B >::type C;
+
+        void operator()( type& p )
+        {
+            if( S == 0 ) throw std::invalid_argument( "invalid array<> dimension" );
+            array_allocate< T,1,B,C,S,A >()( p );
+            try { array_construct< T,1,B,C,S,I,A >()( p ); }
+            catch( ... ) { array_deallocate< T,1,B,C,S,A >()( p ); throw; }
+        }
+    };
+
+//--
+
+    template< class T, std::size_t N, class B, std::size_t S, bool I, class A >
+    struct array_destructor
+    {    
+        typedef typename array_type< T,N,B,A >::type type;
+        typedef typename mpl::next< B >::type C;
+        typedef typename mpl::deref< C >::type D;
+
+        void operator()( type& p )
+        {    
+            array_destructor< T,N-1,C,S*D::value,I,A >()( p[0] );
+            array_deallocate< T,N,B,C,S,A >()( p );
+        }
+    };
+
+    template< class T, class B, std::size_t S, bool I, class A >
+    struct array_destructor< T,1,B,S,I,A >
+    {    
+        typedef typename array_type< T,1,B,A >::type type;
+        typedef typename mpl::next< B >::type C;
+        
+        void operator()( type& p ) 
+        {    
+            array_destroy< T,1,B,C,S,I,A >()( p );
+            array_deallocate< T,1,B,C,S,A >()( p );
+        }
+    };
+
+//--
+
+    template< class T, std::size_t N, class B, std::size_t S, class A >
+    struct array_copy
+    {    
+        typedef typename array_type< T,N,B,A >::type type;
+        typedef typename mpl::next< B >::type C;
+        typedef typename mpl::deref< C >::type D;
+        
+        void operator()( type& p, type const& q ) 
+        {    
+            array_allocate< T,N,B,C,S,A >()( p ); 
+            try { array_copy< T,N-1,C,S*D::value,A >()( p[0], q[0] ); }
+            catch( ... ) { array_deallocate< T,N,B,C,S,A >()( p ); throw; }
+            for( std::size_t j = 1, k = D::value; j != S; ++j ) p[j] = p[j-1] + k;
+        }
+    };
+
+    template< class T, class B, std::size_t S, class A >
+    struct array_copy< T,1,B,S,A >
+    {    
+        typedef typename array_type< T,1,B,A >::type type;
+        typedef typename mpl::next< B >::type C;
+
+        void operator()( type& p, type const& q )
+        {    
+            array_allocate< T,1,B,C,S,A >()( p );
+            try { std::uninitialized_copy( q, q+S, p ); }
+            catch( ... ) { array_deallocate< T,1,B,C,S,A >()( p ); throw; }
+        }
+    };
+
+//--
+
+    template< class T, std::size_t N, class B, std::size_t S, bool I, class A >
+    struct array_assign
+    {    
+        typedef typename array_type< T,N,B,A >::type type;
+        typedef typename mpl::next< B >::type C;
+        typedef typename mpl::deref< C >::type D;
+
+        void operator()( type& p, type const& q ) 
+        {    
+            array_assign< T,N-1,C,S*D::value,I,A >()( p[0], q[0] );
+        }
+    };
+
+    template< class T, class B, std::size_t S, bool I, class A >
+    struct array_assign< T,2,B,S,I,A >
+    {    
+        typedef typename array_type< T,2,B,A >::type type;
+        typedef typename mpl::next< B >::type C;
+        typedef typename mpl::deref< C >::type D;
+
+        void operator()( type& p, type const& q ) 
+        {    
+            array_assign< T,1,C,S*D::value,I,A >()( p[0], q[0] );
+            for( std::size_t j = 0, k = 0; j != S; ++j, k += D::value ) p[j] = &p[0][k];
+        }
+    };
+
+    template< class T, class B, std::size_t S, bool I, class A >
+    struct array_assign< T,1,B,S,I,A >
+    {    
+        typedef typename array_type< T,1,B,A >::type type;
+        typedef typename mpl::next< B >::type C;
+
+        void operator()( type& p, type const& q )
+        {    
+            type t = 0; array_allocate< T,1,B,C,S,A >()( t );
+            try { std::uninitialized_copy( q, q+S, t ); }
+            catch( ... ) { array_deallocate< T,1,B,C,S,A >()( t ); throw; }
+            type r = p; p = t; t = 0; array_destructor< T,1,B,S,I,A >()( r );
+        }
+    };
+
+//--
+
+    template< class T, std::size_t N, class F, class A >
+    struct array_swap
+    {
+        typedef typename array_type< T,N,F,A >::type type;
+
+        void operator()( type& p, type& q ) 
+        {
+            std::swap( p, q );
+        }
+    };
+
+//--
+//--
+
+    template< class T, std::size_t N, class B, std::size_t S, bool I >
+    struct array_constructor< T,N,B,S,I,null::allocator >
+    {
+        typedef typename array_type< T,N,B,null::allocator >::type type;
+
+        void operator()( type& a ) 
+        {   
+            memset( a, 0, S * sizeof(T) ); // '\0'
+        }
+    };
+
+    template< class T, class B, std::size_t S, bool I >
+    struct array_constructor< T,1,B,S,I,null::allocator >
+    {
+        typedef typename array_type< T,1,B,null::allocator >::type type;
+
+        void operator()( type& a ) 
+        {   
+            memset( a, 0, S * sizeof(T) );
+        }
+    };
+
+    template< class T, std::size_t N, class B, std::size_t S >
+    struct array_constructor< T,N,B,S,false,null::allocator >
+    {
+        typedef typename array_type< T,N,B,null::allocator >::type type;
+
+        void operator()( type& ) 
+        {}
+    };
+
+    template< class T, class B, std::size_t S >
+    struct array_constructor< T,1,B,S,false,null::allocator >
+    {
+        typedef typename array_type< T,1,B,null::allocator >::type type;
+
+        void operator()( type& ) 
+        {}
+    };
+
+//--
+
+    template< class T, std::size_t N, class F >
+    struct array_swap< T,N,F,null::allocator >
+    {
+        typedef typename array_type< T,N,F,null::allocator >::type type;
+        typedef typename mpl::deref< F >::type D;
+        typedef typename mpl::next< F >::type G;
+
+        void operator()( type& p, type& q ) 
+        {
+            for( std::size_t i = 0; i != D::value; ++i )
+                array_swap< T,N-1,G,null::allocator >()( p[i], q[i] );
+        }
+    };
+
+    template< class T, class F >
+    struct array_swap< T,1,F,null::allocator >
+    {
+        typedef typename array_type< T,1,F,null::allocator >::type type;
+        typedef typename mpl::deref< F >::type D;
+
+        void operator()( type& p, type& q )
+        {
+            for( std::size_t i = 0; i != D::value; ++i ) 
+                std::swap( p[i], q[i] );
+        }
+    };
+
+//--
+//--
+
+    template< class T, class B, std::size_t N, class F, bool I, class A >
+    struct array_element_const
+    {
+        typedef typename array< T,B,I,A >::const_reference const_reference;
+        typedef typename array_type< T,N,F,A >::type type;
+        typedef typename bounds< N >::const_iterator const_iterator;
+        typedef typename mpl::deref< F >::type D;
+        typedef typename mpl::next< F >::type G;
+
+        const_reference operator()( type const& p, const_iterator i )
+        {
+            BOOST_ASSERT( *i < D::value );
+            return array_element_const< T,B,N-1,G,I,A >()( p[*i], i+1 );
+        }
+    };
+
+    template< class T, class B, class F, bool I, class A >
+    struct array_element_const< T,B,1,F,I,A >
+    {
+        typedef typename array< T,B,I,A >::const_reference const_reference;
+        typedef typename array_type< T,1,F,A >::type type;
+        typedef typename bounds< 1 >::const_iterator const_iterator;
+        typedef typename mpl::deref< F >::type D;
+
+        const_reference operator()( type const& p, const_iterator i )
+        {
+            BOOST_ASSERT( *i < D::value );
+            return p[*i];
+        }
+    };
+
+    template< class T, class B, std::size_t N, class F, bool I, class A >
+    struct array_element
+    {
+        typedef typename array< T,B,I,A >::reference reference;
+        typedef typename array_type< T,N,F,A >::type type;
+        typedef typename bounds< N >::const_iterator const_iterator;
+        typedef typename mpl::deref< F >::type D;
+        typedef typename mpl::next< F >::type G;
+
+        reference operator()( type& p, const_iterator i )
+        {
+            BOOST_ASSERT( *i < D::value );
+            return array_element< T,B,N-1,G,I,A >()( p[*i], i+1 );
+        }
+    };
+
+    template< class T, class B, class F, bool I, class A >
+    struct array_element< T,B,1,F,I,A >
+    {
+        typedef typename array< T,B,I,A >::reference reference;
+        typedef typename array_type< T,1,F,A >::type type;
+        typedef typename bounds< 1 >::const_iterator const_iterator;
+        typedef typename mpl::deref< F >::type D;
+
+        reference operator()( type& p, const_iterator i )
+        {
+            BOOST_ASSERT( *i < D::value );
+            return p[*i];
+        }
+    };
+
+//--
+
+    template< class T, class B, std::size_t N, class F, bool I, class A >
+    struct array_element_at_const
+    {
+        typedef typename array< T,B,I,A >::const_reference const_reference;
+        typedef typename array_type< T,N,F,A >::type type;
+        typedef typename bounds< N >::const_iterator const_iterator;
+        typedef typename mpl::deref< F >::type D;
+        typedef typename mpl::next< F >::type G;
+
+        const_reference operator()( type const& p, const_iterator i )
+        {
+            if( !( *i < D::value ) ) 
+                throw std::out_of_range( "array<> access out of range" );
+            return array_element_at_const< T,B,N-1,G,I,A >()( p[*i], i+1 );
+        }
+    };
+
+    template< class T, class B, class F, bool I, class A >
+    struct array_element_at_const< T,B,1,F,I,A >
+    {
+        typedef typename array< T,B,I,A >::const_reference const_reference;
+        typedef typename array_type< T,1,F,A >::type type;
+        typedef typename bounds< 1 >::const_iterator const_iterator;
+        typedef typename mpl::deref< F >::type D;
+
+        const_reference operator()( type const& p, const_iterator i )
+        {
+            if( !( *i < D::value ) )
+                throw std::out_of_range( "array<> access out of range" );
+            return p[*i];
+        }
+    };
+
+    template< class T, class B, std::size_t N, class F, bool I, class A >
+    struct array_element_at
+    {
+        typedef typename array< T,B,I,A >::reference reference;
+        typedef typename array_type< T,N,F,A >::type type;
+        typedef typename bounds< N >::const_iterator const_iterator;
+        typedef typename mpl::deref< F >::type D;
+        typedef typename mpl::next< F >::type G;
+
+        reference operator()( type& p, const_iterator i )
+        {
+            if( !( *i < D::value ) ) 
+                throw std::out_of_range( "array<> access out of range" );
+            return array_element_at< T,B,N-1,G,I,A >()( p[*i], i+1 );
+        }
+    };
+
+    template< class T, class B, class F, bool I, class A >
+    struct array_element_at< T,B,1,F,I,A >
+    {
+        typedef typename array< T,B,I,A >::reference reference;
+        typedef typename array_type< T,1,F,A >::type type;
+        typedef typename bounds< 1 >::const_iterator const_iterator;
+        typedef typename mpl::deref< F >::type D;
+
+        reference operator()( type& p, const_iterator i )
+        {
+            if( !( *i < D::value ) )
+                throw std::out_of_range( "array<> access out of range" );
+            return p[*i];
+        }
+    };
+
+//--
+
+    template< class T, class B, std::size_t N, class F, bool I, class A >
+    struct array_begin_const
+    {
+        typedef typename array< T,B,I,A >::const_iterator const_iterator;
+        typedef typename array_type< T,N,F,A >::type type;
+        typedef typename mpl::next< F >::type G;
+
+        const_iterator operator()( type const& p ) 
+        {
+            return array_begin_const< T,B,N-1,G,I,A >()( *p );
+        }
+    };
+
+    template< class T, class B, class F, bool I, class A >
+    struct array_begin_const< T,B,1,F,I,A >
+    {
+        typedef typename array< T,B,I,A >::const_iterator const_iterator;
+        typedef typename array_type< T,1,F,A >::type type;
+
+        const_iterator operator()( type const& p )
+        {
+            return p;
+        }
+    };
+
+    template< class T, class B, std::size_t N, class F, bool I, class A >
+    struct array_begin
+    {
+        typedef typename array< T,B,I,A >::iterator iterator;
+        typedef typename array_type< T,N,F,A >::type type;
+        typedef typename mpl::next< F >::type G;
+
+        iterator operator()( type& p ) 
+        {
+            return array_begin< T,B,N-1,G,I,A >()( *p );
+        }
+    };
+
+    template< class T, class B, class F, bool I, class A >
+    struct array_begin< T,B,1,F,I,A >
+    {
+        typedef typename array< T,B,I,A >::iterator iterator;
+        typedef typename array_type< T,1,F,A >::type type;
+
+        iterator operator()( type& p )
+        {
+            return p;
+        }
+    };
+
+//--
+
+    /* 
+        Base type for dynamically allocated array's. 
+    */
+    template< class T, class B, bool I, class A >
+    class array_base
+        : public expression< array< T,B,I,A > >
+    {
+    public:
+
+        typedef array< T,B,I,A > type;
+        typedef type const& type_const_reference;
+        typedef expression< type > base_type;
+        typedef typename array_member_type< T,B,A >::type member_type;
+ 
+        enum { dimensionality = mpl::size< B >::type::value, 
+            size = array_size< B >::type::value };
+
+        array_base();
+
+        array_base( type_const_reference );
+        template< bool I1, class A1 > array_base( array< T,B,I1,A1 > const& );
+
+        void operator=( type_const_reference );
+        template< bool I1, class A1 > void operator=( array< T,B,I1,A1 > const& );
+
+        ~array_base();
+
+    protected:
+
+        typedef typename has_trivial_destructor< T >::type M;
+        typedef typename array_initialize< T,I,A >::type C;
+        typedef typename mpl::size< B >::type N;
+        typedef typename mpl::begin< B >::type F;
+        typedef typename mpl::deref< F >::type D;
+
+        member_type data;
+
+        template< class T1, class B1, bool I1, class A1 > 
+        friend class array;
+    };
+
+//--
+//--
+
+    /* 
+        Base type for statically allocated array's.
+    */
+    template< class T, class B, bool I >
+    class array_base< T,B,I,null::allocator >
+        : public expression< array< T,B,I,null::allocator > >
+    {
+    public:
+
+        typedef array< T,B,I,null::allocator > type;
+        typedef expression< type > base_type;
+        typedef typename array_member_type< T,B,null::allocator >::type member_type;
+
+        enum { dimensionality = mpl::size< B >::type::value, 
+            size = array_size< B >::type::value };
+        
+        array_base();
+
+    protected:
+
+        typedef typename has_trivial_destructor< T >::type M;
+        typedef typename array_initialize< T,I,null::allocator >::type C;
+        typedef typename mpl::size< B >::type N;
+        typedef typename mpl::begin< B >::type F;
+        typedef typename mpl::deref< F >::type D;
+
+        member_type data;
+
+        template< class T1, class B1, bool I1, class A1 > 
+        friend class array;
+    };
+
+//--
+//--
+
+    /*
+        array class template
+
+        parameters
+
+            required
+
+                T - stored data type
+                    type: arbitrary type
+                B - array bounds
+                    type: boundsN< ... > : mpl vectorN_c< std::size_t, ... > 
+                          sequence containing size of each of N dimensions
+            
+            optional
+
+                I - initialization parameter 
+                    type: bool 
+                    default: true, data elements zero/default initialized
+                A - allocator 
+                    type: standard conforming allocator, or null::allocator
+                    default: null::allocator, statically allocated array
+    */
+
+    template< class T, class B, bool I, class A >
+    class array
+        : public array_base< T,B,I,A >
+    {
+    public:
+
+        typedef array type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef type const* type_const_pointer;
+        typedef type* type_pointer;
+        typedef array_base< T,B,I,A > base_type;
+        typedef sub_type< type > subarray_type;
+        typedef typename base_type::member_type member_type;
+        typedef typename array_value_type< T,B,A >::type value_type;
+        typedef value_type const& const_reference_type;
+        typedef value_type& reference_type;
+        typedef value_type const* const_iterator_type;
+        typedef value_type* iterator_type;
+        typedef T element_type;
+        typedef T const& const_reference;
+        typedef T& reference;
+        typedef T const* const_iterator;
+        typedef T* iterator;
+        typedef typename A::template rebind< value_type >::other allocator_type;
+        typedef typename allocator_type::size_type size_type;
+        typedef typename allocator_type::difference_type difference_type;
+        typedef bounds< base_type::dimensionality > bounds_type;
+        typedef bounds_type const& bounds_const_reference;
+        typedef assigner< type,base_type::size-1 > assigner_type; 
+        typedef mpl::bool_< I > initialize;
+        typedef B limits_type;
+
+        array();
+
+        array( type_const_reference );
+        template< bool I1, class A1 > array( array< T,B,I1,A1 > const& );
+
+        type_reference operator=( type_const_reference );
+        template< bool I1, class A1 > type_reference operator=( array< T,B,I1,A1 > const& );
+        assigner_type operator=( const_reference );
+
+        ~array();
+
+        const_reference_type operator[]( size_type ) const;
+        reference_type operator[]( size_type );
+
+        const_reference_type operator*() const;
+        reference_type operator*();
+
+        const_iterator_type operator+( size_type ) const;
+        iterator_type operator+( size_type );
+
+        const_reference operator[]( bounds_const_reference ) const;
+        reference operator[]( bounds_const_reference );
+
+        const_reference at( bounds_const_reference ) const;
+        reference at( bounds_const_reference );
+
+        template< std::size_t U > size_type const bound() const;
+
+        void swap( type_reference );
+        template< bool I1, class A1 > void swap( array< T,B,I1,A1 >& );
+
+        const_iterator begin() const;
+        iterator begin();
+        const_iterator end() const;
+        iterator end();
+
+    };
+
+//--
+//--
+
+    template< class T, class B, bool I, class A >
+    array< T,B,I,A >::array() : base_type()
+    {} // constructor
+
+    template< class T, class B, bool I, class A >
+    array< T,B,I,A >::array( type_const_reference a ) : base_type( a )
+    {} // copy constructor
+
+    template< class T, class B, bool I, class A > template< bool I1, class A1 >
+    array< T,B,I,A >::array( array< T,B,I1,A1 > const& a ) : base_type( a )
+    {} // copy constructor
+
+    template< class T, class B, bool I, class A >
+    typename array< T,B,I,A >::type_reference array< T,B,I,A >::operator=( type_const_reference a )
+    {
+        if( &a != this ) base_type::operator=( a );
+        return *this;
+    } // ( copy ) assignment operator
+
+    template< class T, class B, bool I, class A > template< bool I1, class A1 >
+    typename array< T,B,I,A >::type_reference array< T,B,I,A >::operator=( array< T,B,I1,A1 > const& a )
+    {
+        base_type::operator=( a );
+        return *this;
+    } // ( copy ) assignment operator
+
+    template< class T, class B, bool I, class A >
+    typename array< T,B,I,A >::assigner_type array< T,B,I,A >::operator=( const_reference t )
+    {
+        return assigner_type( *this, begin(), t );
+    } // assigner assignment
+
+    template< class T, class B, bool I, class A >
+    array< T,B,I,A >::~array()
+    {}
+
+    template< class T, class B, bool I, class A >
+    typename array< T,B,I,A >::const_reference_type array< T,B,I,A >::operator[]( size_type s ) const
+    {
+        return this->data[s];
+    } // operator[] const
+
+    template< class T, class B, bool I, class A >
+    typename array< T,B,I,A >::reference_type array< T,B,I,A >::operator[]( size_type s )
+    {
+        return this->data[s];
+    } // operator[]
+
+    template< class T, class B, bool I, class A >
+    typename array< T,B,I,A >::const_reference_type array< T,B,I,A >::operator*() const
+    {
+        return *this->data;
+    } // dereference
+
+    template< class T, class B, bool I, class A >
+    typename array< T,B,I,A >::reference_type array< T,B,I,A >::operator*()
+    {
+        return *this->data;
+    } // dereference
+
+    template< class T, class B, bool I, class A >
+    typename array< T,B,I,A >::const_iterator_type array< T,B,I,A >::operator+( size_type s ) const
+    {
+        return this->data+s;
+    } // operator+, enables explicit indirection expressions
+
+    template< class T, class B, bool I, class A >
+    typename array< T,B,I,A >::iterator_type array< T,B,I,A >::operator+( size_type s )
+    {
+        return this->data+s;
+    } // operator+, enables explicit indirection expressions
+
+    template< class T, class B, bool I, class A >
+    typename array< T,B,I,A >::const_reference array< T,B,I,A >::operator[]( bounds_const_reference b ) const
+    {
+        return array_element_const< T,B,base_type::N::value,typename base_type::F,I,A >()( this->data, b.begin() );
+    } // operator[] const
+
+    template< class T, class B, bool I, class A >
+    typename array< T,B,I,A >::reference array< T,B,I,A >::operator[]( bounds_const_reference b )
+    {
+        return array_element< T,B,base_type::N::value,typename base_type::F,I,A >()( this->data, b.begin() );
+    } // operator[]
+
+    template< class T, class B, bool I, class A >
+    typename array< T,B,I,A >::const_reference array< T,B,I,A >::at( bounds_const_reference b ) const
+    {
+        return array_element_at_const< T,B,base_type::N::value,typename base_type::F,I,A >()( this->data, b.begin() );
+    } // at const
+
+    template< class T, class B, bool I, class A >
+    typename array< T,B,I,A >::reference array< T,B,I,A >::at( bounds_const_reference b )
+    {
+        return array_element_at< T,B,base_type::N::value,typename base_type::F,I,A >()( this->data, b.begin() );
+    } // at
+
+    template< class T, class B, bool I, class A > template< std::size_t U >
+    typename array< T,B,I,A >::size_type const array< T,B,I,A >::bound() const
+    {
+        BOOST_STATIC_ASSERT( U < base_type::dimensionality );
+        return mpl::at< B, mpl::size_t< U > >::type::value;
+    } // bound
+
+    template< class T, class B, bool I, class A >
+    void array< T,B,I,A >::swap( type_reference a )
+    {
+        if( &a != this ) array_swap< T,base_type::N::value,typename base_type::F,A >()( this->data, a.data ); 
+    } // swap
+
+    template< class T, class B, bool I, class A > template< bool I1, class A1 >
+    void array< T,B,I,A >::swap( array< T,B,I1,A1 >& a )
+    {
+        array_swap< T,base_type::N::value,typename base_type::F,A >()( this->data, a.data ); 
+    } // swap
+
+    template< class T, class B, bool I, class A >
+    typename array< T,B,I,A >::const_iterator array< T,B,I,A >::begin() const
+    {
+        return array_begin_const< T,B,base_type::N::value,typename base_type::F,I,A >()( this->data );
+    } // begin const
+
+    template< class T, class B, bool I, class A >
+    typename array< T,B,I,A >::iterator array< T,B,I,A >::begin()
+    {
+        return array_begin< T,B,base_type::N::value,typename base_type::F,I,A >()( this->data );
+    } // begin
+
+    template< class T, class B, bool I, class A >
+    typename array< T,B,I,A >::const_iterator array< T,B,I,A >::end() const
+    {
+        return begin()+base_type::size;
+    } // end const
+
+    template< class T, class B, bool I, class A >
+    typename array< T,B,I,A >::iterator array< T,B,I,A >::end()
+    {
+        return begin()+base_type::size;
+    } // end
+
+//--
+//--
+
+    template< class T, class B, bool I, class A >
+    array_base< T,B,I,A >::array_base()
+    {
+        array_constructor< T,N::value,F,D::value,C::value,A >()( data );
+    } // constructor
+
+    template< class T, class B, bool I, class A >
+    array_base< T,B,I,A >::array_base( type_const_reference a )
+    {
+        array_copy< T,N::value,F,D::value,A >()( data, a.data );
+    } // copy constructor
+
+    template< class T, class B, bool I, class A > template< bool I1, class A1 >
+    array_base< T,B,I,A >::array_base( array< T,B,I1,A1 > const& a )
+    {
+        array_copy< T,N::value,F,D::value,A >()( data, a.data );
+    } // copy constructor
+
+    template< class T, class B, bool I, class A >
+    void array_base< T,B,I,A >::operator=( type_const_reference a )
+    {
+        array_assign< T,N::value,F,D::value,M::value,A >()( data, a.data );
+    } // ( copy ) assignment operator
+
+    template< class T, class B, bool I, class A > template< bool I1, class A1 >
+    void array_base< T,B,I,A >::operator=( array< T,B,I1,A1 > const& a )
+    {
+        array_assign< T,N::value,F,D::value,M::value,A >()( data, a.data );
+    } // ( copy ) assignment operator
+
+    template< class T, class B, bool I, class A >
+    array_base< T,B,I,A >::~array_base()
+    {
+        array_destructor< T,N::value,F,D::value,M::value,A >()( data );
+    }
+
+//--
+//--
+
+    template< class T, class B, bool I >
+    array_base< T,B,I,null::allocator >::array_base()
+    {
+        array_constructor< T,N::value,F,size,C::value,null::allocator >()( data );
+    } // constructor
+
+//--
+//--
+
+    template< class T, class B, bool I, class A >
+    struct sub_type< array< T,B,I,A > >
+    {
+        typedef array< T,typename mpl::pop_front< B >::type,I,A > type;
+    };
+
+//--
+//--
+
+    template< class T, class B, std::size_t N, class F, bool I, class A, class C, class CT >
+    struct array_out
+    {
+        typedef std::basic_ostringstream< C,CT,std::allocator< C > > stream;
+        typedef typename array< T,B,I,A >::const_iterator_type type;
+        typedef typename mpl::pop_front< B >::type P;
+        typedef typename mpl::deref< F >::type D;
+        typedef typename mpl::next< F >::type G;
+
+        stream& operator()( stream& s, type const& a ) 
+        {
+            s << '(';
+            for( std::size_t i = 0; i != D::value; ++i )
+            {   array_out< T,P,N-1,G,I,A,C,CT >()( s, a[i] );
+                if( i != D::value - 1 ) s << ',';
+            }
+            s << ')';
+            return s;
+        }
+    };
+
+    template< class T, class B, class F, bool I, class A, class C, class CT >
+    struct array_out< T,B,1,F,I,A,C,CT >
+    {
+        typedef std::basic_ostringstream< C,CT,std::allocator< C > > stream;
+        typedef typename array< T,B,I,A >::const_iterator_type type;
+        typedef typename mpl::deref< F >::type D;
+
+        stream& operator()( stream& s, type const& a ) 
+        {
+            s << '(';
+            for( std::size_t i = 0; i != D::value - 1; ++i ) s << a[i] << ',';
+            s << a[D::value-1] << ')';
+            return s;
+        }
+    };
+
+//--
+
+    template< std::size_t N, class F, class C, class CT >
+    struct array_out_size
+    {
+        typedef std::basic_ostringstream< C,CT,std::allocator< C > > stream;
+        typedef typename mpl::deref< F >::type D;
+        typedef typename mpl::next< F >::type G;
+
+        void operator()( stream& s ) 
+        {
+            s << '[' << D::value << ']';
+            array_out_size< N-1,G,C,CT >()( s );
+        }
+    };
+
+    template< class F, class C, class CT >
+    struct array_out_size< 1,F,C,CT >
+    {
+        typedef std::basic_ostringstream< C,CT,std::allocator< C > > stream;
+        typedef typename mpl::deref< F >::type D;
+
+        void operator()( stream& s ) 
+        {
+            s << '[' << D::value << ']';
+        }
+    };
+
+//--
+
+    template< class T, class B, bool I, class A, class C, class CT >
+    std::basic_ostream< C,CT >& operator<<( std::basic_ostream< C,CT >& o, array< T,B,I,A > const& a )
+    {
+        typedef typename mpl::size< B >::type N; typedef typename mpl::begin< B >::type F;
+
+        std::basic_ostringstream< C,CT,std::allocator< C > > s;
+        s.flags( o.flags() ); s.imbue( o.getloc() ); s.precision( o.precision() );
+        array_out_size< N::value,F,C,CT >()( s );
+        return o << array_out< T,B,N::value,F,I,A,C,CT >()( s, a+0 ).str().c_str();
+    }
+
+//--
+//--
+
+    template< class T, bool I, class A >
+    class array< T,bounds0,I,A >
+    {
+    public:
+
+        typedef array type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef type const* type_const_pointer;
+        typedef type* type_pointer;
+        typedef bounds0 subarray_type;
+        typedef bounds0 member_type;
+        typedef T value_type;
+        typedef value_type const& const_reference_type;
+        typedef value_type& reference_type;
+        typedef value_type const* const_iterator_type;
+        typedef value_type* iterator_type;
+        typedef T element_type;
+        typedef T const& const_reference;
+        typedef T& reference;
+        typedef T const* const_iterator;
+        typedef T* iterator;
+        typedef typename A::template rebind< T >::other allocator_type;
+        typedef typename allocator_type::size_type size_type;
+        typedef typename allocator_type::difference_type difference_type;
+        typedef bounds< 0 > bounds_type;
+        typedef bounds_type const& bounds_const_reference;
+        typedef mpl::bool_< I > initialize;
+        typedef bounds0 limits;
+
+        enum { dimensionality = 0, size = 0 };
+
+    };
+
+    template< class T, bool I, class A >
+    class array< T,mpl::vector0<>,I,A >
+        : public array< T,bounds0,I,A >
+    {};
+
+//--
+//--
+
+    template< class T, class B, bool I, class A, bool I1, class A1 >
+    bool operator==( array< T,B,I,A > const& x, array< T,B,I1,A1 > const& y )
+    {
+        return std::equal( x.begin(), x.end(), y.begin() );
+    }
+
+    template< class T, class B, bool I, class A, bool I1, class A1 >
+    bool operator<( array< T,B,I,A > const& x, array< T,B,I1,A1 > const& y )
+    {
+        return std::lexicographical_compare( x.begin(), x.end(), y.begin(), y.end() );
+    }
+
+    template< class T, class B, bool I, class A, bool I1, class A1 >
+    bool operator!=( array< T,B,I,A > const& x, array< T,B,I1,A1 > const& y )
+    {
+        return !( x == y );
+    }
+
+    template< class T, class B, bool I, class A, bool I1, class A1 >
+    bool operator>( array< T,B,I,A > const& x, array< T,B,I1,A1 > const& y )
+    {
+        return y < x;
+    }
+
+    template< class T, class B, bool I, class A, bool I1, class A1 >
+    bool operator<=( array< T,B,I,A > const& x, array< T,B,I1,A1 > const& y )
+    {
+        return !( y < x );
+    }
+
+    template< class T, class B, bool I, class A, bool I1, class A1 >
+    bool operator>=( array< T,B,I,A > const& x, array< T,B,I1,A1 > const& y )
+    {
+        return !( x < y );
+    }
+
+//--
+
+    template< class T, class B, bool I, class A >
+    void swap( array< T,B,I,A >& x, array< T,B,I,A >& y )
+    {
+        x.swap( y );
+    }
+
+    template< class T, class B, bool I, class A, bool I1, class A1 >
+    void swap( array< T,B,I,A >& x, array< T,B,I1,A1 >& y )
+    {
+        x.swap( y );
+    }
+
+//--
+
+}} // namespace boost, namespace maps
+
+#ifdef BOOST_MSVC
+# pragma warning( default : 4996 )
+#endif
+
+#endif // BOOST_MAPS_GENERIC_ARRAY_HPP
Added: sandbox/maps/boost/maps/generic/array_.hpp
==============================================================================
--- (empty file)
+++ sandbox/maps/boost/maps/generic/array_.hpp	2011-08-08 19:51:30 EDT (Mon, 08 Aug 2011)
@@ -0,0 +1,1058 @@
+//--
+// Copyright (c) 2010-2011 Brian Smith
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/maps for documentation.
+//--
+#if !defined( BOOST_MAPS_GENERIC_ARRAY_HPP_ )
+#define BOOST_MAPS_GENERIC_ARRAY_HPP_
+
+#include <boost/maps/support/includes.hpp>
+
+#ifdef BOOST_MSVC
+# pragma warning( disable : 4996 ) // std::copy and its relatives deprecated by microsoft
+#endif
+
+namespace boost { namespace maps {
+
+//--
+
+    template< class T, std::size_t N, std::size_t D, std::size_t S, class A >
+    struct array_allocate_
+    {    
+        typedef typename array_type_< T,N,D,A >::type type;
+        typedef typename array_type_< T,N-1,D,A >::type value_type;
+        typedef typename A::template rebind< value_type >::other allocator;
+
+        void operator()( type& p ) 
+        {    
+            allocator a; 
+            p = a.allocate( S );
+        }
+    };
+
+//--
+
+    template< class T, std::size_t N, std::size_t D, std::size_t S, class A >
+    struct array_deallocate_
+    {    
+        typedef typename array_type_< T,N,D,A >::type type;
+        typedef typename array_type_< T,N-1,D,A >::type value_type;
+        typedef typename A::template rebind< value_type >::other allocator;
+
+        void operator()( type& p ) 
+        {    
+            allocator a; 
+            a.deallocate( p, S ); p = 0;
+        }
+    };
+
+//--
+
+    template< class T, std::size_t N, std::size_t D, std::size_t S, bool I, class A >
+    struct array_construct_
+    {    
+        typedef typename array_type_< T,N,D,A >::type type;
+        typedef typename array_type_< T,N-1,D,A >::type value_type;
+        typedef typename A::template rebind< value_type >::other allocator;
+
+        void operator()( type& p ) 
+        {    
+            type f = p, l = p+S;
+            allocator a;
+            try
+            {   T t = T();
+                while( f != l ) { a.construct( f, t ); ++f; }
+            }catch( ... )
+            {   type n = p;
+                while( n != f ) { a.destroy( n ); ++n; }
+                throw;
+            }
+        }
+    };
+
+    template< class T, std::size_t N, std::size_t D, std::size_t S, class A >
+    struct array_construct_< T,N,D,S,false,A >
+    {    
+        typedef typename array_type_< T,N,D,A >::type type;
+
+        void operator()( type& ) 
+        {}
+    };
+
+//--
+
+    template< class T, std::size_t N, std::size_t D, std::size_t S, bool I, class A >
+    struct array_destroy_
+    {    
+        typedef typename array_type_< T,N,D,A >::type type;
+        typedef typename array_type_< T,N-1,D,A >::type value_type;
+        typedef typename A::template rebind< value_type >::other allocator;
+
+        void operator()( type& p ) 
+        {    
+            allocator a; 
+            for( std::size_t i = 0; i != S; ++i ) a.destroy( p+i );
+        }
+    };
+
+    template< class T, std::size_t N, std::size_t D, std::size_t S, class A >
+    struct array_destroy_< T,N,D,S,true,A >
+    {    
+        typedef typename array_type_< T,N,D,A >::type type;
+
+        void operator()( type& ) 
+        {}
+    };
+
+//--
+//--
+
+    template< class T, std::size_t N, std::size_t D, std::size_t S, bool I, class A >
+    struct array_constructor_
+    {
+        typedef typename array_type_< T,N,D,A >::type type;
+
+        void operator()( type& p ) 
+        {    
+            array_allocate_< T,N,D,S,A >()( p );
+            try { array_constructor_< T,N-1,D,S*D,I,A >()( p[0] ); }
+            catch( ... ) { array_deallocate_< T,N,D,S,A >()( p ); throw; }
+            for( std::size_t j = 1, k = D; j != S; ++j ) p[j] = p[j-1] + k;
+        }
+    };
+
+    template< class T, std::size_t D, std::size_t S, bool I, class A >
+    struct array_constructor_< T,1,D,S,I,A >
+    {
+        typedef typename array_type_< T,1,D,A >::type type;
+
+        void operator()( type& p )
+        {
+            array_allocate_< T,1,D,S,A >()( p );
+            try { array_construct_< T,1,D,S,I,A >()( p ); }
+            catch( ... ) { array_deallocate_< T,1,D,S,A >()( p ); throw; }
+        }
+    };
+
+//--
+
+    template< class T, std::size_t N, std::size_t D, std::size_t S, bool I, class A >
+    struct array_destructor_
+    {    
+        typedef typename array_type_< T,N,D,A >::type type;
+
+        void operator()( type& p )
+        {    
+            array_destructor_< T,N-1,D,S*D,I,A >()( p[0] );
+            array_deallocate_< T,N,D,S,A >()( p );
+        }
+    };
+
+    template< class T, std::size_t D, std::size_t S, bool I, class A >
+    struct array_destructor_< T,1,D,S,I,A >
+    {    
+        typedef typename array_type_< T,1,D,A >::type type;
+
+        void operator()( type& p ) 
+        {    
+            array_destroy_< T,1,D,S,I,A >()( p );
+            array_deallocate_< T,1,D,S,A >()( p );
+        }
+    };
+
+//--
+
+    template< class T, std::size_t N, std::size_t D, std::size_t S, class A >
+    struct array_copy_
+    {    
+        typedef typename array_type_< T,N,D,A >::type type;
+
+        void operator()( type& p, type const& q ) 
+        {    
+            array_allocate_< T,N,D,S,A >()( p ); 
+            try { array_copy_< T,N-1,D,S*D,A >()( p[0], q[0] ); }
+            catch( ... ) { array_deallocate_< T,N,D,S,A >()( p ); throw; }
+            for( std::size_t j = 1, k = D; j != S; ++j ) p[j] = p[j-1] + k;
+        }
+    };
+
+    template< class T, std::size_t D, std::size_t S, class A >
+    struct array_copy_< T,1,D,S,A >
+    {    
+        typedef typename array_type_< T,1,D,A >::type type;
+
+        void operator()( type& p, type const& q )
+        {    
+            array_allocate_< T,1,D,S,A >()( p );
+            try { std::uninitialized_copy( q, q+S, p ); }
+            catch( ... ) { array_deallocate_< T,1,D,S,A >()( p ); throw; }
+        }
+    };
+
+//--
+
+    template< class T, std::size_t N, std::size_t D, std::size_t S, bool I, class A >
+    struct array_assign_
+    {    
+        typedef typename array_type_< T,N,D,A >::type type;
+
+        void operator()( type& p, type const& q ) 
+        {    
+            array_assign_< T,N-1,D,S*D,I,A >()( p[0], q[0] );
+        }
+    };
+
+    template< class T, std::size_t D, std::size_t S, bool I, class A >
+    struct array_assign_< T,2,D,S,I,A >
+    {    
+        typedef typename array_type_< T,2,D,A >::type type;
+
+        void operator()( type& p, type const& q ) 
+        {    
+            array_assign_< T,1,D,S*D,I,A >()( p[0], q[0] );
+            for( std::size_t j = 0, k = 0; j != S; ++j, k += D ) p[j] = &p[0][k];
+        }
+    };
+
+    template< class T, std::size_t D, std::size_t S, bool I, class A >
+    struct array_assign_< T,1,D,S,I,A >
+    {    
+        typedef typename array_type_< T,1,D,A >::type type;
+
+        void operator()( type& p, type const& q )
+        {    
+            type t = 0; array_allocate_< T,1,D,S,A >()( t );
+            try { std::uninitialized_copy( q, q+S, t ); }
+            catch( ... ) { array_deallocate_< T,1,D,S,A >()( t ); throw; }
+            type r = p; p = t; t = 0; array_destructor_< T,1,D,S,I,A >()( r );
+        }
+    };
+
+//--
+
+    template< class T, std::size_t N, std::size_t D, class A >
+    struct array_swap_
+    {
+        typedef typename array_type_< T,N,D,A >::type type;
+
+        void operator()( type& p, type& q ) 
+        {
+            std::swap( p, q );
+        }
+    };
+
+//--
+//--
+
+    template< class T, std::size_t N, std::size_t D, std::size_t S, bool I >
+    struct array_constructor_< T,N,D,S,I,null::allocator >
+    {
+        typedef typename array_type_< T,N,D,null::allocator >::type type;
+
+        void operator()( type& a ) 
+        {   
+            memset( a, 0, S * sizeof(T) );
+        }
+    };
+
+    template< class T, std::size_t D, std::size_t S, bool I >
+    struct array_constructor_< T,1,D,S,I,null::allocator >
+    {
+        typedef typename array_type_< T,1,D,null::allocator >::type type;
+
+        void operator()( type& a ) 
+        {   
+            memset( a, 0, S * sizeof(T) );
+        }
+    };
+
+    template< class T, std::size_t N, std::size_t D, std::size_t S >
+    struct array_constructor_< T,N,D,S,false,null::allocator >
+    {
+        typedef typename array_type_< T,N,D,null::allocator >::type type;
+
+        void operator()( type& ) 
+        {}
+    };
+
+    template< class T, std::size_t D, std::size_t S >
+    struct array_constructor_< T,1,D,S,false,null::allocator >
+    {
+        typedef typename array_type_< T,1,D,null::allocator >::type type;
+
+        void operator()( type& ) 
+        {}
+    };
+
+//--
+
+    template< class T, std::size_t N, std::size_t D >
+    struct array_swap_< T,N,D,null::allocator >
+    {
+        typedef typename array_type_< T,N,D,null::allocator >::type type;
+
+        void operator()( type& p, type& q ) 
+        {
+            for( std::size_t i = 0; i != D; ++i )
+                array_swap_< T,N-1,D,null::allocator >()( p[i], q[i] );
+        }
+    };
+
+    template< class T, std::size_t D >
+    struct array_swap_< T,1,D,null::allocator >
+    {
+        typedef typename array_type_< T,1,D,null::allocator >::type type;
+
+        void operator()( type& p, type& q )
+        {
+            for( std::size_t i = 0; i != D; ++i ) 
+                std::swap( p[i], q[i] );
+        }
+    };
+
+//--
+//--
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    struct array_element_const_
+    {
+        typedef typename array_< T,N,D,I,A >::const_reference const_reference;
+        typedef typename array_type_< T,N,D,A >::type type;
+        typedef typename bounds< N >::const_iterator const_iterator;
+
+        const_reference operator()( type const& p, const_iterator i )
+        {
+            BOOST_ASSERT( *i < D );
+            return array_element_const_< T,N-1,D,I,A >()( p[*i], i+1 );
+        }
+    };
+
+    template< class T, std::size_t D, bool I, class A >
+    struct array_element_const_< T,1,D,I,A >
+    {
+        typedef typename array_< T,1,D,I,A >::const_reference const_reference;
+        typedef typename array_type_< T,1,D,A >::type type;
+        typedef typename bounds< 1 >::const_iterator const_iterator;
+
+        const_reference operator()( type const& p, const_iterator i )
+        {
+            BOOST_ASSERT( *i < D );
+            return p[*i];
+        }
+    };
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    struct array_element_
+    {
+        typedef typename array_< T,N,D,I,A >::reference reference;
+        typedef typename array_type_< T,N,D,A >::type type;
+        typedef typename bounds< N >::const_iterator const_iterator;
+
+        reference operator()( type& p, const_iterator i )
+        {
+            BOOST_ASSERT( *i < D );
+            return array_element_< T,N-1,D,I,A >()( p[*i], i+1 );
+        }
+    };
+
+    template< class T, std::size_t D, bool I, class A >
+    struct array_element_< T,1,D,I,A >
+    {
+        typedef typename array_< T,1,D,I,A >::reference reference;
+        typedef typename array_type_< T,1,D,A >::type type;
+        typedef typename bounds< 1 >::const_iterator const_iterator;
+
+        reference operator()( type& p, const_iterator i )
+        {
+            BOOST_ASSERT( *i < D );
+            return p[*i];
+        }
+    };
+
+//--
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    struct array_element_at_const_
+    {
+        typedef typename array_< T,N,D,I,A >::const_reference const_reference;
+        typedef typename array_type_< T,N,D,A >::type type;
+        typedef typename bounds< N >::const_iterator const_iterator;
+
+        const_reference operator()( type const& p, const_iterator i )
+        {
+            if( !( *i < D ) ) 
+                throw std::out_of_range( "array_<> access out of range" );
+            return array_element_at_const_< T,N-1,D,I,A >()( p[*i], i+1 );
+        }
+    };
+
+    template< class T, std::size_t D, bool I, class A >
+    struct array_element_at_const_< T,1,D,I,A >
+    {
+        typedef typename array_< T,1,D,I,A >::const_reference const_reference;
+        typedef typename array_type_< T,1,D,A >::type type;
+        typedef typename bounds< 1 >::const_iterator const_iterator;
+
+        const_reference operator()( type const& p, const_iterator i )
+        {
+            if( !( *i < D ) )
+                throw std::out_of_range( "array_<> access out of range" );
+            return p[*i];
+        }
+    };
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    struct array_element_at_
+    {
+        typedef typename array_< T,N,D,I,A >::reference reference;
+        typedef typename array_type_< T,N,D,A >::type type;
+        typedef typename bounds< N >::const_iterator const_iterator;
+
+        reference operator()( type& p, const_iterator i )
+        {
+            if( !( *i < D ) ) 
+                throw std::out_of_range( "array_<> access out of range" );
+            return array_element_at_< T,N-1,D,I,A >()( p[*i], i+1 );
+        }
+    };
+
+    template< class T, std::size_t D, bool I, class A >
+    struct array_element_at_< T,1,D,I,A >
+    {
+        typedef typename array_< T,1,D,I,A >::reference reference;
+        typedef typename array_type_< T,1,D,A >::type type;
+        typedef typename bounds< 1 >::const_iterator const_iterator;
+
+        reference operator()( type& p, const_iterator i )
+        {
+            if( !( *i < D ) )
+                throw std::out_of_range( "array_<> access out of range" );
+            return p[*i];
+        }
+    };
+
+//--
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    struct array_begin_const_
+    {
+        typedef typename array_< T,N,D,I,A >::const_iterator const_iterator;
+        typedef typename array_type_< T,N,D,A >::type type;
+
+        const_iterator operator()( type const& p ) 
+        {
+            return array_begin_const_< T,N-1,D,I,A >()( *p );
+        }
+    };
+
+    template< class T, std::size_t D, bool I, class A >
+    struct array_begin_const_< T,1,D,I,A >
+    {    
+        typedef typename array_< T,1,D,I,A >::const_iterator const_iterator;
+        typedef typename array_type_< T,1,D,A >::type type;
+
+        const_iterator operator()( type const& p )
+        {
+            return p;
+        }
+    };
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    struct array_begin_
+    {    
+        typedef typename array_< T,N,D,I,A >::iterator iterator;
+        typedef typename array_type_< T,N,D,A >::type type;
+
+        iterator operator()( type& p ) 
+        {
+            return array_begin_< T,N-1,D,I,A >()( *p );
+        }
+    };
+
+    template< class T, std::size_t D, bool I, class A >
+    struct array_begin_< T,1,D,I,A >
+    {
+        typedef typename array_< T,1,D,I,A >::iterator iterator;
+        typedef typename array_type_< T,1,D,A >::type type;
+
+        iterator operator()( type& p )
+        {
+            return p;
+        }
+    };
+
+//--
+
+    // Base type for dynamically allocated array_'s.
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    class array_base_
+        : public expression< array_< T,N,D,I,A > >
+    {
+    public:
+
+        typedef array_< T,N,D,I,A > type;
+        typedef type const& type_const_reference;
+        typedef expression< type > base_type;
+        typedef typename array_member_type_< T,N,D,A >::type member_type;
+        
+        enum { dimensionality = N, size = array_size_< N,D >::type::value };
+
+        array_base_();
+
+        array_base_( type_const_reference );
+        template< bool I1, class A1 > array_base_( array_< T,N,D,I1,A1 > const& );
+
+        void operator=( type_const_reference );
+        template< bool I1, class A1 > void operator=( array_< T,N,D,I1,A1 > const& );
+
+        ~array_base_();
+
+    protected:
+
+        typedef typename has_trivial_destructor< T >::type M;
+        typedef typename array_initialize< T,I,A >::type C;
+
+        member_type data;
+
+        template< class T1, std::size_t N1, std::size_t D1, bool I1, class A1 > 
+        friend class array_;
+    };
+
+//--
+//--
+
+    // Base type for statically allocated array_'s.
+    template< class T, std::size_t N, std::size_t D, bool I >
+    class array_base_< T,N,D,I,null::allocator >
+        : public expression< array_< T,N,D,I,null::allocator > >
+    {
+    public:
+
+        typedef array_< T,N,D,I,null::allocator > type;
+        typedef expression< type > base_type;
+        typedef typename array_member_type_< T,N,D,null::allocator >::type member_type;
+        
+        enum { dimensionality = N, size = array_size_< N,D >::type::value };
+
+        array_base_();
+
+    protected:
+
+        typedef typename array_initialize< T,I,null::allocator >::type C;
+
+        member_type data;
+
+        template< class T1, std::size_t N1, std::size_t D1, bool I1, class A1 > 
+        friend class array_;
+    };
+
+//--
+//--
+
+    /*
+        array_ class template
+
+        parameters
+
+            required
+
+                T - stored data type
+                    type: arbitrary type
+                N - number of dimensions 
+                    type: std::size_t
+                D - size of each dimension
+                    type: std::size_t
+
+            optional
+
+                I - initialization parameter 
+                    type: bool 
+                    default: true, data elements zero/default initialized
+                A - allocator 
+                    type: standard conforming allocator, or null::allocator
+                    default: null::allocator, statically allocated array
+    */
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    class array_
+        : public array_base_< T,N,D,I,A >
+    {
+    public:
+
+        typedef array_ type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef type const* type_const_pointer;
+        typedef type* type_pointer;
+        typedef array_base_< T,N,D,I,A > base_type;
+        typedef sub_type< type > subarray_type;
+        typedef typename base_type::member_type member_type;
+        typedef typename array_value_type_< T,N,D,A >::type value_type;
+        typedef value_type const& const_reference_type;
+        typedef value_type& reference_type;
+        typedef value_type const* const_iterator_type;
+        typedef value_type* iterator_type;
+        typedef T element_type;
+        typedef T const& const_reference;
+        typedef T& reference;
+        typedef T const* const_iterator;
+        typedef T* iterator;
+        typedef typename A::template rebind< value_type >::other allocator_type;
+        typedef typename allocator_type::size_type size_type;
+        typedef typename allocator_type::difference_type difference_type;
+        typedef bounds< base_type::dimensionality > bounds_type;
+        typedef bounds_type const& bounds_const_reference;
+        typedef assigner< type,base_type::size-1 > assigner_type; 
+        typedef mpl::bool_< I > initialize;
+        typedef typename array_bounds_< N,D >::type limits_type;
+
+        array_();
+
+        array_( type_const_reference );
+        template< bool I1, class A1 > array_( array_< T,N,D,I1,A1 > const& );
+
+        type_reference operator=( type_const_reference );
+        template< bool I1, class A1 > type_reference operator=( array_< T,N,D,I1,A1 > const& );
+        assigner_type operator=( const_reference );
+
+        ~array_();
+
+        const_reference_type operator[]( size_type ) const;
+        reference_type operator[]( size_type );
+
+        const_reference_type operator*() const;
+        reference_type operator*();
+
+        const_iterator_type operator+( size_type ) const;
+        iterator_type operator+( size_type );
+
+        const_reference operator[]( bounds_const_reference ) const;
+        reference operator[]( bounds_const_reference );
+
+        const_reference at( bounds_const_reference ) const;
+        reference at( bounds_const_reference );
+
+        template< std::size_t U > size_type const bound() const;
+
+        void swap( type_reference );
+        template< bool I1, class A1 > void swap( array_< T,N,D,I1,A1 >& );
+
+        const_iterator begin() const;
+        iterator begin();
+        const_iterator end() const;
+        iterator end();
+
+    };
+
+//--
+//--
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    array_< T,N,D,I,A >::array_() : base_type()
+    {} // constructor
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    array_< T,N,D,I,A >::array_( type_const_reference a ) : base_type( a )
+    {} // copy constructor
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A > template< bool I1, class A1 >
+    array_< T,N,D,I,A >::array_( array_< T,N,D,I1,A1 > const& a ) : base_type( a )
+    {} // copy constructor
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    typename array_< T,N,D,I,A >::type_reference array_< T,N,D,I,A >::operator=( type_const_reference a )
+    {
+        if( &a != this ) base_type::operator=( a );
+        return *this;
+    } // ( copy ) assignment operator
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A > template< bool I1, class A1 >
+    typename array_< T,N,D,I,A >::type_reference array_< T,N,D,I,A >::operator=( array_< T,N,D,I1,A1 > const& a )
+    {
+        base_type::operator=( a );
+        return *this;
+    } // ( copy ) assignment operator
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    typename array_< T,N,D,I,A >::assigner_type array_< T,N,D,I,A >::operator=( const_reference t )
+    {
+        return assigner_type( *this, begin(), t );
+    } // assigner assignment
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    array_< T,N,D,I,A >::~array_()
+    {}
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    typename array_< T,N,D,I,A >::const_reference_type array_< T,N,D,I,A >::operator[]( size_type s ) const
+    {
+        return this->data[s];
+    } // operator[] const
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    typename array_< T,N,D,I,A >::reference_type array_< T,N,D,I,A >::operator[]( size_type s )
+    {
+        return this->data[s];
+    } // operator[]
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    typename array_< T,N,D,I,A >::const_reference_type array_< T,N,D,I,A >::operator*() const
+    {
+        return *this->data;
+    } // dereference
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    typename array_< T,N,D,I,A >::reference_type array_< T,N,D,I,A >::operator*()
+    {
+        return *this->data;
+    } // dereference
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    typename array_< T,N,D,I,A >::const_iterator_type array_< T,N,D,I,A >::operator+( size_type s ) const
+    {
+        return this->data+s;
+    } // operator+, enables explicit indirection expressions
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    typename array_< T,N,D,I,A >::iterator_type array_< T,N,D,I,A >::operator+( size_type s )
+    {
+        return this->data+s;
+    } // operator+, enables explicit indirection expressions
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    typename array_< T,N,D,I,A >::const_reference array_< T,N,D,I,A >::operator[]( bounds_const_reference b ) const
+    {
+        return array_element_const_< T,N,D,I,A >()( this->data, b.begin() );
+    } // operator[] const
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    typename array_< T,N,D,I,A >::reference array_< T,N,D,I,A >::operator[]( bounds_const_reference b )
+    {
+        return array_element_< T,N,D,I,A >()( this->data, b.begin() );
+    } // operator[]
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    typename array_< T,N,D,I,A >::const_reference array_< T,N,D,I,A >::at( bounds_const_reference b ) const
+    {
+        return array_element_at_const_< T,N,D,I,A >()( this->data, b.begin() );
+    } // at const
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    typename array_< T,N,D,I,A >::reference array_< T,N,D,I,A >::at( bounds_const_reference b )
+    {
+        return array_element_at_< T,N,D,I,A >()( this->data, b.begin() );
+    } // at
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A > template< std::size_t U >
+    typename array_< T,N,D,I,A >::size_type const array_< T,N,D,I,A >::bound() const
+    {
+        BOOST_STATIC_ASSERT( U < N );
+        return D;
+    } // bound
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    void array_< T,N,D,I,A >::swap( type_reference a )
+    {
+        if( &a != this ) array_swap_< T,N,D,A >()( this->data, a.data ); 
+    } // swap
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A > template< bool I1, class A1 >
+    void array_< T,N,D,I,A >::swap( array_< T,N,D,I1,A1 >& a )
+    {
+        array_swap_< T,N,D,A >()( this->data, a.data );
+    } // swap
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    typename array_< T,N,D,I,A >::const_iterator array_< T,N,D,I,A >::begin() const
+    {
+        return array_begin_const_< T,N,D,I,A >()( this->data );
+    } // begin const
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    typename array_< T,N,D,I,A >::iterator array_< T,N,D,I,A >::begin()
+    {
+        return array_begin_< T,N,D,I,A >()( this->data );
+    } // begin
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    typename array_< T,N,D,I,A >::const_iterator array_< T,N,D,I,A >::end() const
+    {
+        return begin()+base_type::size;
+    } // end const
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    typename array_< T,N,D,I,A >::iterator array_< T,N,D,I,A >::end()
+    {
+        return begin()+base_type::size;
+    } // end
+
+//--
+//--
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    array_base_< T,N,D,I,A >::array_base_()
+    {
+        array_constructor_< T,N,D,D,C::value,A >()( data );
+    } // constructor
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    array_base_< T,N,D,I,A >::array_base_( type_const_reference a )
+    {
+        array_copy_< T,N,D,D,A >()( data, a.data );
+    } // copy constructor
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A > template< bool I1, class A1 >
+    array_base_< T,N,D,I,A >::array_base_( array_< T,N,D,I1,A1 > const& a )
+    {
+        array_copy_< T,N,D,D,A >()( data, a.data );
+    } // copy constructor
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    void array_base_< T,N,D,I,A >::operator=( type_const_reference a )
+    {
+        array_assign_< T,N,D,D,M::value,A >()( data, a.data );
+    } // ( copy ) assignment operator
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A > template< bool I1, class A1 >
+    void array_base_< T,N,D,I,A >::operator=( array_< T,N,D,I1,A1 > const& a )
+    {
+        array_assign_< T,N,D,D,M::value,A >()( data, a.data );
+    } // ( copy ) assignment operator
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    array_base_< T,N,D,I,A >::~array_base_()
+    {
+        array_destructor_< T,N,D,D,M::value,A >()( data );
+    }
+
+//--
+//--
+
+    template< class T, std::size_t N, std::size_t D, bool I >
+    array_base_< T,N,D,I,null::allocator >::array_base_()
+    {
+        array_constructor_< T,N,D,size,C::value,null::allocator >()( data );
+    } // constructor
+
+//--
+//--
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    struct sub_type< array_< T,N,D,I,A > >
+    {
+        typedef array_< T,N-1,D,I,A > type;
+    };
+
+//--
+//--
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A, class C, class CT >
+    struct array_out_
+    {
+        typedef std::basic_ostringstream< C,CT,std::allocator< C > > stream;
+        typedef typename array_< T,N,D,I,A >::const_iterator_type type;
+
+        stream& operator()( stream& s, type const& a ) 
+        {
+            s << '(';
+            for( std::size_t i = 0; i != D; ++i )
+            {   array_out_< T,N-1,D,I,A,C,CT >()( s, a[i] );
+                if( i != D - 1 ) s << ',';
+            }
+            s << ')';
+            return s;
+        }
+    };
+
+    template< class T, std::size_t D, bool I, class A, class C, class CT >
+    struct array_out_< T,1,D,I,A,C,CT >
+    {
+        typedef std::basic_ostringstream< C,CT,std::allocator< C > > stream;
+        typedef typename array_< T,1,D,I,A >::const_iterator_type type;
+
+        stream& operator()( stream& s, type const& a ) 
+        {
+            s << '(';
+            for( std::size_t i = 0; i != D - 1; ++i ) s << a[i] << ',';
+            s << a[D-1] << ')';
+            return s;
+        }
+    };
+
+//--
+
+    template< std::size_t N, std::size_t D, class C, class CT >
+    struct array_out_size_
+    {
+        typedef std::basic_ostringstream< C,CT,std::allocator< C > > stream;
+
+        void operator()( stream& s ) 
+        {
+            s << '[' << D << ']';
+            array_out_size_< N-1,D,C,CT >()( s );
+        }
+    };
+
+    template< std::size_t D, class C, class CT >
+    struct array_out_size_< 1,D,C,CT >
+    {
+        typedef std::basic_ostringstream< C,CT,std::allocator< C > > stream;
+
+        void operator()( stream& s ) 
+        {
+            s << '[' << D << ']';
+        }
+    };
+
+//--
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A, class C, class CT >
+    std::basic_ostream< C,CT >& operator<<( std::basic_ostream< C,CT >& o, array_< T,N,D,I,A > const& a )
+    {
+        std::basic_ostringstream< C,CT,std::allocator< C > > s;
+        s.flags( o.flags() ); s.imbue( o.getloc() ); s.precision( o.precision() );
+        array_out_size_< N,D,C,CT >()( s );
+        return o << array_out_< T,N,D,I,A,C,CT >()( s, a+0 ).str().c_str();
+    }
+
+//--
+//--
+
+    template< class T, std::size_t N, bool I, class A >
+    class array_< T,N,0,I,A >
+    {
+    public:
+
+        typedef array_ type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef type const* type_const_pointer;
+        typedef type* type_pointer;
+        typedef bounds0 subarray_type;
+        typedef bounds0 member_type;
+        typedef T value_type;
+        typedef value_type const& const_reference_type;
+        typedef value_type& reference_type;
+        typedef value_type const* const_iterator_type;
+        typedef value_type* iterator_type;
+        typedef T element_type;
+        typedef T const& const_reference;
+        typedef T& reference;
+        typedef T const* const_iterator;
+        typedef T* iterator;
+        typedef typename A::template rebind< T >::other allocator_type;
+        typedef typename allocator_type::size_type size_type;
+        typedef typename allocator_type::difference_type difference_type;
+        typedef bounds< N > bounds_type;
+        typedef bounds_type const& bounds_const_reference;
+        typedef mpl::bool_< I > initialize;
+        typedef mpl::vector0<> limits;
+
+        enum { dimensionality = N, size = 0 };
+
+    };
+
+    template< class T, bool I, class A >
+    class array_< T,0,0,I,A >
+    {
+    public:
+
+        typedef array_ type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef type const* type_const_pointer;
+        typedef type* type_pointer;
+        typedef bounds0 subarray_type;
+        typedef bounds0 member_type;
+        typedef T value_type;
+        typedef value_type const& const_reference_type;
+        typedef value_type& reference_type;
+        typedef value_type const* const_iterator_type;
+        typedef value_type* iterator_type;
+        typedef T element_type;
+        typedef T const& const_reference;
+        typedef T& reference;
+        typedef T const* const_iterator;
+        typedef T* iterator;
+        typedef typename A::template rebind< T >::other allocator_type;
+        typedef typename allocator_type::size_type size_type;
+        typedef typename allocator_type::difference_type difference_type;
+        typedef bounds< 0 > bounds_type;
+        typedef bounds_type const& bounds_const_reference;
+        typedef mpl::bool_< I > initialize;
+        typedef mpl::vector0<> limits;
+
+        enum { dimensionality = 0, size = 0 };
+
+    };
+
+    template< class T, std::size_t D, bool I, class A >
+    class array_< T,0,D,I,A >
+        : public array_< T,0,0,I,A >
+    {};
+
+//--
+//--
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A, bool I1, class A1 >
+    bool operator==( array_< T,N,D,I,A > const& x, array_< T,N,D,I1,A1 > const& y )
+    {
+        return std::equal( x.begin(), x.end(), y.begin() );
+    }
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A, bool I1, class A1 >
+    bool operator<( array_< T,N,D,I,A > const& x, array_< T,N,D,I1,A1 > const& y )
+    {
+        return std::lexicographical_compare( x.begin(), x.end(), y.begin(), y.end() );
+    }
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A, bool I1, class A1 >
+    bool operator!=( array_< T,N,D,I,A > const& x, array_< T,N,D,I1,A1 > const& y )
+    {
+        return !( x == y );
+    }
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A, bool I1, class A1 >
+    bool operator>( array_< T,N,D,I,A > const& x, array_< T,N,D,I1,A1 > const& y )
+    {
+        return y < x;
+    }
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A, bool I1, class A1 >
+    bool operator<=( array_< T,N,D,I,A > const& x, array_< T,N,D,I1,A1 > const& y )
+    {
+        return !( y < x );
+    }
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A, bool I1, class A1 >
+    bool operator>=( array_< T,N,D,I,A > const& x, array_< T,N,D,I1,A1 > const& y )
+    {
+        return !( x < y );
+    }
+
+//--
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    void swap( array_< T,N,D,I,A >& x, array_< T,N,D,I,A >& y )
+    {
+        x.swap( y );
+    } 
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A, bool I1, class A1 >
+    void swap( array_< T,N,D,I,A >& x, array_< T,N,D,I1,A1 >& y )
+    {
+        x.swap( y );
+    }
+
+//--
+
+}} // namespace boost, namespace maps
+
+#ifdef BOOST_MSVC
+# pragma warning( default : 4996 )
+#endif
+
+#endif // BOOST_MAPS_GENERIC_ARRAY_HPP_
Added: sandbox/maps/boost/maps/generic/pointer.hpp
==============================================================================
--- (empty file)
+++ sandbox/maps/boost/maps/generic/pointer.hpp	2011-08-08 19:51:30 EDT (Mon, 08 Aug 2011)
@@ -0,0 +1,1142 @@
+//--
+// Copyright (c) 2010-2011 Brian Smith
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/maps for documentation.
+//--
+#if !defined( BOOST_MAPS_GENERIC_POINTER_HPP )
+#define BOOST_MAPS_GENERIC_POINTER_HPP
+
+#include <boost/maps/support/includes.hpp>
+
+#ifdef BOOST_MSVC
+# pragma warning( disable : 4996 ) // std::copy and its relatives deprecated by microsoft
+#endif
+
+namespace boost { namespace maps {
+
+//--
+
+    template< class T, std::size_t N, class A >
+    struct pointer_allocate
+    {    
+        typedef typename pointer_type< T,N >::type type;
+        typedef typename A::template rebind< typename pointer_type< T,N-1 >::type >::other allocator;
+        typedef typename bounds< N >::size_type size_type;
+
+        void operator()( type& p, size_type s ) 
+        {    
+            allocator a; 
+            p = a.allocate( s );
+        }
+    };
+
+//--
+
+    template< class T, std::size_t N, class A >
+    struct pointer_deallocate
+    {    
+        typedef typename pointer_type< T,N >::type type;
+        typedef typename A::template rebind< typename pointer_type< T,N-1 >::type >::other allocator;
+        typedef typename bounds< N >::size_type size_type;
+
+        void operator()( type& p, size_type s ) 
+        {    
+            allocator a; 
+            a.deallocate( p, s ); p = 0;
+        }
+    };
+
+//--
+
+    template< class T, std::size_t N, bool I, class A >
+    struct pointer_construct
+    {    
+        typedef typename pointer_type< T,N >::type type;
+        typedef typename A::template rebind< typename pointer_type< T,N-1 >::type >::other allocator;
+        typedef typename bounds< N >::size_type size_type;
+
+        void operator()( type& p, size_type s ) 
+        {    
+            type f = p, l = p+s;
+            allocator a;
+            try
+            {   T t = T();
+                while( f != l ) { a.construct( f, t ); ++f; }
+            }catch( ... )
+            {   type n = p;
+                while( n != f ) { a.destroy( n ); ++n; }
+                throw;
+            }
+        }
+    };
+
+    template< class T, std::size_t N, class A >
+    struct pointer_construct< T,N,false,A >
+    {    
+        typedef typename pointer_type< T,N >::type type;
+        typedef typename bounds< N >::size_type size_type;
+
+        void operator()( type&, size_type ) 
+        {}
+    };
+
+//--
+
+    template< class T, std::size_t N, bool D, class A >
+    struct pointer_destroy
+    {    
+        typedef typename pointer_type< T,N >::type type;
+        typedef typename A::template rebind< typename pointer_type< T,N-1 >::type >::other allocator;
+        typedef typename bounds< N >::size_type size_type;
+
+        void operator()( type& p, size_type s ) 
+        {    
+            allocator a; 
+            for( std::size_t i = 0; i != s; ++i ) a.destroy( p+i );
+        }
+    };
+
+    template< class T, std::size_t N, class A >
+    struct pointer_destroy< T,N,true,A >
+    {    
+        typedef typename pointer_type< T,N >::type type;
+        typedef typename A::template rebind< typename pointer_type< T,N-1 >::type >::other allocator;
+        typedef typename bounds< N >::size_type size_type;
+
+        void operator()( type&, size_type ) 
+        {}
+    };
+
+//--
+
+    template< class T, std::size_t N, bool I, class A >
+    struct pointer_constructor
+    {
+        typedef typename pointer_type< T,N >::type type;
+        typedef typename bounds< N >::iterator iterator;
+        typedef typename bounds< N >::const_iterator const_iterator;
+        typedef typename bounds< N >::size_type size_type;
+
+        void operator()( type& p, iterator i, const_iterator c, size_type s ) 
+        {    
+            if( s == 0 ) throw std::invalid_argument( "invalid pointer<> dimension" );
+            pointer_allocate< T,N,A >()( p, s ); *i = *c;
+            try { pointer_constructor< T,N-1,I,A >()( p[0], i+1, c+1, s * *( c+1 ) ); }
+            catch( ... ) { pointer_deallocate< T,N,A >()( p, s ); *i = 0; throw; }
+            for( std::size_t j = 1, k = *( c+1 ); j != s; ++j ) p[j] = p[j-1] + k;
+        }
+    };
+
+    template< class T, bool I, class A >
+    struct pointer_constructor< T,1,I,A >
+    {
+        typedef typename pointer_type< T,1 >::type type;
+        typedef typename bounds< 1 >::iterator iterator;
+        typedef typename bounds< 1 >::const_iterator const_iterator;
+        typedef typename bounds< 1 >::size_type size_type;
+
+        void operator()( type& p, iterator i, const_iterator c, size_type s )
+        {
+            if( s == 0 ) throw std::invalid_argument( "invalid pointer<> dimension" );
+            pointer_allocate< T,1,A >()( p, s );
+            try { pointer_construct< T,1,I,A >()( p, s ); }
+            catch( ... ) { pointer_deallocate< T,1,A >()( p, s ); throw; }
+            *i = *c;
+        }
+    };
+
+//--
+
+    template< class T, std::size_t N, bool D, class A >
+    struct pointer_destructor
+    {    
+        typedef typename pointer_type< T,N >::type type;
+        typedef typename bounds< N >::iterator iterator;
+        typedef typename bounds< N >::size_type size_type;
+
+        void operator()( type& p, iterator i, size_type s )
+        {    
+            pointer_destructor< T,N-1,D,A >()( p[0], i+1, s * *( i+1 ) );
+            pointer_deallocate< T,N,A >()( p, s ); *i = 0;
+        }
+    };
+
+    template< class T, bool D, class A >
+    struct pointer_destructor< T,1,D,A >
+    {    
+        typedef typename pointer_type< T,1 >::type type;
+        typedef typename bounds< 1 >::iterator iterator;
+        typedef typename bounds< 1 >::size_type size_type;
+
+        void operator()( type& p, iterator i, size_type s ) 
+        {    
+            pointer_destroy< T,1,D,A >()( p, s );
+            pointer_deallocate< T,1,A >()( p, s ); *i = 0;
+        }
+    };
+
+//--
+
+    template< class T, std::size_t N, class A >
+    struct pointer_copy
+    {    
+        typedef typename pointer_type< T,N >::type type;
+        typedef typename bounds< N >::iterator iterator;
+        typedef typename bounds< N >::const_iterator const_iterator;
+        typedef typename bounds< N >::size_type size_type;
+
+        void operator()( type& p, iterator i, type const& q, const_iterator c, size_type s ) 
+        {    
+            pointer_allocate< T,N,A >()( p, s ); *i = *c; 
+            try { pointer_copy< T,N-1,A >()( p[0], i+1, q[0], c+1, s * *( c+1 ) ); }
+            catch( ... ) { pointer_deallocate< T,N,A >()( p, s ); *i = 0; throw; }
+            for( std::size_t j = 1, k = *( c+1 ); j != s; ++j ) p[j] = p[j-1] + k;
+        }
+    };
+
+    template< class T, class A >
+    struct pointer_copy< T,1,A >
+    {    
+        typedef typename pointer_type< T,1 >::type type;
+        typedef typename bounds< 1 >::iterator iterator;
+        typedef typename bounds< 1 >::const_iterator const_iterator;
+        typedef typename bounds< 1 >::size_type size_type;
+
+        void operator()( type& p, iterator i, type const& q, const_iterator c, size_type s )
+        {    
+            pointer_allocate< T,1,A >()( p, s );
+            try { std::uninitialized_copy( q, q+s, p ); }
+            catch( ... ) { pointer_deallocate< T,1,A >()( p, s ); throw; }
+            *i = *c;
+        }
+    };
+
+//--
+
+    template< class T, std::size_t N, bool D, class A >
+    struct pointer_assign
+    {    
+        typedef typename pointer_type< T,N >::type type;
+        typedef typename bounds< N >::iterator iterator;
+        typedef typename bounds< N >::const_iterator const_iterator;
+        typedef typename bounds< N >::size_type size_type;
+
+        void operator()( type& p, iterator i, size_type s, type const& q, const_iterator c, size_type n ) 
+        {    
+            type t = 0; if( n != s ) pointer_allocate< T,N,A >()( t, n );
+            try { pointer_assign< T,N-1,D,A >()( p[0], i+1, s * *( i+1 ), q[0], c+1, n * *( c+1 ) ); }
+            catch( ... ) { if( t ) pointer_deallocate< T,N,A >()( t, n ); throw; }
+            if( t )
+            {   for( std::size_t j = 0, k = 0; j != n; ++j, k += *( c+1 ) ) t[j] = &p[0][k];
+                type r = p; p = t; t = 0; pointer_deallocate< T,N,A >()( r, s );
+            }else
+                for( std::size_t j = 0, k = 0; j != n; ++j, k += *( c+1 ) ) p[j] = &p[0][k];
+            *i = *c;
+        }
+    };
+
+    template< class T, bool D, class A >
+    struct pointer_assign< T,1,D,A >
+    {    
+        typedef typename pointer_type< T,1 >::type type;
+        typedef typename bounds< 1 >::iterator iterator;
+        typedef typename bounds< 1 >::const_iterator const_iterator;
+        typedef typename bounds< 1 >::size_type size_type;
+        
+        void operator()( type& p, iterator i, size_type s, type const& q, const_iterator c, size_type n )
+        {    
+            type t = 0; pointer_allocate< T,1,A >()( t, n );
+            try { std::uninitialized_copy( q, q+n, t ); }
+            catch( ... ) { pointer_deallocate< T,1,A >()( t, n ); throw; }
+            type r = p; p = t; t = 0; pointer_destructor< T,1,D,A >()( r, i, s );
+            *i = *c;
+        }
+    };
+
+//--
+
+    template< class T, std::size_t N, bool I, bool D, class A, bool P >
+    struct pointer_resize
+    {    
+        typedef typename pointer_type< T,N >::type type;
+        typedef typename bounds< N >::iterator iterator;
+        typedef typename bounds< N >::const_iterator const_iterator;
+        typedef typename bounds< N >::size_type size_type;
+
+        void operator()( type& p, iterator i, size_type s, const_iterator c, size_type n ) 
+        {    
+            if( n == 0 ) throw std::invalid_argument( "invalid pointer<> dimension" );
+            type t = 0; if( n != s ) pointer_allocate< T,N,A >()( t, n );
+            try { pointer_resize< T,N-1,I,D,A,P >()( p[0], i+1, s * *( i+1 ), c+1, n * *( c+1 ) ); }
+            catch( ... ) { if( t ) pointer_deallocate< T,N,A >()( t, n ); throw; }
+            if( t )
+            {   for( std::size_t j = 0, k = 0; j != n; ++j, k += *( c+1 ) ) t[j] = &p[0][k];
+                type r = p; p = t; t = 0; pointer_deallocate< T,N,A >()( r, s );
+            }else
+                for( std::size_t j = 0, k = 0; j != n; ++j, k += *( c+1 ) ) p[j] = &p[0][k];
+            *i = *c;
+        }
+    };
+
+    template< class T, bool I, bool D, class A, bool P > 
+    struct pointer_resize< T,1,I,D,A,P >
+    {    
+        typedef typename pointer_type< T,1 >::type type;
+        typedef typename bounds< 1 >::iterator iterator;
+        typedef typename bounds< 1 >::const_iterator const_iterator;
+        typedef typename bounds< 1 >::size_type size_type;
+
+        void operator()( type& p, iterator i, size_type s, const_iterator c, size_type n )
+        {    
+            if( n == 0 ) throw std::invalid_argument( "invalid pointer<> dimension" );
+            type t = 0; pointer_allocate< T,1,A >()( t, n );
+            try { pointer_construct< T,1,I,A >()( t, n ); }
+            catch( ... ) { pointer_deallocate< T,1,A >()( t, n ); throw; }
+            type r = p; p = t; t = 0; pointer_destructor< T,1,D,A >()( r, i, s );
+            *i = *c;
+        }
+    };
+
+    template< class T, bool I, bool D, class A > 
+    struct pointer_resize< T,1,I,D,A,true >
+    {    
+        typedef typename pointer_type< T,1 >::type type;
+        typedef typename bounds< 1 >::iterator iterator;
+        typedef typename bounds< 1 >::const_iterator const_iterator;
+        typedef typename bounds< 1 >::size_type size_type;
+
+        void operator()( type& p, iterator i, size_type s, const_iterator c, size_type n )
+        {   
+            if( n == 0 ) throw std::invalid_argument( "invalid pointer<> bound" );
+            if( n != s )
+            {   type t = 0; pointer_allocate< T,1,A >()( t, n );
+                if( n < s )
+                {   try{ std::uninitialized_copy( p, p+n, t ); }
+                    catch( ... ) { pointer_deallocate< T,1,A >()( t, n ); throw; }
+                }else
+                {   try { std::uninitialized_copy( p, p+s, t ); }
+                    catch( ... ) { pointer_deallocate< T,1,A >()( t, n ); throw; }
+                    try{ T d = T(); std::uninitialized_fill( t+s, t+n, d ); }
+                    catch( ... ) 
+                    {   pointer_destroy< T,1,D,A >()( t, s );
+                        pointer_deallocate< T,1,A >()( t, n ); throw;
+                    }
+                }
+                type r = p; p = t; t = 0; pointer_destructor< T,1,D,A >()( r, i, s );
+            }
+            *i = *c;
+        }
+    };
+
+//--
+
+    template< class T, std::size_t N, bool I, class A >
+    struct pointer_element_const
+    {
+        typedef typename pointer< T,N,I,A >::const_reference const_reference;
+        typedef typename pointer_type< T,N >::type type;
+        typedef typename bounds< N >::const_iterator const_iterator;
+
+        const_reference operator()( type const& p, const_iterator d, const_iterator i ) 
+        {    
+            BOOST_ASSERT( *i < *d );
+            return pointer_element_const< T,N-1,I,A >()( p[*i], d+1, i+1 ); 
+        }
+    };
+
+    template< class T, bool I, class A >
+    struct pointer_element_const< T,1,I,A >
+    {    
+        typedef typename pointer< T,1,I,A >::const_reference const_reference;
+        typedef typename pointer_type< T,1 >::type type;
+        typedef typename bounds< 1 >::const_iterator const_iterator;
+
+        const_reference operator()( type const& p, const_iterator d, const_iterator i ) 
+        {    
+            BOOST_ASSERT( *i < *d );
+            return p[*i];
+        }
+    };
+
+    template< class T, std::size_t N, bool I, class A >
+    struct pointer_element
+    {
+        typedef typename pointer< T,N,I,A >::reference reference;
+        typedef typename pointer_type< T,N >::type type;
+        typedef typename bounds< N >::const_iterator const_iterator;
+
+        reference operator()( type& p, const_iterator d, const_iterator i ) 
+        {    
+            BOOST_ASSERT( *i < *d );
+            return pointer_element< T,N-1,I,A >()( p[*i], d+1, i+1 ); 
+        }
+    };
+
+    template< class T, bool I, class A >
+    struct pointer_element< T,1,I,A >
+    {    
+        typedef typename pointer< T,1,I,A >::reference reference;
+        typedef typename pointer_type< T,1 >::type type;
+        typedef typename bounds< 1 >::const_iterator const_iterator;
+
+        reference operator()( type& p, const_iterator d, const_iterator i ) 
+        {    
+            BOOST_ASSERT( *i < *d );
+            return p[*i];
+        }
+    };
+
+//--
+
+    template< class T, std::size_t N, bool D, class A >
+    struct pointer_reconstruct
+    {   
+        typedef typename pointer_type< T,N >::type type;
+        typedef typename bounds< N >::const_iterator const_iterator;
+        typedef typename bounds< N >::size_type size_type;
+
+        bool operator()( type& p, const_iterator i, size_type s ) 
+        {   
+            type t = 0; 
+            try { pointer_allocate< T,N,A >()( t, s ); }
+            catch( ... ) { pointer_deallocate< T,N,A >()( t, s ); return false; }
+            if( pointer_reconstruct< T,N-1,D,A >()( p[0], i+1, s * *( i+1 ) ) )
+            {   for( std::size_t j = 0, k = 0; j != s; ++j, k += *( i+1 ) ) t[j] = &p[0][k];
+                type r = p; p = t; t = 0; pointer_deallocate< T,N,A >()( r, s );
+                return true;
+            }else return false;
+        }
+    };
+
+    template< class T, bool D, class A >
+    struct pointer_reconstruct< T,1,D,A >
+    {    
+        typedef typename pointer_type< T,1 >::type type;
+        typedef typename bounds< 1 >::const_iterator const_iterator;
+        typedef typename bounds< 1 >::size_type size_type;
+
+        bool operator()( type& p, const_iterator, size_type s )
+        {    
+            type t = 0;
+            try 
+            {   pointer_allocate< T,1,A >()( t, s );
+                std::uninitialized_copy( p, p+s, t ); 
+            }catch( ... ) { pointer_deallocate< T,1,A >()( t, s ); return false; }
+            type r = p; p = t; t = 0; pointer_destructor< T,1,D,A >()( r, &s, s );
+            return true;
+        }
+    };
+
+//--
+
+    template< class T, std::size_t N, bool I, bool D, class A >
+    struct pointer_reset
+    {   
+        typedef typename pointer_type< T,N >::type type;
+        typedef typename bounds< N >::const_iterator const_iterator;
+        typedef typename bounds< N >::size_type size_type;
+
+        bool operator()( type& p, const_iterator i, size_type s ) 
+        {   
+            if( pointer_reset< T,N-1,I,D,A >()( p[0], i+1, s * *( i+1 ) ) ) 
+                return true;
+            else return false;
+        }
+    };
+
+    template< class T, bool I, bool D, class A >
+    struct pointer_reset< T,2,I,D,A >
+    {   
+        typedef typename pointer_type< T,2 >::type type;
+        typedef typename bounds< 2 >::const_iterator const_iterator;
+        typedef typename bounds< 2 >::size_type size_type;
+
+        bool operator()( type& p, const_iterator i, size_type s ) 
+        {   
+            if( pointer_reset< T,1,I,D,A >()( p[0], i+1, s * *( i+1 ) ) ) 
+            {   for( std::size_t j = 0, k = 0; j != s; ++j, k += *( i+1 ) ) p[j] = &p[0][k];
+                return true;
+            }else return false;
+        }
+    };
+
+    template< class T, bool I, bool D, class A >
+    struct pointer_reset< T,1,I,D,A >
+    {    
+        typedef typename pointer_type< T,1 >::type type;
+        typedef typename bounds< 1 >::const_iterator const_iterator;
+        typedef typename bounds< 1 >::size_type size_type;
+
+        bool operator()( type& p, const_iterator, size_type s )
+        {    
+            type t = 0;
+            try 
+            {   pointer_allocate< T,1,A >()( t, s );
+                pointer_construct< T,1,I,A >()( t, s ); 
+            }catch( ... ) { pointer_deallocate< T,1,A >()( t, s ); return false; }
+            type r = p; p = t; t = 0; pointer_destructor< T,1,D,A >()( r, &s, s );
+            return true;
+        }
+    };
+
+//--
+
+    template< class T, std::size_t N, bool I, class A >
+    struct pointer_begin_const
+    {    
+        typedef typename pointer< T,N,I,A >::const_iterator const_iterator;
+        typedef typename pointer_type< T,N >::type type;
+
+        const_iterator operator()( type const p ) 
+        {    
+            return pointer_begin_const< T,N-1,I,A >()( *p );
+        }
+    };
+
+    template< class T, bool I, class A >
+    struct pointer_begin_const< T,1,I,A >
+    {    
+        typedef typename pointer< T,1,I,A >::const_iterator const_iterator;
+        typedef typename pointer_type< T,1 >::type type;
+
+        const_iterator operator()( type const p )
+        {    
+            return p;
+        }
+    };
+
+    template< class T, std::size_t N, bool I, class A >
+    struct pointer_begin
+    {    
+        typedef typename pointer< T,N,I,A >::iterator iterator;
+        typedef typename pointer_type< T,N >::type type;
+
+        iterator operator()( type p ) 
+        {    
+            return pointer_begin< T,N-1,I,A >()( *p );
+        }
+    };
+
+    template< class T, bool I, class A >
+    struct pointer_begin< T,1,I,A >
+    {    
+        typedef typename pointer< T,1,I,A >::iterator iterator;
+        typedef typename pointer_type< T,1 >::type type;
+
+        iterator operator()( type p )
+        {    
+            return p;
+        }
+    };
+
+//--
+
+    template< class T, std::size_t N, bool I, class A >
+    struct pointer_end_const
+    {    
+        typedef typename pointer< T,N,I,A >::const_iterator output_iterator;
+        typedef typename pointer_type< T,N >::type type;
+        typedef typename bounds< N >::const_iterator input_iterator;
+        typedef typename bounds< N >::size_type size_type;
+
+        output_iterator operator()( type const p, input_iterator i, size_type s ) 
+        {    
+            return pointer_end_const< T,N-1,I,A >()( *p, i+1, s * *( i+1 ) );
+        }
+    };
+
+    template< class T, bool I, class A >
+    struct pointer_end_const< T,1,I,A >
+    {    
+        typedef typename pointer< T,1,I,A >::const_iterator output_iterator;
+        typedef typename pointer_type< T,1 >::type type;
+        typedef typename bounds< 1 >::const_iterator input_iterator;
+        typedef typename bounds< 1 >::size_type size_type;
+
+        output_iterator operator()( type const p, input_iterator, size_type s )
+        {    
+            return p+s;
+        }
+    };
+
+    template< class T, std::size_t N, bool I, class A >
+    struct pointer_end
+    {    
+        typedef typename pointer< T,N,I,A >::iterator iterator;
+        typedef typename pointer_type< T,N >::type type;
+        typedef typename bounds< N >::const_iterator const_iterator;
+        typedef typename bounds< N >::size_type size_type;
+
+        iterator operator()( type p, const_iterator i, size_type s ) 
+        {    
+            return pointer_end< T,N-1,I,A >()( *p, i+1, s * *( i+1 ) );
+        }
+    };
+
+    template< class T, bool I, class A >
+    struct pointer_end< T,1,I,A >
+    {    
+        typedef typename pointer< T,1,I,A >::iterator iterator;
+        typedef typename pointer_type< T,1 >::type type;
+        typedef typename bounds< 1 >::const_iterator const_iterator;
+        typedef typename bounds< 1 >::size_type size_type;
+
+        iterator operator()( type p, const_iterator, size_type s )
+        {    
+            return p+s;
+        }
+    };
+
+//--
+
+    template< std::size_t N >
+    struct pointer_size
+    {    
+        typedef typename bounds< N >::const_iterator const_iterator;
+        typedef typename bounds< N >::size_type size_type;
+
+        size_type operator()( const_iterator c )
+        {    
+            return *c * pointer_size< N-1 >()( c+1 );
+        }
+    };
+
+    template<>
+    struct pointer_size< 1 >
+    {    
+        typedef bounds< 1 >::const_iterator const_iterator;
+        typedef bounds< 1 >::size_type size_type;
+
+        size_type operator()( const_iterator c )
+        {    
+            return *c;
+        }
+    };
+
+//--
+
+    template< std::size_t N >
+    struct pointer_bounds
+    {
+        typedef bounds< N > bounds_type;
+    };
+
+//--
+
+    /*
+        pointer class template
+
+        parameters
+
+            required
+
+                T - data type we wish to store 
+                    type: arbitrary type
+                N - number of dimensions 
+                    type: std::size_t
+
+            optional
+
+                I - default initialization parameter 
+                    type: bool, default = false
+                A - allocator 
+                    type: standard conforming allocator, default std::allocator<T>
+    */
+
+    template< class T, std::size_t N, bool I, class A >
+    class pointer
+        : public expression< pointer< T,N,I,A > >
+    {
+    public:
+
+        typedef pointer type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef type const* type_const_pointer;
+        typedef type* type_pointer;
+        typedef expression< type > base_type;
+        typedef sub_type< type > subarray_type;
+        typedef typename pointer_type< T,N >::type member_type;
+        typedef typename pointer_type< T,N-1 >::type value_type;
+        typedef value_type const& const_reference_type;
+        typedef value_type& reference_type;
+        typedef value_type const* const_iterator_type;
+        typedef value_type* iterator_type;
+        typedef T element_type;
+        typedef T const& const_reference;
+        typedef T& reference;
+        typedef T const* const_iterator;
+        typedef T* iterator;
+        typedef typename A::template rebind< T >::other allocator_type;
+        typedef typename allocator_type::size_type size_type;
+        typedef typename allocator_type::difference_type difference_type;
+        typedef typename pointer_bounds< N >::bounds_type bounds_type;
+        typedef bounds_type const& bounds_const_reference;
+        typedef mpl::bool_< I > initialize;
+        typedef bounds_type limits_type;
+
+        enum { dimensionality = N };
+
+        pointer();
+        explicit pointer( bounds_const_reference );
+
+        pointer( type_const_reference );
+        template< bool I1, class A1 > 
+        pointer( pointer< T,N,I1,A1 > const& );
+
+        type_reference operator=( type_const_reference );
+        template< bool I1, class A1 > 
+        type_reference operator=( pointer< T,N,I1,A1 > const& );
+
+        ~pointer();
+
+        template< bool P > void resize( bounds_const_reference );
+
+        const_reference_type operator[]( size_type ) const;
+        reference_type operator[]( size_type );
+
+        const_reference_type operator*() const;
+        reference_type operator*();
+
+        const_iterator_type operator+( size_type ) const;
+        iterator_type operator+( size_type );
+
+        const_reference operator[]( bounds_const_reference ) const;
+        reference operator[]( bounds_const_reference );
+
+        const_reference at( bounds_const_reference ) const;
+        reference at( bounds_const_reference );
+
+        bool const empty() const;
+        size_type const size() const;
+        bounds_const_reference bounds() const;
+        template< std::size_t U > size_type const bound() const;
+
+        void swap( type_reference );
+        template< bool I1, class A1 > void swap( pointer< T,N,I1,A1 >& );
+   
+        bool reconstruct();
+        bool reset();
+        void clear();
+
+        const_iterator begin() const;
+        iterator begin();
+        const_iterator end() const;
+        iterator end();
+
+    protected:
+
+        typedef typename has_trivial_destructor< T >::type M;
+        typedef typename array_initialize< T,I,A >::type C;
+
+        bounds_type limits;
+        member_type data;
+
+        template< class T1, std::size_t N1, bool I1, class A1 > 
+        friend class pointer;
+    };
+
+//--
+//--
+
+    template< class T, std::size_t N, bool I, class A >
+    pointer< T,N,I,A >::pointer() : data( 0 )
+    {} // constructor
+
+    template< class T, std::size_t N, bool I, class A >
+    pointer< T,N,I,A >::pointer( bounds_const_reference b ) : data( 0 )
+    {    
+        pointer_constructor< T,N,C::value,A >()( data, limits.begin(), b.begin(), b[0] );
+    } // constructor
+
+    template< class T, std::size_t N, bool I, class A >
+    pointer< T,N,I,A >::pointer( type_const_reference p ) : data( 0 )
+    {
+        if( p.data ) pointer_copy< T,N,A >()( data, limits.begin(), p.data, p.limits.begin(), p.limits[0] );
+    } // copy constructor
+
+    template< class T, std::size_t N, bool I, class A > template< bool I1, class A1 >
+    pointer< T,N,I,A >::pointer( pointer< T,N,I1,A1 > const& p ) : data( 0 )
+    {
+        if( p.data ) pointer_copy< T,N,A >()( data, limits.begin(), p.data, p.limits.begin(), p.limits[0] );
+    } // copy constructor
+
+    template< class T, std::size_t N, bool I, class A >
+    typename pointer< T,N,I,A >::type_reference pointer< T,N,I,A >::operator=( type_const_reference p )
+    {    
+        if( &p != this )
+        {   if( p.data )
+            {   if( data ) pointer_assign< T,N,M::value,A >()( data, limits.begin(), limits[0], p.data, p.limits.begin(), p.limits[0] );
+                else pointer_copy< T,N,A >()( data, limits.begin(), p.data, p.limits.begin(), p.limits[0] );
+            }else
+            {   if( data ) pointer_destructor< T,N,M::value,A >()( data, limits.begin(), limits[0] );
+            }
+        }
+        return *this;
+    } // ( copy ) assignment operator
+
+    template< class T, std::size_t N, bool I, class A > template< bool I1, class A1 >
+    typename pointer< T,N,I,A >::type_reference pointer< T,N,I,A >::operator=( pointer< T,N,I1,A1 > const& p )
+    {    
+        if( p.data )
+        {   if( data ) pointer_assign< T,N,M::value,A >()( data, limits.begin(), limits[0], p.data, p.limits.begin(), p.limits[0] );
+            else pointer_copy< T,N,A >()( data, limits.begin(), p.data, p.limits.begin(), p.limits[0] );
+        }else
+        {   if( data ) pointer_destructor< T,N,M::value,A >()( data, limits.begin(), limits[0] );
+        }
+        return *this;
+    } // ( copy ) assignment operator
+
+    template< class T, std::size_t N, bool I, class A >
+    pointer< T,N,I,A >::~pointer()
+    {    
+        if( data ) pointer_destructor< T,N,M::value,A >()( data, limits.begin(), limits[0] );
+    } // destructor
+
+    template< class T, std::size_t N, bool I, class A > template< bool P >
+    void pointer< T,N,I,A >::resize( bounds_const_reference b )
+    {    
+        if( data ) pointer_resize< T,N,C::value,M::value,A,P >()( data, limits.begin(), limits[0], b.begin(), b[0] );
+        else pointer_constructor< T,N,C::value,A >()( data, limits.begin(), b.begin(), b[0] );
+    } // resize
+
+    template< class T, std::size_t N, bool I, class A >
+    typename pointer< T,N,I,A >::const_reference_type pointer< T,N,I,A >::operator[]( size_type s ) const
+    {    
+        BOOST_ASSERT( data );
+        return data[s];
+    } // operator[] const
+
+    template< class T, std::size_t N, bool I, class A >
+    typename pointer< T,N,I,A >::reference_type pointer< T,N,I,A >::operator[]( size_type s )
+    {    
+        BOOST_ASSERT( data );
+        return data[s];
+    } // operator[]
+
+    template< class T, std::size_t N, bool I, class A >
+    typename pointer< T,N,I,A >::const_reference_type pointer< T,N,I,A >::operator*() const
+    {
+        BOOST_ASSERT( data );
+        return *data;
+    } // dereference const
+
+    template< class T, std::size_t N, bool I, class A >
+    typename pointer< T,N,I,A >::reference_type pointer< T,N,I,A >::operator*()
+    {
+        BOOST_ASSERT( data );
+        return *data;
+    } // dereference
+
+    template< class T, std::size_t N, bool I, class A >
+    typename pointer< T,N,I,A >::const_iterator_type pointer< T,N,I,A >::operator+( size_type s ) const
+    {
+        BOOST_ASSERT( data );
+        return data+s;
+    } // operator+ const
+
+    template< class T, std::size_t N, bool I, class A >
+    typename pointer< T,N,I,A >::iterator_type pointer< T,N,I,A >::operator+( size_type s )
+    {
+        BOOST_ASSERT( data );
+        return data+s;
+    } // operator+
+
+    template< class T, std::size_t N, bool I, class A >
+    typename pointer< T,N,I,A >::const_reference pointer< T,N,I,A >::operator[]( bounds_const_reference b ) const
+    {   
+        BOOST_ASSERT( data );
+        return pointer_element_const< T,N,I,A >()( data, limits.begin(), b.begin() );
+    } // operator[] const
+
+    template< class T, std::size_t N, bool I, class A >
+    typename pointer< T,N,I,A >::reference pointer< T,N,I,A >::operator[]( bounds_const_reference b )
+    {   
+        BOOST_ASSERT( data );
+        return pointer_element< T,N,I,A >()( data, limits.begin(), b.begin() );
+    } // operator[]
+
+    template< class T, std::size_t N, bool I, class A >
+    typename pointer< T,N,I,A >::const_reference pointer< T,N,I,A >::at( bounds_const_reference b ) const
+    {
+        if( !( b < limits ) )
+            throw std::out_of_range( "pointer<> access out of range" );
+        return pointer_element_const< T,N,I,A >()( data, limits.begin(), b.begin() );
+    } // at const
+
+    template< class T, std::size_t N, bool I, class A >
+    typename pointer< T,N,I,A >::reference pointer< T,N,I,A >::at( bounds_const_reference b )
+    {    
+        if( !( b < limits ) )
+            throw std::out_of_range( "pointer<> access out of range" );
+        return pointer_element< T,N,I,A >()( data, limits.begin(), b.begin() );
+    } // at
+
+    template< class T, std::size_t N, bool I, class A >
+    bool const pointer< T,N,I,A >::empty() const
+    {    
+        return ( data == 0 );
+    } // empty
+
+    template< class T, std::size_t N, bool I, class A >
+    typename pointer< T,N,I,A >::size_type const pointer< T,N,I,A >::size() const
+    {    
+        return pointer_size< N >()( limits.begin() );
+    } // size
+
+    template< class T, std::size_t N, bool I, class A >
+    typename pointer< T,N,I,A >::bounds_const_reference pointer< T,N,I,A >::bounds() const
+    {    
+        return limits;
+    } // bounds
+
+    template< class T, std::size_t N, bool I, class A > template< std::size_t U >
+    typename pointer< T,N,I,A >::size_type const pointer< T,N,I,A >::bound() const
+    {    
+        BOOST_STATIC_ASSERT( U < N );
+        return limits[U];
+    } // bound
+
+    template< class T, std::size_t N, bool I, class A >
+    void pointer< T,N,I,A >::swap( type_reference p )
+    {    
+        if( &p != this ) { std::swap( data, p.data ); std::swap( limits, p.limits ); }
+    } // swap
+
+    template< class T, std::size_t N, bool I, class A > template< bool I1, class A1 >
+    void pointer< T,N,I,A >::swap( pointer< T,N,I1,A1 >& p )
+    {
+        std::swap( data, p.data ); std::swap( limits, p.limits );
+    } // swap
+
+    template< class T, std::size_t N, bool I, class A >
+    bool pointer< T,N,I,A >::reconstruct()
+    {    
+        if( data ) return pointer_reconstruct< T,N,M::value,A >()( data, limits.begin(), limits[0] );
+        return true;
+    } // reconstruct
+
+    template< class T, std::size_t N, bool I, class A >
+    bool pointer< T,N,I,A >::reset()
+    {    
+        if( data ) return pointer_reset< T,N,C::value,M::value,A >()( data, limits.begin(), limits[0] );
+        return true;
+    } // reset
+
+    template< class T, std::size_t N, bool I, class A >
+    void pointer< T,N,I,A >::clear()
+    {    
+        if( data ) pointer_destructor< T,N,M::value,A >()( data, limits.begin(), limits[0] );
+    } // clear
+
+    template< class T, std::size_t N, bool I, class A >
+    typename pointer< T,N,I,A >::const_iterator pointer< T,N,I,A >::begin() const
+    {    
+        if( data ) return pointer_begin_const< T,N,I,A >()( data );
+        return 0;
+    } // begin const
+
+    template< class T, std::size_t N, bool I, class A >
+    typename pointer< T,N,I,A >::iterator pointer< T,N,I,A >::begin()
+    {    
+        if( data ) return pointer_begin< T,N,I,A >()( data );
+        return 0;
+    } // begin
+
+    template< class T, std::size_t N, bool I, class A >
+    typename pointer< T,N,I,A >::const_iterator pointer< T,N,I,A >::end() const
+    {    
+        if( data ) return pointer_end_const< T,N,I,A >()( data, limits.begin(), limits[0] );
+        return 0;
+    } // end const
+
+    template< class T, std::size_t N, bool I, class A >
+    typename pointer< T,N,I,A >::iterator pointer< T,N,I,A >::end()
+    {    
+        if( data ) return pointer_end< T,N,I,A >()( data, limits.begin(), limits[0] );
+        return 0;
+    } // end
+
+//--
+//--
+
+    template< class T, std::size_t N, bool I, class A >
+    struct sub_type< pointer< T,N,I,A > >
+    {
+        typedef pointer< T,N-1,I,A > type;
+    };
+
+//--
+//--
+
+    template< class T, std::size_t N, bool I, class A, class C, class CT >
+    struct pointer_out
+    {    
+        typedef std::basic_ostringstream< C,CT,std::allocator< C > > stream;
+        typedef typename pointer< T,N,I,A >::const_iterator_type type;
+        typedef typename bounds< N >::const_iterator const_iterator;
+
+        stream& operator()( stream& s, type const& p, const_iterator d ) 
+        {    
+            s << '(';
+            for( std::size_t i = 0; i != *d; ++i )
+            {   pointer_out< T,N-1,I,A,C,CT >()( s, p[i], d+1 );
+                if( i != *d - 1 ) s << ',';
+            }
+            s << ')';
+            return s;
+        }
+    };
+
+    template< class T, bool I, class A, class C, class CT >
+    struct pointer_out< T,1,I,A,C,CT >
+    {    
+        typedef std::basic_ostringstream< C,CT,std::allocator< C > > stream;
+        typedef typename pointer< T,1,I,A >::const_iterator_type type;
+        typedef typename bounds< 1 >::const_iterator const_iterator;
+
+        stream& operator()( stream& s, type const& p, const_iterator d ) 
+        {    
+            s << '(';
+            for( std::size_t i = 0; i != *d - 1; ++i ) s << p[i] << ',';
+            s << p[*d-1] << ')';
+            return s;
+        }
+    };
+
+//--
+
+    template< std::size_t N, class C, class CT >
+    struct pointer_out_size
+    {    
+        typedef std::basic_ostringstream< C,CT,std::allocator< C > > stream;
+        typedef typename bounds< N >::const_iterator const_iterator;
+
+        void operator()( stream& s, const_iterator d ) 
+        {    
+            s << '[' << *d << ']';
+            pointer_out_size< N-1,C,CT >()( s, d+1 );
+        }
+    };
+
+    template< class C, class CT >
+    struct pointer_out_size< 1,C,CT >
+    {    
+        typedef std::basic_ostringstream< C,CT,std::allocator< C > > stream;
+        typedef typename bounds< 1 >::const_iterator const_iterator;
+
+        void operator()( stream& s, const_iterator d ) 
+        {    
+            s << '[' << *d << ']';
+        }
+    };
+
+//--
+
+    template< class T, std::size_t N, bool I, class A, class C, class CT >
+    std::basic_ostream< C,CT >& operator<<( std::basic_ostream< C,CT >& o, pointer< T,N,I,A > const& p )
+    {
+        std::basic_ostringstream< C,CT,std::allocator< C > > s;
+        s.flags( o.flags() ); s.imbue( o.getloc() ); s.precision( o.precision() );
+        pointer_out_size< N,C,CT >()( s, p.bounds().begin() );
+        return o << pointer_out< T,N,I,A,C,CT >()( s, p+0, p.bounds().begin() ).str().c_str();
+    }
+
+//--
+//--
+
+    template< class T, bool I, class A >
+    class pointer< T,0,I,A >
+    {
+    public:
+
+        typedef pointer type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef type const* type_const_pointer;
+        typedef type* type_pointer;
+        typedef T value_type;
+        typedef value_type const& const_reference_type;
+        typedef value_type& reference_type;
+        typedef value_type const* const_iterator_type;
+        typedef value_type* iterator_type;
+        typedef T element_type;
+        typedef T const& const_reference;
+        typedef T& reference;
+        typedef T const* const_iterator;
+        typedef T* iterator;
+        typedef typename A::template rebind< T >::other allocator_type;
+        typedef typename allocator_type::size_type size_type;
+        typedef typename allocator_type::difference_type difference_type;
+        typedef bounds< 0 > bounds_type;
+        typedef bounds_type const& bounds_const_reference;
+        typedef mpl::bool_< I > initialize;
+
+        enum { dimensionality = 0 };
+
+    };
+
+//--
+
+    template< class T, std::size_t N, bool I, class A, bool I1, class A1  >
+    bool operator==( pointer< T,N,I,A > const& x, pointer< T,N,I1,A1 > const& y )
+    {    
+        return std::equal( x.begin(), x.end(), y.begin() );
+    }
+
+    template< class T, std::size_t N, bool I, class A, bool I1, class A1  >
+    bool operator<( pointer< T,N,I,A > const& x, pointer< T,N,I1,A1 > const& y )
+    {    
+        return std::lexicographical_compare( x.begin(), x.end(), y.begin(), y.end() );
+    }
+
+    template< class T, std::size_t N, bool I, class A, bool I1, class A1  >
+    bool operator!=( pointer< T,N,I,A > const& x, pointer< T,N,I1,A1 > const& y )
+    {    
+        return !( x == y );
+    }
+
+    template< class T, std::size_t N, bool I, class A, bool I1, class A1  >
+    bool operator>( pointer< T,N,I,A > const& x, pointer< T,N,I1,A1 > const& y )
+    {    
+        return y < x;
+    }
+
+    template< class T, std::size_t N, bool I, class A, bool I1, class A1  >
+    bool operator<=( pointer< T,N,I,A > const& x, pointer< T,N,I1,A1 > const& y )
+    {    
+        return !( y < x );
+    }
+
+    template< class T, std::size_t N, bool I, class A, bool I1, class A1  >
+    bool operator>=( pointer< T,N,I,A > const& x, pointer< T,N,I1,A1 > const& y )
+    {    
+        return !( x < y );
+    }
+
+//--
+
+    template< class T, std::size_t N, bool I, class A >
+    void swap( pointer< T,N,I,A >& x, pointer< T,N,I,A >& y )
+    {    
+        x.swap( y );
+    }
+
+    template< class T, std::size_t N, bool I, class A, bool I1, class A1  >
+    void swap( pointer< T,N,I,A >& x, pointer< T,N,I1,A1 >& y )
+    {    
+        x.swap( y );
+    }
+
+//--
+
+}} // namespace boost, namespace maps
+
+#ifdef BOOST_MSVC
+# pragma warning( default : 4996 )
+#endif
+
+#endif // BOOST_MAPS_GENERIC_POINTER_HPP
\ No newline at end of file
Added: sandbox/maps/boost/maps/generic/view.hpp
==============================================================================
--- (empty file)
+++ sandbox/maps/boost/maps/generic/view.hpp	2011-08-08 19:51:30 EDT (Mon, 08 Aug 2011)
@@ -0,0 +1,1249 @@
+//--
+// Copyright (c) 2010-2011 Brian Smith
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/maps for documentation.
+//--
+#if !defined( BOOST_MAPS_GENERIC_VIEW_HPP )
+#define BOOST_MAPS_GENERIC_VIEW_HPP
+
+#include <boost/maps/generic/array.hpp>
+#include <boost/maps/generic/pointer.hpp>
+
+namespace boost { namespace maps {
+
+//--
+
+    template< class P, std::size_t N, std::size_t I, bool B, class L >
+    struct construct_view
+    {
+        typedef typename view< P,B >::member_type type;
+        typedef typename view< P,B >::bounds_type::iterator iterator1;
+        typedef typename view< P,B >::ranges_type::const_iterator_type iterator2;
+        typedef typename view< P,B >::size_type size_type;
+        typedef typename mpl::deref< L >::type S;
+        typedef typename view< P,B >::element_type T;
+        typedef typename view< P,B >::allocator_type A;
+        typedef typename P::subarray_type::type R;
+        typedef typename mpl::next< L >::type M;
+
+        void operator()( type& v, iterator1 b, iterator2 r, size_type a ) 
+        {
+            size_type f = r[I][0], l = r[I][1], s = r[I][2], c = ( l - f ) / s;
+            if( s == 0 || f >= l || ( l - s ) >= S::value || ( l - f ) % s != 0 || c > S::value )
+                throw std::invalid_argument( "invalid view<> range" );
+            pointer_allocate< T,N,A >()( v, a *= c ); *b = c;
+            try { construct_view< R,N-1,I+1,B,M >()( v[0], b+1, r, a ); }
+            catch( ... ) { pointer_deallocate< T,N,A >()( v, a ); *b = 0; throw; }
+            for( std::size_t j = 1, k = *( b+1 ); j != a; ++j ) v[j] = v[j-1] + k;
+        }
+    };
+
+    template< class P, std::size_t I, bool B, class L >
+    struct construct_view< P,1,I,B,L >
+    {
+        typedef typename view< P,B >::member_type type;
+        typedef typename view< P,B >::bounds_type::iterator iterator1;
+        typedef typename view< P,B >::ranges_type::const_iterator_type iterator2;
+        typedef typename view< P,B >::size_type size_type;
+        typedef typename mpl::deref< L >::type S;
+        typedef typename view< P,B >::element_type T;
+        typedef typename view< P,B >::allocator_type A;
+
+        void operator()( type& v, iterator1 b, iterator2 r, size_type a )
+        {
+            size_type f = r[I][0], l = r[I][1], s = r[I][2], c = ( l - f ) / s;
+            if( s == 0 || f >= l || ( l - s ) >= S::value || ( l - f ) % s != 0 || c > S::value )
+                throw std::invalid_argument( "invalid view<> range" );
+            pointer_allocate< T,1,A >()( v, a * c ); *b = c; 
+        }
+    };
+
+    template< class P, std::size_t I, class L >
+    struct construct_view< P,1,I,false,L >
+    {
+        typedef typename view< P,false >::member_type type;
+        typedef typename view< P,false >::bounds_type::iterator iterator1;
+        typedef typename view< P,false >::ranges_type::const_iterator_type iterator2;
+        typedef typename view< P,false >::size_type size_type;
+        typedef typename mpl::deref< L >::type S;
+        typedef typename view< P,false >::element_type T;
+        typedef typename has_trivial_constructor< T >::type C;
+        typedef typename view< P,false >::allocator_type A;
+
+        void operator()( type& v, iterator1 b, iterator2 r, size_type a )
+        {
+            size_type f = r[I][0], l = r[I][1], s = r[I][2], c = ( l - f ) / s;
+            if( s == 0 || f >= l || ( l - s ) >= S::value || ( l - f ) % s != 0 || c > S::value )
+                throw std::invalid_argument( "invalid view<> range" );
+            pointer_allocate< T,1,A >()( v, a *= c ); 
+            try { pointer_construct< T,1,!C::value,A >()( v, a ); }
+            catch( ... ) { pointer_deallocate< T,1,A >()( v, a ); throw; }
+            *b = c; 
+        }
+    };
+
+//--
+
+    template< class P, std::size_t N, std::size_t I, bool B >
+    struct construct_view< P,N,I,B,bounds<N> >
+    {
+        typedef typename view< P,B >::member_type type;
+        typedef typename view< P,B >::bounds_type::iterator iterator1;
+        typedef typename view< P,B >::ranges_type::const_iterator_type iterator2;
+        typedef typename P::bounds_type::const_iterator iterator3;
+        typedef typename view< P,B >::size_type size_type;
+        typedef typename view< P,B >::element_type T;
+        typedef typename view< P,B >::allocator_type A;
+        typedef typename P::subarray_type::type R;
+
+        void operator()( type& v, iterator1 b, iterator2 r, iterator3 i, size_type a ) 
+        {
+            size_type f = r[I][0], l = r[I][1], s = r[I][2], c = ( l - f ) / s;
+            if( s == 0 || f >= l || ( l - s ) >= *i || ( l - f ) % s != 0 || c > *i )
+                throw std::invalid_argument( "invalid view<> range" );
+            pointer_allocate< T,N,A >()( v, a *= c ); *b = c;
+            try { construct_view< R,N-1,I+1,B,bounds<N-1> >()( v[0], b+1, r, i+1, a ); }
+            catch( ... ) { pointer_deallocate< T,N,A >()( v, a ); *b = 0; throw; }
+            for( std::size_t j = 1, k = *( b+1 ); j != a; ++j ) v[j] = v[j-1] + k;
+        }
+    };
+
+    template< class P, std::size_t I, bool B >
+    struct construct_view< P,1,I,B,bounds<1> >
+    {
+        typedef typename view< P,B >::member_type type;
+        typedef typename view< P,B >::bounds_type::iterator iterator1;
+        typedef typename view< P,B >::ranges_type::const_iterator_type iterator2;
+        typedef typename P::bounds_type::const_iterator iterator3;
+        typedef typename view< P,B >::size_type size_type;
+        typedef typename view< P,B >::element_type T;
+        typedef typename view< P,B >::allocator_type A;
+
+        void operator()( type& v, iterator1 b, iterator2 r, iterator3 i, size_type a )
+        {
+            size_type f = r[I][0], l = r[I][1], s = r[I][2], c = ( l - f ) / s;
+            if( s == 0 || f >= l || ( l - s ) >= *i || ( l - f ) % s != 0 || c > *i )
+                throw std::invalid_argument( "invalid view<> range" );
+            pointer_allocate< T,1,A >()( v, a * c ); *b = c; 
+        }
+    };
+
+    template< class P, std::size_t I >
+    struct construct_view< P,1,I,false,bounds<1> >
+    {
+        typedef typename view< P,false >::member_type type;
+        typedef typename view< P,false >::bounds_type::iterator iterator1;
+        typedef typename view< P,false >::ranges_type::const_iterator_type iterator2;
+        typedef typename P::bounds_type::const_iterator iterator3;
+        typedef typename view< P,false >::size_type size_type;
+        typedef typename view< P,false >::element_type T;
+        typedef typename has_trivial_constructor< T >::type C;
+        typedef typename view< P,false >::allocator_type A;
+
+        void operator()( type& v, iterator1 b, iterator2 r, iterator3 i, size_type a )
+        {
+            size_type f = r[I][0], l = r[I][1], s = r[I][2], c = ( l - f ) / s;
+            if( s == 0 || f >= l || ( l - s ) >= *i || ( l - f ) % s != 0 || c > *i )
+                throw std::invalid_argument( "invalid view<> range" );
+            pointer_allocate< T,1,A >()( v, a *= c ); 
+            try { pointer_construct< T,1,!C::value,A >()( v, a ); }
+            catch( ... ) { pointer_deallocate< T,1,A >()( v, a ); throw; }
+            *b = c; 
+        }
+    };
+    
+//--
+
+    template< class P, std::size_t N, bool B, class L >
+    struct view_constructor
+    {
+        typedef typename view< P,B >::member_type type;
+        typedef typename view< P,B >::bounds_type::iterator iterator1;
+        typedef typename view< P,B >::ranges_type::const_iterator_type iterator2;
+        
+        void operator()( type& v, iterator1 b, iterator2 r, P const& p )
+        {
+            construct_view< P,N,0,B,typename mpl::begin< L >::type >()( v, b, r, 1 );
+        }
+    };
+
+    template< class P, std::size_t N, bool B >
+    struct view_constructor< P,N,B,bounds<N> >
+    {
+        typedef typename view< P,B >::member_type type;
+        typedef typename view< P,B >::bounds_type::iterator iterator1;
+        typedef typename view< P,B >::ranges_type::const_iterator_type iterator2;
+        
+        void operator()( type& v, iterator1 b, iterator2 r, P const& p )
+        {
+            construct_view< P,N,0,B,bounds<N> >()( v, b, r, p.bounds().begin(), 1 );
+        }
+    };
+
+//--
+
+    template< class P, std::size_t N, std::size_t I, bool B, class L >
+    struct resize_view
+    {
+        typedef typename view< P,B >::member_type type;
+        typedef typename view< P,B >::ranges_type::const_iterator_type iterator1;
+        typedef typename view< P,B >::bounds_type::iterator iterator2;
+        typedef typename view< P,B >::size_type size_type;
+        typedef typename mpl::deref< L >::type S;
+        typedef typename view< P,B >::element_type T;
+        typedef typename view< P,B >::allocator_type A;
+        typedef typename P::subarray_type::type R;
+        typedef typename mpl::next< L >::type M;
+
+        void operator()( type& v, iterator1 r, iterator2 b, size_type a, size_type n ) 
+        {
+            size_type f = r[I][0], l = r[I][1], s = r[I][2], c = ( l - f ) / s;
+            if( s == 0 || f >= l || ( l - s ) >= S::value || ( l - f ) % s != 0 || c > S::value )
+                throw std::invalid_argument( "invalid view<> range" );
+            type t = 0; if( ( a *= *b ) != ( n *= c ) ) pointer_allocate< T,N,A >()( t, n );
+            try { resize_view< R,N-1,I+1,B,M >()( v[0], r, b+1, a, n ); }
+            catch( ... ) { if( t ) pointer_deallocate< T,N,A >()( t, n ); throw; }
+            if( t )
+            {   for( std::size_t j = 0, k = 0; j != n; ++j, k += *( b+1 ) ) t[j] = &v[0][k];
+                type r = v; v = t; t = 0; pointer_deallocate< T,N,A >()( r, a );
+            }else
+                for( std::size_t j = 0, k = 0; j != a; ++j, k += *( b+1 ) ) v[j] = &v[0][k];
+            *b = c;
+        }
+    };
+
+    template< class P, std::size_t I, bool B, class L >
+    struct resize_view< P,1,I,B,L >
+    {
+        typedef typename view< P,B >::member_type type;
+        typedef typename view< P,B >::ranges_type::const_iterator_type iterator1;
+        typedef typename view< P,B >::bounds_type::iterator iterator2;
+        typedef typename view< P,B >::size_type size_type;
+        typedef typename mpl::deref< L >::type S;
+        typedef typename view< P,B >::element_type T;
+        typedef typename view< P,B >::allocator_type A;
+
+        void operator()( type& v, iterator1 r, iterator2 b, size_type a, size_type n ) 
+        {
+            size_type f = r[I][0], l = r[I][1], s = r[I][2], c = ( l - f ) / s;
+            if( s == 0 || f >= l || ( l - s ) >= S::value || ( l - f ) % s != 0 || c > S::value )
+                throw std::invalid_argument( "invalid view<> range" );
+            if( ( a *= *b ) != ( n *= c ) )
+            {   type t = 0; pointer_allocate< T,1,A >()( t, n );
+                type r = v; v = t; t = 0; pointer_deallocate< T,1,A >()( r, a );
+            }
+            *b = c;
+        }
+    };
+
+    template< class P, std::size_t I, class L >
+    struct resize_view< P,1,I,false,L >
+    {
+        typedef typename view< P,false >::member_type type;
+        typedef typename view< P,false >::ranges_type::const_iterator_type iterator1;
+        typedef typename view< P,false >::bounds_type::iterator iterator2;
+        typedef typename P::bounds_type::const_iterator iterator3;
+        typedef typename view< P,false >::size_type size_type;
+        typedef typename mpl::deref< L >::type S;
+        typedef typename view< P,false >::element_type T;
+        typedef typename has_trivial_constructor< T >::type C;
+        typedef typename has_trivial_destructor< T >::type D;
+        typedef typename view< P,false >::allocator_type A;
+
+        void operator()( type& v, iterator1 r, iterator2 b, size_type a, size_type n ) 
+        {
+            size_type f = r[I][0], l = r[I][1], s = r[I][2], c = ( l - f ) / s;
+            if( s == 0 || f >= l || ( l - s ) >= S::value || ( l - f ) % s != 0 || c > S::value )
+                throw std::invalid_argument( "invalid view<> range" );
+            if( ( a *= *b ) != ( n *= c ) )
+            {   type t = 0; pointer_allocate< T,1,A >()( t, n );
+                try { pointer_construct< T,1,!C::value,A >()( t, n ); }
+                catch( ... ) { pointer_deallocate< T,1,A >()( t, n ); throw; }
+                type r = v; v = t; t = 0; pointer_destructor< T,1,D::value,A >()( r, b, a );
+            }
+            *b = c;
+        }
+    };
+
+//--
+
+    template< class P, std::size_t N, std::size_t I, bool B >
+    struct resize_view< P,N,I,B,bounds<N> >
+    {
+        typedef typename view< P,B >::member_type type;
+        typedef typename view< P,B >::ranges_type::const_iterator_type iterator1;
+        typedef typename view< P,B >::bounds_type::iterator iterator2;
+        typedef typename P::bounds_type::const_iterator iterator3;
+        typedef typename view< P,B >::size_type size_type;
+        typedef typename view< P,B >::element_type T;
+        typedef typename view< P,B >::allocator_type A;
+        typedef typename P::subarray_type::type R;
+
+        void operator()( type& v, iterator1 r, iterator2 b, iterator3 i, size_type a, size_type n ) 
+        {
+            size_type f = r[I][0], l = r[I][1], s = r[I][2], c = ( l - f ) / s;
+            if( s == 0 || f >= l || ( l - s ) >= *i || ( l - f ) % s != 0 || c > *i )
+                throw std::invalid_argument( "invalid view<> range" );
+            type t = 0; if( ( a *= *b ) != ( n *= c ) ) pointer_allocate< T,N,A >()( t, n );
+            try { resize_view< R,N-1,I+1,B,bounds<N-1> >()( v[0], r, b+1, i+1, a, n ); }
+            catch( ... ) { if( t ) pointer_deallocate< T,N,A >()( t, n ); throw; }
+            if( t )
+            {   for( std::size_t j = 0, k = 0; j != n; ++j, k += *( b+1 ) ) t[j] = &v[0][k];
+                type r = v; v = t; t = 0; pointer_deallocate< T,N,A >()( r, a );
+            }else
+                for( std::size_t j = 0, k = 0; j != a; ++j, k += *( b+1 ) ) v[j] = &v[0][k];
+            *b = c;
+        }
+    };
+
+    template< class P, std::size_t I, bool B >
+    struct resize_view< P,1,I,B,bounds<1> >
+    {
+        typedef typename view< P,B >::member_type type;
+        typedef typename view< P,B >::ranges_type::const_iterator_type iterator1;
+        typedef typename view< P,B >::bounds_type::iterator iterator2;
+        typedef typename P::bounds_type::const_iterator iterator3;
+        typedef typename view< P,B >::size_type size_type;
+        typedef typename view< P,B >::element_type T;
+        typedef typename view< P,B >::allocator_type A;
+
+        void operator()( type& v, iterator1 r, iterator2 b, iterator3 i, size_type a, size_type n ) 
+        {
+            size_type f = r[I][0], l = r[I][1], s = r[I][2], c = ( l - f ) / s;
+            if( s == 0 || f >= l || ( l - s ) >= *i || ( l - f ) % s != 0 || c > *i )
+                throw std::invalid_argument( "invalid view<> range" );
+            if( ( a *= *b ) != ( n *= c ) )
+            {   type t = 0; pointer_allocate< T,1,A >()( t, n );
+                type r = v; v = t; t = 0; pointer_deallocate< T,1,A >()( r, a );
+            }
+            *b = c;
+        }
+    };
+
+    template< class P, std::size_t I >
+    struct resize_view< P,1,I,false,bounds<1> >
+    {
+        typedef typename view< P,false >::member_type type;
+        typedef typename view< P,false >::ranges_type::const_iterator_type iterator1;
+        typedef typename view< P,false >::bounds_type::iterator iterator2;
+        typedef typename P::bounds_type::const_iterator iterator3;
+        typedef typename view< P,false >::size_type size_type;
+        typedef typename view< P,false >::element_type T;
+        typedef typename has_trivial_constructor< T >::type C;
+        typedef typename has_trivial_destructor< T >::type D;
+        typedef typename view< P,false >::allocator_type A;
+
+        void operator()( type& v, iterator1 r, iterator2 b, iterator3 i, size_type a, size_type n ) 
+        {
+            size_type f = r[I][0], l = r[I][1], s = r[I][2], c = ( l - f ) / s;
+            if( s == 0 || f >= l || ( l - s ) >= *i || ( l - f ) % s != 0 || c > *i )
+                throw std::invalid_argument( "invalid view<> range" );
+            if( ( a *= *b ) != ( n *= c ) )
+            {   type t = 0; pointer_allocate< T,1,A >()( t, n );
+                try { pointer_construct< T,1,!C::value,A >()( t, n ); }
+                catch( ... ) { pointer_deallocate< T,1,A >()( t, n ); throw; }
+                type r = v; v = t; t = 0; pointer_destructor< T,1,D::value,A >()( r, b, a );
+            }
+            *b = c;
+        }
+    };
+
+//--
+
+    template< class P, std::size_t N, bool B, class L >
+    struct view_resize
+    {
+        typedef typename view< P,B >::member_type type;
+        typedef typename view< P,B >::ranges_type::const_iterator_type iterator1;
+        typedef typename view< P,B >::bounds_type::iterator iterator2;
+
+        void operator()( type& v, iterator1 r, iterator2 b, P const& p )
+        {
+            resize_view< P,N,0,B,typename mpl::begin< L >::type >()( v, r, b, 1, 1 );
+        }
+    };
+
+    template< class P, std::size_t N, bool B >
+    struct view_resize< P,N,B,bounds<N> >
+    {
+        typedef typename view< P,B >::member_type type;
+        typedef typename view< P,B >::ranges_type::const_iterator_type iterator1;
+        typedef typename view< P,B >::bounds_type::iterator iterator2;
+
+        void operator()( type& v, iterator1 r, iterator2 b, P const& p )
+        {
+            resize_view< P,N,0,B,bounds<N> >()( v, r, b, p.bounds().begin(), 1, 1 );
+        }
+    };
+
+//--
+
+    template< class P, std::size_t N, std::size_t I, bool B >
+    struct view_reset
+    {
+        typedef typename view< P,B >::iterator_type iterator1;
+        typedef typename P::iterator_type iterator2;
+        typedef typename view< P,B >::ranges_type::const_iterator_type iterator3;
+        typedef typename view< P,B >::size_type size_type;
+        typedef typename P::subarray_type::type R;
+
+        void operator()( iterator1 v, iterator2 p, iterator3 r ) 
+        {
+            size_type f = r[I][0], l = r[I][1], s = r[I][2];
+            for( std::size_t i = 0, j = f; j != l; ++i, j += s )
+                view_reset< R,N-1,I+1,B >()( v[i], p[j], r );
+        }
+    };
+
+    template< class P, std::size_t I, bool B >
+    struct view_reset< P,1,I,B >
+    {
+        typedef typename view< P,B >::iterator_type iterator1;
+        typedef typename P::iterator_type iterator2;
+        typedef typename view< P,B >::ranges_type::const_iterator_type iterator3;
+        typedef typename view< P,B >::size_type size_type;
+
+        void operator()( iterator1 v, iterator2 p, iterator3 r )
+        {
+            size_type f = r[I][0], l = r[I][1], s = r[I][2];
+            for( std::size_t i = 0, j = f; j != l; ++i, j += s ) v[i] = &p[j];
+        }
+    };
+
+    template< class P, std::size_t I >
+    struct view_reset< P,1,I,false >
+    {
+        typedef typename view< P,false >::iterator_type iterator1;
+        typedef typename P::iterator_type iterator2;
+        typedef typename view< P,false >::ranges_type::const_iterator_type iterator3;
+        typedef typename view< P,false >::size_type size_type;
+
+        void operator()( iterator1 v, iterator2 p, iterator3 r )
+        {
+            size_type f = r[I][0], l = r[I][1], s = r[I][2];
+            for( std::size_t i = 0, j = f; j != l; ++i, j += s ) v[i] = p[j];
+        }
+    };
+
+//--
+
+    template< class P, class P1, std::size_t N, std::size_t I, bool B, class L >
+    struct validate_view
+    {
+        typedef typename view< P,B >::ranges_type::const_iterator_type iterator;
+        typedef typename view< P,B >::size_type size_type;
+        typedef typename mpl::front< L >::type S;
+        typedef typename mpl::pop_front< L >::type M;
+
+        void operator()( iterator r ) 
+        {
+            size_type f = r[I][0], l = r[I][1], s = r[I][2];
+            if( s == 0 || f >= l || ( l - s ) >= S::value || ( l - f ) % s != 0 || ( l - f ) / s > S::value )
+                throw std::invalid_argument( "invalid view<> range" );
+            validate_view< P,P1,N-1,I+1,B,M >()( r );
+        }
+    };
+
+    template< class P, class P1, std::size_t I, bool B, class L >
+    struct validate_view< P,P1,1,I,B,L >
+    {
+        typedef typename view< P,B >::ranges_type::const_iterator_type iterator;
+        typedef typename view< P,B >::size_type size_type;
+        typedef typename mpl::front< L >::type S;
+
+        void operator()( iterator r )
+        {
+            size_type f = r[I][0], l = r[I][1], s = r[I][2];
+            if( s == 0 || f >= l || ( l - s ) >= S::value || ( l - f ) % s != 0 || ( l - f ) / s > S::value )
+                throw std::invalid_argument( "invalid view<> range" );
+        }
+    };
+
+//--
+
+    template< class P, class P1, std::size_t N, std::size_t I, bool B >
+    struct validate_view< P,P1,N,I,B,bounds<N> >
+    {
+        typedef typename view< P,B >::ranges_type::const_iterator_type iterator1;
+        typedef typename view< P,B >::size_type size_type;
+        typedef typename P1::bounds_type::const_iterator iterator2;
+
+        void operator()( iterator1 r, iterator2 i ) 
+        {
+            size_type f = r[I][0], l = r[I][1], s = r[I][2];
+            if( s == 0 || f >= l || ( l - s ) >= *i || ( l - f ) % s != 0 || ( l - f ) / s > *i )
+                throw std::invalid_argument( "invalid view<> range" );
+            validate_view< P,P1,N-1,I+1,B,bounds<N-1> >()( r, i+1 );
+        }
+    };
+
+    template< class P, class P1, std::size_t I, bool B >
+    struct validate_view< P,P1,1,I,B,bounds<1> >
+    {
+        typedef typename view< P,B >::ranges_type::const_iterator_type iterator1;
+        typedef typename view< P,B >::size_type size_type;
+        typedef typename P1::bounds_type::const_iterator iterator2;
+
+        void operator()( iterator1 r, iterator2 i )
+        {
+            size_type f = r[I][0], l = r[I][1], s = r[I][2];
+            if( s == 0 || f >= l || ( l - s ) >= *i || ( l - f ) % s != 0 || ( l - f ) / s > *i )
+                throw std::invalid_argument( "invalid view<> range" );
+        }
+    };
+
+//--
+
+    template< class P, class P1, std::size_t N, bool B, class L >
+    struct view_validate
+    {
+        typedef typename view< P,B >::ranges_type::const_iterator_type iterator1;
+        
+        void operator()( iterator1 r, P1 const& ) 
+        {
+            validate_view< P,P1,N,0,B,L >()( r );
+        }
+    };
+
+    template< class P, class P1, std::size_t N, bool B >
+    struct view_validate< P,P1,N,B,bounds<N> >
+    {
+        typedef typename view< P,B >::ranges_type::const_iterator_type iterator1;
+        
+        void operator()( iterator1 r, P1 const& p ) 
+        {
+            validate_view< P,P1,N,0,B,bounds<N> >()( r, p.bounds().begin() );
+        }
+    };
+
+//--
+
+    template< class P1, class P, std::size_t N, std::size_t I, bool B >
+    struct view_set
+    {
+        typedef typename P1::iterator_type iterator1;
+        typedef typename view< P,B >::iterator_type iterator2;
+        typedef typename view< P,B >::ranges_type::const_iterator_type iterator3;
+        typedef typename view< P,B >::size_type size_type;
+        typedef typename P1::subarray_type::type R1;
+        typedef typename P::subarray_type::type R;
+
+        void operator()( iterator1 p, iterator2 v, iterator3 r )
+        {
+            size_type f = r[I][0], l = r[I][1], s = r[I][2];
+            for( std::size_t i = 0, j = f; j != l; ++i, j += s )
+                view_set< R1,R,N-1,I+1,B >()( p[j], v[i], r );
+        }
+    };
+
+    template< class P1, class P, std::size_t I, bool B >
+    struct view_set< P1,P,1,I,B >
+    {
+        typedef typename P1::iterator_type iterator1;
+        typedef typename view< P,B >::iterator_type iterator2;
+        typedef typename view< P,B >::ranges_type::const_iterator_type iterator3;
+        typedef typename view< P,B >::size_type size_type;
+
+        void operator()( iterator1 p, iterator2 v, iterator3 r )
+        {
+            size_type f = r[I][0], l = r[I][1], s = r[I][2];
+            for( std::size_t i = 0, j = f; j != l; ++i, j += s ) p[j] = *v[i];
+        }
+    };
+
+    template< class P1, class P, std::size_t I >
+    struct view_set< P1,P,1,I,false >
+    {
+        typedef typename P1::iterator_type iterator1;
+        typedef typename view< P,false >::iterator_type iterator2;
+        typedef typename view< P,false >::ranges_type::const_iterator_type iterator3;
+        typedef typename view< P,false >::size_type size_type;
+
+        void operator()( iterator1 p, iterator2 v, iterator3 r )
+        {
+            size_type f = r[I][0], l = r[I][1], s = r[I][2];
+            for( std::size_t i = 0, j = f; j != l; ++i, j += s ) p[j] = v[i];
+        }
+    };
+
+//--
+
+    template< class P, std::size_t N, bool B >
+    struct view_destructor
+    {
+        typedef typename view< P,B >::member_type type;
+        typedef typename view< P,B >::bounds_type::iterator iterator;
+        typedef typename view< P,B >::size_type size_type;
+        typedef typename view< P,B >::element_type T;
+        typedef typename view< P,B >::allocator_type A;
+        typedef typename P::subarray_type::type R;
+
+        void operator()( type& v, iterator i, size_type s ) 
+        {
+            view_destructor< R,N-1,B >()( v[0], i+1, s * *( i+1 ) );
+            pointer_deallocate< T,N,A >()( v, s ); *i = 0;
+        }
+    };
+
+    template< class P, bool B >
+    struct view_destructor< P,1,B >
+    {
+        typedef typename view< P,B >::member_type type;
+        typedef typename view< P,B >::bounds_type::iterator iterator;
+        typedef typename view< P,B >::size_type size_type;
+        typedef typename view< P,B >::element_type T;
+        typedef typename view< P,B >::allocator_type A;
+
+        void operator()( type& v, iterator i, size_type s ) 
+        {
+            pointer_deallocate< T,1,A >()( v, s ); *i = 0;
+        }
+    };
+
+    template< class P >
+    struct view_destructor< P,1,false >
+    {
+        typedef typename view< P,false >::member_type type;
+        typedef typename view< P,false >::bounds_type::iterator iterator;
+        typedef typename view< P,false >::size_type size_type;
+        typedef typename view< P,false >::element_type T;
+        typedef typename has_trivial_destructor< T >::type D;
+        typedef typename view< P,false >::allocator_type A;
+
+        void operator()( type& v, iterator i, size_type s ) 
+        {
+            pointer_destroy< T,1,D::value,A >()( v, s );
+            pointer_deallocate< T,1,A >()( v, s ); *i = 0;
+        }
+    };
+
+    //--
+
+    template< class P, std::size_t N, bool B >
+    struct view_element_const
+    {
+        typedef typename view< P,B >::const_reference const_reference;
+        typedef typename view< P,B >::member_type type;
+        typedef typename view< P,B >::bounds_type::const_iterator const_iterator;
+        typedef typename P::subarray_type::type R;
+
+        const_reference operator()( type const& v, const_iterator d, const_iterator i ) 
+        {
+            BOOST_ASSERT( *i < *d );
+            return view_element_const< R,N-1,B >()( v[*i], d+1, i+1 ); 
+        }
+    };
+
+    template< class P, bool B >
+    struct view_element_const< P,1,B >
+    {
+        typedef typename view< P,B >::const_reference const_reference;
+        typedef typename view< P,B >::member_type type;
+        typedef typename view< P,B >::bounds_type::const_iterator const_iterator;
+
+        const_reference operator()( type const& v, const_iterator d, const_iterator i ) 
+        {
+            BOOST_ASSERT( *i < *d );
+            return v[*i];
+        }
+    };
+
+//--
+
+    template< class P, std::size_t N, bool B >
+    struct view_element
+    {
+        typedef typename view< P,B >::reference reference;
+        typedef typename view< P,B >::member_type type;
+        typedef typename view< P,B >::bounds_type::const_iterator const_iterator;
+        typedef typename P::subarray_type::type R;
+
+        reference operator()( type& v, const_iterator d, const_iterator i ) 
+        {
+            BOOST_ASSERT( *i < *d );
+            return view_element< R,N-1,B >()( v[*i], d+1, i+1 ); 
+        }
+    };
+
+    template< class P, bool B >
+    struct view_element< P,1,B >
+    {
+        typedef typename view< P,B >::reference reference;
+        typedef typename view< P,B >::member_type type;
+        typedef typename view< P,B >::bounds_type::const_iterator const_iterator;
+
+        reference operator()( type& v, const_iterator d, const_iterator i ) 
+        {
+            BOOST_ASSERT( *i < *d );
+            return v[*i];
+        }
+    };
+
+//--
+
+    template< class P1, class P, std::size_t N, bool B, class L >
+    struct view_bounds_equality
+    {
+        typedef typename view< P,B >::bounds_type::const_iterator const_iterator;
+        typedef typename mpl::front< L >::type F;
+        typedef typename mpl::pop_front< L >::type M;
+
+        bool operator()( const_iterator b ) 
+        {
+            if( *b != F::value ) return false;
+            return view_bounds_equality< P1,P,N-1,B,M >()( b+1 );
+        }
+    };
+
+    template< class P1, class P, bool B, class L >
+    struct view_bounds_equality< P1,P,1,B,L >
+    {
+        typedef typename view< P,B >::bounds_type::const_iterator const_iterator;
+        typedef typename mpl::front< L >::type F;
+
+        bool operator()( const_iterator b ) 
+        {
+            if( *b != F::value ) return false;
+            return true;
+        }
+    };
+
+//--
+
+    template< class P1, class P, std::size_t N, bool B >
+    struct view_bounds_equality< P1,P,N,B,bounds<N> >
+    {
+        typedef typename view< P,B >::bounds_const_reference const_reference1;
+        typedef typename P1::bounds_const_reference const_reference2;
+
+        bool operator()( const_reference1 b, const_reference2 p ) 
+        {
+            if( b != p ) return false;
+            return true;
+        }
+    };
+
+//--
+
+    template< class P1, class P, std::size_t N, bool B, class L >
+    struct view_bounds_equal
+    {
+        typedef typename view< P,B >::bounds_const_reference const_reference;
+        
+        bool operator()( const_reference b, P1 const& p ) 
+        {
+            return view_bounds_equality< P1,P,N,B,L >()( b.begin() );
+        }
+    };
+
+    template< class P1, class P, std::size_t N, bool B >
+    struct view_bounds_equal< P1,P,N,B,bounds<N> >
+    {
+        typedef typename view< P,B >::bounds_const_reference const_reference;
+
+        bool operator()( const_reference b, P1 const& p ) 
+        {
+            return view_bounds_equality< P1,P,N,B,bounds<N> >()( b, p.bounds() );
+        }
+    };
+
+//--
+
+    template< class P1, class P, std::size_t N, bool B >
+    struct view_to
+    {
+        typedef typename P1::iterator_type iterator1;
+        typedef typename view< P,B >::const_iterator_type iterator2;
+        typedef typename view< P,B >::bounds_type::const_iterator const_iterator;
+        typedef typename view< P,B >::size_type size_type;
+        typedef typename P1::subarray_type::type R1;
+        typedef typename P::subarray_type::type R;
+
+        void operator()( iterator1 p, iterator2 v, const_iterator c ) 
+        {
+            size_type s = *c;
+            for( size_t i = 0; i != s; ++i )
+                view_to< R1,R,N-1,B >()( p[i], v[i], c+1 );
+        }
+    };
+
+    template< class P1, class P, bool B >
+    struct view_to< P1,P,1,B >
+    {
+        typedef typename P1::iterator_type iterator1;
+        typedef typename view< P,B >::const_iterator_type iterator2;
+        typedef typename view< P,B >::bounds_type::const_iterator const_iterator;
+        typedef typename view< P,B >::size_type size_type;
+
+        void operator()( iterator1 p, iterator2 v, const_iterator c )
+        {
+            size_type s = *c;
+            for( std::size_t i = 0; i != s; ++i ) p[i] = *v[i];
+        }
+    };
+
+    template< class P1, class P >
+    struct view_to< P1,P,1,false >
+    {
+        typedef typename P1::iterator_type iterator1;
+        typedef typename view< P,false >::const_iterator_type iterator2;
+        typedef typename view< P,false >::bounds_type::const_iterator const_iterator;
+        typedef typename view< P,false >::size_type size_type;
+
+        void operator()( iterator1 p, iterator2 v, const_iterator c )
+        {
+            size_type s = *c;
+            for( std::size_t i = 0; i != s; ++i ) p[i] = v[i];
+        }
+    };
+
+//--
+
+    template< class P, class P1, std::size_t N, bool B >
+    struct view_from
+    {
+        typedef typename view< P,B >::iterator_type iterator1;
+        typedef typename P1::const_iterator_type iterator2;
+        typedef typename view< P,B >::bounds_type::const_iterator const_iterator;
+        typedef typename view< P,B >::size_type size_type;
+        typedef typename P::subarray_type::type R;
+        typedef typename P1::subarray_type::type R1;
+
+        void operator()( iterator1 v, iterator2 p, const_iterator c ) 
+        {
+            size_type s = *c;
+            for( size_t i = 0; i != s; ++i )
+                view_from< R,R1,N-1,B >()( v[i], p[i], c+1 );
+        }
+    };
+
+    template< class P, class P1, bool B >
+    struct view_from< P,P1,1,B >
+    {
+        typedef typename view< P,B >::iterator_type iterator1;
+        typedef typename P1::const_iterator_type iterator2;
+        typedef typename view< P,B >::bounds_type::const_iterator const_iterator;
+        typedef typename view< P,B >::size_type size_type;
+
+        void operator()( iterator1 v, iterator2 p, const_iterator c )
+        {
+            size_type s = *c;
+            for( std::size_t i = 0; i != s; ++i ) *v[i] = p[i];
+        }
+    };
+
+    template< class P, class P1 >
+    struct view_from< P,P1,1,false >
+    {
+        typedef typename view< P,false >::iterator_type iterator1;
+        typedef typename P1::const_iterator_type iterator2;
+        typedef typename view< P,false >::bounds_type::const_iterator const_iterator;
+        typedef typename view< P,false >::size_type size_type;
+
+        void operator()( iterator1 v, iterator2 p, const_iterator c )
+        {
+            size_type s = *c;
+            for( std::size_t i = 0; i != s; ++i ) v[i] = p[i];
+        }
+    };
+
+//--
+
+    template< class P, std::size_t N, bool B >
+    struct view_begin_const
+    {
+        typedef typename view< P,B >::const_iterator const_iterator;
+        typedef typename view< P,B >::member_type type;
+        typedef typename P::subarray_type::type R;
+
+        const_iterator operator()( type const p )
+        {
+            return view_begin_const< R,N-1,B >()( *p );
+        }
+    };
+
+    template< class P, bool B >
+    struct view_begin_const< P,1,B >
+    {
+        typedef typename view< P,B >::const_iterator const_iterator;
+        typedef typename view< P,B >::member_type type;
+
+        const_iterator operator()( type const p )
+        {
+            return p;
+        }
+    };
+
+//--
+
+    template< class P, std::size_t N, bool B >
+    struct view_begin
+    {
+        typedef typename view< P,B >::iterator iterator;
+        typedef typename view< P,B >::member_type type;
+        typedef typename P::subarray_type::type R;
+
+        iterator operator()( type p )
+        {
+            return view_begin< R,N-1,B >()( *p );
+        }
+    };
+
+    template< class P, bool B >
+    struct view_begin< P,1,B >
+    {
+        typedef typename view< P,B >::iterator iterator;
+        typedef typename view< P,B >::member_type type;
+
+        iterator operator()( type p )
+        {
+            return p;
+        }
+    };
+
+//--
+//--
+
+    template< class P, bool B >
+    class view
+        : public expression< view< P,B > >
+    {
+    public:
+
+        typedef view type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef type const* type_const_pointer;
+        typedef type* type_pointer;
+        typedef expression< type > base_type;
+        typedef typename view_traits< P,B >::member_type member_type;
+        typedef typename view_traits< P,B >::value_type value_type;
+        typedef typename view_traits< P,B >::const_reference_type const_reference_type;
+        typedef typename view_traits< P,B >::reference_type reference_type;
+        typedef typename view_traits< P,B >::const_iterator_type const_iterator_type;
+        typedef typename view_traits< P,B >::iterator_type iterator_type;
+        typedef typename view_traits< P,B >::element_type element_type;
+        typedef typename view_traits< P,B >::const_iterator const_iterator;
+        typedef typename view_traits< P,B >::iterator iterator;
+        typedef typename view_traits< P,B >::const_reference const_reference;
+        typedef typename view_traits< P,B >::reference reference;
+        typedef typename view_traits< P,B >::allocator_type allocator_type;
+        typedef typename view_traits< P,B >::size_type size_type;
+        typedef typename view_traits< P,B >::difference_type difference_type;
+        typedef typename view_traits< P,B >::bounds_type bounds_type;
+        typedef typename view_traits< P,B >::bounds_const_reference bounds_const_reference;
+        typedef typename view_traits< P,B >::limits_type limits_type;
+        typedef typename view_traits< P,B >::ranges ranges_type;
+        typedef typename view_traits< P,B >::ranges_const_reference ranges_const_reference;
+
+        enum { dimensionality = P::dimensionality };
+
+        view();
+
+        ~view();
+
+        void reset( P& );
+        template< class P1 > void set( P1& ) const;
+
+        const_reference_type operator[]( size_type ) const;
+        reference_type operator[]( size_type );
+
+        const_reference_type operator*() const;
+        reference_type operator*();
+
+        const_iterator_type operator+( size_type ) const;
+        iterator_type operator+( size_type );
+
+        const_reference operator[]( bounds_const_reference ) const;
+        reference operator[]( bounds_const_reference );
+
+        const_reference at( bounds_const_reference ) const;
+        reference at( bounds_const_reference );
+
+        bool const empty() const;
+        size_type const size() const;
+        bounds_const_reference bounds() const;
+        template< std::size_t U > size_type const bound() const;
+
+        template< class P1 > void to( P1& );
+        template< class P1 > void from( P1 const& );
+
+        void clear();
+
+        const_iterator begin() const;
+        iterator begin();
+        const_iterator end() const;
+        iterator end();
+
+        template< std::size_t R >
+        class range
+        {
+        public:
+
+            typedef range type;
+            typedef type const& type_const_reference;
+            typedef type& type_reference;
+            typedef type const* type_const_pointer;
+            typedef type* type_pointer;
+            typedef std::size_t size_type;
+            typedef std::size_t element_type;
+            typedef typename ranges_type::value_type value_type;
+            typedef value_type const& const_reference_type;
+            typedef value_type& reference_type;
+            typedef value_type const* const_iterator_type;
+            typedef value_type* iterator_type;
+            typedef size_type const& const_reference;
+            typedef size_type& reference;
+            typedef size_type const* const_iterator;
+            typedef size_type* iterator;
+            typedef assigner< type,2 > assigner_type;
+
+            explicit range( view& );
+
+            assigner_type operator=( const_reference );
+
+            const_reference operator[]( size_type ) const;
+            reference operator[]( size_type );
+
+        protected:
+
+            view& v;
+        };
+
+    protected:
+
+        bounds_type limits;
+        ranges_type ranges;
+        member_type data;
+
+    private:
+
+        typedef typename mpl::size_t< dimensionality >::type N;
+        typedef limits_type L;
+
+        view( type_const_reference );
+        type_reference operator=( type_const_reference );
+
+    };
+
+//--
+//--
+
+    template< class P, bool B >
+    view< P,B >::view() : data( 0 )
+    {}
+
+    template< class P, bool B >
+    view< P,B >::~view()
+    {
+        if( data ) view_destructor< P,N::value,B >()( data, limits.begin(), limits[0] );
+    }
+
+    template< class P, bool B >
+    void view< P,B >::reset( P& p )
+    {
+        if( data ) view_resize< P,N::value,B,L >()( data, ranges+0, limits.begin(), p );
+        else view_constructor< P,N::value,B,L >()( data, limits.begin(), ranges+0, p );
+        view_reset< P,N::value,0,B >()( data, p+0, ranges+0 );
+    }
+
+    template< class P, bool B > template< class P1 >
+    void view< P,B >::set( P1& p ) const
+    {
+        if( data )
+        {   view_validate< P,P1,N::value,B,typename P1::limits_type >()( ranges+0, p );
+            view_set< P1,P,N::value,0,B >()( p+0, data, ranges+0 );
+        }
+    }
+
+    template< class P, bool B > 
+    typename view< P,B >::const_reference_type view< P,B >::operator[]( size_type s ) const 
+    {
+        BOOST_ASSERT( data );
+        return data[s]; 
+    }
+
+    template< class P, bool B >
+    typename view< P,B >::reference_type view< P,B >::operator[]( size_type s ) 
+    {
+        BOOST_ASSERT( data );
+        return data[s];
+    }
+
+    template< class P, bool B >
+    typename view< P,B >::const_reference_type view< P,B >::operator*() const
+    {
+        BOOST_ASSERT( data );
+        return *data;
+    }
+
+    template< class P, bool B >
+    typename view< P,B >::reference_type view< P,B >::operator*()
+    {
+        BOOST_ASSERT( data );
+        return *data;
+    }
+
+    template< class P, bool B >
+    typename view< P,B >::const_iterator_type view< P,B >::operator+( size_type s ) const
+    {
+        BOOST_ASSERT( data );
+        return data+s;
+    }
+
+    template< class P, bool B >
+    typename view< P,B >::iterator_type view< P,B >::operator+( size_type s )
+    {
+        BOOST_ASSERT( data );
+        return data+s;
+    }
+
+    template< class P, bool B >
+    typename view< P,B >::const_reference view< P,B >::operator[]( bounds_const_reference b ) const
+    {
+        BOOST_ASSERT( data );
+        return view_element_const< P,N::value,B >()( data, limits.begin(), b.begin() );
+    }
+
+    template< class P, bool B >
+    typename view< P,B >::reference view< P,B >::operator[]( bounds_const_reference b )
+    {
+        BOOST_ASSERT( data );
+        return view_element< P,N::value,B >()( data, limits.begin(), b.begin() );
+    }
+
+    template< class P, bool B >
+    typename view< P,B >::const_reference view< P,B >::at( bounds_const_reference b ) const
+    {
+        if( !( b < limits ) )
+            throw std::out_of_range( "view<> access out of range" );
+        return view_element_const< P,N::value,B >()( data, limits.begin(), b.begin() );
+    }
+
+    template< class P, bool B >
+    typename view< P,B >::reference view< P,B >::at( bounds_const_reference b )
+    {
+        if( !( b < limits ) )
+            throw std::out_of_range( "view<> access out of range" );
+        return view_element< P,N::value,B >()( data, limits.begin(), b.begin() );
+    }
+
+    template< class P, bool B >
+    bool const view< P,B >::empty() const
+    {
+        return ( data == 0 );
+    }
+
+    template< class P, bool B >
+    typename view< P,B >::size_type const view< P,B >::size() const
+    {
+        return pointer_size< N::value >()( limits.begin() );
+    }
+
+    template< class P, bool B >
+    typename view< P,B >::bounds_const_reference view< P,B >::bounds() const
+    {
+        return limits;
+    }
+
+    template< class P, bool B > template< std::size_t U >
+    typename view< P,B >::size_type const view< P,B >::bound() const
+    {
+        BOOST_STATIC_ASSERT( U < N::value ); 
+        return limits[U];
+    }
+
+    template< class P, bool B > template< class P1 > 
+    void view< P,B >::to( P1& p )
+    {
+        if( !view_bounds_equal< P1,P,N::value,B,typename P1::limits_type >()( limits, p ) )
+            throw std::invalid_argument( "view<> 'to' invalid argument" );
+        if( data ) view_to< P1,P,N::value,B >()( p+0, data, limits.begin() );
+    }
+
+    template< class P, bool B > template< class P1 > 
+    void view< P,B >::from( P1 const& p )
+    {
+        if( !view_bounds_equal< P1,P,N::value,B,typename P1::limits_type >()( limits, p ) )
+            throw std::invalid_argument( "view<> 'from' invalid argument" );
+        if( data ) view_from< P,P1,N::value,B >()( data, p+0, limits.begin() );
+    }
+
+    template< class P, bool B >
+    void view< P,B >::clear()
+    {
+        if( data ) view_destructor< P,N::value,B >()( data, limits.begin(), limits[0] );
+    }
+
+    template< class P, bool B > 
+    typename view< P,B >::const_iterator view< P,B >::begin() const
+    {
+        if( data ) return view_begin_const< P,N::value,B >()( data );
+        return 0;
+    }
+
+    template< class P, bool B >
+    typename view< P,B >::iterator view< P,B >::begin()
+    {
+        if( data ) return view_begin< P,N::value,B >()( data );
+        return 0;
+    }
+
+    template< class P, bool B >
+    typename view< P,B >::const_iterator view< P,B >::end() const
+    {
+        if( data ) return begin()+size();
+        return 0;
+    }
+
+    template< class P, bool B >
+    typename view< P,B >::iterator view< P,B >::end()
+    {
+        if( data ) return begin()+size();
+        return 0;
+    }
+
+    template< class P, bool B >
+    view< P,B >::view( type_const_reference ) 
+    {}
+
+    template< class P, bool B >
+    typename view< P,B >::type_reference view< P,B >::operator=( type_const_reference ) 
+    {}
+
+//--
+
+    template< class P, bool B > template< std::size_t R >
+    view< P,B >::range< R >::range( view& v ) : v( v )
+    {
+        BOOST_STATIC_ASSERT( R < dimensionality ); 
+    }
+
+    template< class P, bool B > template< std::size_t R >
+    typename view< P,B >::template range< R >::assigner_type view< P,B >::range< R >::operator=( const_reference x ) 
+    {
+        return assigner_type( *this, v.ranges[R], x ); 
+    }
+
+    template< class P, bool B > template< std::size_t R >
+    typename view< P,B >::template range< R >::const_reference view< P,B >::range< R >::operator[]( size_type s ) const 
+    {
+        BOOST_ASSERT( s < 3 );
+        return v.ranges[R][s];
+    }
+
+    template< class P, bool B > template< std::size_t R >
+    typename view< P,B >::template range< R >::reference view< P,B >::range< R >::operator[]( size_type s ) 
+    {
+        BOOST_ASSERT( s < 3 );
+        return v.ranges[R][s];
+    }
+
+//--
+
+}} // namespace boost, namespace maps
+
+#endif // BOOST_MAPS_GENERIC_VIEW_HPP
\ No newline at end of file
Added: sandbox/maps/boost/maps/generic/view_.hpp
==============================================================================
--- (empty file)
+++ sandbox/maps/boost/maps/generic/view_.hpp	2011-08-08 19:51:30 EDT (Mon, 08 Aug 2011)
@@ -0,0 +1,663 @@
+//--
+// Copyright (c) 2010-2011 Brian Smith
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/maps for documentation.
+//--
+#if !defined( BOOST_MAPS_GENERIC_VIEW_HPP_ )
+#define BOOST_MAPS_GENERIC_VIEW_HPP_
+
+#include <boost/maps/support/preprocessor_ranges.hpp>
+
+namespace boost { namespace maps {
+
+//--
+
+    template< class A, class R, std::size_t N, bool B >
+    struct view_reset_
+    {    
+        typedef typename view_< A,R,B >::iterator_type view_iterator;
+        typedef typename A::iterator_type array_iterator;
+        typedef view_range< typename mpl::front< R >::type > range;
+        typedef typename A::subarray_type::type P;
+        typedef typename mpl::pop_front< R >::type Q;
+  
+        void operator()( view_iterator v, array_iterator a ) 
+        {
+            for( std::size_t i = 0, j = range::first::value; 
+                j != range::last::value; ++i, j += range::step::value )
+                view_reset_< P,Q,N-1,B >()( v[i], a[j] );
+        }
+    };
+
+    template< class A, class R, bool B >
+    struct view_reset_< A,R,1,B >
+    {    
+        typedef typename view_< A,R,B >::iterator_type view_iterator;
+        typedef typename A::iterator_type array_iterator;
+        typedef view_range< typename mpl::front< R >::type > range;
+
+        void operator()( view_iterator v, array_iterator a )
+        {
+            for( std::size_t i = 0, j = range::first::value; 
+                j != range::last::value; ++i, j += range::step::value ) v[i] = &a[j];
+        }
+    };
+
+    template< class A, class R >
+    struct view_reset_< A,R,1,false >
+    {    
+        typedef typename view_< A,R,false >::iterator_type view_iterator;
+        typedef typename A::iterator_type array_iterator;
+        typedef view_range< typename mpl::front< R >::type > range;
+
+        void operator()( view_iterator v, array_iterator a )
+        {
+            for( std::size_t i = 0, j = range::first::value; 
+                j != range::last::value; ++i, j += range::step::value ) v[i] = a[j];
+        }
+    };
+
+//--
+
+    template< class A1, class A, class R, std::size_t N, bool B >
+    struct view_set_
+    {    
+        typedef typename A1::iterator_type array_iterator;
+        typedef typename view_< A,R,B >::const_iterator_type view_iterator;
+        typedef view_range< typename mpl::front< R >::type > range;
+        typedef typename A1::subarray_type::type P1;
+        typedef typename A::subarray_type::type P;
+        typedef typename mpl::pop_front< R >::type Q;
+
+        void operator()( array_iterator a, view_iterator v ) 
+        {
+            for( std::size_t i = 0, j = range::first::value; 
+                j != range::last::value; ++i, j += range::step::value )
+                view_set_< P1,P,Q,N-1,B >()( a[j], v[i] );
+        }
+    };
+
+    template< class A1, class A, class R, bool B >
+    struct view_set_< A1,A,R,1,B >
+    {    
+        typedef typename A1::iterator_type array_iterator;
+        typedef typename view_< A,R,B >::const_iterator_type view_iterator;
+        typedef view_range< typename mpl::front< R >::type > range;
+
+        void operator()( array_iterator a, view_iterator v )
+        {
+            for( std::size_t i = 0, j = range::first::value; 
+                j != range::last::value; ++i, j += range::step::value ) a[j] = *v[i];
+        }
+    };
+
+    template< class A1, class A, class R >
+    struct view_set_< A1,A,R,1,false >
+    {    
+        typedef typename A1::iterator_type array_iterator;
+        typedef typename view_< A,R,false >::const_iterator_type view_iterator;
+        typedef view_range< typename mpl::front< R >::type > range;
+
+        void operator()( array_iterator a, view_iterator v )
+        {
+            for( std::size_t i = 0, j = range::first::value; 
+                j != range::last::value; ++i, j += range::step::value ) a[j] = v[i];
+        }
+    };
+
+//--
+
+    template< class A, class R, std::size_t N, bool B >
+    struct view_element_const_
+    {
+        typedef typename view_< A,R,B >::const_reference const_reference;
+        typedef typename view_< A,R,B >::const_iterator_type iterator_type;
+        typedef typename bounds< A::dimensionality >::const_iterator const_iterator;
+        typedef typename view_range< typename mpl::front< R >::type >::bound bound;
+        typedef typename A::subarray_type::type P;
+        typedef typename mpl::pop_front< R >::type Q;
+
+        const_reference operator()( iterator_type p, const_iterator i )
+        {
+            BOOST_ASSERT( *i < bound::value );
+            return view_element_const_< P,Q,N-1,B >()( p[*i], i+1 );
+        }
+    };
+
+    template< class A, class R, bool B >
+    struct view_element_const_< A,R,1,B >
+    {
+        typedef typename view_< A,R,B >::const_reference const_reference;
+        typedef typename view_< A,R,B >::const_iterator_type iterator_type;
+        typedef typename bounds< A::dimensionality >::const_iterator const_iterator;
+        typedef typename view_range< typename mpl::front< R >::type >::bound bound;
+
+        const_reference operator()( iterator_type p, const_iterator i )
+        {
+            BOOST_ASSERT( *i < bound::value );
+            return p[*i];
+        }
+    };
+
+//--
+
+    template< class A, class R, std::size_t N, bool B >
+    struct view_element_
+    {
+        typedef typename view_< A,R,B >::reference reference;
+        typedef typename view_< A,R,B >::iterator_type iterator_type;
+        typedef typename bounds< A::dimensionality >::const_iterator const_iterator;
+        typedef typename view_range< typename mpl::front< R >::type >::bound bound;
+        typedef typename A::subarray_type::type P;
+        typedef typename mpl::pop_front< R >::type Q;
+
+        reference operator()( iterator_type p, const_iterator i )
+        {
+            BOOST_ASSERT( *i < bound::value );
+            return view_element_< P,Q,N-1,B >()( p[*i], i+1 );
+        }
+    };
+
+    template< class A, class R, bool B >
+    struct view_element_< A,R,1,B >
+    {
+        typedef typename view_< A,R,B >::reference reference;
+        typedef typename view_< A,R,B >::iterator_type iterator_type;
+        typedef typename bounds< A::dimensionality >::const_iterator const_iterator;
+        typedef typename view_range< typename mpl::front< R >::type >::bound bound;
+
+        reference operator()( iterator_type p, const_iterator i )
+        {
+            BOOST_ASSERT( *i < bound::value );
+            return p[*i];
+        }
+    };
+
+//--
+
+    template< class A, class R, std::size_t N, bool B >
+    struct view_element_at_const_
+    {
+        typedef typename view_< A,R,B >::const_reference const_reference;
+        typedef typename view_< A,R,B >::const_iterator_type iterator_type;
+        typedef typename bounds< A::dimensionality >::const_iterator const_iterator;
+        typedef typename view_range< typename mpl::front< R >::type >::bound bound;
+        typedef typename A::subarray_type::type P;
+        typedef typename mpl::pop_front< R >::type Q;
+
+        const_reference operator()( iterator_type p, const_iterator i )
+        {
+            if( !( *i < bound::value ) ) 
+                throw std::out_of_range( "view_<> access out of range" );
+            return view_element_at_const_< P,Q,N-1,B >()( p[*i], i+1 );
+        }
+    };
+
+    template< class A, class R, bool B >
+    struct view_element_at_const_< A,R,1,B >
+    {
+        typedef typename view_< A,R,B >::const_reference const_reference;
+        typedef typename view_< A,R,B >::const_iterator_type iterator_type;
+        typedef typename bounds< A::dimensionality >::const_iterator const_iterator;
+        typedef typename view_range< typename mpl::front< R >::type >::bound bound;
+
+        const_reference operator()( iterator_type p, const_iterator i )
+        {
+            if( !( *i < bound::value ) ) 
+                throw std::out_of_range( "view_<> access out of range" );
+            return p[*i];
+        }
+    };
+
+//--
+
+    template< class A, class R, std::size_t N, bool B >
+    struct view_element_at_
+    {
+        typedef typename view_< A,R,B >::reference reference;
+        typedef typename view_< A,R,B >::iterator_type iterator_type;
+        typedef typename bounds< A::dimensionality >::const_iterator const_iterator;
+        typedef typename view_range< typename mpl::front< R >::type >::bound bound;
+        typedef typename A::subarray_type::type P;
+        typedef typename mpl::pop_front< R >::type Q;
+
+        reference operator()( iterator_type p, const_iterator i )
+        {
+            if( !( *i < bound::value ) ) 
+                throw std::out_of_range( "view_<> access out of range" );
+            return view_element_at_< P,Q,N-1,B >()( p[*i], i+1 );
+        }
+    };
+
+    template< class A, class R, bool B >
+    struct view_element_at_< A,R,1,B >
+    {
+        typedef typename view_< A,R,B >::reference reference;
+        typedef typename view_< A,R,B >::iterator_type iterator_type;
+        typedef typename bounds< A::dimensionality >::const_iterator const_iterator;
+        typedef typename view_range< typename mpl::front< R >::type >::bound bound;
+
+        reference operator()( iterator_type p, const_iterator i )
+        {
+            if( !( *i < bound::value ) ) 
+                throw std::out_of_range( "view_<> access out of range" );
+            return p[*i];
+        }
+    };
+
+//--
+
+    template< class A, class R, std::size_t N, bool B, std::size_t S >
+    struct view_empty_
+    {
+        typedef typename view_< A,R,B >::const_iterator_type iterator_type;
+        typedef typename A::subarray_type::type P;
+        typedef typename mpl::pop_front< R >::type Q;
+        typedef typename view_range< typename mpl::front< Q >::type >::bound D;
+
+        bool operator()( iterator_type v ) 
+        {
+            return view_empty_< P,Q,N-1,B,S*D::value >()( v[0] );
+        }
+    };
+
+    template< class A, class R, std::size_t S >
+    struct view_empty_< A,R,1,false,S >
+    {
+        typedef typename view_< A,R,false >::const_iterator_type iterator_type;
+
+        bool operator()( iterator_type ) 
+        {
+            return false;
+        }
+    };
+
+    template< class A, class R, bool B, std::size_t S >
+    struct view_empty_< A,R,1,B,S >
+    {
+        typedef typename view_< A,R,B >::const_iterator_type iterator_type;
+        typedef typename view_range< typename mpl::front< R >::type >::bound D;
+
+        bool operator()( iterator_type v )
+        {
+            for( std::size_t i = 0; i != S * D::value; ++i ) 
+                if( v[i] == 0 ) return true;
+            return false;
+        }
+    };
+
+//--
+
+    template< class A1, class A, class R, std::size_t N, bool B, std::size_t S >
+    struct view_to_
+    {    
+        typedef typename A1::iterator_type array_iterator;
+        typedef typename view_< A,R,B >::const_iterator_type view_iterator;
+        typedef typename mpl::front< typename A1::bounds >::type F;
+        typedef typename A1::subarray_type::type P1;
+        typedef typename A::subarray_type::type P;
+        typedef typename mpl::pop_front< R >::type Q;
+
+        void operator()( array_iterator a, view_iterator v ) 
+        {
+            view_to_< P1,P,Q,N-1,B,S*F::value >()( a[0], v[0] );
+        }
+    };
+
+    template< class A1, class A, class R, bool B, std::size_t S >
+    struct view_to_< A1,A,R,1,B,S >
+    {
+        typedef typename A1::iterator_type array_iterator;
+        typedef typename view_< A,R,B >::const_iterator_type view_iterator;
+        typedef typename mpl::front< typename A1::bounds >::type F;
+
+        void operator()( array_iterator a, view_iterator v )
+        {
+            for( std::size_t i = 0; i != S * F::value; ++i ) a[i] = *v[i];
+        }
+    };
+
+    template< class A1, class A, class R, std::size_t S >
+    struct view_to_< A1,A,R,1,false,S >
+    {
+        typedef typename A1::iterator_type array_iterator;
+        typedef typename view_< A,mpl::vector1< R >,false >::const_iterator_type view_iterator;
+        typedef typename mpl::front< typename A1::bounds >::type F;
+
+        void operator()( array_iterator a, view_iterator v )
+        {
+            for( std::size_t i = 0; i != S * F::value; ++i ) a[i] = v[i];
+        }
+    };
+
+//--
+
+    template< class A, class A1, class R, std::size_t N, bool B, std::size_t S >
+    struct view_from_
+    {    
+        typedef typename view_< A,R,B >::iterator_type view_iterator;
+        typedef typename A1::const_iterator_type array_iterator;
+        typedef typename mpl::front< typename A1::bounds >::type F;
+        typedef typename A::subarray_type::type P;
+        typedef typename A1::subarray_type::type P1;
+        typedef typename mpl::pop_front< R >::type Q;
+
+        void operator()( view_iterator v, array_iterator a ) 
+        {
+            view_from_< P,P1,Q,N-1,B,S*F::value >()( v[0], a[0] );
+        }
+    };
+
+    template< class A, class A1, class R, bool B, std::size_t S >
+    struct view_from_< A,A1,R,1,B,S >
+    {
+        typedef typename view_< A,mpl::vector1< R >,B >::iterator_type view_iterator;
+        typedef typename A1::const_iterator_type array_iterator;
+        typedef typename mpl::front< typename A1::bounds >::type F;
+
+        void operator()( view_iterator v, array_iterator a )
+        {
+            for( std::size_t i = 0; i != S * F::value; ++i ) *v[i] = a[i];
+        }
+    };
+
+    template< class A, class A1, class R, std::size_t S >
+    struct view_from_< A,A1,R,1,false,S >
+    {
+        typedef typename view_< A,mpl::vector1< R >,false >::iterator_type view_iterator;
+        typedef typename A1::const_iterator_type array_iterator;
+        typedef typename mpl::front< typename A1::bounds >::type F;
+
+        void operator()( view_iterator v, array_iterator a )
+        {
+            for( std::size_t i = 0; i != S * F::value; ++i ) v[i] = a[i];
+        }
+    };
+
+//--
+
+    template< class A, class R, std::size_t N, bool B >
+    struct view_begin_const_
+    {    
+        typedef typename view_< A,R,B >::const_iterator const_iterator;
+        typedef typename view_< A,R,B >::const_iterator_type iterator_type;
+        typedef typename A::subarray_type::type P;
+        typedef typename mpl::pop_front< R >::type Q;
+
+        const_iterator operator()( iterator_type p ) 
+        {
+            return view_begin_const_< P,Q,N-1,B >()( p[0] );
+        }
+    };
+
+    template< class A, class R, bool B >
+    struct view_begin_const_< A,R,1,B >
+    {    
+        typedef typename view_< A,R,B >::const_iterator const_iterator;
+        typedef typename view_< A,R,B >::const_iterator_type iterator_type;
+
+        const_iterator operator()( iterator_type p )
+        {
+            return p;
+        }
+    };
+
+    template< class A, class R, std::size_t N, bool B >
+    struct view_begin_
+    {    
+        typedef typename view_< A,R,B >::iterator iterator;
+        typedef typename view_< A,R,B >::iterator_type iterator_type;
+        typedef typename A::subarray_type::type P;
+        typedef typename mpl::pop_front< R >::type Q;
+
+        iterator operator()( iterator_type p ) 
+        {
+            return view_begin_< P,Q,N-1,B >()( p[0] );
+        }
+    };
+
+    template< class A, class R, bool B >
+    struct view_begin_< A,R,1,B >
+    {    
+        typedef typename view_< A,R,B >::iterator iterator;
+        typedef typename view_< A,R,B >::iterator_type iterator_type;
+
+        iterator operator()( iterator_type p )
+        {
+            return p;
+        }
+    };
+
+//--
+//--
+
+    template< class A, class R, bool B >
+    class view_
+        : public expression< view_< A,R,B > >
+    {
+    public:
+
+        typedef view_ type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef type const* type_const_pointer;
+        typedef type* type_pointer;
+        typedef expression< type > base_type;
+        typedef typename view_traits_< A,R,B >::value_type value_type;
+        typedef typename view_traits_< A,R,B >::const_reference_type const_reference_type;
+        typedef typename view_traits_< A,R,B >::reference_type reference_type;
+        typedef typename view_traits_< A,R,B >::const_iterator_type const_iterator_type;
+        typedef typename view_traits_< A,R,B >::iterator_type iterator_type;
+        typedef typename view_traits_< A,R,B >::element_type element_type;
+        typedef typename view_traits_< A,R,B >::const_iterator const_iterator;
+        typedef typename view_traits_< A,R,B >::iterator iterator;
+        typedef typename view_traits_< A,R,B >::const_reference const_reference;
+        typedef typename view_traits_< A,R,B >::reference reference;
+        typedef typename view_traits_< A,R,B >::allocator_type allocator_type;
+        typedef typename view_traits_< A,R,B >::size_type size_type;
+        typedef typename view_traits_< A,R,B >::difference_type difference_type;
+        typedef typename view_traits_< A,R,B >::bounds_type bounds_type;
+        typedef typename view_traits_< A,R,B >::bounds_const_reference bounds_const_reference;
+        typedef typename view_traits_< A,R,B >::bounds bounds;
+        typedef typename view_traits_< A,R,B >::ranges ranges;
+
+        enum { dimensionality = A::dimensionality, size = view_size< R >::type::value };
+
+        view_();
+        explicit view_( A& );
+
+        void reset( A& );
+        template< class A1 > void set( A1& ) const;
+
+        const_reference_type operator[]( size_type ) const;
+        reference_type operator[]( size_type );
+
+        const_reference_type operator*() const;
+        reference_type operator*();
+
+        const_iterator_type operator+( size_type ) const;
+        iterator_type operator+( size_type );
+
+        const_reference operator[]( bounds_const_reference ) const;
+        reference operator[]( bounds_const_reference );
+
+        const_reference at( bounds_const_reference ) const;
+        reference at( bounds_const_reference );
+
+        bool const empty() const;
+        template< std::size_t U > size_type const bound() const;
+
+        template< class A1 > void to( A1& );
+        template< class A1 > void from( A1 const& );
+
+        const_iterator begin() const;
+        iterator begin();
+        const_iterator end() const;
+        iterator end();
+
+    protected:
+
+        typedef typename mpl::size< R >::type N;
+        typedef typename view_traits_< A,R,B >::member_type member_type;
+
+        member_type data;
+
+    private:
+
+        view_( type_const_reference ) {}
+        type_reference operator=( type_const_reference ) {}
+
+    };
+
+//--
+//--
+
+    template< class A, class R, bool B >
+    view_< A,R,B >::view_()
+    {
+        BOOST_MPL_ASSERT(( view_valid< A,R > ));
+    }
+
+    template< class A, class R, bool B >
+    view_< A,R,B >::view_( A& a )
+    {
+        BOOST_MPL_ASSERT(( view_valid< A,R > ));
+        view_reset_< A,R,N::value,B >()( data+0, a+0 );
+    }
+
+    // Set this view_ representation to contain the values or pointers 
+    // to the values, determined by parameter B, contained in array a.
+    template< class A, class R, bool B >
+    void view_< A,R,B >::reset( A& a )
+    {
+        view_reset_< A,R,N::value,B >()( data+0, a+0 );
+    }
+
+    // Sets the values of a to the corresponding values of the array 
+    // that this view_ represents.
+    template< class A, class R, bool B > template< class A1 >
+    void view_< A,R,B >::set( A1& a ) const
+    {
+        BOOST_MPL_ASSERT(( mpl::equal< typename A::bounds, typename A1::bounds > ));
+        view_set_< A1,A,R,N::value,B >()( a+0, data+0 );
+    }
+
+    template< class A, class R, bool B >
+    typename view_< A,R,B >::const_reference_type view_< A,R,B >::operator[]( size_type s ) const
+    {
+        return data[s];
+    }
+
+    template< class A, class R, bool B >
+    typename view_< A,R,B >::reference_type view_< A,R,B >::operator[]( size_type s )
+    {
+        return data[s];
+    }
+
+    template< class A, class R, bool B >
+    typename view_< A,R,B >::const_reference_type view_< A,R,B >::operator*() const
+    {
+        return *data;
+    }
+
+    template< class A, class R, bool B >
+    typename view_< A,R,B >::reference_type view_< A,R,B >::operator*()
+    {
+        return *data;
+    }
+
+    template< class A, class R, bool B >
+    typename view_< A,R,B >::const_iterator_type view_< A,R,B >::operator+( size_type s ) const
+    {
+        return data+s;
+    }
+
+    template< class A, class R, bool B >
+    typename view_< A,R,B >::iterator_type view_< A,R,B >::operator+( size_type s )
+    {
+        return data+s;
+    }
+
+    template< class A, class R, bool B >
+    typename view_< A,R,B >::const_reference view_< A,R,B >::operator[]( bounds_const_reference b ) const
+    {
+        return view_element_const_< A,R,N::value,B >()( data+0, b.begin() );
+    }
+
+    template< class A, class R, bool B >
+    typename view_< A,R,B >::reference view_< A,R,B >::operator[]( bounds_const_reference b )
+    {
+        return view_element_< A,R,N::value,B >()( data+0, b.begin() );
+    }
+
+    template< class A, class R, bool B >
+    typename view_< A,R,B >::const_reference view_< A,R,B >::at( bounds_const_reference b ) const
+    {
+        return view_element_at_const_< A,R,N::value,B >()( data+0, b.begin() );
+    }
+
+    template< class A, class R, bool B >
+    typename view_< A,R,B >::reference view_< A,R,B >::at( bounds_const_reference b )
+    {
+        return view_element_at_< A,R,N::value,B >()( data+0, b.begin() );
+    }
+
+    template< class A, class R, bool B >
+    bool const view_< A,R,B >::empty() const
+    {
+        return view_empty_< A,R,N::value,B,1 >()( data+0 );
+    }
+
+    template< class A, class R, bool B > template< std::size_t U > 
+    typename view_< A,R,B >::size_type const view_< A,R,B >::bound() const
+    {
+        BOOST_STATIC_ASSERT( U < dimensionality );
+        return mpl::at< bounds,mpl::size_t< U > >::type::value;
+    }
+
+    template< class A, class R, bool B > template< class A1 > 
+    void view_< A,R,B >::to( A1& a )
+    {
+        BOOST_MPL_ASSERT(( mpl::equal< bounds, typename A1::bounds > ));
+        view_to_< A1,A,R,N::value,B,1 >()( a+0, data+0 );
+    }
+
+    template< class A, class R, bool B > template< class A1 > 
+    void view_< A,R,B >::from( A1 const& a )
+    {
+        BOOST_MPL_ASSERT(( mpl::equal< bounds, typename A1::bounds > ));
+        view_from_< A,A1,R,N::value,B,1 >()( data+0, a+0 );
+    }
+
+    template< class A, class R, bool B >
+    typename view_< A,R,B >::const_iterator view_< A,R,B >::begin() const
+    {
+        return view_begin_const_< A,R,N::value,B >()( data+0 );
+    }
+
+    template< class A, class R, bool B >
+    typename view_< A,R,B >::iterator view_< A,R,B >::begin()
+    {
+        return view_begin_< A,R,N::value,B >()( data+0 );
+    }
+
+    template< class A, class R, bool B >
+    typename view_< A,R,B >::const_iterator view_< A,R,B >::end() const
+    {
+        return begin()+size;
+    }
+
+    template< class A, class R, bool B >
+    typename view_< A,R,B >::iterator view_< A,R,B >::end()
+    {
+        return begin()+size;
+    }
+
+//--
+
+}} // namespace boost, namespace maps
+
+#endif // BOOST_MAPS_GENERIC_VIEW_HPP_
\ No newline at end of file
Added: sandbox/maps/boost/maps/math/matrix.hpp
==============================================================================
--- (empty file)
+++ sandbox/maps/boost/maps/math/matrix.hpp	2011-08-08 19:51:30 EDT (Mon, 08 Aug 2011)
@@ -0,0 +1,449 @@
+//--
+// Copyright (c) 2010-2011 Brian Smith
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/maps for documentation.
+//--
+#if !defined( BOOST_MAPS_MATH_MATRIX_HPP )
+#define BOOST_MAPS_MATH_MATRIX_HPP
+
+#include <boost/maps/support/math.hpp>
+#include <boost/maps/math/matrix_matrix.hpp>
+#include <boost/maps/math/matrix_scalar.hpp>
+#include <boost/maps/math/matrix_vector.hpp>
+
+namespace boost { namespace maps {
+
+//--
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A, std::size_t K >
+    struct matrix_equality
+    {
+        typedef typename matrix< T,M,N,I,A >::const_iterator const_iterator;
+
+        bool operator()( const_iterator x, const_iterator y )
+        {
+            if( *x != *y ) return false;
+            else return matrix_equality< T,M,N,I,A,K-1 >()( x+1, y+1 );
+        }
+    };
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A >
+    struct matrix_equality< T,M,N,I,A,1 >
+    {
+        typedef typename matrix< T,M,N,I,A >::const_iterator const_iterator;
+
+        bool operator()( const_iterator x, const_iterator y )
+        {
+            if( *x != *y ) return false;
+            else return true;
+        }
+    };
+
+//--
+
+    /*
+        fixed size matrix class template
+
+        parameters
+
+            required
+
+                T - data type we wish to store
+                    type: arbitrary type
+                M - number of rows
+                    type: std::size_t
+                N - number of columns
+                    type: std::size_t
+
+            optional
+
+                I - initialization parameter 
+                    type: bool 
+                    default: true, data elements zero/default initialized
+                A - allocator 
+                    type: standard conforming allocator, or null::allocator
+                    default: null::allocator, statically allocated array
+    */
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A >
+    class matrix
+        : public matrix_expression< matrix< T,M,N,I,A >,M,N >
+    {
+    public:
+
+        typedef matrix type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef type const* type_const_pointer;
+        typedef type* type_pointer;
+        typedef matrix_expression< type,M,N > base_type; 
+        typedef typename matrix_type< T,M,N,I,A >::type representation_type;
+        typedef typename representation_type::value_type value_type;
+        typedef typename representation_type::const_reference_type const_reference_type;
+        typedef typename representation_type::reference_type reference_type;
+        typedef typename representation_type::const_iterator_type const_iterator_type;
+        typedef typename representation_type::iterator_type iterator_type;
+        typedef typename representation_type::element_type element_type;
+        typedef typename representation_type::const_reference const_reference;
+        typedef typename representation_type::reference reference;
+        typedef typename representation_type::allocator_type allocator_type;
+        typedef typename representation_type::size_type size_type;
+        typedef typename representation_type::difference_type difference_type;
+        typedef typename representation_type::const_iterator const_iterator;
+        typedef typename representation_type::iterator iterator;
+        typedef mpl::size_t< 2 > dimensionality;
+        typedef mpl::bool_< I > initialize;
+
+        using matrix_expression< type,M,N >::operator();
+
+        enum { rows = M, cols = N, size = M * N };
+        enum { linear = true };
+
+    protected:
+
+        typedef assigner< type,M*N-1 > assigner_type;
+
+    public:
+
+        matrix();
+
+        matrix( matrix const& );
+        template< class E > matrix( matrix_expression< E,M,N > const& );
+
+        matrix& operator=( matrix const& );
+        template< class E > matrix& operator=( matrix_expression< E,M,N > const& );
+        assigner_type operator=( const_reference );
+
+        ~matrix();
+
+        template< size_t B > size_type const bound() const;
+
+        void swap( matrix& );
+
+        const_reference_type operator[]( size_type ) const;
+        reference_type operator[]( size_type );
+
+        const_reference operator()( reference, size_type, size_type ) const;
+        reference operator()( reference, size_type, size_type );
+
+        const_reference operator()( size_type, size_type ) const;
+        reference operator()( size_type, size_type );
+
+        const_reference operator()( size_type ) const;
+        reference operator()( size_type );
+
+        const_iterator begin() const;
+        iterator begin();
+        const_iterator end() const;
+        iterator end();
+
+        matrix& operator*=( matrix< T,N,N,I,A > const& );
+        matrix& operator+=( matrix const& );
+        matrix& operator-=( matrix const& );
+        matrix& operator*=( T const& );
+        matrix& operator/=( T const& );
+
+        template< class E > matrix& operator*=( matrix_expression< E,N,N > const& );
+        template< class E > matrix& operator+=( matrix_expression< E,M,N > const& );
+        template< class E > matrix& operator-=( matrix_expression< E,M,N > const& );
+        template< class E > matrix& operator*=( scalar_expression< E > const& );
+        template< class E > matrix& operator/=( scalar_expression< E > const& );
+
+        void clear();
+
+        bool const operator==( matrix const& ) const;
+        bool const operator!=( matrix const& ) const;
+
+        template< class U > 
+        bool const references( scalar< U > const& ) const;
+        template< class U, std::size_t Q, bool J, class B > 
+        bool const references( vector< U,Q,J,B > const& ) const;
+        template< class U, std::size_t P, std::size_t Q, bool J, class B > 
+        bool const references( matrix< U,P,Q,J,B > const& ) const;
+
+    private:
+
+        representation_type data;
+
+    public:
+
+        template< class T1, std::size_t M1, std::size_t N1, bool I1, class A1, class C, class CT >
+        friend std::basic_ostream< C,CT >& operator<<( std::basic_ostream< C,CT >&, matrix< T1,M1,N1,I1,A1 > const& );
+    };
+
+//--
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A >
+    matrix< T,M,N,I,A >::matrix()
+    {} // constructor
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A >
+    matrix< T,M,N,I,A >::matrix( matrix const& m ) : data( m.data )
+    {}
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A > template< class E >
+    matrix< T,M,N,I,A >::matrix( matrix_expression< E,M,N > const& e )
+    {
+        matrix_assign< type,E,M,N,matrix_matrix_assign< type,E >,E::linear,true >()( *this, e );
+    }
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A >
+    matrix< T,M,N,I,A >& matrix< T,M,N,I,A >::operator=( matrix const& m )
+    {
+        if( &m != this ) data = m.data;
+        return *this;
+    }
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A > template< class E >
+    matrix< T,M,N,I,A >& matrix< T,M,N,I,A >::operator=( matrix_expression< E,M,N > const& e )
+    {
+        matrix_assign< type,E,M,N,matrix_matrix_assign< type,E >,E::linear,false >()( *this, e );
+        return *this;
+    }
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A >
+    typename matrix< T,M,N,I,A >::assigner_type matrix< T,M,N,I,A >::operator=( const_reference t )
+    {
+        return assigner_type( *this, begin(), t );
+    } // element assignment
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A >
+    matrix< T,M,N,I,A >::~matrix()
+    {} // destructor
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A > template< size_t B > 
+    typename matrix< T,M,N,I,A >::size_type const matrix< T,M,N,I,A >::bound() const
+    {
+        BOOST_STATIC_ASSERT( B < 2 );
+        return B == 0 ? M : N;
+    } // bound
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A >
+    void matrix< T,M,N,I,A >::swap( matrix& m )
+    {
+        if( &m != this ) data.swap( m.data );
+    } // swap
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A >
+    typename matrix< T,M,N,I,A >::const_reference_type matrix< T,M,N,I,A >::operator[]( size_type s ) const
+    {
+        return data[s];
+    } // operator[] const
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A >
+    typename matrix< T,M,N,I,A >::reference_type matrix< T,M,N,I,A >::operator[]( size_type s )
+    {
+        return data[s];
+    } // operator[]
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A >
+    typename matrix< T,M,N,I,A >::const_reference matrix< T,M,N,I,A >::operator()( reference, size_type i, size_type j ) const
+    {
+        BOOST_ASSERT( i < M && j < N );
+        return *(*( data+i)+j );
+    } // operator() const
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A >
+    typename matrix< T,M,N,I,A >::reference matrix< T,M,N,I,A >::operator()( reference, size_type i, size_type j )
+    {
+        BOOST_ASSERT( i < M && j < N );
+        return *(*( data+i)+j );
+    } // operator()
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A >
+    typename matrix< T,M,N,I,A >::const_reference matrix< T,M,N,I,A >::operator()( size_type i, size_type j ) const
+    {
+        BOOST_ASSERT( i < M && j < N );
+        return *(*( data+i)+j );
+    } // operator() const
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A >
+    typename matrix< T,M,N,I,A >::reference matrix< T,M,N,I,A >::operator()( size_type i, size_type j )
+    {
+        BOOST_ASSERT( i < M && j < N );
+        return *(*( data+i)+j );
+    } // operator()
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A >
+    typename matrix< T,M,N,I,A >::const_reference matrix< T,M,N,I,A >::operator()( size_type s ) const
+    {
+        BOOST_ASSERT( s < size );
+        return *( data.begin()+s );
+    } // operator() const
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A >
+    typename matrix< T,M,N,I,A >::reference matrix< T,M,N,I,A >::operator()( size_type s )
+    {
+        BOOST_ASSERT( s < size );
+        return *( data.begin()+s );
+    } // operator()
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A >
+    typename matrix< T,M,N,I,A >::const_iterator matrix< T,M,N,I,A >::begin() const
+    {
+        return data.begin();
+    } // begin const
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A >
+    typename matrix< T,M,N,I,A >::iterator matrix< T,M,N,I,A >::begin()
+    {
+        return data.begin();
+    } // begin
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A >
+    typename matrix< T,M,N,I,A >::const_iterator matrix< T,M,N,I,A >::end() const
+    {
+        return data.end();
+    } // end const
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A >
+    typename matrix< T,M,N,I,A >::iterator matrix< T,M,N,I,A >::end()
+    {
+        return data.end();
+    } // end
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A >
+    matrix< T,M,N,I,A >& matrix< T,M,N,I,A >::operator*=( matrix< T,N,N,I,A > const& m )
+    {
+        *this = *this * m;
+        return *this;
+    } // operator*= matrix
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A >
+    matrix< T,M,N,I,A >& matrix< T,M,N,I,A >::operator+=( matrix const& m )
+    {
+        for( std::size_t i = 0; i != M; ++i )
+        for( std::size_t j = 0; j != N; ++j )
+            data[i][j] += m[i][j];
+        return *this;
+    } // operator+= matrix
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A >
+    matrix< T,M,N,I,A >& matrix< T,M,N,I,A >::operator-=( matrix const& m )
+    {
+        for( std::size_t i = 0; i != M; ++i )
+        for( std::size_t j = 0; j != N; ++j )
+            data[i][j] -= m[i][j];
+        return *this;
+    } // operator-= matrix
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A > 
+    matrix< T,M,N,I,A >& matrix< T,M,N,I,A >::operator*=( T const& t )
+    {
+        for( std::size_t i = 0; i != M; ++i )
+        for( std::size_t j = 0; j != N; ++j )
+            data[i][j] *= t;
+        return *this;
+    } // operator*= scalar
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A > 
+    matrix< T,M,N,I,A >& matrix< T,M,N,I,A >::operator/=( T const& t )
+    {
+        T s = t;
+        BOOST_ASSERT( s != T(0) );
+        for( std::size_t i = 0; i != M; ++i )
+        for( std::size_t j = 0; j != N; ++j )
+            data[i][j] /= s;
+        return *this;
+    } // operator/= scalar
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A > template< class E > 
+    matrix< T,M,N,I,A >& matrix< T,M,N,I,A >::operator*=( matrix_expression< E,N,N > const& e )
+    {
+        *this = *this * e;
+        return *this;
+    } // operator*= matrix_expression
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A > template< class E > 
+    matrix< T,M,N,I,A >& matrix< T,M,N,I,A >::operator+=( matrix_expression< E,M,N > const& e )
+    {
+        for( std::size_t i = 0; i != M; ++i )
+        for( std::size_t j = 0; j != N; ++j )
+            data[i][j] += e()( i,j );
+        return *this;
+    } // operator+= matrix_expression
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A > template< class E >
+    matrix< T,M,N,I,A >& matrix< T,M,N,I,A >::operator-=( matrix_expression< E,M,N > const& e )
+    {
+        for( std::size_t i = 0; i != M; ++i )
+        for( std::size_t j = 0; j != N; ++j )
+            data[i][j] -= e()( i,j );
+        return *this;
+    } // operator-= matrix_expression
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A > template< class E > 
+    matrix< T,M,N,I,A >& matrix< T,M,N,I,A >::operator*=( scalar_expression< E > const& e )
+    {
+        T s = e()( 0 );
+        for( std::size_t i = 0; i != M; ++i )
+        for( std::size_t j = 0; j != N; ++j )
+            data[i][j] *= s;
+        return *this;
+    } // operator*= scalar_expression
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A > template< class E > 
+    matrix< T,M,N,I,A >& matrix< T,M,N,I,A >::operator/=( scalar_expression< E > const& e )
+    {
+        T s = e()( 0 );
+        BOOST_ASSERT( s != T(0) );
+        for( std::size_t i = 0; i != M; ++i )
+        for( std::size_t j = 0; j != N; ++j )
+            data[i][j] /= s;
+        return *this;
+    } // operator/= scalar_expression
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A > 
+    void matrix< T,M,N,I,A >::clear()
+    {
+        T t = T(); std::fill( begin(), end(), t );
+    } // clear : set all elements to default
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A >
+    bool const matrix< T,M,N,I,A >::operator==( matrix< T,M,N,I,A > const& m ) const
+    {
+        return matrix_equality< T,M,N,I,A,size >()( data.begin(), m.data.begin() );
+    } // operator ==
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A >
+    bool const matrix< T,M,N,I,A >::operator!=( matrix< T,M,N,I,A > const& m ) const
+    {
+        return !( matrix_equality< T,M,N,I,A,size >()( data.begin(), m.data.begin() ) );
+    } // operator !=
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A > template< class U > 
+    bool const matrix< T,M,N,I,A >::references( scalar< U > const& ) const
+    {
+        return false;
+    }
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A > template< class U, std::size_t Q, bool J, class B > 
+    bool const matrix< T,M,N,I,A >::references( vector< U,Q,J,B > const& ) const
+    {
+        return false;
+    }
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A > template< class U, std::size_t P, std::size_t Q, bool J, class B > 
+    bool const matrix< T,M,N,I,A >::references( matrix< U,P,Q,J,B > const& m ) const
+    {
+        return ( reinterpret_cast< matrix< T,M,N,I,A > const* >( &m ) == this );
+    }
+
+//--
+//--
+
+    template< class T1, std::size_t M1, std::size_t N1, bool I1, class A1, class C, class CT >
+    std::basic_ostream< C,CT >& operator<<( std::basic_ostream< C,CT >& o, matrix< T1,M1,N1,I1,A1 > const& m )
+    {
+        o << m.data;
+        return o;
+    }
+
+//--
+
+}} // namespace boost, namespace maps
+
+#endif // BOOST_MAPS_MATH_MATRIX_HPP
Added: sandbox/maps/boost/maps/math/matrix_matrix.hpp
==============================================================================
--- (empty file)
+++ sandbox/maps/boost/maps/math/matrix_matrix.hpp	2011-08-08 19:51:30 EDT (Mon, 08 Aug 2011)
@@ -0,0 +1,2443 @@
+//--
+// Copyright (c) 2010-2011 Brian Smith
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/maps for documentation.
+//--
+#if !defined( BOOST_MAPS_MATH_MATRIX_MATRIX_HPP )
+#define BOOST_MAPS_MATH_MATRIX_MATRIX_HPP
+
+#include <boost/maps/math/scalar_scalar.hpp>
+
+namespace boost { namespace maps { 
+
+//--
+
+    template< class E, std::size_t M, std::size_t N >
+    class matrix_expression
+        : expression< matrix_expression< E,M,N > >
+    {
+    public:
+
+        typedef matrix_expression type;
+        typedef E value_type;
+        typedef value_type const& const_reference;
+        typedef value_type& reference;
+
+        const_reference operator()() const
+        {
+            return *static_cast< value_type const* >( this );
+        }
+
+        reference operator()()
+        {
+            return *static_cast< value_type* >( this );
+        }
+
+    };
+
+//--
+
+    template< class E1, class E2, std::size_t M, std::size_t N, class O, bool L >
+    class matrix_binary_expression
+        : public matrix_expression< matrix_binary_expression< E1,E2,M,N,O,L >,M,N >
+    {
+    public:
+
+        typedef matrix_binary_expression type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef typename E1::type_const_reference expression1_const_reference;
+        typedef typename E2::type_const_reference expression2_const_reference;
+        typedef E1 expression_type1;
+        typedef E2 expression_type2;
+        typedef O operator_type;
+        typedef typename operator_type::result_type result_type;
+        typedef result_type element_type;
+        typedef element_type const& const_reference;
+        typedef element_type& reference;
+        typedef typename operator_type::size_type size_type;
+        typedef typename operator_type::allocator_type allocator_type;
+
+        using matrix_expression< type,M,N >::operator();
+
+        enum { rows = M, cols = N };
+        enum { linear = ( L & E1::linear & E2::linear ) };
+
+        matrix_binary_expression( E1 const&, E2 const& );
+        type_reference operator=( type_const_reference );
+
+        expression_type1 const& expression1() const;
+        expression_type2 const& expression2() const;
+
+        reference operator()( reference, size_type, size_type ) const;
+        result_type const operator()( size_type, size_type ) const;
+        result_type const operator()( size_type ) const;
+
+        template< class U > 
+        bool const references( scalar< U > const& ) const;
+        template< class U, std::size_t Q, bool J, class B > 
+        bool const references( vector< U,Q,J,B > const& ) const;
+        template< class U, std::size_t P, std::size_t Q, bool J, class B > 
+        bool const references( matrix< U,P,Q,J,B > const& ) const;
+
+    private:
+
+        expression1_const_reference t1;
+        expression2_const_reference t2;
+
+    };
+
+//--
+
+    template< class E1, class E2, std::size_t M, std::size_t N, class O, bool L >
+    matrix_binary_expression< E1,E2,M,N,O,L >::matrix_binary_expression( E1 const& e1, E2 const& e2 )
+        : t1( e1 ), t2( e2 )
+    {}
+
+    template< class E1, class E2, std::size_t M, std::size_t N, class O, bool L >
+    typename matrix_binary_expression< E1,E2,M,N,O,L >::type_reference
+        matrix_binary_expression< E1,E2,M,N,O,L >::operator=( type_const_reference e )
+    {
+        if( &e != this ) { t1 = e.t1; t2 = e.t2; }
+        return *this;
+    }
+
+    template< class E1, class E2, std::size_t M, std::size_t N, class O, bool L >
+    typename matrix_binary_expression< E1,E2,M,N,O,L >::expression_type1 const& 
+        matrix_binary_expression< E1,E2,M,N,O,L >::expression1() const
+    {
+        return t1;
+    }
+
+    template< class E1, class E2, std::size_t M, std::size_t N, class O, bool L >
+    typename matrix_binary_expression< E1,E2,M,N,O,L >::expression_type2 const& 
+        matrix_binary_expression< E1,E2,M,N,O,L >::expression2() const
+    {
+        return t2;
+    }
+
+    template< class E1, class E2, std::size_t M, std::size_t N, class O, bool L >
+    typename matrix_binary_expression< E1,E2,M,N,O,L >::reference 
+        matrix_binary_expression< E1,E2,M,N,O,L >::operator()( reference r, size_type i, size_type j ) const
+    {
+        return operator_type()( r,t1,t2,i,j );
+    }
+
+    template< class E1, class E2, std::size_t M, std::size_t N, class O, bool L >
+    typename matrix_binary_expression< E1,E2,M,N,O,L >::result_type const 
+        matrix_binary_expression< E1,E2,M,N,O,L >::operator()( size_type i, size_type j ) const
+    {
+        return operator_type()( t1,t2,i,j );
+    }
+
+    template< class E1, class E2, std::size_t M, std::size_t N, class O, bool L >
+    typename matrix_binary_expression< E1,E2,M,N,O,L >::result_type const 
+        matrix_binary_expression< E1,E2,M,N,O,L >::operator()( size_type s ) const
+    {
+        return operator_type()( t1( s ), t2( s ) );
+    }
+
+    template< class E1, class E2, std::size_t M, std::size_t N, class O, bool L > template< class U >
+    bool const matrix_binary_expression< E1,E2,M,N,O,L >::references( scalar< U > const& s ) const
+    {
+        return ( t1().references( s ) || t2().references( s ) );
+    }
+
+    template< class E1, class E2, std::size_t M, std::size_t N, class O, bool L > template< class U, std::size_t Q, bool J, class B >
+    bool const matrix_binary_expression< E1,E2,M,N,O,L >::references( vector< U,Q,J,B > const& v ) const
+    {
+        return ( t1().references( v ) || t2().references( v ) );
+    }
+
+    template< class E1, class E2, std::size_t M, std::size_t N, class O, bool L > template< class U, std::size_t P, std::size_t Q, bool J, class B >
+    bool const matrix_binary_expression< E1,E2,M,N,O,L >::references( matrix< U,P,Q,J,B > const& m ) const
+    {
+        return ( t1().references( m ) || t2().references( m ) );
+    }
+
+//--
+//--
+
+    template< class T1, class T2 > struct matrix_matrix_product;
+
+    // matrix product
+    template< class E1, class E2, std::size_t M, std::size_t N, bool L >
+    class matrix_binary_expression< E1,E2,M,N,matrix_matrix_product< E1,E2 >,L >
+        : public matrix_expression< matrix_binary_expression< E1,E2,M,N,matrix_matrix_product< E1,E2 >,L >,M,N >
+    {
+    public:
+
+        typedef matrix_binary_expression type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef E1 expression_type1;
+        typedef E2 expression_type2;
+        typedef matrix_matrix_product< E1,E2 > operator_type;
+        typedef typename operator_type::result_type result_type;
+        typedef result_type element_type;
+        typedef element_type const& const_reference;
+        typedef element_type& reference;
+        typedef typename operator_type::size_type size_type;
+        typedef typename operator_type::allocator_type allocator_type;
+        typedef matrix< element_type,M,N,false,allocator_type > matrix_type;
+        typedef matrix_type expression_type;
+
+        using matrix_expression< type,M,N >::operator();
+
+        enum { rows = M, cols = N };
+        enum { linear = false };
+
+        matrix_binary_expression( E1 const&, E2 const& );
+
+        expression_type const& expression() const;
+
+        const_reference operator()( size_type, size_type ) const;
+        const_reference operator()( size_type ) const;
+
+        template< class U > 
+        bool const references( scalar< U > const& ) const;
+        template< class U, std::size_t Q, bool J, class B > 
+        bool const references( vector< U,Q,J,B > const& ) const;
+        template< class U, std::size_t P, std::size_t Q, bool J, class B > 
+        bool const references( matrix< U,P,Q,J,B > const& ) const;
+
+    private:
+
+        matrix_type t;
+
+    };
+
+//--
+
+    template< class E1, class E2, std::size_t M, std::size_t N, bool L >
+    matrix_binary_expression< E1,E2,M,N,matrix_matrix_product< E1,E2 >,L >::matrix_binary_expression( E1 const& e1, E2 const& e2 )
+    {
+        result_type s;
+        for( std::size_t i = 0; i != M; ++i )
+        for( std::size_t j = 0; j != N; ++j )
+        {   s = result_type();
+            for( std::size_t k = 0; k != E1::cols; ++k )
+                s += e1( i,k ) * e2( k,j );
+            t( i,j ) = s;
+        }
+    }
+
+    template< class E1, class E2, std::size_t M, std::size_t N, bool L >
+    typename matrix_binary_expression< E1,E2,M,N,matrix_matrix_product< E1,E2 >,L >::expression_type const&
+        matrix_binary_expression< E1,E2,M,N,matrix_matrix_product< E1,E2 >,L >::expression() const
+    {
+        return t;
+    }
+
+    template< class E1, class E2, std::size_t M, std::size_t N, bool L >
+    typename matrix_binary_expression< E1,E2,M,N,matrix_matrix_product< E1,E2 >,L >::const_reference
+        matrix_binary_expression< E1,E2,M,N,matrix_matrix_product< E1,E2 >,L >::operator()( size_type i, size_type j ) const
+    {
+        return t( i,j );
+    }
+
+    template< class E1, class E2, std::size_t M, std::size_t N, bool L >
+    typename matrix_binary_expression< E1,E2,M,N,matrix_matrix_product< E1,E2 >,L >::const_reference 
+        matrix_binary_expression< E1,E2,M,N,matrix_matrix_product< E1,E2 >,L >::operator()( size_type s ) const
+    {
+        return t( s );
+    }
+
+    template< class E1, class E2, std::size_t M, std::size_t N, bool L > template< class U >
+    bool const matrix_binary_expression< E1,E2,M,N,matrix_matrix_product< E1,E2 >,L >::references( scalar< U > const& ) const
+    {
+        return false;
+    }
+
+    template< class E1, class E2, std::size_t M, std::size_t N, bool L > template< class U, std::size_t Q, bool J, class B >
+    bool const matrix_binary_expression< E1,E2,M,N,matrix_matrix_product< E1,E2 >,L >::references( vector< U,Q,J,B > const& ) const
+    {
+        return false;
+    }
+
+    template< class E1, class E2, std::size_t M, std::size_t N, bool L > template< class U, std::size_t P, std::size_t Q, bool J, class B >
+    bool const matrix_binary_expression< E1,E2,M,N,matrix_matrix_product< E1,E2 >,L >::references( matrix< U,P,Q,J,B > const& ) const
+    {
+        return false;
+    }
+
+//--
+//--
+
+    // The following specializations are for blocked matrix types.
+
+    // matrix< matrix< ... > > * E
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L >
+    class matrix_binary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E,M,N,matrix_matrix_product< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E >,L >
+        : public matrix_expression< matrix_binary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E,M,N,matrix_matrix_product< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E >,L >,M,N >
+    {
+    public:
+
+        typedef matrix_binary_expression type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 > expression_type1;
+        typedef E expression_type2;
+        typedef matrix_matrix_product< expression_type1,expression_type2 > operator_type;
+        typedef typename operator_type::result_type result_type;
+        typedef result_type element_type;
+        typedef element_type const& const_reference;
+        typedef element_type& reference;
+        typedef typename operator_type::size_type size_type;
+        typedef typename operator_type::allocator_type allocator_type;
+        typedef matrix< element_type,M,N,true,A2 > matrix_type;
+        typedef matrix_type expression_type;
+
+        using matrix_expression< type,M,N >::operator();
+
+        enum { rows = M, cols = N };
+        enum { linear = false };
+
+        matrix_binary_expression( expression_type1 const&, expression_type2 const& );
+
+        expression_type const& expression() const;
+
+        const_reference operator()( size_type, size_type ) const;
+        const_reference operator()( size_type ) const;
+
+        template< class U > 
+        bool const references( scalar< U > const& ) const;
+        template< class U, std::size_t Q, bool J, class B > 
+        bool const references( vector< U,Q,J,B > const& ) const;
+        template< class U, std::size_t P, std::size_t Q, bool J, class B > 
+        bool const references( matrix< U,P,Q,J,B > const& ) const;
+
+    private:
+
+        matrix_type t;
+
+    };
+
+//--
+
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L >
+    matrix_binary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E,M,N,matrix_matrix_product< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E >,L >::matrix_binary_expression( expression_type1 const& e1, expression_type2 const& e2 )
+    {
+        for( std::size_t i = 0; i != M; ++i )
+        for( std::size_t j = 0; j != N; ++j )
+        for( std::size_t k = 0; k != R; ++k )
+            t( i,j ) += product( e1( i,k ), e2( k,j ) );
+    }
+
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L >
+    typename matrix_binary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E,M,N,matrix_matrix_product< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E >,L >::expression_type const&
+        matrix_binary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E,M,N,matrix_matrix_product< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E >,L >::expression() const
+    {
+        return t;
+    }
+
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L >
+    typename matrix_binary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E,M,N,matrix_matrix_product< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E >,L >::const_reference
+        matrix_binary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E,M,N,matrix_matrix_product< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E >,L >::operator()( size_type i, size_type j ) const
+    {
+        return t( i,j );
+    }
+
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L >
+    typename matrix_binary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E,M,N,matrix_matrix_product< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E >,L >::const_reference 
+        matrix_binary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E,M,N,matrix_matrix_product< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E >,L >::operator()( size_type s ) const
+    {
+        return t( s );
+    }
+
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L > template< class U >
+    bool const matrix_binary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E,M,N,matrix_matrix_product< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E >,L >::references( scalar< U > const& ) const
+    {
+        return false;
+    }
+
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L > template< class U, std::size_t Q, bool J, class B >
+    bool const matrix_binary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E,M,N,matrix_matrix_product< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E >,L >::references( vector< U,Q,J,B > const& ) const
+    {
+        return false;
+    }
+
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L > template< class U, std::size_t P, std::size_t Q, bool J, class B >
+    bool const matrix_binary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E,M,N,matrix_matrix_product< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E >,L >::references( matrix< U,P,Q,J,B > const& ) const
+    {
+        return false;
+    }
+
+//--
+//--
+
+    // E * matrix< matrix< ... > >
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L >
+    class matrix_binary_expression< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 >,M,N,matrix_matrix_product< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 > >,L >
+        : public matrix_expression< matrix_binary_expression< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 >,M,N,matrix_matrix_product< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 > >,L >,M,N >
+    {
+    public:
+
+        typedef matrix_binary_expression type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef E expression_type1;
+        typedef matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 > expression_type2;
+        typedef matrix_matrix_product< expression_type1,expression_type2 > operator_type;
+        typedef typename operator_type::result_type result_type;
+        typedef result_type element_type;
+        typedef element_type const& const_reference;
+        typedef element_type& reference;
+        typedef typename operator_type::size_type size_type;
+        typedef typename operator_type::allocator_type allocator_type;
+        typedef matrix< element_type,M,N,true,A2 > matrix_type;
+        typedef matrix_type expression_type;
+
+        using matrix_expression< type,M,N >::operator();
+
+        enum { rows = M, cols = N };
+        enum { linear = false };
+
+        matrix_binary_expression( expression_type1 const&, expression_type2 const& );
+
+        expression_type const& expression() const;
+
+        const_reference operator()( size_type, size_type ) const;
+        const_reference operator()( size_type ) const;
+
+        template< class U > 
+        bool const references( scalar< U > const& ) const;
+        template< class U, std::size_t Q, bool J, class B > 
+        bool const references( vector< U,Q,J,B > const& ) const;
+        template< class U, std::size_t P, std::size_t Q, bool J, class B > 
+        bool const references( matrix< U,P,Q,J,B > const& ) const;
+
+    private:
+
+        matrix_type t;
+
+    };
+
+//--
+
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L >
+    matrix_binary_expression< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 >,M,N,matrix_matrix_product< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 > >,L >::matrix_binary_expression( expression_type1 const& e1, expression_type2 const& e2 )
+    {
+        for( std::size_t i = 0; i != M; ++i )
+        for( std::size_t j = 0; j != N; ++j )
+        for( std::size_t k = 0; k != R; ++k )
+            t( i,j ) += product( e1( i,k ), e2( k,j ) );
+    }
+
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L >
+    typename matrix_binary_expression< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 >,M,N,matrix_matrix_product< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 > >,L >::expression_type const&
+        matrix_binary_expression< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 >,M,N,matrix_matrix_product< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 > >,L >::expression() const
+    {
+        return t;
+    }
+
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L >
+    typename matrix_binary_expression< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 >,M,N,matrix_matrix_product< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 > >,L >::const_reference
+        matrix_binary_expression< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 >,M,N,matrix_matrix_product< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 > >,L >::operator()( size_type i, size_type j ) const
+    {
+        return t( i,j );
+    }
+
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L >
+    typename matrix_binary_expression< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 >,M,N,matrix_matrix_product< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 > >,L >::const_reference 
+        matrix_binary_expression< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 >,M,N,matrix_matrix_product< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 > >,L >::operator()( size_type s ) const
+    {
+        return t( s );
+    }
+
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L > template< class U >
+    bool const matrix_binary_expression< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 >,M,N,matrix_matrix_product< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 > >,L >::references( scalar< U > const& ) const
+    {
+        return false;
+    }
+
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L > template< class U, std::size_t Q, bool J, class B >
+    bool const matrix_binary_expression< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 >,M,N,matrix_matrix_product< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 > >,L >::references( vector< U,Q,J,B > const& ) const
+    {
+        return false;
+    }
+
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L > template< class U, std::size_t P, std::size_t Q, bool J, class B >
+    bool const matrix_binary_expression< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 >,M,N,matrix_matrix_product< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 > >,L >::references( matrix< U,P,Q,J,B > const& ) const
+    {
+        return false;
+    }
+
+//--
+//--
+
+    // matrix< matrix< ... > > * matrix< matrix< ... > >
+    template< class T1, std::size_t M1, std::size_t P1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, class T2, std::size_t N1, bool I3, class A3, std::size_t N,  bool I4, class A4, bool L >
+    class matrix_binary_expression< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 >,M,N,matrix_matrix_product< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 > >,L >
+        : public matrix_expression< matrix_binary_expression< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 >,M,N,matrix_matrix_product< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 > >,L >,M,N >
+    {
+    public:
+
+        typedef matrix_binary_expression type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 > expression_type1;
+        typedef matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 > expression_type2;
+        typedef matrix_matrix_product< expression_type1,expression_type2 > operator_type;
+        typedef typename operator_type::result_type result_type;
+        typedef result_type element_type;
+        typedef element_type const& const_reference;
+        typedef element_type& reference;
+        typedef typename operator_type::size_type size_type;
+        typedef typename operator_type::allocator_type allocator_type;
+        typedef matrix< element_type,M,N,true,A2 > matrix_type;
+        typedef matrix_type expression_type;
+
+        using matrix_expression< type,M,N >::operator();
+
+        enum { rows = M, cols = N };
+        enum { linear = false };
+
+        matrix_binary_expression( expression_type1 const&, expression_type2 const& );
+
+        expression_type const& expression() const;
+
+        const_reference operator()( size_type, size_type ) const;
+        const_reference operator()( size_type ) const;
+
+        template< class U > 
+        bool const references( scalar< U > const& ) const;
+        template< class U, std::size_t Q, bool J, class B > 
+        bool const references( vector< U,Q,J,B > const& ) const;
+        template< class U, std::size_t P, std::size_t Q, bool J, class B > 
+        bool const references( matrix< U,P,Q,J,B > const& ) const;
+
+    private:
+
+        matrix_type t;
+
+    };
+
+//--
+
+    template< class T1, std::size_t M1, std::size_t P1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, class T2, std::size_t N1, bool I3, class A3, std::size_t N,  bool I4, class A4, bool L >
+    matrix_binary_expression< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 >,M,N,matrix_matrix_product< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 > >,L >::matrix_binary_expression( expression_type1 const& e1, expression_type2 const& e2 )
+    {
+        for( std::size_t i = 0; i != M; ++i )
+        for( std::size_t j = 0; j != N; ++j )
+        for( std::size_t k = 0; k != R; ++k )
+            t( i,j ) += product( e1( i,k ), e2( k,j ) );
+    }
+
+    template< class T1, std::size_t M1, std::size_t P1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, class T2, std::size_t N1, bool I3, class A3, std::size_t N,  bool I4, class A4, bool L >
+    typename matrix_binary_expression< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 >,M,N,matrix_matrix_product< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 > >,L >::expression_type const&
+        matrix_binary_expression< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 >,M,N,matrix_matrix_product< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 > >,L >::expression() const
+    {
+        return t;
+    }
+
+    template< class T1, std::size_t M1, std::size_t P1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, class T2, std::size_t N1, bool I3, class A3, std::size_t N,  bool I4, class A4, bool L >
+    typename matrix_binary_expression< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 >,M,N,matrix_matrix_product< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 > >,L >::const_reference
+        matrix_binary_expression< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 >,M,N,matrix_matrix_product< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 > >,L >::operator()( size_type i, size_type j ) const
+    {
+        return t( i,j );
+    }
+
+    template< class T1, std::size_t M1, std::size_t P1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, class T2, std::size_t N1, bool I3, class A3, std::size_t N,  bool I4, class A4, bool L >
+    typename matrix_binary_expression< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 >,M,N,matrix_matrix_product< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 > >,L >::const_reference 
+        matrix_binary_expression< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 >,M,N,matrix_matrix_product< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 > >,L >::operator()( size_type s ) const
+    {
+        return t( s );
+    }
+
+    template< class T1, std::size_t M1, std::size_t P1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, class T2, std::size_t N1, bool I3, class A3, std::size_t N,  bool I4, class A4, bool L > template< class U >
+    bool const matrix_binary_expression< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 >,M,N,matrix_matrix_product< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 > >,L >::references( scalar< U > const& ) const
+    {
+        return false;
+    }
+
+    template< class T1, std::size_t M1, std::size_t P1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, class T2, std::size_t N1, bool I3, class A3, std::size_t N,  bool I4, class A4, bool L > template< class U, std::size_t Q, bool J, class B >
+    bool const matrix_binary_expression< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 >,M,N,matrix_matrix_product< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 > >,L >::references( vector< U,Q,J,B > const& ) const
+    {
+        return false;
+    }
+
+    template< class T1, std::size_t M1, std::size_t P1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, class T2, std::size_t N1, bool I3, class A3, std::size_t N,  bool I4, class A4, bool L > template< class U, std::size_t P, std::size_t Q, bool J, class B >
+    bool const matrix_binary_expression< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 >,M,N,matrix_matrix_product< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 > >,L >::references( matrix< U,P,Q,J,B > const& ) const
+    {
+        return false;
+    }
+
+//--
+//--
+
+    template< class T1, class T2 > struct matrix_expression_product;
+
+    // matrix product
+    // The following specializations are for blocked matrix types.
+
+    // matrix< matrix< ... > > * E
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L >
+    class matrix_binary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E,M,N,matrix_expression_product< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E >,L >
+        : public matrix_expression< matrix_binary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E,M,N,matrix_expression_product< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E >,L >,M,N >
+    {
+    public:
+
+        typedef matrix_binary_expression type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 > expression_type1;
+        typedef E expression_type2;
+        typedef typename expression_type1::type_const_reference expression1_const_reference;
+        typedef typename expression_type2::type_const_reference expression2_const_reference;
+        typedef matrix_expression_product< expression_type1,expression_type2 > operator_type;
+        typedef typename operator_type::result_type result_type;
+        typedef result_type element_type;
+        typedef element_type const& const_reference;
+        typedef element_type& reference;
+        typedef typename result_type::size_type size_type;
+        typedef typename result_type::allocator_type allocator_type;
+
+        using matrix_expression< type,M,N >::operator();
+
+        enum { rows = M, cols = N };
+        enum { linear = false };
+
+        matrix_binary_expression( expression_type1 const&, expression_type2 const& );
+
+        expression_type1 const& expression1() const;
+        expression_type2 const& expression2() const;
+
+        result_type const operator()( size_type, size_type ) const;
+        result_type const operator()( size_type ) const;
+
+        template< class U > 
+        bool const references( scalar< U > const& ) const;
+        template< class U, std::size_t Q, bool J, class B > 
+        bool const references( vector< U,Q,J,B > const& ) const;
+        template< class U, std::size_t P, std::size_t Q, bool J, class B > 
+        bool const references( matrix< U,P,Q,J,B > const& ) const;
+
+    private:
+
+        expression1_const_reference t1;
+        expression2_const_reference t2;
+
+    };
+
+//--
+
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L >
+    matrix_binary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E,M,N,matrix_expression_product< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E >,L >::matrix_binary_expression( expression_type1 const& e1, expression_type2 const& e2 )
+        : t1( e1 ), t2( e2 )
+    {}
+
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L >
+    typename matrix_binary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E,M,N,matrix_expression_product< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E >,L >::expression_type1 const&
+        matrix_binary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E,M,N,matrix_expression_product< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E >,L >::expression1() const
+    {
+        return t1;
+    }
+
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L >
+    typename matrix_binary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E,M,N,matrix_expression_product< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E >,L >::expression_type2 const&
+        matrix_binary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E,M,N,matrix_expression_product< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E >,L >::expression2() const
+    {
+        return t2;
+    }
+
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L >
+    typename matrix_binary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E,M,N,matrix_expression_product< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E >,L >::result_type const
+        matrix_binary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E,M,N,matrix_expression_product< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E >,L >::operator()( size_type i, size_type j ) const
+    {
+        return operator_type()( t1,t2,i,j );
+    }
+
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L >
+    typename matrix_binary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E,M,N,matrix_expression_product< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E >,L >::result_type const 
+        matrix_binary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E,M,N,matrix_expression_product< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E >,L >::operator()( size_type s ) const
+    {
+        return operator_type()( t1( s ), t2( s ) );
+    }
+
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L > template< class U >
+    bool const matrix_binary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E,M,N,matrix_expression_product< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E >,L >::references( scalar< U > const& s ) const
+    {
+        return ( t1().references( s ) || t2().references( s ) );
+    }
+
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L > template< class U, std::size_t Q, bool J, class B >
+    bool const matrix_binary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E,M,N,matrix_expression_product< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E >,L >::references( vector< U,Q,J,B > const& v ) const
+    {
+        return ( t1().references( v ) || t2().references( v ) );
+    }
+
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L > template< class U, std::size_t P, std::size_t Q, bool J, class B >
+    bool const matrix_binary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E,M,N,matrix_expression_product< matrix< matrix< T,M1,N1,I1,A1 >,M,R,I2,A2 >,E >,L >::references( matrix< U,P,Q,J,B > const& m ) const
+    {
+        return ( t1().references( m ) || t2().references( m ) );
+    }
+
+//--
+//--
+
+    // E * matrix< matrix< ... > >
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L >
+    class matrix_binary_expression< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 >,M,N,matrix_expression_product< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 > >,L >
+        : public matrix_expression< matrix_binary_expression< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 >,M,N,matrix_expression_product< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 > >,L >,M,N >
+    {
+    public:
+
+        typedef matrix_binary_expression type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef E expression_type1;
+        typedef matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 > expression_type2;
+        typedef typename expression_type1::type_const_reference expression1_const_reference;
+        typedef typename expression_type2::type_const_reference expression2_const_reference;
+        typedef matrix_expression_product< expression_type1,expression_type2 > operator_type;
+        typedef typename operator_type::result_type result_type;
+        typedef result_type element_type;
+        typedef element_type const& const_reference;
+        typedef element_type& reference;
+        typedef typename result_type::size_type size_type;
+        typedef typename result_type::allocator_type allocator_type;
+
+        using matrix_expression< type,M,N >::operator();
+
+        enum { rows = M, cols = N };
+        enum { linear = false };
+
+        matrix_binary_expression( expression_type1 const&, expression_type2 const& );
+
+        expression_type1 const& expression1() const;
+        expression_type2 const& expression2() const;
+
+        result_type const operator()( size_type, size_type ) const;
+        result_type const operator()( size_type ) const;
+
+        template< class U > 
+        bool const references( scalar< U > const& ) const;
+        template< class U, std::size_t Q, bool J, class B > 
+        bool const references( vector< U,Q,J,B > const& ) const;
+        template< class U, std::size_t P, std::size_t Q, bool J, class B > 
+        bool const references( matrix< U,P,Q,J,B > const& ) const;
+
+    private:
+
+        expression1_const_reference t1;
+        expression2_const_reference t2;
+
+    };
+
+//--
+
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L >
+    matrix_binary_expression< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 >,M,N,matrix_expression_product< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 > >,L >::matrix_binary_expression( expression_type1 const& e1, expression_type2 const& e2 )
+        : t1( e1 ), t2( e2 )
+    {}
+
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L >
+    typename matrix_binary_expression< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 >,M,N,matrix_expression_product< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 > >,L >::expression_type1 const&
+        matrix_binary_expression< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 >,M,N,matrix_expression_product< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 > >,L >::expression1() const
+    {
+        return t1;
+    }
+
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L >
+    typename matrix_binary_expression< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 >,M,N,matrix_expression_product< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 > >,L >::expression_type2 const&
+        matrix_binary_expression< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 >,M,N,matrix_expression_product< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 > >,L >::expression2() const
+    {
+        return t2;
+    }
+
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L >
+    typename matrix_binary_expression< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 >,M,N,matrix_expression_product< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 > >,L >::result_type const
+        matrix_binary_expression< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 >,M,N,matrix_expression_product< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 > >,L >::operator()( size_type i, size_type j ) const
+    {
+        return operator_type()( t1,t2,i,j );
+    }
+
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L >
+    typename matrix_binary_expression< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 >,M,N,matrix_expression_product< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 > >,L >::result_type const 
+        matrix_binary_expression< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 >,M,N,matrix_expression_product< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 > >,L >::operator()( size_type s ) const
+    {
+        return operator_type()( t1( s ), t2( s ) );
+    }
+
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L > template< class U >
+    bool const matrix_binary_expression< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 >,M,N,matrix_expression_product< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 > >,L >::references( scalar< U > const& s ) const
+    {
+        return ( t1().references( s ) || t2().references( s ) );
+    }
+
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L > template< class U, std::size_t Q, bool J, class B >
+    bool const matrix_binary_expression< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 >,M,N,matrix_expression_product< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 > >,L >::references( vector< U,Q,J,B > const& v ) const
+    {
+        return ( t1().references( v ) || t2().references( v ) );
+    }
+
+    template< class E, class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, std::size_t N, bool L > template< class U, std::size_t P, std::size_t Q, bool J, class B >
+    bool const matrix_binary_expression< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 >,M,N,matrix_expression_product< E,matrix< matrix< T,M1,N1,I1,A1 >,R,N,I2,A2 > >,L >::references( matrix< U,P,Q,J,B > const& m ) const
+    {
+        return ( t1().references( m ) || t2().references( m ) );
+    }
+
+//--
+//--
+
+    // matrix< matrix< ... > > * matrix< matrix< ... > >
+    template< class T1, std::size_t M1, std::size_t P1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, class T2, std::size_t N1, bool I3, class A3, std::size_t N,  bool I4, class A4, bool L >
+    class matrix_binary_expression< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 >,M,N,matrix_expression_product< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 > >,L >
+        : public matrix_expression< matrix_binary_expression< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 >,M,N,matrix_expression_product< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 > >,L >,M,N >
+    {
+    public:
+
+        typedef matrix_binary_expression type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 > expression_type1;
+        typedef matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 > expression_type2;
+        typedef typename expression_type1::type_const_reference expression1_const_reference;
+        typedef typename expression_type2::type_const_reference expression2_const_reference;
+        typedef matrix_expression_product< expression_type1,expression_type2 > operator_type;
+        typedef typename operator_type::result_type result_type;
+        typedef result_type element_type;
+        typedef element_type const& const_reference;
+        typedef element_type& reference;
+        typedef typename result_type::size_type size_type;
+        typedef typename result_type::allocator_type allocator_type;
+
+        using matrix_expression< type,M,N >::operator();
+
+        enum { rows = M, cols = N };
+        enum { linear = false };
+
+        matrix_binary_expression( expression_type1 const&, expression_type2 const& );
+
+        expression_type1 const& expression1() const;
+        expression_type2 const& expression2() const;
+
+        result_type const operator()( size_type, size_type ) const;
+        result_type const operator()( size_type ) const;
+
+        template< class U > 
+        bool const references( scalar< U > const& ) const;
+        template< class U, std::size_t Q, bool J, class B > 
+        bool const references( vector< U,Q,J,B > const& ) const;
+        template< class U, std::size_t P, std::size_t Q, bool J, class B > 
+        bool const references( matrix< U,P,Q,J,B > const& ) const;
+
+    private:
+
+        expression1_const_reference t1;
+        expression2_const_reference t2;
+
+    };
+
+//--
+
+    template< class T1, std::size_t M1, std::size_t P1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, class T2, std::size_t N1, bool I3, class A3, std::size_t N,  bool I4, class A4, bool L >
+    matrix_binary_expression< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 >,M,N,matrix_expression_product< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 > >,L >::matrix_binary_expression( expression_type1 const& e1, expression_type2 const& e2 )
+        : t1( e1 ), t2( e2 )
+    {}
+
+    template< class T1, std::size_t M1, std::size_t P1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, class T2, std::size_t N1, bool I3, class A3, std::size_t N,  bool I4, class A4, bool L >
+    typename matrix_binary_expression< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 >,M,N,matrix_expression_product< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 > >,L >::expression_type1 const&
+        matrix_binary_expression< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 >,M,N,matrix_expression_product< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 > >,L >::expression1() const
+    {
+        return t1;
+    }
+
+    template< class T1, std::size_t M1, std::size_t P1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, class T2, std::size_t N1, bool I3, class A3, std::size_t N,  bool I4, class A4, bool L >
+    typename matrix_binary_expression< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 >,M,N,matrix_expression_product< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 > >,L >::expression_type2 const&
+        matrix_binary_expression< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 >,M,N,matrix_expression_product< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 > >,L >::expression2() const
+    {
+        return t2;
+    }
+
+    template< class T1, std::size_t M1, std::size_t P1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, class T2, std::size_t N1, bool I3, class A3, std::size_t N,  bool I4, class A4, bool L >
+    typename matrix_binary_expression< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 >,M,N,matrix_expression_product< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 > >,L >::result_type const
+        matrix_binary_expression< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 >,M,N,matrix_expression_product< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 > >,L >::operator()( size_type i, size_type j ) const
+    {
+        return operator_type()( t1,t2,i,j );
+    }
+
+    template< class T1, std::size_t M1, std::size_t P1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, class T2, std::size_t N1, bool I3, class A3, std::size_t N,  bool I4, class A4, bool L >
+    typename matrix_binary_expression< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 >,M,N,matrix_expression_product< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 > >,L >::result_type const 
+        matrix_binary_expression< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 >,M,N,matrix_expression_product< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 > >,L >::operator()( size_type s ) const
+    {
+        return operator_type()( t1( s ), t2( s ) );
+    }
+
+    template< class T1, std::size_t M1, std::size_t P1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, class T2, std::size_t N1, bool I3, class A3, std::size_t N,  bool I4, class A4, bool L > template< class U >
+    bool const matrix_binary_expression< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 >,M,N,matrix_expression_product< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 > >,L >::references( scalar< U > const& s ) const
+    {
+        return ( t1().references( s ) || t2().references( s ) );
+    }
+
+    template< class T1, std::size_t M1, std::size_t P1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, class T2, std::size_t N1, bool I3, class A3, std::size_t N,  bool I4, class A4, bool L > template< class U, std::size_t Q, bool J, class B >
+    bool const matrix_binary_expression< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 >,M,N,matrix_expression_product< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 > >,L >::references( vector< U,Q,J,B > const& v ) const
+    {
+        return ( t1().references( v ) || t2().references( v ) );
+    }
+
+    template< class T1, std::size_t M1, std::size_t P1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, class T2, std::size_t N1, bool I3, class A3, std::size_t N,  bool I4, class A4, bool L > template< class U, std::size_t P, std::size_t Q, bool J, class B >
+    bool const matrix_binary_expression< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 >,M,N,matrix_expression_product< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 > >,L >::references( matrix< U,P,Q,J,B > const& m ) const
+    {
+        return ( t1().references( m ) || t2().references( m ) );
+    }
+
+//--
+//--
+
+    template< class T1, class T2 >
+    struct matrix_product_traits
+    {
+        typedef typename expression_traits< T1 >::type_const_reference type_const_reference1;
+        typedef typename expression_traits< T2 >::type_const_reference type_const_reference2;
+        typedef typename expression_traits< T1 >::type_reference type_reference1;
+        typedef typename expression_traits< T2 >::type_reference type_reference2;
+        typedef typename expression_traits< T1 >::const_reference const_reference1;
+        typedef typename expression_traits< T2 >::const_reference const_reference2;
+        typedef typename expression_traits< T1 >::reference reference1;
+        typedef typename expression_traits< T2 >::reference reference2;
+        typedef typename expression_traits< T1 >::element_type element_type1;
+        typedef typename expression_traits< T2 >::element_type element_type2;
+        typedef typename expression_traits< T1 >::allocator_type allocator_type;
+        typedef typename expression_traits< T1 >::size_type size_type;
+        typedef typename matrix_product_type< element_type1,element_type2 >::type result_type;
+
+    };
+
+//--
+//--
+
+    template< class T1, class T2 >
+    struct matrix_matrix_product
+        : matrix_product_traits< T1,T2 >
+    {
+        typedef typename matrix_product_traits< T1,T2 >::result_type result_type;
+        typedef typename matrix_product_traits< T1,T2 >::type_const_reference1 type_const_reference1;
+        typedef typename matrix_product_traits< T1,T2 >::type_const_reference2 type_const_reference2;
+        typedef typename matrix_product_traits< T1,T2 >::size_type size_type;
+
+        result_type& operator()( result_type& r, type_const_reference1 t1, type_const_reference2 t2, size_type i, size_type j )
+        {
+            for( size_type k = 0; k != t1.cols; ++k )
+                r += t1( r,i,k ) * t2( r,k,j );
+            return r;
+        }
+
+        result_type operator()( type_const_reference1 t1, type_const_reference2 t2, size_type i, size_type j )
+        {
+            result_type r = result_type();
+            for( size_type k = 0; k != t1.cols; ++k )
+                r += t1( i,k ) * t2( k,j );
+            return r;
+        }
+    };
+
+//--
+
+    template< class T1, class T2 >
+    struct matrix_expression_product
+        : matrix_product_traits< T1,T2 >
+    {
+        typedef typename matrix_product_traits< T1,T2 >::result_type result_type;
+        typedef typename matrix_product_traits< T1,T2 >::type_const_reference1 type_const_reference1;
+        typedef typename matrix_product_traits< T1,T2 >::type_const_reference2 type_const_reference2;
+        typedef typename matrix_product_traits< T1,T2 >::size_type size_type;
+
+        result_type operator()( type_const_reference1 t1, type_const_reference2 t2, size_type i, size_type j )
+        {
+            result_type r = result_type();
+            for( size_type k = 0; k != t1.cols; ++k )
+                r += t1( i,k ) * t2( k,j );
+            return r;
+        }
+    };
+
+    // matrix< matrix< ... > > * T
+    template< class T, class T1, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t N, bool I2, class A2 >
+    struct matrix_expression_product< matrix< matrix< T1,M1,N1,I1,A1 >,M,N,I2,A2 >,T >
+        : matrix_product_traits< matrix< matrix< T1,M1,N1,I1,A1 >,M,N,I2,A2 >,T >
+    {
+        typedef matrix_product_traits< matrix< matrix< T1,M1,N1,I1,A1 >,M,N,I2,A2 >,T > traits;
+        typedef typename traits::result_type result_type;
+        typedef typename traits::type_const_reference1 type_const_reference1;
+        typedef typename traits::type_const_reference2 type_const_reference2;
+        typedef typename traits::size_type size_type;
+
+        result_type operator()( type_const_reference1 t1, type_const_reference2 t2, size_type i, size_type j )
+        {
+            result_type r = result_type();
+            for( size_type k = 0; k != t1.cols; ++k )
+                r += product( t1( i,k ), t2( k,j ) );
+            return r;
+        }
+    };
+
+    // T * matrix< matrix< ... > >
+    template< class T, class T1, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t N, bool I2, class A2 >
+    struct matrix_expression_product< T,matrix< matrix< T1,M1,N1,I1,A1 >,M,N,I2,A2 > >
+        : matrix_product_traits< T,matrix< matrix< T1,M1,N1,I1,A1 >,M,N,I2,A2 > >
+    {
+        typedef matrix_product_traits< T,matrix< matrix< T1,M1,N1,I1,A1 >,M,N,I2,A2 > > traits;
+        typedef typename traits::result_type result_type;
+        typedef typename traits::type_const_reference1 type_const_reference1;
+        typedef typename traits::type_const_reference2 type_const_reference2;
+        typedef typename traits::size_type size_type;
+
+        result_type operator()( type_const_reference1 t1, type_const_reference2 t2, size_type i, size_type j )
+        {
+            result_type r = result_type();
+            for( size_type k = 0; k != t1.cols; ++k )
+                r += product( t1( i,k ), t2( k,j ) );
+            return r;
+        }
+    };
+
+    // matrix< matrix< ... > > * matrix< matrix< ... > >
+    template< class T1, std::size_t M1, std::size_t P1, bool I1, class A1, std::size_t M, std::size_t R, bool I2, class A2, class T2, std::size_t N1, bool I3, class A3, std::size_t N,  bool I4, class A4 >
+    struct matrix_expression_product< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 > >
+        : matrix_product_traits< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 > >
+    {
+        typedef matrix_product_traits< matrix< matrix< T1,M1,P1,I1,A1 >,M,R,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,R,N,I4,A4 > > traits;
+        typedef typename traits::result_type result_type;
+        typedef typename traits::type_const_reference1 type_const_reference1;
+        typedef typename traits::type_const_reference2 type_const_reference2;
+        typedef typename traits::size_type size_type;
+
+        result_type operator()( type_const_reference1 t1, type_const_reference2 t2, size_type i, size_type j )
+        {
+            result_type r = result_type();
+            for( size_type k = 0; k != t1.cols; ++k )
+                r += product( t1( i,k ), t2( k,j ) );
+            return r;
+        }
+    };
+
+//--
+
+    template< class T1, class T2 >
+    struct matrix_matrix_addition
+        : expression_binary_traits< T1,T2 >
+    {
+        typedef typename expression_binary_traits< T1,T2 >::result_type result_type;
+        typedef typename expression_binary_traits< T1,T2 >::type_const_reference1 type_const_reference1;
+        typedef typename expression_binary_traits< T1,T2 >::type_const_reference2 type_const_reference2;
+        typedef typename expression_binary_traits< T1,T2 >::const_reference1 const_reference1;
+        typedef typename expression_binary_traits< T1,T2 >::const_reference2 const_reference2;
+        typedef typename expression_binary_traits< T1,T2 >::size_type size_type;
+
+        result_type& operator()( result_type& r, type_const_reference1 t1, type_const_reference2 t2, size_type i, size_type j )
+        {
+            return r = t1( r,i,j ) + t2( r,i,j );
+        }
+
+        result_type& operator()( result_type& r, const_reference1 t1, const_reference2 t2 )
+        {
+            return r = t1 + t2;
+        }
+
+        result_type operator()( const_reference1 t1, const_reference2 t2 )
+        {
+            return t1 + t2;
+        }
+
+        result_type operator()( type_const_reference1 t1, type_const_reference2 t2, size_type i, size_type j )
+        {
+            return t1( i,j ) + t2( i,j );
+        }
+    };
+
+    template< class T1, class T2 >
+    struct matrix_matrix_subtraction
+        : expression_binary_traits< T1,T2 >
+    {
+        typedef typename expression_binary_traits< T1,T2 >::result_type result_type;
+        typedef typename expression_binary_traits< T1,T2 >::type_const_reference1 type_const_reference1;
+        typedef typename expression_binary_traits< T1,T2 >::type_const_reference2 type_const_reference2;
+        typedef typename expression_binary_traits< T1,T2 >::const_reference1 const_reference1;
+        typedef typename expression_binary_traits< T1,T2 >::const_reference2 const_reference2;
+        typedef typename expression_binary_traits< T1,T2 >::size_type size_type;
+
+        result_type& operator()( result_type& r, type_const_reference1 t1, type_const_reference2 t2, size_type i, size_type j )
+        {
+            return r = t1( r,i,j ) - t2( r,i,j );
+        }
+
+        result_type& operator()( result_type& r, const_reference1 t1, const_reference2 t2 )
+        {
+            return r = t1 - t2;
+        }
+
+        result_type operator()( const_reference1 t1, const_reference2 t2 )
+        {
+            return t1 - t2;
+        }
+
+        result_type operator()( type_const_reference1 t1, type_const_reference2 t2, size_type i, size_type j )
+        {
+            return t1( i,j ) - t2( i,j );
+        }
+    };
+
+//--
+//--
+
+    template< class E1, class E2, std::size_t M, std::size_t P, std::size_t N >
+    matrix_binary_expression< E1,E2,M,N,matrix_matrix_product< E1,E2 >,false >
+    operator*( matrix_expression< E1,M,P > const& e1, matrix_expression< E2,P,N > const& e2 )
+    {
+        return matrix_binary_expression< E1,E2,M,N, 
+            matrix_matrix_product< E1,E2 >,false >( e1(), e2() );
+    }
+
+    template< class E1, class E2, std::size_t M, std::size_t P, std::size_t N >
+    matrix_binary_expression< E1,E2,M,N,matrix_expression_product< E1,E2 >,false >
+    product( matrix_expression< E1,M,P > const& e1, matrix_expression< E2,P,N > const& e2 )
+    {
+        return matrix_binary_expression< E1,E2,M,N, 
+            matrix_expression_product< E1,E2 >,false >( e1(), e2() );
+    }
+
+    template< class E1, class E2, std::size_t M, std::size_t N >
+    matrix_binary_expression< E1,E2,M,N,matrix_matrix_addition< E1,E2 >,true >
+    operator+( matrix_expression< E1,M,N > const& e1, matrix_expression< E2,M,N > const& e2 )
+    {
+        return matrix_binary_expression< E1,E2,M,N, 
+            matrix_matrix_addition< E1,E2 >,true >( e1(), e2() );
+    }
+
+    template< class E1, class E2, std::size_t M, std::size_t N >
+    matrix_binary_expression< E1,E2,M,N,matrix_matrix_subtraction< E1,E2 >,true >
+    operator-( matrix_expression< E1,M,N > const& e1, matrix_expression< E2,M,N > const& e2 )
+    {
+        return matrix_binary_expression< E1,E2,M,N, 
+            matrix_matrix_subtraction< E1,E2 >,true >( e1(), e2() );
+    }
+
+//--
+
+    template< class T1, class T2 >
+    struct matrix_matrix_assign
+        : expression_binary_traits< T1,T2 >
+    {
+        typedef typename expression_binary_traits< T1,T2 >::reference1 reference1;
+        typedef typename expression_binary_traits< T1,T2 >::const_reference2 const_reference2;
+        typedef typename expression_binary_traits< T1,T2 >::type_reference1 type_reference1;
+        typedef typename expression_binary_traits< T1,T2 >::type_const_reference2 type_const_reference2;
+        typedef typename expression_binary_traits< T1,T2 >::size_type size_type;
+
+        void operator()( reference1 t1, const_reference2 t2 )
+        {
+            t1 = t2;
+        }
+
+        void operator()( type_reference1 t1, type_const_reference2 t2, size_type i, size_type j )
+        {
+            t1( i,j ) = t2( i,j );
+        }
+    };
+
+//--
+
+    template< class T, class E, std::size_t M, std::size_t N, class O, bool L, bool C >
+    struct matrix_assign
+    {
+        typedef T& reference;
+        typedef matrix_expression< E,M,N > const& expression_const_reference;
+        typedef O operator_type;
+
+        void operator()( reference m, expression_const_reference e )
+        {
+            if( e().references( m ) )
+            {   T t;
+                for( std::size_t i = 0; i != M; ++i )
+                for( std::size_t j = 0; j != N; ++j )
+                    operator_type()( t( i,j ), e()( i,j ) );
+                t.swap( m );
+            }else
+            {   for( std::size_t i = 0; i != M; ++i )
+                for( std::size_t j = 0; j != N; ++j )
+                    operator_type()( m( i,j ), e()( i,j ) );
+            }
+        }
+    };
+
+//--
+
+    template< class T, class E, std::size_t M, std::size_t N, class O, bool C >
+    struct matrix_assign< T,E,M,N,O,true,C >
+    {
+        typedef T& reference;
+        typedef matrix_expression< E,M,N > const& expression_const_reference;
+        typedef O operator_type;
+
+        void operator()( reference m, expression_const_reference e )
+        {
+            for( std::size_t i = 0; i != m.size; ++i )
+                operator_type()( m( i ), e()( i ) );
+        }
+    };
+
+    template< class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t N, bool I, class A, class E, class O, bool C >
+    struct matrix_assign< matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A >,E,M,N,O,true,C >
+    {
+        typedef matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A >& reference;
+        typedef matrix_expression< E,M,N > const& expression_const_reference;
+
+        void operator()( reference m, expression_const_reference e )
+        {
+            for( std::size_t i = 0; i != M; ++i )
+            for( std::size_t j = 0; j != N; ++j )
+                e()( m( i,j ),i,j );
+        }
+    };
+
+//--
+
+    template< class T, class E, std::size_t M, std::size_t N, class O >
+    struct matrix_assign< T,E,M,N,O,false,true >
+    {
+        typedef T& reference;
+        typedef matrix_expression< E,M,N > const& expression_const_reference;
+        typedef O operator_type;
+
+        void operator()( reference m, expression_const_reference e )
+        {
+            for( std::size_t i = 0; i != M; ++i )
+            for( std::size_t j = 0; j != N; ++j )
+                operator_type()( m( i,j ), e()( i,j ) );
+        }
+    };
+
+//--
+//--
+
+    template< class E, std::size_t M, std::size_t N, class O, bool L >
+    class matrix_unary_expression
+        : public matrix_expression< matrix_unary_expression< E,M,N,O,L >,M,N >
+    {
+    public:
+
+        typedef matrix_unary_expression type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef typename E::type_const_reference expression_const_reference;
+        typedef E expression_type;
+        typedef O operator_type;
+        typedef typename O::result_type result_type;
+        typedef result_type element_type;
+        typedef element_type const& const_reference;
+        typedef element_type& reference;
+        typedef typename operator_type::size_type size_type;
+        typedef typename operator_type::allocator_type allocator_type;
+
+        using matrix_expression< type,M,N >::operator();
+
+        enum { rows = M, cols = N };
+        enum { linear = ( L & E::linear ) };
+
+        matrix_unary_expression( E const& );
+        type_reference operator=( type_const_reference );
+
+        expression_type const& expression() const;
+
+        result_type const operator()( reference, size_type, size_type ) const;
+        result_type const operator()( size_type, size_type ) const;
+        result_type const operator()( size_type ) const;
+
+        template< class U > 
+        bool const references( scalar< U > const& ) const;
+        template< class U, std::size_t Q, bool J, class B > 
+        bool const references( vector< U,Q,J,B > const& ) const;
+        template< class U, std::size_t P, std::size_t Q, bool J, class B > 
+        bool const references( matrix< U,P,Q,J,B > const& ) const;
+
+    private:
+
+        expression_const_reference t;
+
+    };
+
+//--
+
+    template< class E, std::size_t M, std::size_t N, class O, bool L >
+    matrix_unary_expression< E,M,N,O,L >::matrix_unary_expression( E const& e )
+        : t( e )
+    {}
+
+    template< class E, std::size_t M, std::size_t N, class O, bool L >
+    typename matrix_unary_expression< E,M,N,O,L >::type_reference
+        matrix_unary_expression< E,M,N,O,L >::operator=( type_const_reference e )
+    {
+        if( &e != this ) t = e.t;
+        return *this;
+    }
+
+    template< class E, std::size_t M, std::size_t N, class O, bool L >
+    typename matrix_unary_expression< E,M,N,O,L >::expression_type const& 
+        matrix_unary_expression< E,M,N,O,L >::expression() const
+    {
+        return t;
+    }
+
+    template< class E, std::size_t M, std::size_t N, class O, bool L >
+    typename matrix_unary_expression< E,M,N,O,L >::result_type const 
+        matrix_unary_expression< E,M,N,O,L >::operator()( reference r, size_type i, size_type j ) const
+    {
+        return operator_type()( r,t,i,j );
+    }
+
+    template< class E, std::size_t M, std::size_t N, class O, bool L >
+    typename matrix_unary_expression< E,M,N,O,L >::result_type const 
+        matrix_unary_expression< E,M,N,O,L >::operator()( size_type i, size_type j ) const
+    {
+        return operator_type()( t,i,j );
+    }
+
+    template< class E, std::size_t M, std::size_t N, class O, bool L >
+    typename matrix_unary_expression< E,M,N,O,L >::result_type const 
+        matrix_unary_expression< E,M,N,O,L >::operator()( size_type s ) const
+    {
+        return operator_type()( t( s ) );
+    }
+
+    template< class E, std::size_t M, std::size_t N, class O, bool L > template< class U >
+    bool const matrix_unary_expression< E,M,N,O,L >::references( scalar< U > const& s ) const
+    {
+        return ( t().references( s ) );
+    }
+
+    template< class E, std::size_t M, std::size_t N, class O, bool L > template< class U, std::size_t Q, bool J, class B >
+    bool const matrix_unary_expression< E,M,N,O,L >::references( vector< U,Q,J,B > const& v ) const
+    {
+        return ( t().references( v ) );
+    }
+
+    template< class E, std::size_t M, std::size_t N, class O, bool L > template< class U, std::size_t P, std::size_t Q, bool J, class B >
+    bool const matrix_unary_expression< E,M,N,O,L >::references( matrix< U,P,Q,J,B > const& m ) const
+    {
+        return ( t().references( m ) );
+    }
+
+//--
+//--
+
+    template< class T > struct matrix_transpose;
+
+    // matrix transpose matrix< matrix< ... > >
+    template< class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t N, bool I, class A, bool L >
+    class matrix_unary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A >,N,M,matrix_transpose< matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A > >,L >
+        : public matrix_expression< matrix_unary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A >,N,M,matrix_transpose< matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A > >,L >,N,M >
+    {
+    public:
+
+        typedef matrix_unary_expression type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A > expression_type1;
+        typedef expression_type1 const& expression_const_reference;
+        typedef matrix_transpose< expression_type1 > operator_type;
+        typedef typename operator_type::result_type result_type;
+        typedef result_type element_type;
+        typedef element_type const& const_reference;
+        typedef element_type& reference;
+        typedef typename operator_type::size_type size_type;
+        typedef typename operator_type::allocator_type allocator_type;
+        typedef typename matrix_transpose_type< expression_type1 >::type matrix_type;
+        typedef matrix_type expression_type;
+
+        using matrix_expression< type,N,M >::operator();
+
+        enum { rows = N, cols = M };
+        enum { linear = false };
+
+        matrix_unary_expression( expression_const_reference );
+        
+        type_reference operator=( type_const_reference );
+
+        expression_type const& expression() const;
+
+        const_reference operator()( size_type, size_type ) const;
+        const_reference operator()( size_type ) const;
+
+        template< class U > 
+        bool const references( scalar< U > const& ) const;
+        template< class U, std::size_t Q, bool J, class B > 
+        bool const references( vector< U,Q,J,B > const& ) const;
+        template< class U, std::size_t P, std::size_t Q, bool J, class B > 
+        bool const references( matrix< U,P,Q,J,B > const& ) const;
+
+    private:
+
+        matrix_type t;
+
+    };
+
+//--
+
+    template< class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t N, bool I, class A, bool L >
+    matrix_unary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A >,N,M,matrix_transpose< matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A > >,L >::matrix_unary_expression( expression_const_reference e )
+    {
+        operator_type()( t,e );
+    }
+
+    template< class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t N, bool I, class A, bool L >
+    typename matrix_unary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A >,N,M,matrix_transpose< matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A > >,L >::type_reference
+        matrix_unary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A >,N,M,matrix_transpose< matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A > >,L >::operator=( type_const_reference e )
+    {
+        if( &e != this ) t = e.t;
+        return *this;
+    }
+
+    template< class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t N, bool I, class A, bool L >
+    typename matrix_unary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A >,N,M,matrix_transpose< matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A > >,L >::expression_type const& 
+        matrix_unary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A >,N,M,matrix_transpose< matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A > >,L >::expression() const
+    {
+        return t;
+    }
+
+    template< class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t N, bool I, class A, bool L >
+    typename matrix_unary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A >,N,M,matrix_transpose< matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A > >,L >::const_reference 
+        matrix_unary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A >,N,M,matrix_transpose< matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A > >,L >::operator()( size_type i, size_type j ) const
+    {
+        return t( i,j );
+    }
+
+    template< class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t N, bool I, class A, bool L >
+    typename matrix_unary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A >,N,M,matrix_transpose< matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A > >,L >::const_reference 
+        matrix_unary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A >,N,M,matrix_transpose< matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A > >,L >::operator()( size_type s ) const
+    {
+        return t( s );
+    }
+
+    template< class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t N, bool I, class A, bool L > template< class U >
+    bool const matrix_unary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A >,N,M,matrix_transpose< matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A > >,L >::references( scalar< U > const& ) const
+    {
+        return false;
+    }
+
+    template< class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t N, bool I, class A, bool L > template< class U, std::size_t Q, bool J, class B >
+    bool const matrix_unary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A >,N,M,matrix_transpose< matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A > >,L >::references( vector< U,Q,J,B > const& ) const
+    {
+        return false;
+    }
+
+    template< class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t N, bool I, class A, bool L > template< class U, std::size_t P, std::size_t Q, bool J, class B >
+    bool const matrix_unary_expression< matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A >,N,M,matrix_transpose< matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A > >,L >::references( matrix< U,P,Q,J,B > const& ) const
+    {
+        return false;
+    }
+
+//--
+//--
+
+    template< class T >
+    struct matrix_transpose_traits
+    {
+        typedef typename matrix_transpose_type< T >::type T1;
+        typedef typename expression_traits< T1 >::type_const_reference type_const_reference1;
+        typedef typename expression_traits< T >::type_const_reference type_const_reference2;
+        typedef typename expression_traits< T1 >::type_reference type_reference1;
+        typedef typename expression_traits< T >::type_reference type_reference2;
+        typedef typename expression_traits< T1 >::const_reference const_reference1;
+        typedef typename expression_traits< T >::const_reference const_reference2;
+        typedef typename expression_traits< T1 >::reference reference1;
+        typedef typename expression_traits< T >::reference reference2;
+        typedef typename expression_traits< T1 >::element_type element_type1;
+        typedef typename expression_traits< T >::element_type element_type2;
+        typedef typename expression_traits< T1 >::allocator_type allocator_type;
+        typedef typename expression_traits< T1 >::size_type size_type;
+        typedef element_type1 result_type;
+
+    };
+
+//--
+//--
+
+    namespace detail {
+
+    template< class T, bool E >
+    struct matrix_transpose
+        : matrix_transpose_traits< T >
+    {
+        typedef typename matrix_transpose_traits< T >::result_type result_type;
+        typedef typename matrix_transpose_traits< T >::const_reference2 const_reference2;
+
+        result_type operator()( const_reference2 t )
+        {
+            return transpose( t );
+        }
+    };
+
+    template< class T >
+    struct matrix_transpose< T,false >
+        : matrix_transpose_traits< T >
+    {
+        typedef typename matrix_transpose_traits< T >::const_reference2 const_reference2;
+
+        const_reference2 operator()( const_reference2 t )
+        {
+            return t;
+        }
+    };
+
+    } // namespace detail
+
+    template< class T >
+    struct matrix_transpose
+        : matrix_transpose_traits< T >
+    {
+        typedef typename matrix_transpose_traits< T >::result_type result_type;
+        typedef typename matrix_transpose_traits< T >::type_const_reference2 type_const_reference2;
+        typedef typename matrix_transpose_traits< T >::type_reference1 type_reference1;
+        typedef typename matrix_transpose_traits< T >::size_type size_type;
+
+        result_type operator()( type_const_reference2 t, size_type i, size_type j )
+        {
+            return detail::matrix_transpose< T,is_matrix< result_type >::type::value >()( t( j,i ) );
+        }
+
+        void operator()( type_reference1 t1, type_const_reference2 t2 )
+        {
+            for( std::size_t i = 0; i != t2.rows; ++i )
+            for( std::size_t j = 0; j != t2.cols; ++j )
+                t1( j,i ) = t2( i,j );
+        }
+    };
+
+    template< class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t N, bool I, class A >
+    struct matrix_transpose< matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A > >
+        : matrix_transpose_traits< matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A > >
+    {
+        typedef matrix_transpose_traits< matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A > > traits;
+        typedef typename traits::type_reference1 type_reference1;
+        typedef typename traits::type_const_reference2 type_const_reference2;
+
+        void operator()( type_reference1 t1, type_const_reference2 t2 )
+        {
+            for( std::size_t i = 0; i != M; ++i )
+            for( std::size_t j = 0; j != N; ++j )
+                matrix_transpose< matrix< T,M1,N1,I1,A1 > >()( t1( j,i ), t2( i,j ) );
+        }
+    };
+
+    template< class T >
+    struct matrix_scalar_negate
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::type_const_reference type_const_reference;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+        typedef typename expression_unary_traits< T >::size_type size_type;
+
+        result_type operator()( type_const_reference t, size_type i, size_type j )
+        {
+            return -t( i,j );
+        }
+
+        result_type operator()( const_reference t )
+        {
+            return -t;
+        }
+    };
+
+    template< class T >
+    struct matrix_scalar_sin
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::type_const_reference type_const_reference;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+        typedef typename expression_unary_traits< T >::size_type size_type;
+
+        result_type operator()( type_const_reference t, size_type i, size_type j )
+        {
+            return std::sin( t( i,j ) );
+        }
+
+        result_type operator()( const_reference t )
+        {
+            return std::sin( t );
+        }
+    };
+
+    template< class T >
+    struct matrix_scalar_cos
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::type_const_reference type_const_reference;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+        typedef typename expression_unary_traits< T >::size_type size_type;
+
+        result_type operator()( type_const_reference t, size_type i, size_type j )
+        {
+            return std::cos( t( i,j ) );
+        }
+
+        result_type operator()( const_reference t )
+        {
+            return std::cos( t );
+        }
+    };
+
+    template< class T >
+    struct matrix_scalar_tan
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::type_const_reference type_const_reference;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+        typedef typename expression_unary_traits< T >::size_type size_type;
+
+        result_type operator()( type_const_reference t, size_type i, size_type j )
+        {
+            return std::tan( t( i,j ) );
+        }
+
+        result_type operator()( const_reference t )
+        {
+            return std::tan( t );
+        }
+    };
+
+    template< class T >
+    struct matrix_scalar_cosec
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::type_const_reference type_const_reference;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+        typedef typename expression_unary_traits< T >::size_type size_type;
+
+        result_type operator()( type_const_reference t, size_type i, size_type j )
+        {
+            return T(1) / std::sin( t( i,j ) );
+        }
+
+        result_type operator()( const_reference t )
+        {
+            return T(1) / std::sin( t );
+        }
+    };
+
+    template< class T >
+    struct matrix_scalar_sec
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::type_const_reference type_const_reference;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+        typedef typename expression_unary_traits< T >::size_type size_type;
+
+        result_type operator()( type_const_reference t, size_type i, size_type j )
+        {
+            return T(1) / std::cos( t( i,j ) );
+        }
+
+        result_type operator()( const_reference t )
+        {
+            return T(1) / std::cos( t );
+        }
+    };
+
+    template< class T >
+    struct matrix_scalar_cot
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::type_const_reference type_const_reference;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+        typedef typename expression_unary_traits< T >::size_type size_type;
+
+        result_type operator()( type_const_reference t, size_type i, size_type j )
+        {
+            return T(1) / std::tan( t( i,j ) );
+        }
+
+        result_type operator()( const_reference t )
+        {
+            return T(1) / std::tan( t );
+        }
+    };
+
+    template< class T >
+    struct matrix_scalar_sinh
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::type_const_reference type_const_reference;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+        typedef typename expression_unary_traits< T >::size_type size_type;
+
+        result_type operator()( type_const_reference t, size_type i, size_type j )
+        {
+            return std::sinh( t( i,j ) );
+        }
+
+        result_type operator()( const_reference t )
+        {
+            return std::sinh( t );
+        }
+    };
+
+    template< class T >
+    struct matrix_scalar_cosh
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::type_const_reference type_const_reference;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+        typedef typename expression_unary_traits< T >::size_type size_type;
+
+        result_type operator()( type_const_reference t, size_type i, size_type j )
+        {
+            return std::cosh( t( i,j ) );
+        }
+
+        result_type operator()( const_reference t )
+        {
+            return std::cosh( t );
+        }
+    };
+
+    template< class T >
+    struct matrix_scalar_tanh
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::type_const_reference type_const_reference;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+        typedef typename expression_unary_traits< T >::size_type size_type;
+
+        result_type operator()( type_const_reference t, size_type i, size_type j )
+        {
+            return std::tanh( t( i,j ) );
+        }
+
+        result_type operator()( const_reference t )
+        {
+            return std::tanh( t );
+        }
+    };
+
+    template< class T >
+    struct matrix_scalar_cosech
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::type_const_reference type_const_reference;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+        typedef typename expression_unary_traits< T >::size_type size_type;
+
+        result_type operator()( type_const_reference t, size_type i, size_type j )
+        {
+            return T(1) / std::sinh( t( i,j ) );
+        }
+
+        result_type operator()( const_reference t )
+        {
+            return T(1) / std::sinh( t );
+        }
+    };
+
+    template< class T >
+    struct matrix_scalar_sech
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::type_const_reference type_const_reference;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+        typedef typename expression_unary_traits< T >::size_type size_type;
+
+        result_type operator()( type_const_reference t, size_type i, size_type j )
+        {
+            return T(1) / std::cosh( t( i,j ) );
+        }
+
+        result_type operator()( const_reference t )
+        {
+            return T(1) / std::cosh( t );
+        }
+    };
+
+    template< class T >
+    struct matrix_scalar_coth
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::type_const_reference type_const_reference;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+        typedef typename expression_unary_traits< T >::size_type size_type;
+
+        result_type operator()( type_const_reference t, size_type i, size_type j )
+        {
+            return T(1) / std::tanh( t( i,j ) );
+        }
+
+        result_type operator()( const_reference t )
+        {
+            return T(1) / std::tanh( t );
+        }
+    };
+
+    template< class T >
+    struct matrix_scalar_asin
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::type_const_reference type_const_reference;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+        typedef typename expression_unary_traits< T >::size_type size_type;
+
+        result_type operator()( type_const_reference t, size_type i, size_type j )
+        {
+            return std::asin( t( i,j ) );
+        }
+
+        result_type operator()( const_reference t )
+        {
+            return std::asin( t );
+        }
+    };
+
+    template< class T >
+    struct matrix_scalar_asin< std::complex< T > >
+        : expression_unary_traits< std::complex< T > >
+    {
+        typedef typename expression_unary_traits< std::complex< T > >::result_type result_type;
+        typedef typename expression_unary_traits< std::complex< T > >::type_const_reference type_const_reference;
+        typedef typename expression_unary_traits< std::complex< T > >::const_reference const_reference;
+        typedef typename expression_unary_traits< std::complex< T > >::size_type size_type;
+
+        result_type operator()( type_const_reference t, size_type i, size_type j )
+        {
+            return math::asin( t( i,j ) );
+        }
+
+        result_type operator()( const_reference t )
+        {
+            return math::asin( t );
+        }
+    };
+
+    template< class T >
+    struct matrix_scalar_acos
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::type_const_reference type_const_reference;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+        typedef typename expression_unary_traits< T >::size_type size_type;
+
+        result_type operator()( type_const_reference t, size_type i, size_type j )
+        {
+            return std::acos( t( i,j ) );
+        }
+
+        result_type operator()( const_reference t )
+        {
+            return std::cos( t );
+        }
+    };
+
+    template< class T >
+    struct matrix_scalar_acos< std::complex< T > >
+        : expression_unary_traits< std::complex< T > >
+    {
+        typedef typename expression_unary_traits< std::complex< T > >::result_type result_type;
+        typedef typename expression_unary_traits< std::complex< T > >::type_const_reference type_const_reference;
+        typedef typename expression_unary_traits< std::complex< T > >::const_reference const_reference;
+        typedef typename expression_unary_traits< std::complex< T > >::size_type size_type;
+
+        result_type operator()( type_const_reference t, size_type i, size_type j )
+        {
+            return math::acos( t( i,j ) );
+        }
+
+        result_type operator()( const_reference t )
+        {
+            return math::acos( t );
+        }
+    };
+
+    template< class T >
+    struct matrix_scalar_atan
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::type_const_reference type_const_reference;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+        typedef typename expression_unary_traits< T >::size_type size_type;
+
+        result_type operator()( type_const_reference t, size_type i, size_type j )
+        {
+            return std::atan( t( i,j ) );
+        }
+
+        result_type operator()( const_reference t )
+        {
+            return std::atan( t );
+        }
+    };
+
+    template< class T >
+    struct matrix_scalar_atan< std::complex< T > >
+        : expression_unary_traits< std::complex< T > >
+    {
+        typedef typename expression_unary_traits< std::complex< T > >::result_type result_type;
+        typedef typename expression_unary_traits< std::complex< T > >::type_const_reference type_const_reference;
+        typedef typename expression_unary_traits< std::complex< T > >::const_reference const_reference;
+        typedef typename expression_unary_traits< std::complex< T > >::size_type size_type;
+
+        result_type operator()( type_const_reference t, size_type i, size_type j )
+        {
+            return math::atan( t( i,j ) );
+        }
+
+        result_type operator()( const_reference t )
+        {
+            return math::atan( t );
+        }
+    };
+
+    template< class T >
+    struct matrix_scalar_asinh
+        : expression_unary_traits< T >
+    {};
+
+    template< class T >
+    struct matrix_scalar_acosh
+        : expression_unary_traits< T >
+    {};
+
+    template< class T >
+    struct matrix_scalar_atanh
+        : expression_unary_traits< T >
+    {};
+
+    template< class T >
+    struct matrix_scalar_asinh< std::complex< T > >
+        : expression_unary_traits< std::complex< T > >
+    {
+        typedef typename expression_unary_traits< std::complex< T > >::result_type result_type;
+        typedef typename expression_unary_traits< std::complex< T > >::type_const_reference type_const_reference;
+        typedef typename expression_unary_traits< std::complex< T > >::const_reference const_reference;
+        typedef typename expression_unary_traits< std::complex< T > >::size_type size_type;
+
+        result_type operator()( type_const_reference t, size_type i, size_type j )
+        {
+            return math::asinh( t( i,j ) );
+        }
+
+        result_type operator()( const_reference t )
+        {
+            return math::asinh( t );
+        }
+    };
+
+    template< class T >
+    struct matrix_scalar_acosh< std::complex< T > >
+        : expression_unary_traits< std::complex< T > >
+    {
+        typedef typename expression_unary_traits< std::complex< T > >::result_type result_type;
+        typedef typename expression_unary_traits< std::complex< T > >::type_const_reference type_const_reference;
+        typedef typename expression_unary_traits< std::complex< T > >::const_reference const_reference;
+        typedef typename expression_unary_traits< std::complex< T > >::size_type size_type;
+
+        result_type operator()( type_const_reference t, size_type i, size_type j )
+        {
+            return math::acosh( t( i,j ) );
+        }
+
+        result_type operator()( const_reference t )
+        {
+            return math::acosh( t );
+        }
+    };
+
+    template< class T >
+    struct matrix_scalar_atanh< std::complex< T > >
+        : expression_unary_traits< std::complex< T > >
+    {
+        typedef typename expression_unary_traits< std::complex< T > >::result_type result_type;
+        typedef typename expression_unary_traits< std::complex< T > >::type_const_reference type_const_reference;
+        typedef typename expression_unary_traits< std::complex< T > >::const_reference const_reference;
+        typedef typename expression_unary_traits< std::complex< T > >::size_type size_type;
+
+        result_type operator()( type_const_reference t, size_type i, size_type j )
+        {
+            return math::atanh( t( i,j ) );
+        }
+
+        result_type operator()( const_reference t )
+        {
+            return math::atanh( t );
+        }
+    };
+
+    template< class T >
+    struct matrix_scalar_exp
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::type_const_reference type_const_reference;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+        typedef typename expression_unary_traits< T >::size_type size_type;
+
+        result_type operator()( type_const_reference t, size_type i, size_type j )
+        {
+            return std::exp( t( i,j ) );
+        }
+
+        result_type operator()( const_reference t )
+        {
+            return std::exp( t );
+        }
+    };
+
+    template< class T >
+    struct matrix_scalar_log
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::type_const_reference type_const_reference;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+        typedef typename expression_unary_traits< T >::size_type size_type;
+
+        result_type operator()( type_const_reference t, size_type i, size_type j )
+        {
+            return std::log( t( i,j ) );
+        }
+
+        result_type operator()( const_reference t )
+        {
+            return std::log( t );
+        }
+    };
+
+    template< class T >
+    struct matrix_scalar_log10
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::type_const_reference type_const_reference;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+        typedef typename expression_unary_traits< T >::size_type size_type;
+
+        result_type operator()( type_const_reference t, size_type i, size_type j )
+        {
+            return std::log10( t( i,j ) );
+        }
+
+        result_type operator()( const_reference t )
+        {
+            return std::log10( t );
+        }
+    };
+
+    template< class T >
+    struct matrix_scalar_sqrt
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::type_const_reference type_const_reference;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+        typedef typename expression_unary_traits< T >::size_type size_type;
+
+        result_type operator()( type_const_reference t, size_type i, size_type j )
+        {
+            return std::sqrt( t( i,j ) );
+        }
+
+        result_type operator()( const_reference t )
+        {
+            return std::sqrt( t );
+        }
+    };
+
+    template< class T >
+    struct matrix_scalar_abs
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::type_const_reference type_const_reference;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+        typedef typename expression_unary_traits< T >::size_type size_type;
+
+        result_type operator()( type_const_reference t, size_type i, size_type j )
+        {
+            return std::abs( t( i,j ) );
+        }
+
+        result_type operator()( const_reference t )
+        {
+            return std::abs( t );
+        }
+    };
+
+    template< class T >
+    struct matrix_scalar_fabs
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::type_const_reference type_const_reference;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+        typedef typename expression_unary_traits< T >::size_type size_type;
+
+        result_type operator()( type_const_reference t, size_type i, size_type j )
+        {
+            return std::fabs( t( i,j ) );
+        }
+
+        result_type operator()( const_reference t )
+        {
+            return std::fabs( t );
+        }
+    };
+
+    template< class T >
+    struct matrix_scalar_fabs< std::complex< T > >
+        : expression_unary_traits< std::complex< T > >
+    {
+        typedef typename expression_unary_traits< std::complex< T > >::result_type result_type;
+        typedef typename expression_unary_traits< std::complex< T > >::type_const_reference type_const_reference;
+        typedef typename expression_unary_traits< std::complex< T > >::const_reference const_reference;
+        typedef typename expression_unary_traits< std::complex< T > >::size_type size_type;
+
+        result_type operator()( type_const_reference t, size_type i, size_type j )
+        {
+            return math::fabs( t( i,j ) );
+        }
+
+        result_type operator()( const_reference t )
+        {
+            return math::fabs( t );
+        }
+    };
+
+//--
+
+    template< class E, std::size_t M, std::size_t N >
+    matrix_unary_expression< E,N,M,matrix_transpose< E >,false >
+    transpose( matrix_expression< E,M,N > const& e )
+    {
+         return matrix_unary_expression< E,N,M,matrix_transpose< E >,false >( e() );
+    }
+
+    template< class E, std::size_t M, std::size_t N >
+    matrix_unary_expression< E,M,N,matrix_scalar_negate< E >,true >
+    operator-( matrix_expression< E,M,N > const& e )
+    {
+        return matrix_unary_expression< E,M,N,matrix_scalar_negate< E >,true >( e() );
+    }
+
+    template< class E, std::size_t M, std::size_t N >
+    matrix_unary_expression< E,M,N,matrix_scalar_sin< E >,true >
+    sin( matrix_expression< E,M,N > const& e )
+    {
+        return matrix_unary_expression< E,M,N,matrix_scalar_sin< E >,true >( e() );
+    }
+
+    template< class E, std::size_t M, std::size_t N >
+    matrix_unary_expression< E,M,N,matrix_scalar_cos< E >,true >
+    cos( matrix_expression< E,M,N > const& e )
+    {
+        return matrix_unary_expression< E,M,N,matrix_scalar_cos< E >,true >( e() );
+    }
+
+    template< class E, std::size_t M, std::size_t N >
+    matrix_unary_expression< E,M,N,matrix_scalar_tan< E >,true >
+    tan( matrix_expression< E,M,N > const& e )
+    {
+        return matrix_unary_expression< E,M,N,matrix_scalar_tan< E >,true >( e() );
+    }
+
+    template< class E, std::size_t M, std::size_t N >
+    matrix_unary_expression< E,M,N,matrix_scalar_cosec< E >,true >
+    cosec( matrix_expression< E,M,N > const& e )
+    {
+        return matrix_unary_expression< E,M,N,matrix_scalar_cosec< E >,true >( e() );
+    }
+
+    template< class E, std::size_t M, std::size_t N >
+    matrix_unary_expression< E,M,N,matrix_scalar_sec< E >,true >
+    sec( matrix_expression< E,M,N > const& e )
+    {
+        return matrix_unary_expression< E,M,N,matrix_scalar_sec< E >,true >( e() );
+    }
+
+    template< class E, std::size_t M, std::size_t N >
+    matrix_unary_expression< E,M,N,matrix_scalar_cot< E >,true >
+    cot( matrix_expression< E,M,N > const& e )
+    {
+        return matrix_unary_expression< E,M,N,matrix_scalar_cot< E >,true >( e() );
+    }
+
+    template< class E, std::size_t M, std::size_t N >
+    matrix_unary_expression< E,M,N,matrix_scalar_sinh< E >,true >
+    sinh( matrix_expression< E,M,N > const& e )
+    {
+        return matrix_unary_expression< E,M,N,matrix_scalar_sinh< E >,true >( e() );
+    }
+
+    template< class E, std::size_t M, std::size_t N >
+    matrix_unary_expression< E,M,N,matrix_scalar_cosh< E >,true >
+    cosh( matrix_expression< E,M,N > const& e )
+    {
+        return matrix_unary_expression< E,M,N,matrix_scalar_cosh< E >,true >( e() );
+    }
+
+    template< class E, std::size_t M, std::size_t N >
+    matrix_unary_expression< E,M,N,matrix_scalar_tanh< E >,true >
+    tanh( matrix_expression< E,M,N > const& e )
+    {
+        return matrix_unary_expression< E,M,N,matrix_scalar_tanh< E >,true >( e() );
+    }
+
+    template< class E, std::size_t M, std::size_t N >
+    matrix_unary_expression< E,M,N,matrix_scalar_cosech< E >,true >
+    cosech( matrix_expression< E,M,N > const& e )
+    {
+        return matrix_unary_expression< E,M,N,matrix_scalar_cosech< E >,true >( e() );
+    }
+
+    template< class E, std::size_t M, std::size_t N >
+    matrix_unary_expression< E,M,N,matrix_scalar_sech< E >,true >
+    sech( matrix_expression< E,M,N > const& e )
+    {
+        return matrix_unary_expression< E,M,N,matrix_scalar_sech< E >,true >( e() );
+    }
+
+    template< class E, std::size_t M, std::size_t N >
+    matrix_unary_expression< E,M,N,matrix_scalar_coth< E >,true >
+    coth( matrix_expression< E,M,N > const& e )
+    {
+        return matrix_unary_expression< E,M,N,matrix_scalar_coth< E >,true >( e() );
+    }
+
+    template< class E, std::size_t M, std::size_t N >
+    matrix_unary_expression< E,M,N,matrix_scalar_asin< E >,true >
+    asin( matrix_expression< E,M,N > const& e )
+    {
+        return matrix_unary_expression< E,M,N,matrix_scalar_asin< E >,true >( e() );
+    }
+
+    template< class E, std::size_t M, std::size_t N >
+    matrix_unary_expression< E,M,N,matrix_scalar_acos< E >,true >
+    acos( matrix_expression< E,M,N > const& e )
+    {
+        return matrix_unary_expression< E,M,N,matrix_scalar_acos< E >,true >( e() );
+    }
+
+    template< class E, std::size_t M, std::size_t N >
+    matrix_unary_expression< E,M,N,matrix_scalar_atan< E >,true >
+    atan( matrix_expression< E,M,N > const& e )
+    {
+        return matrix_unary_expression< E,M,N,matrix_scalar_atan< E >,true >( e() );
+    }
+
+    template< class E, std::size_t M, std::size_t N >
+    matrix_unary_expression< E,M,N,matrix_scalar_asinh< E >,true >
+    asinh( matrix_expression< E,M,N > const& e )
+    {
+        return matrix_unary_expression< E,M,N,matrix_scalar_asinh< E >,true >( e() );
+    }
+
+    template< class E, std::size_t M, std::size_t N >
+    matrix_unary_expression< E,M,N,matrix_scalar_acosh< E >,true >
+    acosh( matrix_expression< E,M,N > const& e )
+    {
+        return matrix_unary_expression< E,M,N,matrix_scalar_acosh< E >,true >( e() );
+    }
+
+    template< class E, std::size_t M, std::size_t N >
+    matrix_unary_expression< E,M,N,matrix_scalar_atanh< E >,true >
+    atanh( matrix_expression< E,M,N > const& e )
+    {
+        return matrix_unary_expression< E,M,N,matrix_scalar_atanh< E >,true >( e() );
+    }
+
+    template< class E, std::size_t M, std::size_t N >
+    matrix_unary_expression< E,M,N,matrix_scalar_exp< E >,true >
+    exp( matrix_expression< E,M,N > const& e )
+    {
+        return matrix_unary_expression< E,M,N,matrix_scalar_exp< E >,true >( e() );
+    }
+
+    template< class E, std::size_t M, std::size_t N >
+    matrix_unary_expression< E,M,N,matrix_scalar_log< E >,true >
+    log( matrix_expression< E,M,N > const& e )
+    {
+        return matrix_unary_expression< E,M,N,matrix_scalar_log< E >,true >( e() );
+    }
+
+    template< class E, std::size_t M, std::size_t N >
+    matrix_unary_expression< E,M,N,matrix_scalar_log10< E >,true >
+    log10( matrix_expression< E,M,N > const& e )
+    {
+        return matrix_unary_expression< E,M,N,matrix_scalar_log10< E >,true >( e() );
+    }
+
+    template< class E, std::size_t M, std::size_t N >
+    matrix_unary_expression< E,M,N,matrix_scalar_sqrt< E >,true >
+    sqrt( matrix_expression< E,M,N > const& e )
+    {
+        return matrix_unary_expression< E,M,N,matrix_scalar_sqrt< E >,true >( e() );
+    }
+
+    template< class E, std::size_t M, std::size_t N >
+    matrix_unary_expression< E,M,N,matrix_scalar_abs< E >,true >
+    abs( matrix_expression< E,M,N > const& e )
+    {
+        return matrix_unary_expression< E,M,N,matrix_scalar_abs< E >,true >( e() );
+    }
+
+    template< class E, std::size_t M, std::size_t N >
+    matrix_unary_expression< E,M,N,matrix_scalar_fabs< E >,true >
+    fabs( matrix_expression< E,M,N > const& e )
+    {
+        return matrix_unary_expression< E,M,N,matrix_scalar_fabs< E >,true >( e() );
+    }
+
+//--
+
+    template< class E, std::size_t M, std::size_t N, class O, bool L >
+    class matrix_matrix_expression
+        : public matrix_expression< matrix_matrix_expression< E,M,N,O,L >,M,N >
+    {
+    public:
+
+        typedef matrix_matrix_expression type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef E expression_type;
+        typedef O operator_type;
+        typedef typename O::result_type result_type;
+        typedef result_type element_type;
+        typedef element_type const& const_reference;
+        typedef element_type& reference;
+        typedef typename operator_type::size_type size_type;
+        typedef typename operator_type::allocator_type allocator_type;
+
+        using matrix_expression< type,M,N >::operator();
+
+        enum { rows = M, cols = N };
+        enum { linear = ( L & E::linear ) };
+
+        matrix_matrix_expression();
+
+        result_type const operator()( size_type, size_type ) const;
+        result_type const operator()( size_type ) const;
+
+        template< class U > 
+        bool const references( scalar< U > const& ) const;
+        template< class U, std::size_t Q, bool J, class B > 
+        bool const references( vector< U,Q,J,B > const& ) const;
+        template< class U, std::size_t P, std::size_t Q, bool J, class B > 
+        bool const references( matrix< U,P,Q,J,B > const& ) const;
+
+    };
+
+//--
+
+    template< class E, std::size_t M, std::size_t N, class O, bool L >
+    matrix_matrix_expression< E,M,N,O,L >::matrix_matrix_expression()
+    {}
+
+    template< class E, std::size_t M, std::size_t N, class O, bool L >
+    typename matrix_matrix_expression< E,M,N,O,L >::result_type const 
+        matrix_matrix_expression< E,M,N,O,L >::operator()( size_type i, size_type j ) const
+    {
+        return operator_type()( i,j );
+    }
+
+    template< class E, std::size_t M, std::size_t N, class O, bool L >
+    typename matrix_matrix_expression< E,M,N,O,L >::result_type const 
+        matrix_matrix_expression< E,M,N,O,L >::operator()( size_type s ) const
+    {
+        return operator_type()( s );
+    }
+
+    template< class E, std::size_t M, std::size_t N, class O, bool L > template< class U >
+    bool const matrix_matrix_expression< E,M,N,O,L >::references( scalar< U > const& ) const
+    {
+        return false;
+    }
+
+    template< class E, std::size_t M, std::size_t N, class O, bool L > template< class U, std::size_t Q, bool J, class B >
+    bool const matrix_matrix_expression< E,M,N,O,L >::references( vector< U,Q,J,B > const& ) const
+    {
+        return false;
+    }
+
+    template< class E, std::size_t M, std::size_t N, class O, bool L > template< class U, std::size_t P, std::size_t Q, bool J, class B >
+    bool const matrix_matrix_expression< E,M,N,O,L >::references( matrix< U,P,Q,J,B > const& ) const
+    {
+        return false;
+    }
+
+//--
+
+    template< class T >
+    struct matrix_matrix_zero
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::size_type size_type;
+
+        result_type operator()( size_type, size_type )
+        {
+            return result_type(0);
+        }
+
+        result_type operator()( size_type )
+        {
+            return result_type(0);
+        }
+    };
+
+    template< class T >
+    struct matrix_matrix_identity
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::size_type size_type;
+
+        result_type operator()( size_type i, size_type j )
+        {
+            return i == j ? result_type(1) : result_type(0);
+        }
+
+        result_type operator()( size_type s )
+        {
+            return ((s % (T::cols + 1)) == 0) ? result_type(1) : result_type(0);
+        }
+    };
+
+//--
+
+    template< class T, std::size_t M, std::size_t N >
+    matrix_matrix_expression< matrix< T,M,N >,M,N,matrix_matrix_zero< matrix< T,M,N > >,true >
+    matrix_zero()
+    {
+        return matrix_matrix_expression< matrix< T,M,N >,M,N, 
+            matrix_matrix_zero< matrix< T,M,N > >,true >();
+    }
+
+    template< class T, std::size_t N >
+    matrix_matrix_expression< matrix< T,N,N >,N,N,matrix_matrix_identity< matrix< T,N,N > >,true >
+    matrix_identity()
+    {
+        return matrix_matrix_expression< matrix< T,N,N >,N,N, 
+            matrix_matrix_identity< matrix< T,N,N > >,true >();
+    }
+
+//--
+
+}} // namespace boost, namespace maps
+
+#endif // BOOST_MAPS_MATH_MATRIX_MATRIX_HPP
\ No newline at end of file
Added: sandbox/maps/boost/maps/math/matrix_scalar.hpp
==============================================================================
--- (empty file)
+++ sandbox/maps/boost/maps/math/matrix_scalar.hpp	2011-08-08 19:51:30 EDT (Mon, 08 Aug 2011)
@@ -0,0 +1,244 @@
+//--
+// Copyright (c) 2010-2011 Brian Smith
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/maps for documentation.
+//--
+#if !defined( BOOST_MAPS_MATH_MATRIX_SCALAR_HPP )
+#define BOOST_MAPS_MATH_MATRIX_SCALAR_HPP
+
+#include <boost/maps/math/matrix_matrix.hpp>
+#include <boost/maps/math/scalar_scalar.hpp>
+
+namespace boost { namespace maps {
+
+//--
+
+    template< class E1, class E2, std::size_t M, std::size_t N, class O, bool L >
+    class matrix_scalar_binary_expression
+        : public matrix_expression< matrix_scalar_binary_expression< E1,E2,M,N,O,L >,M,N >
+    {
+    public:
+
+        typedef matrix_scalar_binary_expression type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef typename E1::type_const_reference expression1_const_reference;
+        typedef typename E2::type_const_reference expression2_const_reference;
+        typedef E1 expression_type1;
+        typedef E2 expression_type2;
+        typedef O operator_type;
+        typedef typename O::result_type result_type;
+        typedef result_type element_type;
+        typedef element_type const& const_reference;
+        typedef element_type& reference;
+        typedef typename operator_type::size_type size_type;
+        typedef typename operator_type::allocator_type allocator_type;
+
+        using matrix_expression< type,M,N >::operator();
+
+        enum { rows = M, cols = N };
+        enum { linear = ( L & E1::linear & E2::linear ) };
+
+        matrix_scalar_binary_expression( E1 const&, E2 const& );
+        type_reference operator=( type_const_reference );
+
+        expression_type1 const& expression1() const;
+        expression_type2 const& expression2() const;
+
+        reference operator()( reference, size_type, size_type ) const;
+        result_type const operator()( size_type, size_type ) const;
+        result_type const operator()( size_type ) const;
+
+        template< class U > 
+        bool const references( scalar< U > const& ) const;
+        template< class U, std::size_t Q, bool J, class B > 
+        bool const references( vector< U,Q,J,B > const& ) const;
+        template< class U, std::size_t P, std::size_t Q, bool J, class B > 
+        bool const references( matrix< U,P,Q,J,B > const& ) const;
+
+    private:
+
+        expression1_const_reference t1;
+        expression2_const_reference t2;
+
+    };
+
+    //--
+
+    template< class E1, class E2, std::size_t M, std::size_t N, class O, bool L >
+    matrix_scalar_binary_expression< E1,E2,M,N,O,L >::matrix_scalar_binary_expression( E1 const& e1, E2 const& e2 )
+        : t1( e1 ), t2( e2 )
+    {}
+
+    template< class E1, class E2, std::size_t M, std::size_t N, class O, bool L >
+    typename matrix_scalar_binary_expression< E1,E2,M,N,O,L >::type_reference
+        matrix_scalar_binary_expression< E1,E2,M,N,O,L >::operator=( type_const_reference e )
+    {
+        if( &e != this ) { t1 = e.t1; t2 = e.t2; }
+        return *this;
+    }
+
+    template< class E1, class E2, std::size_t M, std::size_t N, class O, bool L >
+    typename matrix_scalar_binary_expression< E1,E2,M,N,O,L >::expression_type1 const& 
+        matrix_scalar_binary_expression< E1,E2,M,N,O,L >::expression1() const
+    {
+        return t1;
+    }
+
+    template< class E1, class E2, std::size_t M, std::size_t N, class O, bool L >
+    typename matrix_scalar_binary_expression< E1,E2,M,N,O,L >::expression_type2 const& 
+        matrix_scalar_binary_expression< E1,E2,M,N,O,L >::expression2() const
+    {
+        return t2;
+    }
+
+    template< class E1, class E2, std::size_t M, std::size_t N, class O, bool L >
+    typename matrix_scalar_binary_expression< E1,E2,M,N,O,L >::reference 
+        matrix_scalar_binary_expression< E1,E2,M,N,O,L >::operator()( reference r, size_type i, size_type j ) const
+    {
+        return operator_type()( r,t1,t2,i,j );
+    }
+
+    template< class E1, class E2, std::size_t M, std::size_t N, class O, bool L >
+    typename matrix_scalar_binary_expression< E1,E2,M,N,O,L >::result_type const 
+        matrix_scalar_binary_expression< E1,E2,M,N,O,L >::operator()( size_type i, size_type j ) const
+    {
+        return operator_type()( t1,t2,i,j );
+    }
+
+    template< class E1, class E2, std::size_t M, std::size_t N, class O, bool L >
+    typename matrix_scalar_binary_expression< E1,E2,M,N,O,L >::result_type const 
+        matrix_scalar_binary_expression< E1,E2,M,N,O,L >::operator()( size_type s ) const
+    {
+        return operator_type()( t1,t2,s );
+    }
+
+    template< class E1, class E2, std::size_t M, std::size_t N, class O, bool L > template< class U >
+    bool const matrix_scalar_binary_expression< E1,E2,M,N,O,L >::references( scalar< U > const& s ) const
+    {
+        return ( t1().references( s ) || t2().references( s ) );
+    }
+
+    template< class E1, class E2, std::size_t M, std::size_t N, class O, bool L > template< class U, std::size_t Q, bool J, class B >
+    bool const matrix_scalar_binary_expression< E1,E2,M,N,O,L >::references( vector< U,Q,J,B > const& v ) const
+    {
+        return ( t1().references( v ) || t2().references( v ) );
+    }
+
+    template< class E1, class E2, std::size_t M, std::size_t N, class O, bool L > template< class U, std::size_t P, std::size_t Q, bool J, class B >
+    bool const matrix_scalar_binary_expression< E1,E2,M,N,O,L >::references( matrix< U,P,Q,J,B > const& m ) const
+    {
+        return ( t1().references( m ) || t2().references( m ) );
+    }
+
+//--
+//--
+
+    template< class T1, class T2 >
+    struct matrix_scalar_traits
+    {
+        typedef typename expression_traits< T1 >::type_const_reference type_const_reference1;
+        typedef typename expression_traits< T2 >::type_const_reference type_const_reference2;
+        typedef typename expression_traits< T1 >::type_reference type_reference1;
+        typedef typename expression_traits< T2 >::type_reference type_reference2;
+        typedef typename expression_traits< T1 >::const_reference const_reference1;
+        typedef typename expression_traits< T2 >::const_reference const_reference2;
+        typedef typename expression_traits< T1 >::reference reference1;
+        typedef typename expression_traits< T2 >::reference reference2;
+        typedef typename expression_traits< T1 >::element_type element_type1;
+        typedef typename expression_traits< T2 >::element_type element_type2;
+        typedef typename expression_traits< T1 >::allocator_type allocator_type;
+        typedef typename expression_traits< T1 >::size_type size_type;
+        typedef typename matrix_scalar_type< element_type1,element_type2 >::type result_type;
+
+    };
+
+//--
+//--
+
+    template< class T1, class T2 >
+    struct matrix_scalar_product
+        : matrix_scalar_traits< T1,T2 >
+    {
+        typedef typename matrix_scalar_traits< T1,T2 >::result_type result_type;
+        typedef typename matrix_scalar_traits< T1,T2 >::type_const_reference1 type_const_reference1;
+        typedef typename matrix_scalar_traits< T1,T2 >::type_const_reference2 type_const_reference2;
+        typedef typename matrix_scalar_traits< T1,T2 >::size_type size_type;
+
+        result_type& operator()( result_type& r, type_const_reference1 t1, type_const_reference2 t2, size_type i, size_type j )
+        {
+            return r = t1( r,i,j ) * t2();
+        }
+
+        result_type& operator()( result_type& r, type_const_reference1 t1, type_const_reference2 t2, size_type s )
+        {
+            return r = t1( r,s ) * t2();
+        }
+
+        result_type operator()( type_const_reference1 t1, type_const_reference2 t2, size_type i, size_type j )
+        {
+            return t1( i,j ) * t2();
+        }
+
+        result_type operator()( type_const_reference1 t1, type_const_reference2 t2, size_type s )
+        {
+            return t1( s ) * t2();
+        }
+    };
+
+    template< class T1, class T2 >
+    struct scalar_matrix_product
+        : matrix_scalar_traits< T1,T2 >
+    {
+        typedef typename matrix_scalar_traits< T1,T2 >::result_type result_type;
+        typedef typename matrix_scalar_traits< T1,T2 >::type_const_reference1 type_const_reference1;
+        typedef typename matrix_scalar_traits< T1,T2 >::type_const_reference2 type_const_reference2;
+        typedef typename matrix_scalar_traits< T1,T2 >::size_type size_type;
+
+        result_type& operator()( result_type& r, type_const_reference1 t1, type_const_reference2 t2, size_type i, size_type j )
+        {
+            return r = t1() * t2( r,i,j );
+        }
+
+        result_type& operator()( result_type& r, type_const_reference1 t1, type_const_reference2 t2, size_type s )
+        {
+            return r = t1() * t2( r,s );
+        }
+
+        result_type operator()( type_const_reference1 t1, type_const_reference2 t2, size_type i, size_type j )
+        {
+            return t1() * t2( i,j );
+        }
+
+        result_type operator()( type_const_reference1 t1, type_const_reference2 t2, size_type s )
+        {
+            return t1() * t2( s );
+        }
+    };
+
+//--
+
+    template< class E1, class E2, std::size_t M, std::size_t N >
+    matrix_scalar_binary_expression< E1,E2,M,N,matrix_scalar_product< E1,E2 >,true >
+    operator*( matrix_expression< E1,M,N > const& e1, scalar_expression< E2 > const& e2 )
+    {
+        return matrix_scalar_binary_expression< E1,E2,M,N, 
+            matrix_scalar_product< E1,E2 >,true >( e1(), e2() );
+    }
+
+    template< class E1, class E2, std::size_t M, std::size_t N >
+    matrix_scalar_binary_expression< E1,E2,M,N,scalar_matrix_product< E1,E2 >,true >
+    operator*( scalar_expression< E1 > const& e1, matrix_expression< E2,M,N > const& e2 )
+    {
+        return matrix_scalar_binary_expression< E1,E2,M,N, 
+            scalar_matrix_product< E1,E2 >,true >( e1(), e2() );
+    }
+
+//--
+
+}} // namespace boost, namespace maps
+
+#endif // BOOST_MAPS_MATH_MATRIX_SCALAR_HPP
\ No newline at end of file
Added: sandbox/maps/boost/maps/math/matrix_vector.hpp
==============================================================================
--- (empty file)
+++ sandbox/maps/boost/maps/math/matrix_vector.hpp	2011-08-08 19:51:30 EDT (Mon, 08 Aug 2011)
@@ -0,0 +1,211 @@
+//--
+// Copyright (c) 2010-2011 Brian Smith
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/maps for documentation.
+//--
+#if !defined( BOOST_MAPS_MATH_MATRIX_VECTOR_HPP )
+#define BOOST_MAPS_MATH_MATRIX_VECTOR_HPP
+
+#include <boost/maps/math/matrix_matrix.hpp>
+#include <boost/maps/math/vector_vector.hpp>
+
+namespace boost { namespace maps {
+
+//--
+
+    template< class E1, class E2, std::size_t N, class O, bool L >
+    class matrix_vector_binary_expression
+        : public matrix_expression< matrix_vector_binary_expression< E1,E2,N,O,L >,N,N >
+    {
+    public:
+
+        typedef matrix_vector_binary_expression type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef typename E1::type_const_reference expression1_const_reference;
+        typedef typename E2::type_const_reference expression2_const_reference;
+        typedef E1 expression_type1;
+        typedef E2 expression_type2;
+        typedef O operator_type;
+        typedef typename O::result_type result_type;
+        typedef result_type element_type;
+        typedef element_type const& const_reference;
+        typedef element_type& reference;
+        typedef typename operator_type::size_type size_type;
+        typedef typename operator_type::allocator_type allocator_type;
+
+        using matrix_expression< type,N,N >::operator();
+
+        enum { rows = N, cols = N };
+        enum { linear = ( L & E1::linear & E2::linear ) };
+
+        matrix_vector_binary_expression( E1 const&, E2 const& );
+        type_reference operator=( type_const_reference );
+
+        expression_type1 const& expression1() const;
+        expression_type2 const& expression2() const;
+
+        reference operator()( reference, size_type, size_type ) const;
+        result_type const operator()( size_type, size_type ) const;
+        result_type const operator()( size_type ) const;
+
+        template< class U > 
+        bool const references( scalar< U > const& ) const;
+        template< class U, std::size_t Q, bool J, class B > 
+        bool const references( vector< U,Q,J,B > const& ) const;
+        template< class U, std::size_t P, std::size_t Q, bool J, class B > 
+        bool const references( matrix< U,P,Q,J,B > const& ) const;
+
+    private:
+
+        expression1_const_reference t1;
+        expression2_const_reference t2;
+
+    };
+
+//--
+
+    template< class E1, class E2, std::size_t N, class O, bool L >
+    matrix_vector_binary_expression< E1,E2,N,O,L >::matrix_vector_binary_expression( E1 const& e1, E2 const& e2 )
+        : t1( e1 ), t2( e2 )
+    {}
+
+    template< class E1, class E2, std::size_t N, class O, bool L >
+    typename matrix_vector_binary_expression< E1,E2,N,O,L >::type_reference
+        matrix_vector_binary_expression< E1,E2,N,O,L >::operator=( type_const_reference e )
+    {
+        if( &e != this ) { t1 = e.t1; t2 = e.t2; }
+        return *this;
+    }
+
+    template< class E1, class E2, std::size_t N, class O, bool L >
+    typename matrix_vector_binary_expression< E1,E2,N,O,L >::expression_type1 const& 
+        matrix_vector_binary_expression< E1,E2,N,O,L >::expression1() const
+    {
+        return t1;
+    }
+
+    template< class E1, class E2, std::size_t N, class O, bool L >
+    typename matrix_vector_binary_expression< E1,E2,N,O,L >::expression_type2 const& 
+        matrix_vector_binary_expression< E1,E2,N,O,L >::expression2() const
+    {
+        return t2;
+    }
+
+    template< class E1, class E2, std::size_t N, class O, bool L >
+    typename matrix_vector_binary_expression< E1,E2,N,O,L >::reference 
+        matrix_vector_binary_expression< E1,E2,N,O,L >::operator()( reference r, size_type i, size_type j ) const
+    {
+        return operator_type()( r,t1,t2,i,j );
+    }
+
+    template< class E1, class E2, std::size_t N, class O, bool L >
+    typename matrix_vector_binary_expression< E1,E2,N,O,L >::result_type const 
+        matrix_vector_binary_expression< E1,E2,N,O,L >::operator()( size_type i, size_type j ) const
+    {
+        return operator_type()( t1,t2,i,j );
+    }
+
+    template< class E1, class E2, std::size_t N, class O, bool L >
+    typename matrix_vector_binary_expression< E1,E2,N,O,L >::result_type const 
+        matrix_vector_binary_expression< E1,E2,N,O,L >::operator()( size_type s ) const
+    {
+        return operator_type()( t1( s ), t2( s ) );
+    }
+
+    template< class E1, class E2, std::size_t N, class O, bool L > template< class U >
+    bool const matrix_vector_binary_expression< E1,E2,N,O,L >::references( scalar< U > const& s ) const
+    {
+        return ( t1().references( s ) || t2().references( s ) );
+    }
+
+    template< class E1, class E2, std::size_t N, class O, bool L > template< class U, std::size_t Q, bool J, class B >
+    bool const matrix_vector_binary_expression< E1,E2,N,O,L >::references( vector< U,Q,J,B > const& v ) const
+    {
+        return ( t1().references( v ) || t2().references( v ) );
+    }
+
+    template< class E1, class E2, std::size_t N, class O, bool L > template< class U, std::size_t P, std::size_t Q, bool J, class B >
+    bool const matrix_vector_binary_expression< E1,E2,N,O,L >::references( matrix< U,P,Q,J,B > const& m ) const
+    {
+        return ( t1().references( m ) || t2().references( m ) );
+    }
+
+//--
+//--
+
+    template< class T1, class T2 >
+    struct outer_product_traits
+    {
+        typedef typename expression_traits< T1 >::type_const_reference type_const_reference1;
+        typedef typename expression_traits< T2 >::type_const_reference type_const_reference2;
+        typedef typename expression_traits< T1 >::type_reference type_reference1;
+        typedef typename expression_traits< T2 >::type_reference type_reference2;
+        typedef typename expression_traits< T1 >::const_reference const_reference1;
+        typedef typename expression_traits< T2 >::const_reference const_reference2;
+        typedef typename expression_traits< T1 >::reference reference1;
+        typedef typename expression_traits< T2 >::reference reference2;
+        typedef typename expression_traits< T1 >::element_type element_type1;
+        typedef typename expression_traits< T2 >::element_type element_type2;
+        typedef typename expression_traits< T1 >::allocator_type allocator_type;
+        typedef typename expression_traits< T1 >::size_type size_type;
+        typedef typename matrix_vector_type< element_type1,element_type2 >::type result_type;
+
+    };
+
+//--
+//--
+
+    template< class T1, class T2 >
+    struct vector_vector_outer_product
+        : outer_product_traits< T1,T2 >
+    {
+        typedef typename outer_product_traits< T1,T2 >::result_type result_type;
+        typedef typename outer_product_traits< T1,T2 >::type_const_reference1 type_const_reference1;
+        typedef typename outer_product_traits< T1,T2 >::type_const_reference2 type_const_reference2;
+        typedef typename outer_product_traits< T1,T2 >::const_reference1 const_reference1;
+        typedef typename outer_product_traits< T1,T2 >::const_reference2 const_reference2;
+        typedef typename outer_product_traits< T1,T2 >::size_type size_type;
+
+        result_type& operator()( result_type& r, type_const_reference1 t1, type_const_reference2 t2, size_type i, size_type j )
+        {
+            return r = t1( r,i ) * t2( r,j );
+        }
+
+        result_type operator()( type_const_reference1 t1, type_const_reference2 t2, size_type i, size_type j )
+        {
+            return t1( i ) * t2( j );
+        }
+
+        result_type operator()( const_reference1 t1, const_reference2 t2 )
+        {
+            return t1 * t2;
+        }
+    };
+
+//--
+
+    template< class E1, class E2, std::size_t N >
+    matrix_vector_binary_expression< E1,E2,N,vector_vector_outer_product< E1,E2 >,false >
+    outer_product( vector_expression< E1,N > const& e1, vector_expression< E2,N > const& e2 )
+    {
+        return matrix_vector_binary_expression< E1,E2,N, 
+            vector_vector_outer_product< E1,E2 >,false >( e1(), e2() );
+    }
+
+    template< class E1, class E2, std::size_t N >
+    matrix_vector_binary_expression< E1,E2,N,vector_vector_outer_product< E1,E2 >,false >
+    operator*( vector_expression< E1,N > const& e1, vector_expression< E2,N > const& e2 )
+    {
+        return matrix_vector_binary_expression< E1,E2,N, 
+            vector_vector_outer_product< E1,E2 >,false >( e1(), e2() );
+    }
+
+//--
+
+}} // namespace boost, namespace maps
+
+#endif // BOOST_MAPS_MATH_MATRIX_VECTOR_HPP
\ No newline at end of file
Added: sandbox/maps/boost/maps/math/scalar.hpp
==============================================================================
--- (empty file)
+++ sandbox/maps/boost/maps/math/scalar.hpp	2011-08-08 19:51:30 EDT (Mon, 08 Aug 2011)
@@ -0,0 +1,321 @@
+//--
+// Copyright (c) 2010-2011 Brian Smith
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/maps for documentation.
+//--
+#if !defined( BOOST_MAPS_MATH_SCALAR_HPP )
+#define BOOST_MAPS_MATH_SCALAR_HPP
+
+#include <boost/maps/support/math.hpp>
+#include <boost/maps/math/scalar_scalar.hpp>
+#include <boost/maps/math/scalar_vector.hpp>
+
+namespace boost { namespace maps {
+
+    /*
+        scalar class template
+
+        parameters
+
+            required
+
+                T - data type we wish to store
+                    type: arbitrary type
+    */
+
+    template< class T >
+    class scalar
+        : public scalar_expression< scalar< T > >
+    {
+    public:
+
+        typedef scalar type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef type const* type_const_pointer;
+        typedef type* type_pointer;
+        typedef scalar_expression< type > base_type;
+        typedef T representation_type;
+        typedef T value_type;
+        typedef T const& const_reference_type;
+        typedef T& reference_type;
+        typedef T element_type;
+        typedef T const& const_reference;
+        typedef T& reference;
+        typedef std::size_t size_type;
+        typedef std::ptrdiff_t difference_type;
+        typedef T const* const_iterator;
+        typedef T* iterator;
+        typedef null::allocator allocator_type;
+        typedef mpl::size_t< 0 > dimensionality;
+
+        using scalar_expression< type >::operator();
+
+        enum { size = 1 };
+        enum { linear = true };
+
+        scalar();
+
+        scalar( scalar const& );
+        scalar( T const& );
+        template< class E > scalar( scalar_expression< E > const& );
+
+        scalar& operator=( scalar const& );
+        scalar& operator=( T const& );
+        template< class E > scalar& operator=( scalar_expression< E > const& );
+
+        ~scalar() {}
+
+        template< size_t B >size_type const bound() const;
+
+        void swap( scalar& );
+
+        const_reference operator[]( size_type ) const; 
+        reference operator[]( size_type );
+
+        const_reference operator()( size_type ) const; 
+        reference operator()( size_type );
+
+        operator T() const;
+
+        scalar& operator*=( T const& );
+        scalar& operator/=( T const& );
+        scalar& operator+=( T const& );
+        scalar& operator-=( T const& );
+
+        scalar& operator*=( scalar const& );
+        scalar& operator/=( scalar const& );
+        scalar& operator+=( scalar const& );
+        scalar& operator-=( scalar const& );
+
+        template< class E > scalar& operator*=( scalar_expression< E > const& );
+        template< class E > scalar& operator/=( scalar_expression< E > const& );
+        template< class E > scalar& operator+=( scalar_expression< E > const& );
+        template< class E > scalar& operator-=( scalar_expression< E > const& );
+
+        template< class U > 
+        bool const references( scalar< U > const& ) const;
+        template< class U, std::size_t Q, bool J, class B > 
+        bool const references( vector< U,Q,J,B > const& ) const;
+        template< class U, std::size_t P, std::size_t Q, bool J, class B > 
+        bool const references( matrix< U,P,Q,J,B > const& ) const;
+
+    private:
+
+        representation_type data;
+
+    public:
+
+        template< class T1, class C, class CT >
+        friend std::basic_ostream< C,CT >& operator<<( std::basic_ostream< C,CT >& o, scalar< T1 > const& );
+
+    };
+
+//--
+
+    template< class T >
+    scalar< T >::scalar() : data( T() )
+    {}
+
+    template< class T >
+    scalar< T >::scalar( scalar const& t ) : data( t.data )
+    {}
+
+    template< class T >
+    scalar< T >::scalar( T const& t ) : data( t )
+    {}
+
+    template< class T > template< class E >
+    scalar< T >::scalar( scalar_expression< E > const& e )
+    {
+        scalar_assign< type,E,scalar_scalar_assign< type,E >,E::linear >()( *this, e );
+    }
+
+    template< class T >
+    scalar< T >& scalar< T >::operator=( T const& t )
+    {
+        data = t;
+        return *this;
+    }
+
+    template< class T >
+    scalar< T >& scalar< T >::operator=( scalar const& t )
+    {
+        if( &t != this ) data = t.data;
+        return *this;
+    }
+
+    template< class T > template< class E >
+    scalar< T >& scalar< T >::operator=( scalar_expression< E > const& e )
+    {
+        scalar_assign< type,E,scalar_scalar_assign< type,E >,E::linear >()( *this, e );
+        return *this;
+    }
+
+    template< class T > template< size_t B > 
+    typename scalar< T >::size_type const scalar< T >::bound() const
+    {
+        BOOST_STATIC_ASSERT( B == 0 );
+        return 1;
+    } // bound
+
+    template< class T >
+    void scalar< T >::swap( scalar& o )
+    {
+        if( &o != this ) { T t = o.data; o.data = data; data = t; }
+    } // swap
+
+    template< class T >
+    typename scalar< T >::const_reference scalar< T >::operator[]( size_type s ) const
+    {
+        BOOST_ASSERT( s == 0 );
+        return data;
+    } // operator() const
+
+    template< class T >
+    typename scalar< T >::reference scalar< T >::operator[]( size_type s )
+    {
+        BOOST_ASSERT( s == 0 );
+        return data;
+    } // operator()
+
+    template< class T >
+    typename scalar< T >::const_reference scalar< T >::operator()( size_type s ) const
+    {
+        BOOST_ASSERT( s == 0 );
+        return data;
+    } // operator() const
+
+    template< class T >
+    typename scalar< T >::reference scalar< T >::operator()( size_type s )
+    {
+        BOOST_ASSERT( s == 0 );
+        return data;
+    } // operator()
+
+    template< class T >
+    scalar< T >::operator T() const
+    {
+        return data;
+    }
+
+    template< class T > 
+    scalar< T >& scalar< T >::operator*=( T const& t )
+    {
+        data *= t;
+        return *this;
+    } // operator*=
+
+    template< class T > 
+    scalar< T >& scalar< T >::operator/=( T const& t )
+    {
+        data /= t;
+        return *this;
+    } // operator/=
+
+    template< class T >
+    scalar< T >& scalar< T >::operator+=( T const& t )
+    {
+        data += t;
+        return *this;
+    } // operator+=
+
+    template< class T >
+    scalar< T >& scalar< T >::operator-=( T const& t )
+    {
+        data -= t;
+        return *this;
+    } // operator-=
+
+    template< class T > 
+    scalar< T >& scalar< T >::operator*=( scalar const& s )
+    {
+        data *= s.data;
+        return *this;
+    } // operator*=
+
+    template< class T > 
+    scalar< T >& scalar< T >::operator/=( scalar const& s )
+    {
+        data /= s.data;
+        return *this;
+    } // operator/=
+
+    template< class T >
+    scalar< T >& scalar< T >::operator+=( scalar const& s )
+    {
+        data += s.data;
+        return *this;
+    } // operator+=
+
+    template< class T >
+    scalar< T >& scalar< T >::operator-=( scalar const& s )
+    {
+        data -= s.data;
+        return *this;
+    } // operator-=
+
+    template< class T > template< class E > 
+    scalar< T >& scalar< T >::operator*=( scalar_expression< E > const& e )
+    {
+        data *= e()( 0 );
+        return *this;
+    } // operator*=
+
+    template< class T > template< class E > 
+    scalar< T >& scalar< T >::operator/=( scalar_expression< E > const& e )
+    {
+        data /= e()( 0 );
+        return *this;
+    } // operator/=
+
+    template< class T > template< class E >
+    scalar< T >& scalar< T >::operator+=( scalar_expression< E > const& e )
+    {
+        data += e()( 0 );
+        return *this;
+    } // operator+=
+
+    template< class T > template< class E >
+    scalar< T >& scalar< T >::operator-=( scalar_expression< E > const& e )
+    {
+        data -= e()( 0 );
+        return *this;
+    } // operator-=
+
+    template< class T > template< class U > 
+    bool const scalar< T >::references( scalar< U > const& s ) const
+    {
+        return ( reinterpret_cast< scalar< T > const* >( &s ) == this );
+    }
+
+    template< class T > template< class U, std::size_t Q, bool J, class B > 
+    bool const scalar< T >::references( vector< U,Q,J,B > const& ) const
+    {
+        return false;
+    }
+
+    template< class T > template< class U, std::size_t P, std::size_t Q, bool J, class B > 
+    bool const scalar< T >::references( matrix< U,P,Q,J,B > const& ) const
+    {
+        return false;
+    }
+
+//--
+//--
+
+    template< class T1, class C, class CT >
+    std::basic_ostream< C,CT >& operator<<( std::basic_ostream< C,CT >& o, scalar< T1 > const& s )
+    {
+        o << s.data;
+        return o;
+    }
+
+//--
+
+}} // namespace boost, namespace maps
+
+#endif // BOOST_MAPS_MATH_SCALAR_HPP
Added: sandbox/maps/boost/maps/math/scalar_matrix.hpp
==============================================================================
--- (empty file)
+++ sandbox/maps/boost/maps/math/scalar_matrix.hpp	2011-08-08 19:51:30 EDT (Mon, 08 Aug 2011)
@@ -0,0 +1,146 @@
+//--
+// Copyright (c) 2010-2011 Brian Smith
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/maps for documentation.
+//--
+#if !defined( BOOST_MAPS_MATH_SCALAR_MATRIX_HPP )
+#define BOOST_MAPS_MATH_SCALAR_MATRIX_HPP
+
+#include <boost/maps/math/scalar_scalar.hpp>
+#include <boost/maps/math/matrix_matrix.hpp>
+
+namespace boost { namespace maps {
+
+//--
+
+    template< class E, class O, bool L >
+    class scalar_matrix_unary_expression
+        : public scalar_expression< scalar_matrix_unary_expression< E,O,L > >
+    {
+    public:
+
+        typedef scalar_matrix_unary_expression type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef typename E::type_const_reference expression_const_reference;
+        typedef E expression_type;
+        typedef O operator_type;
+        typedef typename O::result_type result_type;
+        typedef result_type element_type;
+        typedef element_type const& const_reference;
+        typedef element_type& reference;
+        typedef typename operator_type::size_type size_type;
+        typedef typename operator_type::allocator_type allocator_type;
+
+        using scalar_expression< type >::operator();
+
+        enum { size = 1 };
+        enum { linear = ( L & E::linear ) };
+
+        scalar_matrix_unary_expression( E const& );
+        type_reference operator=( type_const_reference );
+
+        expression_type const& expression() const;
+
+        result_type const operator()( size_type ) const;
+
+        template< class U >
+        bool const references( scalar< U > const& ) const;
+        template< class U, std::size_t Q, bool J, class B >
+        bool const references( vector< U,Q,J,B > const& ) const;
+        template< class U, std::size_t P, std::size_t Q, bool J, class B >
+        bool const references( matrix< U,P,Q,J,B > const& ) const;
+
+    private:
+
+        expression_const_reference t;
+
+    };
+
+//--
+
+    template< class E, class O, bool L >
+    scalar_matrix_unary_expression< E,O,L >::scalar_matrix_unary_expression( E const& e )
+        : t( e )
+    {}
+
+    template< class E, class O, bool L >
+    typename scalar_matrix_unary_expression< E,O,L >::type_reference
+        scalar_matrix_unary_expression< E,O,L >::operator=( type_const_reference e )
+    {
+        if( &e != this ) t = e.t;
+        return *this;
+    }
+
+    template< class E, class O, bool L >
+    typename scalar_matrix_unary_expression< E,O,L >::expression_type const& 
+        scalar_matrix_unary_expression< E,O,L >::expression() const
+    {
+        return t;
+    }
+
+    template< class E, class O, bool L >
+    typename scalar_matrix_unary_expression< E,O,L >::result_type const 
+        scalar_matrix_unary_expression< E,O,L >::operator()( size_type s ) const
+    {
+        return operator_type()( t );
+    }
+
+    template< class E, class O, bool L > template< class U >
+    bool const scalar_matrix_unary_expression< E,O,L >::references( scalar< U > const& s ) const
+    {
+        return ( t().references( s ) );
+    }
+
+    template< class E, class O, bool L > template< class U, std::size_t Q, bool J, class B >
+    bool const scalar_matrix_unary_expression< E,O,L >::references( vector< U,Q,J,B > const& v ) const
+    {
+        return ( t().references( v ) );
+    }
+
+    template< class E, class O, bool L > template< class U, std::size_t P, std::size_t Q, bool J, class B >
+    bool const scalar_matrix_unary_expression< E,O,L >::references( matrix< U,P,Q,J,B > const& m ) const
+    {
+        return ( t().references( m ) );
+    }
+
+//--
+
+    template< class T >
+    struct matrix_norm_1
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::type_const_reference type_const_reference;
+        typedef typename expression_unary_traits< T >::size_type size_type;
+
+        result_type operator()( type_const_reference t )
+        {
+            result_type r = result_type();
+            for( size_type j = 0; j != t.cols; ++j )
+            {   result_type s = result_type();
+                for( size_type i = 0; i != t.rows; ++i )
+                    s += std::abs( t( i,j ) );
+                if( s > r ) r = s; 
+            }
+            return r;
+        }
+    };
+
+//--
+
+    template< class E, std::size_t M, std::size_t N >
+    scalar_matrix_unary_expression< E,matrix_norm_1< E >,true >
+    norm_1( matrix_expression< E,M,N > const& e )
+    {
+         return scalar_matrix_unary_expression< E,matrix_norm_1< E >,true >( e() );
+    }
+
+//--
+
+}} // namespace boost, namespace maps
+
+#endif // BOOST_MAPS_MATH_SCALAR_MATRIX_HPP
\ No newline at end of file
Added: sandbox/maps/boost/maps/math/scalar_scalar.hpp
==============================================================================
--- (empty file)
+++ sandbox/maps/boost/maps/math/scalar_scalar.hpp	2011-08-08 19:51:30 EDT (Mon, 08 Aug 2011)
@@ -0,0 +1,952 @@
+//--
+// Copyright (c) 2010-2011 Brian Smith
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/maps for documentation.
+//--
+#if !defined( BOOST_MAPS_MATH_SCALAR_SCALAR_HPP )
+#define BOOST_MAPS_MATH_SCALAR_SCALAR_HPP
+
+#include <boost/maps/support/expression.hpp>
+
+#include <boost/math/complex.hpp>
+
+namespace boost { namespace maps {
+
+//--
+
+    template< class E >
+    class scalar_expression
+        : expression< scalar_expression< E > >
+    {
+    public:
+
+        typedef scalar_expression type;
+        typedef E value_type;
+        typedef value_type const& const_reference;
+        typedef value_type& reference;
+
+        const_reference operator()() const
+        {
+            return *static_cast< value_type const* >( this );
+        }
+
+        reference operator()()
+        {
+            return *static_cast< value_type* >( this );
+        }
+
+    };
+
+//--
+
+    template< class E1, class E2, class O, bool L >
+    class scalar_binary_expression
+        : public scalar_expression< scalar_binary_expression< E1,E2,O,L > >
+    {
+    public:
+
+        typedef scalar_binary_expression type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef typename E1::type_const_reference expression1_const_reference;
+        typedef typename E2::type_const_reference expression2_const_reference;
+        typedef E1 expression_type1;
+        typedef E2 expression_type2;
+        typedef O operator_type;
+        typedef typename O::result_type result_type;
+        typedef result_type element_type;
+        typedef element_type const& const_reference;
+        typedef element_type& reference;
+        typedef typename operator_type::size_type size_type;
+        typedef typename operator_type::allocator_type allocator_type;
+
+        using scalar_expression< type >::operator();
+
+        enum { size = E1::size };
+        enum { linear = ( L & E1::linear & E2::linear ) };
+
+        scalar_binary_expression( E1 const&, E2 const& );
+        type_reference operator=( type_const_reference );
+
+        expression_type1 const& expression1() const;
+        expression_type2 const& expression2() const;
+
+        result_type const operator()( size_type ) const;
+
+        template< class U > 
+        bool const references( scalar< U > const& ) const;
+        template< class U, std::size_t Q, bool J, class B > 
+        bool const references( vector< U,Q,J,B > const& ) const;
+        template< class U, std::size_t P, std::size_t Q, bool J, class B > 
+        bool const references( matrix< U,P,Q,J,B > const& ) const;
+
+    private:
+
+        expression1_const_reference t1;
+        expression2_const_reference t2;
+
+    };
+
+//--
+
+    template< class E1, class E2, class O, bool L >
+    scalar_binary_expression< E1,E2,O,L >::scalar_binary_expression( E1 const& e1, E2 const& e2 )
+        : t1( e1 ), t2( e2 )
+    {}
+
+    template< class E1, class E2, class O, bool L >
+    typename scalar_binary_expression< E1,E2,O,L >::type_reference
+        scalar_binary_expression< E1,E2,O,L >::operator=( type_const_reference e )
+    {
+        if( &e != this ) { t1 = e.t1; t2 = e.t2; }
+        return *this;
+    }
+
+    template< class E1, class E2, class O, bool L >
+    typename scalar_binary_expression< E1,E2,O,L >::expression_type1 const& 
+        scalar_binary_expression< E1,E2,O,L >::expression1() const
+    {
+        return t1;
+    }
+
+    template< class E1, class E2, class O, bool L >
+    typename scalar_binary_expression< E1,E2,O,L >::expression_type2 const& 
+        scalar_binary_expression< E1,E2,O,L >::expression2() const
+    {
+        return t2;
+    }
+
+    template< class E1, class E2, class O, bool L >
+    typename scalar_binary_expression< E1,E2,O,L >::result_type const 
+        scalar_binary_expression< E1,E2,O,L >::operator()( size_type s ) const
+    {
+        return operator_type()( t1( s ), t2( s ) );
+    }
+
+    template< class E1, class E2, class O, bool L > template< class U >
+    bool const scalar_binary_expression< E1,E2,O,L >::references( scalar< U > const& s ) const
+    {
+        return ( t1().references( s ) || t2().references( s ) );
+    }
+
+    template< class E1, class E2, class O, bool L > template< class U, std::size_t Q, bool J, class B >
+    bool const scalar_binary_expression< E1,E2,O,L >::references( vector< U,Q,J,B > const& v ) const
+    {
+        return ( t1().references( v ) || t2().references( v ) );
+    }
+
+    template< class E1, class E2, class O, bool L > template< class U, std::size_t P, std::size_t Q, bool J, class B >
+    bool const scalar_binary_expression< E1,E2,O,L >::references( matrix< U,P,Q,J,B > const& m ) const
+    {
+        return ( t1().references( m ) || t2().references( m ) );
+    }
+
+//--
+//--
+
+    template< class T1, class T2 >
+    struct scalar_scalar_product
+        : expression_binary_traits< T1,T2 >
+    {
+        typedef typename expression_binary_traits< T1,T2 >::result_type result_type;
+        typedef typename expression_binary_traits< T1,T2 >::const_reference1 const_reference1;
+        typedef typename expression_binary_traits< T1,T2 >::const_reference2 const_reference2;
+
+        result_type operator()( const_reference1 t1, const_reference2 t2 )
+        {
+            return t1 * t2;
+        }
+    };
+
+    template< class T1, class T2 >
+    struct scalar_scalar_division
+        : expression_binary_traits< T1,T2 >
+    {
+        typedef typename expression_binary_traits< T1,T2 >::result_type result_type;
+        typedef typename expression_binary_traits< T1,T2 >::const_reference1 const_reference1;
+        typedef typename expression_binary_traits< T1,T2 >::const_reference2 const_reference2;
+
+        result_type operator()( const_reference1 t1, const_reference2 t2 )
+        {
+            return t1 / t2;
+        }
+    };
+
+    template< class T1, class T2 >
+    struct scalar_scalar_addition
+        : expression_binary_traits< T1,T2 >
+    {
+        typedef typename expression_binary_traits< T1,T2 >::result_type result_type;
+        typedef typename expression_binary_traits< T1,T2 >::const_reference1 const_reference1;
+        typedef typename expression_binary_traits< T1,T2 >::const_reference2 const_reference2;
+
+        result_type operator()( const_reference1 t1, const_reference2 t2 )
+        {
+            return t1 + t2;
+        }
+    };
+
+    template< class T1, class T2 >
+    struct scalar_scalar_subtraction
+        : expression_binary_traits< T1,T2 >
+    {
+        typedef typename expression_binary_traits< T1,T2 >::result_type result_type;
+        typedef typename expression_binary_traits< T1,T2 >::const_reference1 const_reference1;
+        typedef typename expression_binary_traits< T1,T2 >::const_reference2 const_reference2;
+
+        result_type operator()( const_reference1 t1, const_reference2 t2 )
+        {
+            return t1 - t2;
+        }
+    };
+
+//--
+
+    template< class E1, class E2 >
+    scalar_binary_expression< E1,E2,scalar_scalar_product< E1,E2 >,true >
+    operator*( scalar_expression< E1 > const& e1, scalar_expression< E2 > const& e2 )
+    {
+        return scalar_binary_expression< E1,E2, 
+            scalar_scalar_product< E1,E2 >,true >( e1(), e2() );
+    }
+
+    template< class E1, class E2 >
+    scalar_binary_expression< E1,E2,scalar_scalar_division< E1,E2 >,true >
+    operator/( scalar_expression< E1 > const& e1, scalar_expression< E2 > const& e2 )
+    {
+        return scalar_binary_expression< E1,E2, 
+            scalar_scalar_division< E1,E2 >,true >( e1(), e2() );
+    }
+
+    template< class E1, class E2 >
+    scalar_binary_expression< E1,E2,scalar_scalar_addition< E1,E2 >,true >
+    operator+( scalar_expression< E1 > const& e1, scalar_expression< E2 > const& e2 )
+    {
+        return scalar_binary_expression< E1,E2, 
+            scalar_scalar_addition< E1,E2 >,true >( e1(), e2() );
+    }
+
+    template< class E1, class E2 >
+    scalar_binary_expression< E1,E2,scalar_scalar_subtraction< E1,E2 >,true >
+    operator-( scalar_expression< E1 > const& e1, scalar_expression< E2 > const& e2 )
+    {
+        return scalar_binary_expression< E1,E2, 
+            scalar_scalar_subtraction< E1,E2 >,true >( e1(), e2() );
+    }
+
+//--
+
+    template< class T1, class T2 >
+    struct scalar_scalar_assign
+        : expression_binary_traits< T1,T2 >
+    {
+        typedef typename expression_binary_traits< T1,T2 >::reference1 reference1;
+        typedef typename expression_binary_traits< T1,T2 >::const_reference2 const_reference2;
+
+        void operator()( reference1 t1, const_reference2 t2 )
+        {
+            t1 = t2;
+        }
+    };
+
+//--
+
+    template< class T, class E, class O, bool L >
+    struct scalar_assign
+    {
+        typedef T& reference;
+        typedef scalar_expression< E > const& expression_const_reference;
+        typedef O operator_type;
+
+        void operator()( reference s, expression_const_reference e )
+        {
+            operator_type()( s( 0 ), e()( 0 ) );
+        }
+    };
+
+//--
+//--
+
+    template< class E, class O, bool L >
+    class scalar_unary_expression
+        : public scalar_expression< scalar_unary_expression< E,O,L > >
+    {
+    public:
+
+        typedef scalar_unary_expression type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef typename E::type_const_reference expression_const_reference;
+        typedef E expression_type;
+        typedef O operator_type;
+        typedef typename O::result_type result_type;
+        typedef result_type element_type;
+        typedef element_type const& const_reference;
+        typedef element_type& reference;
+        typedef typename operator_type::size_type size_type;
+        typedef typename operator_type::allocator_type allocator_type;
+
+        using scalar_expression< type >::operator();
+
+        enum { size = E::size };
+        enum { linear = ( L & E::linear ) };
+
+        scalar_unary_expression( E const& );
+
+        expression_type const& expression() const;
+
+        result_type const operator()( size_type ) const;
+
+        template< class U >
+        bool const references( scalar< U > const& ) const;
+        template< class U, std::size_t Q, bool J, class B >
+        bool const references( vector< U,Q,J,B > const& ) const;
+        template< class U, std::size_t P, std::size_t Q, bool J, class B >
+        bool const references( matrix< U,P,Q,J,B > const& ) const;
+
+    private:
+
+        expression_const_reference t;
+
+    };
+
+//--
+
+    template< class E, class O, bool L >
+    scalar_unary_expression< E,O,L >::scalar_unary_expression( E const& e )
+        : t( e )
+    {}
+
+    template< class E, class O, bool L >
+    typename scalar_unary_expression< E,O,L >::expression_type const& 
+        scalar_unary_expression< E,O,L >::expression() const
+    {
+        return t;
+    }
+
+    template< class E, class O, bool L >
+    typename scalar_unary_expression< E,O,L >::result_type const 
+        scalar_unary_expression< E,O,L >::operator()( size_type s ) const
+    {
+        return operator_type()( t( s ) );
+    }
+
+    template< class E, class O, bool L > template< class U >
+    bool const scalar_unary_expression< E,O,L >::references( scalar< U > const& s ) const
+    {
+        return ( t().references( s ) );
+    }
+
+    template< class E, class O, bool L > template< class U, std::size_t Q, bool J, class B >
+    bool const scalar_unary_expression< E,O,L >::references( vector< U,Q,J,B > const& v ) const
+    {
+        return ( t().references( v ) );
+    }
+
+    template< class E, class O, bool L > template< class U, std::size_t P, std::size_t Q, bool J, class B >
+    bool const scalar_unary_expression< E,O,L >::references( matrix< U,P,Q,J,B > const& m ) const
+    {
+        return ( t().references( m ) );
+    }
+
+//--
+//--
+
+    template< class T >
+    struct scalar_negate
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+
+        result_type operator()( const_reference t )
+        {
+            return -t;
+        }
+    };
+
+    template< class T >
+    struct scalar_sin
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+
+        result_type operator()( const_reference t )
+        {
+            return std::sin( t );
+        }
+    };
+
+    template< class T >
+    struct scalar_cos
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+
+        result_type operator()( const_reference t )
+        {
+            return std::cos( t );
+        }
+    };
+
+    template< class T >
+    struct scalar_tan
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+
+        result_type operator()( const_reference t )
+        {
+            return std::tan( t );
+        }
+    };
+
+    template< class T >
+    struct scalar_cosec
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+
+        result_type operator()( const_reference t )
+        {
+            return T(1) / std::sin( t );
+        }
+    };
+
+    template< class T >
+    struct scalar_sec
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+
+        result_type operator()( const_reference t )
+        {
+            return T(1) / std::cos( t );
+        }
+    };
+
+    template< class T >
+    struct scalar_cot
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+
+        result_type operator()( const_reference t )
+        {
+            return T(1) / std::tan( t );
+        }
+    };
+
+    template< class T >
+    struct scalar_sinh
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+
+        result_type operator()( const_reference t )
+        {
+            return std::sinh( t );
+        }
+    };
+
+    template< class T >
+    struct scalar_cosh
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+
+        result_type operator()( const_reference t )
+        {
+            return std::cosh( t );
+        }
+    };
+
+    template< class T >
+    struct scalar_tanh
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+
+        result_type operator()( const_reference t )
+        {
+            return std::tanh( t );
+        }
+    };
+
+    template< class T >
+    struct scalar_cosech
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+
+        result_type operator()( const_reference t )
+        {
+            return T(1) / std::sinh( t );
+        }
+    };
+
+    template< class T >
+    struct scalar_sech
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+
+        result_type operator()( const_reference t )
+        {
+            return T(1) / std::cosh( t );
+        }
+    };
+
+    template< class T >
+    struct scalar_coth
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+
+        result_type operator()( const_reference t )
+        {
+            return T(1) / std::tanh( t );
+        }
+    };
+
+    template< class T >
+    struct scalar_asin
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+
+        result_type operator()( const_reference t )
+        {
+            return std::asin( t );
+        }
+    };
+
+    template< class T >
+    struct scalar_asin< std::complex< T > >
+        : expression_unary_traits< std::complex< T > >
+    {
+        typedef typename expression_unary_traits< std::complex< T > >::result_type result_type;
+        typedef typename expression_unary_traits< std::complex< T > >::const_reference const_reference;
+
+        result_type operator()( const_reference t )
+        {
+            return math::asin( t );
+        }
+    };
+
+    template< class T >
+    struct scalar_acos
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+
+        result_type operator()( const_reference t )
+        {
+            return std::acos( t );
+        }
+    };
+
+    template< class T >
+    struct scalar_acos< std::complex< T > >
+        : expression_unary_traits< std::complex< T > >
+    {
+        typedef typename expression_unary_traits< std::complex< T > >::result_type result_type;
+        typedef typename expression_unary_traits< std::complex< T > >::const_reference const_reference;
+
+        result_type operator()( const_reference t )
+        {
+            return math::acos( t );
+        }
+    };
+
+    template< class T >
+    struct scalar_atan
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+
+        result_type operator()( const_reference t )
+        {
+            return std::atan( t );
+        }
+    };
+
+    template< class T >
+    struct scalar_atan< std::complex< T > >
+        : expression_unary_traits< std::complex< T > >
+    {
+        typedef typename expression_unary_traits< std::complex< T > >::result_type result_type;
+        typedef typename expression_unary_traits< std::complex< T > >::const_reference const_reference;
+
+        result_type operator()( const_reference t )
+        {
+            return math::atan( t );
+        }
+    };
+
+    template< class T >
+    struct scalar_asinh
+        : expression_unary_traits< T >
+    {};
+
+    template< class T >
+    struct scalar_acosh
+        : expression_unary_traits< T >
+    {};
+
+    template< class T >
+    struct scalar_atanh
+        : expression_unary_traits< T >
+    {};
+
+    template< class T >
+    struct scalar_asinh< std::complex< T > >
+        : expression_unary_traits< std::complex< T > >
+    {
+        typedef typename expression_unary_traits< std::complex< T > >::result_type result_type;
+        typedef typename expression_unary_traits< std::complex< T > >::const_reference const_reference;
+
+        result_type operator()( const_reference t )
+        {
+            return math::asinh( t );
+        }
+    };
+
+    template< class T >
+    struct scalar_acosh< std::complex< T > >
+        : expression_unary_traits< std::complex< T > >
+    {
+        typedef typename expression_unary_traits< std::complex< T > >::result_type result_type;
+        typedef typename expression_unary_traits< std::complex< T > >::const_reference const_reference;
+
+        result_type operator()( const_reference t )
+        {
+            return math::acosh( t );
+        }
+    };
+
+    template< class T >
+    struct scalar_atanh< std::complex< T > >
+        : expression_unary_traits< std::complex< T > >
+    {
+        typedef typename expression_unary_traits< std::complex< T > >::result_type result_type;
+        typedef typename expression_unary_traits< std::complex< T > >::const_reference const_reference;
+
+        result_type operator()( const_reference t )
+        {
+            return math::atanh( t );
+        }
+    };
+
+    template< class T >
+    struct scalar_exp
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+
+        result_type operator()( const_reference t )
+        {
+            return std::exp( t );
+        }
+    };
+
+    template< class T >
+    struct scalar_log
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+
+        result_type operator()( const_reference t )
+        {
+            return std::log( t );
+        }
+    };
+
+    template< class T >
+    struct scalar_log10
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+
+        result_type operator()( const_reference t )
+        {
+            return std::log10( t );
+        }
+    };
+
+    template< class T >
+    struct scalar_sqrt
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+
+        result_type operator()( const_reference t )
+        {
+            return std::sqrt( t );
+        }
+    };
+
+    template< class T >
+    struct scalar_sqr
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+
+        result_type operator()( const_reference t )
+        {
+            return t * t;
+        }
+    };
+
+    template< class T >
+    struct scalar_abs
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+
+        result_type operator()( const_reference t )
+        {
+            return std::abs( t );
+        }
+    };
+
+    template< class T >
+    struct scalar_fabs
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::const_reference const_reference;
+
+        result_type operator()( const_reference t )
+        {
+            return std::fabs( t );
+        }
+    };
+
+    template< class T >
+    struct scalar_fabs< std::complex< T > >
+        : expression_unary_traits< std::complex< T > >
+    {
+        typedef typename expression_unary_traits< std::complex< T > >::result_type result_type;
+        typedef typename expression_unary_traits< std::complex< T > >::const_reference const_reference;
+
+        result_type operator()( const_reference t )
+        {
+            return math::fabs( t );
+        }
+    };
+
+//--
+//--
+
+    template< class E >
+    scalar_unary_expression< E,scalar_negate< E >,true >
+    operator-( scalar_expression< E > const& e )
+    {
+        return scalar_unary_expression< E,scalar_negate< E >,true >( e() );
+    }
+
+    template< class E >
+    scalar_unary_expression< E,scalar_sin< E >,true >
+    sin( scalar_expression< E > const& e )
+    {
+        return scalar_unary_expression< E,scalar_sin< E >,true >( e() );
+    }
+
+    template< class E >
+    scalar_unary_expression< E,scalar_cos< E >,true >
+    cos( scalar_expression< E > const& e )
+    {
+        return scalar_unary_expression< E,scalar_cos< E >,true >( e() );
+    }
+
+    template< class E >
+    scalar_unary_expression< E,scalar_tan< E >,true >
+    tan( scalar_expression< E > const& e )
+    {
+        return scalar_unary_expression< E,scalar_tan< E >,true >( e() );
+    }
+
+    template< class E >
+    scalar_unary_expression< E,scalar_cosec< E >,true >
+    cosec( scalar_expression< E > const& e )
+    {
+        return scalar_unary_expression< E,scalar_cosec< E >,true >( e() );
+    }
+
+    template< class E >
+    scalar_unary_expression< E,scalar_sec< E >,true >
+    sec( scalar_expression< E > const& e )
+    {
+        return scalar_unary_expression< E,scalar_sec< E >,true >( e() );
+    }
+
+    template< class E >
+    scalar_unary_expression< E,scalar_cot< E >,true >
+    cot( scalar_expression< E > const& e )
+    {
+        return scalar_unary_expression< E,scalar_cot< E >,true >( e() );
+    }
+
+    template< class E >
+    scalar_unary_expression< E,scalar_sinh< E >,true >
+    sinh( scalar_expression< E > const& e )
+    {
+        return scalar_unary_expression< E,scalar_sinh< E >,true >( e() );
+    }
+
+    template< class E >
+    scalar_unary_expression< E,scalar_cosh< E >,true >
+    cosh( scalar_expression< E > const& e )
+    {
+        return scalar_unary_expression< E,scalar_cosh< E >,true >( e() );
+    }
+
+    template< class E >
+    scalar_unary_expression< E,scalar_tanh< E >,true >
+    tanh( scalar_expression< E > const& e )
+    {
+        return scalar_unary_expression< E,scalar_tanh< E >,true >( e() );
+    }
+
+    template< class E >
+    scalar_unary_expression< E,scalar_cosech< E >,true >
+    cosech( scalar_expression< E > const& e )
+    {
+        return scalar_unary_expression< E,scalar_cosech< E >,true >( e() );
+    }
+
+    template< class E >
+    scalar_unary_expression< E,scalar_sech< E >,true >
+    sech( scalar_expression< E > const& e )
+    {
+        return scalar_unary_expression< E,scalar_sech< E >,true >( e() );
+    }
+
+    template< class E >
+    scalar_unary_expression< E,scalar_coth< E >,true >
+    coth( scalar_expression< E > const& e )
+    {
+        return scalar_unary_expression< E,scalar_coth< E >,true >( e() );
+    }
+
+    template< class E >
+    scalar_unary_expression< E,scalar_asin< E >,true >
+    asin( scalar_expression< E > const& e )
+    {
+        return scalar_unary_expression< E,scalar_asin< E >,true >( e() );
+    }
+
+    template< class E >
+    scalar_unary_expression< E,scalar_acos< E >,true >
+    acos( scalar_expression< E > const& e )
+    {
+        return scalar_unary_expression< E,scalar_acos< E >,true >( e() );
+    }
+
+    template< class E >
+    scalar_unary_expression< E,scalar_atan< E >,true >
+    atan( scalar_expression< E > const& e )
+    {
+        return scalar_unary_expression< E,scalar_atan< E >,true >( e() );
+    }
+
+    template< class E >
+    scalar_unary_expression< E,scalar_asinh< E >,true >
+    asinh( scalar_expression< E > const& e )
+    {
+        return scalar_unary_expression< E,scalar_asinh< E >,true >( e() );
+    }
+
+    template< class E >
+    scalar_unary_expression< E,scalar_acosh< E >,true >
+    acosh( scalar_expression< E > const& e )
+    {
+        return scalar_unary_expression< E,scalar_acosh< E >,true >( e() );
+    }
+
+    template< class E >
+    scalar_unary_expression< E,scalar_atanh< E >,true >
+    atanh( scalar_expression< E > const& e )
+    {
+        return scalar_unary_expression< E,scalar_atanh< E >,true >( e() );
+    }
+
+    template< class E >
+    scalar_unary_expression< E,scalar_exp< E >,true >
+    exp( scalar_expression< E > const& e )
+    {
+        return scalar_unary_expression< E,scalar_exp< E >,true >( e() );
+    }
+
+    template< class E >
+    scalar_unary_expression< E,scalar_log< E >,true >
+    log( scalar_expression< E > const& e )
+    {
+        return scalar_unary_expression< E,scalar_log< E >,true >( e() );
+    }
+
+    template< class E >
+    scalar_unary_expression< E,scalar_log10< E >,true >
+    log10( scalar_expression< E > const& e )
+    {
+        return scalar_unary_expression< E,scalar_log10< E >,true >( e() );
+    }
+
+    template< class E >
+    scalar_unary_expression< E,scalar_sqrt< E >,true >
+    sqrt( scalar_expression< E > const& e )
+    {
+        return scalar_unary_expression< E,scalar_sqrt< E >,true >( e() );
+    }
+
+    template< class E >
+    scalar_unary_expression< E,scalar_sqr< E >,true >
+    sqr( scalar_expression< E > const& e )
+    {
+        return scalar_unary_expression< E,scalar_sqr< E >,true >( e() );
+    }
+
+    template< class E >
+    scalar_unary_expression< E,scalar_abs< E >,true >
+    abs( scalar_expression< E > const& e )
+    {
+        return scalar_unary_expression< E,scalar_abs< E >,true >( e() );
+    }
+
+    template< class E >
+    scalar_unary_expression< E,scalar_fabs< E >,true >
+    fabs( scalar_expression< E > const& e )
+    {
+        return scalar_unary_expression< E,scalar_fabs< E >,true >( e() );
+    }
+
+//--
+
+}} // namespace boost, namespace maps
+
+#endif // BOOST_MAPS_MATH_SCALAR_SCALAR_HPP
\ No newline at end of file
Added: sandbox/maps/boost/maps/math/scalar_vector.hpp
==============================================================================
--- (empty file)
+++ sandbox/maps/boost/maps/math/scalar_vector.hpp	2011-08-08 19:51:30 EDT (Mon, 08 Aug 2011)
@@ -0,0 +1,307 @@
+//--
+// Copyright (c) 2010-2011 Brian Smith
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/maps for documentation.
+//--
+#if !defined( BOOST_MAPS_MATH_SCALAR_VECTOR_HPP )
+#define BOOST_MAPS_MATH_SCALAR_VECTOR_HPP
+
+#include <boost/maps/math/scalar_scalar.hpp>
+#include <boost/maps/math/vector_vector.hpp>
+
+namespace boost { namespace maps {
+
+//--
+
+    template< class E1, class E2, class O, bool L >
+    class scalar_vector_binary_expression
+        : public scalar_expression< scalar_vector_binary_expression< E1,E2,O,L > >
+    {
+    public:
+
+        typedef scalar_vector_binary_expression type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef typename E1::type_const_reference expression1_const_reference;
+        typedef typename E2::type_const_reference expression2_const_reference;
+        typedef E1 expression_type1;
+        typedef E2 expression_type2;
+        typedef O operator_type;
+        typedef typename O::result_type result_type;
+        typedef result_type element_type;
+        typedef element_type const& const_reference;
+        typedef element_type& reference;
+        typedef typename operator_type::size_type size_type;
+        typedef typename operator_type::allocator_type allocator_type;
+
+        using scalar_expression< type >::operator();
+
+        enum { size = 1 };
+        enum { linear = ( L & E1::linear & E2::linear ) };
+
+        scalar_vector_binary_expression( E1 const&, E2 const& );
+        type_reference operator=( type_const_reference );
+
+        expression_type1 const& expression1() const;
+        expression_type2 const& expression2() const;
+
+        result_type const operator()( size_type ) const;
+
+        template< class U > 
+        bool const references( scalar< U > const& ) const;
+        template< class U, std::size_t Q, bool J, class B > 
+        bool const references( vector< U,Q,J,B > const& ) const;
+        template< class U, std::size_t P, std::size_t Q, bool J, class B > 
+        bool const references( matrix< U,P,Q,J,B > const& ) const;
+
+    private:
+
+        expression1_const_reference t1;
+        expression2_const_reference t2;
+
+    };
+
+//--
+
+    template< class E1, class E2, class O, bool L >
+    scalar_vector_binary_expression< E1,E2,O,L >::scalar_vector_binary_expression( E1 const& e1, E2 const& e2 )
+        : t1( e1 ), t2( e2 )
+    {}
+
+    template< class E1, class E2, class O, bool L >
+    typename scalar_vector_binary_expression< E1,E2,O,L >::type_reference
+        scalar_vector_binary_expression< E1,E2,O,L >::operator=( type_const_reference e )
+    {
+        if( &e != this ) { t1 = e.t1; t2 = e.t2; }
+        return *this;
+    }
+
+    template< class E1, class E2, class O, bool L >
+    typename scalar_vector_binary_expression< E1,E2,O,L >::expression_type1 const& 
+        scalar_vector_binary_expression< E1,E2,O,L >::expression1() const
+    {
+        return t1;
+    }
+
+    template< class E1, class E2, class O, bool L >
+    typename scalar_vector_binary_expression< E1,E2,O,L >::expression_type2 const& 
+        scalar_vector_binary_expression< E1,E2,O,L >::expression2() const
+    {
+        return t2;
+    }
+
+    template< class E1, class E2, class O, bool L >
+    typename scalar_vector_binary_expression< E1,E2,O,L >::result_type const 
+        scalar_vector_binary_expression< E1,E2,O,L >::operator()( size_type ) const
+    {
+        return operator_type()( t1, t2 );
+    }
+
+    template< class E1, class E2, class O, bool L > template< class U >
+    bool const scalar_vector_binary_expression< E1,E2,O,L >::references( scalar< U > const& s ) const
+    {
+        return ( t1().references( s ) || t2().references( s ) );
+    }
+
+    template< class E1, class E2, class O, bool L > template< class U, std::size_t Q, bool J, class B >
+    bool const scalar_vector_binary_expression< E1,E2,O,L >::references( vector< U,Q,J,B > const& v ) const
+    {
+        return ( t1().references( v ) || t2().references( v ) );
+    }
+
+    template< class E1, class E2, class O, bool L > template< class U, std::size_t P, std::size_t Q, bool J, class B >
+    bool const scalar_vector_binary_expression< E1,E2,O,L >::references( matrix< U,P,Q,J,B > const& m ) const
+    {
+        return ( t1().references( m ) || t2().references( m ) );
+    }
+
+//--
+//--
+
+    template< class T1, class T2 >
+    struct scalar_vector_inner_product
+        : expression_binary_traits< T1,T2 >
+    {
+        typedef typename expression_binary_traits< T1,T2 >::result_type result_type;
+        typedef typename expression_binary_traits< T1,T2 >::type_const_reference1 type_const_reference1;
+        typedef typename expression_binary_traits< T1,T2 >::type_const_reference2 type_const_reference2;
+        typedef typename expression_binary_traits< T1,T2 >::size_type size_type;
+
+        result_type operator()( type_const_reference1 t1, type_const_reference2 t2 )
+        {
+            result_type r = result_type();
+            for( size_type k = 0; k != t1.size; ++k )
+                r += t1( k ) * t2( k );
+            return r;
+        }
+    };
+
+//--
+
+    /*
+        vector inner product
+        < x,y > = sum( i = 1 to N ) x( i ).y( i )
+        or < x,y > = ||x||.||y||.cos( t ), t = angle between x and y
+        x, y orthogonal if < x,y > = 0
+        < x,x > = 0 iff x = 0
+    */
+
+    template< class E1, class E2, std::size_t N >
+    scalar_vector_binary_expression< E1,E2,scalar_vector_inner_product< E1,E2 >,true >
+    inner_product( vector_expression< E1,N > const& e1, vector_expression< E2,N > const& e2 )
+    {
+        return scalar_vector_binary_expression< E1,E2, 
+            scalar_vector_inner_product< E1,E2 >,true >( e1(), e2() );
+    }
+
+//--
+//--
+
+    template< class E, class O, bool L >
+    class scalar_vector_unary_expression
+        : public scalar_expression< scalar_vector_unary_expression< E,O,L > >
+    {
+    public:
+
+        typedef scalar_vector_unary_expression type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef typename E::type_const_reference expression_const_reference;
+        typedef E expression_type;
+        typedef O operator_type;
+        typedef typename O::result_type result_type;
+        typedef result_type element_type;
+        typedef element_type const& const_reference;
+        typedef element_type& reference;
+        typedef typename operator_type::size_type size_type;
+        typedef typename operator_type::allocator_type allocator_type;
+
+        using scalar_expression< type >::operator();
+
+        enum { size = 1 };
+        enum { linear = ( L & E::linear ) };
+
+        scalar_vector_unary_expression( E const& );
+        type_reference operator=( type_const_reference );
+
+        expression_type const& expression() const;
+
+        result_type const operator()( size_type ) const;
+
+        template< class U >
+        bool const references( scalar< U > const& ) const;
+        template< class U, std::size_t Q, bool J, class B >
+        bool const references( vector< U,Q,J,B > const& ) const;
+        template< class U, std::size_t P, std::size_t Q, bool J, class B >
+        bool const references( matrix< U,P,Q,J,B > const& ) const;
+
+    private:
+
+        expression_const_reference t;
+
+    };
+
+//--
+
+    template< class E, class O, bool L >
+    scalar_vector_unary_expression< E,O,L >::scalar_vector_unary_expression( E const& e )
+        : t( e )
+    {}
+
+    template< class E, class O, bool L >
+    typename scalar_vector_unary_expression< E,O,L >::type_reference
+        scalar_vector_unary_expression< E,O,L >::operator=( type_const_reference e )
+    {
+        if( &e != this ) t = e.t;
+        return *this;
+    }
+
+    template< class E, class O, bool L >
+    typename scalar_vector_unary_expression< E,O,L >::expression_type const& 
+        scalar_vector_unary_expression< E,O,L >::expression() const
+    {
+        return t;
+    }
+
+    template< class E, class O, bool L >
+    typename scalar_vector_unary_expression< E,O,L >::result_type const 
+        scalar_vector_unary_expression< E,O,L >::operator()( size_type s ) const
+    {
+        return operator_type()( t );
+    }
+
+    template< class E, class O, bool L > template< class U >
+    bool const scalar_vector_unary_expression< E,O,L >::references( scalar< U > const& s ) const
+    {
+        return ( t().references( s ) );
+    }
+
+    template< class E, class O, bool L > template< class U, std::size_t Q, bool J, class B >
+    bool const scalar_vector_unary_expression< E,O,L >::references( vector< U,Q,J,B > const& v ) const
+    {
+        return ( t().references( v ) );
+    }
+
+    template< class E, class O, bool L > template< class U, std::size_t P, std::size_t Q, bool J, class B >
+    bool const scalar_vector_unary_expression< E,O,L >::references( matrix< U,P,Q,J,B > const& m ) const
+    {
+        return ( t().references( m ) );
+    }
+
+//--
+//--
+
+    template< class T >
+    struct scalar_vector_euclidean_norm
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::type_const_reference type_const_reference;
+        typedef typename expression_unary_traits< T >::size_type size_type;
+
+        result_type operator()( type_const_reference t )
+        {
+            result_type r = result_type();
+            for( size_type k = 0; k != t.size; ++k )
+                r += t( k ) * t( k );
+            return r;
+        }
+    };
+
+    template< class T >
+    struct scalar_vector_magnitude
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::type_const_reference type_const_reference;
+
+        result_type operator()( type_const_reference t )
+        {
+            return std::sqrt( scalar_vector_euclidean_norm< T >()( t ) );
+        }
+    };
+
+//--
+
+    template< class E, std::size_t N >
+    scalar_vector_unary_expression< E,scalar_vector_euclidean_norm< E >,false >
+    euclidean_norm( vector_expression< E,N > const& e )
+    {
+        return scalar_vector_unary_expression< E,scalar_vector_euclidean_norm< E >,false >( e() );
+    }
+
+    template< class E, std::size_t N >
+    scalar_vector_unary_expression< E,scalar_vector_magnitude< E >,false >
+    magnitude( vector_expression< E,N > const& e )
+    {
+        return scalar_vector_unary_expression< E,scalar_vector_magnitude< E >,false >( e() );
+    }
+
+//--
+
+}} // namespace boost, namespace maps
+
+#endif // BOOST_MAPS_MATH_SCALAR_VECTOR_HPP
\ No newline at end of file
Added: sandbox/maps/boost/maps/math/vector.hpp
==============================================================================
--- (empty file)
+++ sandbox/maps/boost/maps/math/vector.hpp	2011-08-08 19:51:30 EDT (Mon, 08 Aug 2011)
@@ -0,0 +1,405 @@
+//--
+// Copyright (c) 2010-2011 Brian Smith
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/maps for documentation.
+//--
+#if !defined( BOOST_MAPS_MATH_VECTOR_HPP )
+#define BOOST_MAPS_MATH_VECTOR_HPP
+
+#include <boost/maps/support/math.hpp>
+#include <boost/maps/math/vector_vector.hpp>
+#include <boost/maps/math/vector_matrix.hpp>
+#include <boost/maps/math/vector_scalar.hpp>
+
+namespace boost { namespace maps {
+
+//--
+
+    template< class T, std::size_t N, bool I, class A, std::size_t K >
+    struct vector_equality
+    {
+        typedef typename vector< T,N,I,A >::const_iterator const_iterator;
+
+        bool operator()( const_iterator x, const_iterator y )
+        {
+            if( *x != *y ) return false;
+            else return vector_equality< T,N,I,A,K-1 >()( x+1, y+1 );
+        }
+    };
+
+    template< class T, std::size_t N, bool I, class A >
+    struct vector_equality< T,N,I,A,1 >
+    {
+        typedef typename vector< T,N,I,A >::const_iterator const_iterator;
+
+        bool operator()( const_iterator x, const_iterator y )
+        {
+            if( *x != *y ) return false;
+            else return true;
+        }
+    };
+
+//--
+
+    /*
+        fixed size vector class template
+
+        parameters
+
+            required
+
+                T - data type we wish to store
+                    type: arbitrary type
+                N - number of components
+                    type: std::size_t
+
+            optional
+
+                I - initialization parameter 
+                    type: bool 
+                    default: true, data elements zero/default initialized
+                A - allocator 
+                    type: standard conforming allocator, or null::allocator
+                    default: null::allocator, statically allocated array
+    */
+
+    template< class T, std::size_t N, bool I, class A >
+    class vector
+        : public vector_expression< vector< T,N,I,A >, N >
+    {
+    public:
+
+        typedef vector type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef type const* type_const_pointer;
+        typedef type* type_pointer;
+        typedef vector_expression< type,N > base_type;
+        typedef typename vector_type< T,N,I,A >::type representation_type;
+        typedef typename representation_type::value_type value_type;
+        typedef typename representation_type::const_reference_type const_reference_type;
+        typedef typename representation_type::reference_type reference_type;
+        typedef typename representation_type::element_type element_type;
+        typedef typename representation_type::const_reference const_reference;
+        typedef typename representation_type::reference reference;
+        typedef typename representation_type::size_type size_type;
+        typedef typename representation_type::difference_type difference_type;
+        typedef typename representation_type::const_iterator const_iterator;
+        typedef typename representation_type::iterator iterator;
+        typedef A allocator_type;
+        typedef mpl::size_t< 1 > dimensionality;
+        typedef mpl::bool_< I > initialize;
+
+        using vector_expression< type,N >::operator();
+
+        enum { size = N };
+        enum { linear = true };
+
+    protected:
+
+        typedef assigner< type,N-1 > assigner_type;
+
+    public:
+
+        vector();
+
+        vector( vector const& );
+        template< class E > vector( vector_expression< E,N > const& );
+
+        vector& operator=( vector const& );
+        template< class E > vector& operator=( vector_expression< E,N > const& );
+        assigner_type operator=( const_reference );
+
+        ~vector() {}
+
+        template< size_t B > size_type const bound() const;
+
+        void swap( vector& );
+
+        const_reference_type operator[]( size_type ) const;
+        reference_type operator[]( size_type );
+
+        const_reference operator()( reference, size_type ) const;
+        reference operator()( reference, size_type );
+
+        const_reference operator()( size_type ) const;
+        reference operator()( size_type );
+
+        const_iterator begin() const;
+        iterator begin();
+        const_iterator end() const;
+        iterator end();
+
+        vector& operator+=( vector const& );
+        vector& operator-=( vector const& );
+        vector& operator*=( T const& );
+        vector& operator/=( T const& );
+
+        template< class E > vector& operator+=( vector_expression< E,N > const& );
+        template< class E > vector& operator-=( vector_expression< E,N > const& );
+        template< class E > vector& operator*=( scalar_expression< E > const& );
+        template< class E > vector& operator/=( scalar_expression< E > const& );
+
+        bool const operator==( vector const& ) const;
+        bool const operator!=( vector const& ) const;
+
+        void normalize();
+        void clear();
+
+        template< class U > 
+        bool const references( scalar< U > const& ) const;
+        template< class U, std::size_t Q, bool J, class B > 
+        bool const references( vector< U,Q,J,B > const& ) const;
+        template< class U, std::size_t P, std::size_t Q, bool J, class B > 
+        bool const references( matrix< U,P,Q,J,B > const& ) const;
+
+    private:
+
+        representation_type data;
+
+    public:
+
+        template< class T1, std::size_t N1, bool I1, class A1, class C, class CT >
+        friend std::basic_ostream< C, CT >& operator<<( std::basic_ostream< C, CT >&, vector< T1,N1,I1,A1 > const& );
+
+    };
+
+//--
+
+    template< class T, std::size_t N, bool I, class A >
+    inline vector< T,N,I,A >::vector()
+    {} // constructor
+
+    template< class T, std::size_t N, bool I, class A >
+    vector< T,N,I,A >::vector( vector const& v ) : data( v.data )
+    {}
+
+    template< class T, std::size_t N, bool I, class A > template< class E >
+    vector< T,N,I,A >::vector( vector_expression< E,N > const& e )
+    {
+        vector_assign< type,E,N,vector_vector_assign< type,E >,E::linear,true >()( *this, e );
+    }
+
+    template< class T, std::size_t N, bool I, class A >
+    vector< T,N,I,A >& vector< T,N,I,A >::operator=( vector const& v )
+    {
+        if( &v != this ) data = v.data;
+        return *this;
+    }
+
+    template< class T, std::size_t N, bool I, class A > template< class E >
+    vector< T,N,I,A >& vector< T,N,I,A >::operator=( vector_expression< E,N > const& e )
+    {
+        vector_assign< type,E,N,vector_vector_assign< type,E >,E::linear,false >()( *this, e );
+        return *this;
+    }
+
+    template< class T, std::size_t N, bool I, class A >
+    typename vector< T,N,I,A >::assigner_type vector< T,N,I,A >::operator=( const_reference t )
+    {
+        return assigner_type( *this, begin(), t );
+    } // initializing assignment
+
+    template< class T, std::size_t N, bool I, class A > template< size_t B > 
+    typename vector< T,N,I,A >::size_type const vector< T,N,I,A >::bound() const
+    {
+        BOOST_STATIC_ASSERT( B == 0 );
+        return N;
+    } // bound
+
+    template< class T, std::size_t N, bool I, class A >
+    void vector< T,N,I,A >::swap( vector& o )
+    {
+        if( &o != this ) data.swap( o.data );
+    } // swap
+
+    template< class T, std::size_t N, bool I, class A >
+    typename vector< T,N,I,A >::const_reference_type vector< T,N,I,A >::operator[]( size_type s ) const
+    {
+        BOOST_ASSERT( s < size );
+        return data[s];
+    } // operator[] const
+
+    template< class T, std::size_t N, bool I, class A >
+    typename vector< T,N,I,A >::reference_type vector< T,N,I,A >::operator[]( size_type s )
+    {
+        BOOST_ASSERT( s < size );
+        return data[s];
+    } // operator[]
+
+    template< class T, std::size_t N, bool I, class A >
+    typename vector< T,N,I,A >::const_reference vector< T,N,I,A >::operator()( reference, size_type s ) const
+    {
+        BOOST_ASSERT( s < size );
+        return *( data+s );
+    } // operator() const
+
+    template< class T, std::size_t N, bool I, class A >
+    typename vector< T,N,I,A >::reference vector< T,N,I,A >::operator()( reference, size_type s )
+    {
+        BOOST_ASSERT( s < size );
+        return *( data+s );
+    } // operator()
+
+    template< class T, std::size_t N, bool I, class A >
+    typename vector< T,N,I,A >::const_reference vector< T,N,I,A >::operator()( size_type s ) const
+    {
+        BOOST_ASSERT( s < size );
+        return *( data+s );
+    } // operator() const
+
+    template< class T, std::size_t N, bool I, class A >
+    typename vector< T,N,I,A >::reference vector< T,N,I,A >::operator()( size_type s )
+    {
+        BOOST_ASSERT( s < size );
+        return *( data+s );
+    } // operator()
+
+    template< class T, std::size_t N, bool I, class A >
+    typename vector< T,N,I,A >::const_iterator vector< T,N,I,A >::begin() const
+    {
+        return data.begin();
+    } // begin const
+
+    template< class T, std::size_t N, bool I, class A >
+    typename vector< T,N,I,A >::iterator vector< T,N,I,A >::begin()
+    {
+        return data.begin();
+    } // begin
+
+    template< class T, std::size_t N, bool I, class A >
+    typename vector< T,N,I,A >::const_iterator vector< T,N,I,A >::end() const
+    {
+        return data.end();
+    } // end const
+
+    template< class T, std::size_t N, bool I, class A >
+    typename vector< T,N,I,A >::iterator vector< T,N,I,A >::end()
+    {
+        return data.end();
+    } // end
+
+    template< class T, std::size_t N, bool I, class A >
+    vector< T,N,I,A >& vector< T,N,I,A >::operator+=( vector const& v )
+    {
+        for( std::size_t i = 0; i != N; ++i ) data[i] += v[i];
+        return *this;
+    } // operator += vector
+
+    template< class T, std::size_t N, bool I, class A >
+    vector< T,N,I,A >& vector< T,N,I,A >::operator-=( vector const& v )
+    {
+        for( std::size_t i = 0; i != N; ++i ) data[i] -= v[i];
+        return *this;
+    } // operator -= vector
+
+    template< class T, std::size_t N, bool I, class A >
+    vector< T,N,I,A >& vector< T,N,I,A >::operator*=( T const& t )
+    {
+        for( std::size_t i = 0; i != N; ++i ) data[i] *= t;
+        return *this;
+    } // operator *= scalar
+
+    template< class T, std::size_t N, bool I, class A >
+    vector< T,N,I,A >& vector< T,N,I,A >::operator/=( T const& t )
+    {
+        T x = t;
+        BOOST_ASSERT( x != T(0) );
+        for( std::size_t i = 0; i != N; ++i ) data[i] /= x;
+        return *this;
+    } // operator /= scalar
+
+    template< class T, std::size_t N, bool I, class A > template< class E >
+    vector< T,N,I,A >& vector< T,N,I,A >::operator+=( vector_expression< E,N > const& e )
+    {
+        for( std::size_t i = 0; i != N; ++i ) data[i] += e()( i );
+        return *this;
+    } // operator += vector_expression
+
+    template< class T, std::size_t N, bool I, class A > template< class E >
+    vector< T,N,I,A >& vector< T,N,I,A >::operator-=( vector_expression< E,N > const& e )
+    {
+        for( std::size_t i = 0; i != N; ++i ) data[i] -= e()( i );
+        return *this;
+    } // operator -= vector_expression
+
+    template< class T, std::size_t N, bool I, class A > template< class E >
+    vector< T,N,I,A >& vector< T,N,I,A >::operator*=( scalar_expression< E > const& e )
+    {
+        for( std::size_t i = 0; i != N; ++i ) data[i] *= e()( 0 );
+        return *this;
+    } // operator *= scalar_expression
+
+    template< class T, std::size_t N, bool I, class A > template< class E >
+    vector< T,N,I,A >& vector< T,N,I,A >::operator/=( scalar_expression< E > const& e )
+    {
+        T x = e()( 0 );
+        BOOST_ASSERT( x != T(0) );
+        for( std::size_t i = 0; i != N; ++i ) data[i] /= x;
+        return *this;
+    } // operator /= scalar_expression
+
+    template< class T, std::size_t N, bool I, class A >
+    inline bool const vector< T,N,I,A >::operator==( vector< T,N,I,A > const& o ) const
+    {
+        return vector_equality< T,N,I,A,N >()( begin(), o.begin() );
+    } // operator ==
+
+    template< class T, std::size_t N, bool I, class A >
+    inline bool const vector< T,N,I,A >::operator!=( vector< T,N,I,A > const& o ) const
+    {
+        return !( vector_equality< T,N,I,A,N >()( begin(), o.begin() ) );
+    } // operator !=
+
+    template< class T, std::size_t N, bool I, class A > template< class U > 
+    bool const vector< T,N,I,A >::references( scalar< U > const& s ) const
+    {
+        return false;
+    }
+
+    template< class T, std::size_t N, bool I, class A > template< class U, std::size_t Q, bool J, class B > 
+    bool const vector< T,N,I,A >::references( vector< U,Q,J,B > const& v ) const
+    {
+        return ( reinterpret_cast< vector< T,N,I,A > const* >( &v ) == this );
+    }
+
+    template< class T, std::size_t N, bool I, class A > template< class U, std::size_t P, std::size_t Q, bool J, class B > 
+    bool const vector< T,N,I,A >::references( matrix< U,P,Q,J,B > const& ) const
+    {
+        return false;
+    }
+
+    template< class T, std::size_t N, bool I, class A >
+    void vector< T,N,I,A >::normalize()
+    {
+        T m = vector_magnitude( *this ), x;
+        if( m != T(0) )
+        {   x = T(1) / m;
+            for( std::size_t i = 0; i != N; ++i ) data[i] *= x;
+        }
+    } // normalize
+
+    template< class T, std::size_t N, bool I, class A >
+    void vector< T,N,I,A >::clear()
+    {
+        T t = T();
+        std::fill( begin(), end(), t );
+    } // clear : set all elements to default
+
+//--
+
+    template< class T1, std::size_t N1, bool I1, class A1, class C, class CT >
+    std::basic_ostream< C,CT >& operator<<( std::basic_ostream< C,CT >& o, vector< T1,N1,I1,A1 > const& v )
+    {
+        o << v.data;
+        return o;
+    }
+
+//--
+
+}} // namespace boost, namespace maps
+
+#endif // BOOST_MAPS_MATH_VECTOR_HPP
Added: sandbox/maps/boost/maps/math/vector_matrix.hpp
==============================================================================
--- (empty file)
+++ sandbox/maps/boost/maps/math/vector_matrix.hpp	2011-08-08 19:51:30 EDT (Mon, 08 Aug 2011)
@@ -0,0 +1,338 @@
+//--
+// Copyright (c) 2010-2011 Brian Smith
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/maps for documentation.
+//--
+#if !defined( BOOST_MAPS_MATH_VECTOR_MATRIX_HPP )
+#define BOOST_MAPS_MATH_VECTOR_MATRIX_HPP
+
+#include <boost/maps/math/vector_vector.hpp>
+#include <boost/maps/math/matrix_matrix.hpp>
+
+namespace boost { namespace maps {
+
+//--
+
+    template< class E1, class E2, std::size_t N, class O, bool L >
+    class vector_matrix_binary_expression
+        : public vector_expression< vector_matrix_binary_expression< E1,E2,N,O,L >,N >
+    {
+    public:
+
+        typedef vector_matrix_binary_expression type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef typename E1::type_const_reference expression1_const_reference;
+        typedef typename E2::type_const_reference expression2_const_reference;
+        typedef E1 expression_type1;
+        typedef E2 expression_type2;
+        typedef O operator_type;
+        typedef typename O::result_type result_type;
+        typedef result_type element_type;
+        typedef element_type const& const_reference;
+        typedef element_type& reference;
+        typedef typename operator_type::size_type size_type;
+        typedef typename operator_type::allocator_type allocator_type;
+
+        using vector_expression< type,N >::operator();
+
+        enum { size = N };
+        enum { linear = ( L & E1::linear & E2::linear ) };
+
+        vector_matrix_binary_expression( E1 const&, E2 const& );
+        type_reference operator=( type_const_reference );
+
+        expression_type1 const& expression1() const;
+        expression_type2 const& expression2() const;
+
+        result_type const operator()( size_type ) const;
+
+        template< class U > 
+        bool const references( scalar< U > const& ) const;
+        template< class U, std::size_t Q, bool J, class B > 
+        bool const references( vector< U,Q,J,B > const& ) const;
+        template< class U, std::size_t P, std::size_t Q, bool J, class B > 
+        bool const references( matrix< U,P,Q,J,B > const& ) const;
+
+    private:
+
+        expression1_const_reference t1;
+        expression2_const_reference t2;
+
+    };
+
+//--
+
+    template< class E1, class E2, std::size_t N, class O, bool L >
+    vector_matrix_binary_expression< E1,E2,N,O,L >::vector_matrix_binary_expression( E1 const& e1, E2 const& e2 )
+        : t1( e1 ), t2( e2 )
+    {}
+
+    template< class E1, class E2, std::size_t N, class O, bool L >
+    typename vector_matrix_binary_expression< E1,E2,N,O,L >::type_reference
+        vector_matrix_binary_expression< E1,E2,N,O,L >::operator=( type_const_reference e )
+    {
+        if( &e != this ) { t1 = e.t1; t2 = e.t2; }
+        return *this;
+    }
+
+    template< class E1, class E2, std::size_t N, class O, bool L >
+    typename vector_matrix_binary_expression< E1,E2,N,O,L >::expression_type1 const& 
+        vector_matrix_binary_expression< E1,E2,N,O,L >::expression1() const
+    {
+        return t1;
+    }
+
+    template< class E1, class E2, std::size_t N, class O, bool L >
+    typename vector_matrix_binary_expression< E1,E2,N,O,L >::expression_type2 const& 
+        vector_matrix_binary_expression< E1,E2,N,O,L >::expression2() const
+    {
+        return t2;
+    }
+
+    template< class E1, class E2, std::size_t N, class O, bool L >
+    typename vector_matrix_binary_expression< E1,E2,N,O,L >::result_type const 
+        vector_matrix_binary_expression< E1,E2,N,O,L >::operator()( size_type s ) const
+    {
+        return operator_type()( t1,t2,s );
+    }
+
+    template< class E1, class E2, std::size_t N, class O, bool L > template< class U >
+    bool const vector_matrix_binary_expression< E1,E2,N,O,L >::references( scalar< U > const& s ) const
+    {
+        return ( t1().references( s ) || t2().references( s ) );
+    }
+
+    template< class E1, class E2, std::size_t N, class O, bool L > template< class U, std::size_t Q, bool J, class B >
+    bool const vector_matrix_binary_expression< E1,E2,N,O,L >::references( vector< U,Q,J,B > const& v ) const
+    {
+        return ( t1().references( v ) || t2().references( v ) );
+    }
+
+    template< class E1, class E2, std::size_t N, class O, bool L > template< class U, std::size_t P, std::size_t Q, bool J, class B >
+    bool const vector_matrix_binary_expression< E1,E2,N,O,L >::references( matrix< U,P,Q,J,B > const& m ) const
+    {
+        return ( t1().references( m ) || t2().references( m ) );
+    }
+
+//--
+//--
+
+    template< class T1, class T2 >
+    struct matrix_vector_traits
+    {
+        typedef typename expression_traits< T1 >::type_const_reference type_const_reference1;
+        typedef typename expression_traits< T2 >::type_const_reference type_const_reference2;
+        typedef typename expression_traits< T1 >::type_reference type_reference1;
+        typedef typename expression_traits< T2 >::type_reference type_reference2;
+        typedef typename expression_traits< T1 >::const_reference const_reference1;
+        typedef typename expression_traits< T2 >::const_reference const_reference2;
+        typedef typename expression_traits< T1 >::reference reference1;
+        typedef typename expression_traits< T2 >::reference reference2;
+        typedef typename expression_traits< T1 >::element_type element_type1;
+        typedef typename expression_traits< T2 >::element_type element_type2;
+        typedef typename expression_traits< T1 >::allocator_type allocator_type;
+        typedef typename expression_traits< T1 >::size_type size_type;
+        typedef typename vector_matrix_type< element_type1,element_type2 >::type result_type;
+
+    };
+
+//--
+//--
+
+    template< class T1, class T2 >
+    struct matrix_vector_product
+        : matrix_vector_traits< T1,T2 >
+    {
+        typedef typename matrix_vector_traits< T1,T2 >::result_type result_type;
+        typedef typename matrix_vector_traits< T1,T2 >::type_const_reference1 type_const_reference1;
+        typedef typename matrix_vector_traits< T1,T2 >::type_const_reference2 type_const_reference2;
+        typedef typename matrix_vector_traits< T1,T2 >::const_reference1 const_reference1;
+        typedef typename matrix_vector_traits< T1,T2 >::const_reference2 const_reference2;
+        typedef typename matrix_vector_traits< T1,T2 >::size_type size_type;
+
+        result_type operator()( type_const_reference1 t1, type_const_reference2 t2, size_type s )
+        {
+            result_type r = result_type();
+            for( size_type k = 0; k != t1.cols; ++k )
+                r += t1( s,k ) * t2( k );
+            return r;
+        }
+
+        result_type operator()( const_reference1 t1, const_reference2 t2 )
+        {
+            return t1 * t2;
+        }
+    };
+
+    template< class T1, class T2 >
+    struct vector_matrix_product
+        : matrix_vector_traits< T1,T2 >
+    {
+        typedef typename matrix_vector_traits< T1,T2 >::result_type result_type;
+        typedef typename matrix_vector_traits< T1,T2 >::type_const_reference1 type_const_reference1;
+        typedef typename matrix_vector_traits< T1,T2 >::type_const_reference2 type_const_reference2;
+        typedef typename matrix_vector_traits< T1,T2 >::const_reference1 const_reference1;
+        typedef typename matrix_vector_traits< T1,T2 >::const_reference2 const_reference2;
+        typedef typename matrix_vector_traits< T1,T2 >::size_type size_type;
+
+        result_type operator()( type_const_reference1 t1, type_const_reference2 t2, size_type s )
+        {
+            result_type r = result_type();
+            for( size_type k = 0; k != t2.rows; ++k )
+                r += t1( k ) * t2( k,s );
+            return r;
+        }
+
+        result_type operator()( const_reference1 t1, const_reference2 t2 )
+        {
+            return t1 * t2;
+        }
+    };
+
+//--
+
+    template< class E1, class E2, std::size_t M, std::size_t N >
+    vector_matrix_binary_expression< E1,E2,M,matrix_vector_product< E1,E2 >,false >
+    operator*( matrix_expression< E1,M,N > const& e1, vector_expression< E2,N > const& e2 )
+    {
+        return vector_matrix_binary_expression< E1,E2,M, 
+            matrix_vector_product< E1,E2 >,false >( e1(), e2() );
+    }
+
+    template< class E1, class E2, std::size_t M, std::size_t N >
+    vector_matrix_binary_expression< E1,E2,N,vector_matrix_product< E1,E2 >,false >
+    operator*( vector_expression< E1,M > const& e1, matrix_expression< E2,M,N > const& e2 )
+    {
+        return vector_matrix_binary_expression< E1,E2,N, 
+            vector_matrix_product< E1,E2 >,false >( e1(), e2() );
+    }
+
+//--
+//--
+
+    template< class E, std::size_t N, class O, bool L >
+    class vector_matrix_unary_expression
+        : public vector_expression< vector_matrix_unary_expression< E,N,O,L >,N >
+    {
+    public:
+
+        typedef vector_matrix_unary_expression type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef typename E::type_const_reference expression_const_reference;
+        typedef E expression_type;
+        typedef O operator_type;
+        typedef typename O::result_type result_type;
+        typedef result_type element_type;
+        typedef element_type const& const_reference;
+        typedef element_type& reference;
+        typedef typename operator_type::size_type size_type;
+        typedef typename operator_type::allocator_type allocator_type;
+
+        using vector_expression< type,N >::operator();
+
+        enum { size = N };
+        enum { linear = ( L & E::linear ) };
+
+        vector_matrix_unary_expression( E const& );
+        type_reference operator=( type_const_reference );
+
+        expression_type const& expression() const;
+        
+        result_type const operator()( size_type ) const;
+
+        template< class U > 
+        bool const references( scalar< U > const& ) const;
+        template< class U, std::size_t Q, bool J, class B > 
+        bool const references( vector< U,Q,J,B > const& ) const;
+        template< class U, std::size_t P, std::size_t Q, bool J, class B > 
+        bool const references( matrix< U,P,Q,J,B > const& ) const;
+
+    private:
+
+        expression_const_reference t;
+
+    };
+
+//--
+
+    template< class E, std::size_t N, class O, bool L >
+    vector_matrix_unary_expression< E,N,O,L >::vector_matrix_unary_expression( E const& e )
+        : t( e )
+    {}
+
+    template< class E, std::size_t N, class O, bool L >
+    typename vector_matrix_unary_expression< E,N,O,L >::type_reference
+        vector_matrix_unary_expression< E,N,O,L >::operator=( type_const_reference e )
+    {
+        if( &e != this ) { t = e.t; }
+        return *this;
+    }
+
+    template< class E, std::size_t N, class O, bool L >
+    typename vector_matrix_unary_expression< E,N,O,L >::expression_type const& 
+        vector_matrix_unary_expression< E,N,O,L >::expression() const
+    {
+        return t;
+    }
+
+    template< class E, std::size_t N, class O, bool L >
+    typename vector_matrix_unary_expression< E,N,O,L >::result_type const 
+        vector_matrix_unary_expression< E,N,O,L >::operator()( size_type s ) const
+    {
+        return operator_type()( t,s );
+    }
+
+    template< class E, std::size_t N, class O, bool L > template< class U >
+    bool const vector_matrix_unary_expression< E,N,O,L >::references( scalar< U > const& s ) const
+    {
+        return ( t().references( s ) );
+    }
+
+    template< class E, std::size_t N, class O, bool L > template< class U, std::size_t Q, bool J, class B >
+    bool const vector_matrix_unary_expression< E,N,O,L >::references( vector< U,Q,J,B > const& v ) const
+    {
+        return ( t().references( v ) );
+    }
+
+    template< class E, std::size_t N, class O, bool L > template< class U, std::size_t P, std::size_t Q, bool J, class B >
+    bool const vector_matrix_unary_expression< E,N,O,L >::references( matrix< U,P,Q,J,B > const& m ) const
+    {
+        return ( t().references( m ) );
+    }
+
+//--
+//--
+
+    template< class T >
+    struct matrix_trace
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::type_const_reference type_const_reference;
+        typedef typename expression_unary_traits< T >::size_type size_type;
+
+        result_type operator()( type_const_reference t, size_type i )
+        {
+            return t( i,i );
+        }
+    };
+
+//--
+
+    template< class E, std::size_t N >
+    vector_matrix_unary_expression< E,N,matrix_trace< E >,true >
+    trace( matrix_expression< E,N,N > const& e )
+    {
+         return vector_matrix_unary_expression< E,N,matrix_trace< E >,true >( e() );
+    }
+
+//--
+
+}} // namespace boost, namespace maps
+
+#endif // BOOST_MAPS_MATH_VECTOR_MATRIX_HPP
\ No newline at end of file
Added: sandbox/maps/boost/maps/math/vector_scalar.hpp
==============================================================================
--- (empty file)
+++ sandbox/maps/boost/maps/math/vector_scalar.hpp	2011-08-08 19:51:30 EDT (Mon, 08 Aug 2011)
@@ -0,0 +1,236 @@
+//--
+// Copyright (c) 2010-2011 Brian Smith
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/maps for documentation.
+//--
+#if !defined( BOOST_MAPS_MATH_VECTOR_SCALAR_HPP )
+#define BOOST_MAPS_MATH_VECTOR_SCALAR_HPP
+
+#include <boost/maps/math/vector_vector.hpp>
+#include <boost/maps/math/scalar_scalar.hpp>
+#include <boost/maps/math/scalar_vector.hpp>
+
+namespace boost { namespace maps {
+
+//--
+
+    template< class E1, class E2, std::size_t N, class O, bool L >
+    class vector_scalar_binary_expression
+        : public vector_expression< vector_scalar_binary_expression< E1,E2,N,O,L >,N >
+    {
+    public:
+
+        typedef vector_scalar_binary_expression type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef typename E1::type_const_reference expression1_const_reference;
+        typedef typename E2::type_const_reference expression2_const_reference;
+        typedef E1 expression_type1;
+        typedef E2 expression_type2;
+        typedef O operator_type;
+        typedef typename O::result_type result_type;
+        typedef result_type element_type;
+        typedef element_type const& const_reference;
+        typedef element_type& reference;
+        typedef typename operator_type::size_type size_type;
+        typedef typename operator_type::allocator_type allocator_type;
+
+        using vector_expression< type,N >::operator();
+
+        enum { size = N };
+        enum { linear = ( L & E1::linear & E2::linear ) };
+
+        vector_scalar_binary_expression( E1 const&, E2 const& );
+
+        expression_type1 const& expression1() const;
+        expression_type2 const& expression2() const;
+
+        reference operator()( reference, size_type ) const;
+        result_type const operator()( size_type ) const;
+
+        template< class U > 
+        bool const references( scalar< U > const& ) const;
+        template< class U, std::size_t Q, bool J, class B > 
+        bool const references( vector< U,Q,J,B > const& ) const;
+        template< class U, std::size_t P, std::size_t Q, bool J, class B > 
+        bool const references( matrix< U,P,Q,J,B > const& ) const;
+
+    private:
+
+        expression1_const_reference t1;
+        expression2_const_reference t2;
+
+    };
+
+//--
+
+    template< class E1, class E2, std::size_t N, class O, bool L >
+    vector_scalar_binary_expression< E1,E2,N,O,L >::vector_scalar_binary_expression( E1 const& e1, E2 const& e2 )
+        : t1( e1 ), t2( e2 )
+    {}
+
+    template< class E1, class E2, std::size_t N, class O, bool L >
+    typename vector_scalar_binary_expression< E1,E2,N,O,L >::expression_type1 const& 
+        vector_scalar_binary_expression< E1,E2,N,O,L >::expression1() const
+    {
+        return t1;
+    }
+
+    template< class E1, class E2, std::size_t N, class O, bool L >
+    typename vector_scalar_binary_expression< E1,E2,N,O,L >::expression_type2 const& 
+        vector_scalar_binary_expression< E1,E2,N,O,L >::expression2() const
+    {
+        return t2;
+    }
+
+    template< class E1, class E2, std::size_t N, class O, bool L >
+    typename vector_scalar_binary_expression< E1,E2,N,O,L >::reference 
+        vector_scalar_binary_expression< E1,E2,N,O,L >::operator()( reference r, size_type s ) const
+    {
+        return operator_type()( r,t1,t2,s );
+    }
+
+    template< class E1, class E2, std::size_t N, class O, bool L >
+    typename vector_scalar_binary_expression< E1,E2,N,O,L >::result_type const 
+        vector_scalar_binary_expression< E1,E2,N,O,L >::operator()( size_type s ) const
+    {
+        return operator_type()( t1,t2,s );
+    }
+
+    template< class E1, class E2, std::size_t N, class O, bool L > template< class U >
+    bool const vector_scalar_binary_expression< E1,E2,N,O,L >::references( scalar< U > const& s ) const
+    {
+        return ( t1().references( s ) || t2().references( s ) );
+    }
+
+    template< class E1, class E2, std::size_t N, class O, bool L > template< class U, std::size_t Q, bool J, class B >
+    bool const vector_scalar_binary_expression< E1,E2,N,O,L >::references( vector< U,Q,J,B > const& v ) const
+    {
+        return ( t1().references( v ) || t2().references( v ) );
+    }
+
+    template< class E1, class E2, std::size_t N, class O, bool L > template< class U, std::size_t P, std::size_t Q, bool J, class B >
+    bool const vector_scalar_binary_expression< E1,E2,N,O,L >::references( matrix< U,P,Q,J,B > const& m ) const
+    {
+        return ( t1().references( m ) || t2().references( m ) );
+    }
+
+//--
+//--
+
+    template< class T1, class T2 >
+    struct vector_scalar_traits
+    {
+        typedef typename expression_traits< T1 >::type_const_reference type_const_reference1;
+        typedef typename expression_traits< T2 >::type_const_reference type_const_reference2;
+        typedef typename expression_traits< T1 >::type_reference type_reference1;
+        typedef typename expression_traits< T2 >::type_reference type_reference2;
+        typedef typename expression_traits< T1 >::const_reference const_reference1;
+        typedef typename expression_traits< T2 >::const_reference const_reference2;
+        typedef typename expression_traits< T1 >::reference reference1;
+        typedef typename expression_traits< T2 >::reference reference2;
+        typedef typename expression_traits< T1 >::element_type element_type1;
+        typedef typename expression_traits< T2 >::element_type element_type2;
+        typedef typename expression_traits< T1 >::allocator_type allocator_type;
+        typedef typename expression_traits< T1 >::size_type size_type;
+        typedef typename vector_scalar_type< element_type1,element_type2 >::type result_type;
+
+    };
+
+//--
+//--
+
+    template< class T1, class T2 >
+    struct vector_scalar_product
+        : vector_scalar_traits< T1,T2 >
+    {
+        typedef typename vector_scalar_traits< T1,T2 >::result_type result_type;
+        typedef typename vector_scalar_traits< T1,T2 >::type_const_reference1 type_const_reference1;
+        typedef typename vector_scalar_traits< T1,T2 >::type_const_reference2 type_const_reference2;
+        typedef typename vector_scalar_traits< T1,T2 >::size_type size_type;
+
+        result_type& operator()( result_type& r, type_const_reference1 t1, type_const_reference2 t2, size_type s )
+        {
+            return r = t1( s ) * t2();
+        }
+
+        result_type operator()( type_const_reference1 t1, type_const_reference2 t2, size_type s )
+        {
+            return t1( s ) * t2();
+        }
+    };
+
+    template< class T1, class T2 >
+    struct scalar_vector_product
+        : vector_scalar_traits< T1,T2 >
+    {
+        typedef typename vector_scalar_traits< T1,T2 >::result_type result_type;
+        typedef typename vector_scalar_traits< T1,T2 >::type_const_reference1 type_const_reference1;
+        typedef typename vector_scalar_traits< T1,T2 >::type_const_reference2 type_const_reference2;
+        typedef typename vector_scalar_traits< T1,T2 >::size_type size_type;
+
+        result_type& operator()( result_type& r, type_const_reference1 t1, type_const_reference2 t2, size_type s )
+        {
+            return r = t1() * t2( s );
+        }
+
+        result_type operator()( type_const_reference1 t1, type_const_reference2 t2, size_type s )
+        {
+            return t1() * t2( s );
+        }
+    };
+
+    template< class T1, class T2 >
+    struct vector_scalar_division
+        : vector_scalar_traits< T1,T2 >
+    {
+        typedef typename vector_scalar_traits< T1,T2 >::result_type result_type;
+        typedef typename vector_scalar_traits< T1,T2 >::type_const_reference1 type_const_reference1;
+        typedef typename vector_scalar_traits< T1,T2 >::type_const_reference2 type_const_reference2;
+        typedef typename vector_scalar_traits< T1,T2 >::size_type size_type;
+
+        result_type& operator()( result_type& r, type_const_reference1 t1, type_const_reference2 t2, size_type s )
+        {
+            return r = t1( s ) / t2();
+        }
+
+        result_type operator()( type_const_reference1 t1, type_const_reference2 t2, size_type s )
+        {
+            return t1( s ) / t2();
+        }
+    };
+
+//--
+
+    template< class E1, class E2, std::size_t N >
+    vector_scalar_binary_expression< E1,E2,N,vector_scalar_product< E1,E2 >,true >
+    operator*( vector_expression< E1,N > const& e1, scalar_expression< E2 > const& e2 )
+    {
+        return vector_scalar_binary_expression< E1,E2,N, 
+            vector_scalar_product< E1,E2 >,true >( e1(), e2() );
+    }
+
+    template< class E1, class E2, std::size_t N >
+    vector_scalar_binary_expression< E1,E2,N,scalar_vector_product< E1,E2 >,true >
+    operator*( scalar_expression< E1 > const& e1, vector_expression< E2,N > const& e2 )
+    {
+        return vector_scalar_binary_expression< E1,E2,N, 
+            scalar_vector_product< E1,E2 >,true >( e1(), e2() );
+    }
+
+    template< class E1, class E2, std::size_t N >
+    vector_scalar_binary_expression< E1,E2,N,vector_scalar_division< E1,E2 >,true >
+    operator/( vector_expression< E1,N > const& e1, scalar_expression< E2 > const& e2 )
+    {
+        return vector_scalar_binary_expression< E1,E2,N, 
+            vector_scalar_division< E1,E2 >,true >( e1(), e2() );
+    }
+
+//--
+
+}} // namespace boost, namespace maps
+
+#endif // BOOST_MAPS_MATH_VECTOR_SCALAR_HPP
\ No newline at end of file
Added: sandbox/maps/boost/maps/math/vector_vector.hpp
==============================================================================
--- (empty file)
+++ sandbox/maps/boost/maps/math/vector_vector.hpp	2011-08-08 19:51:30 EDT (Mon, 08 Aug 2011)
@@ -0,0 +1,665 @@
+//--
+// Copyright (c) 2010-2011 Brian Smith
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/maps for documentation.
+//--
+#if !defined( BOOST_MAPS_MATH_VECTOR_VECTOR_HPP )
+#define BOOST_MAPS_MATH_VECTOR_VECTOR_HPP
+
+#include <boost/maps/math/scalar_scalar.hpp>
+
+namespace boost { namespace maps {
+
+//--
+
+    template< class E, std::size_t N >
+    class vector_expression
+        : expression< vector_expression< E,N > >
+    {
+    public:
+
+        typedef vector_expression type;
+        typedef E value_type;
+        typedef value_type const& const_reference;
+        typedef value_type& reference;
+
+        const_reference operator()() const
+        {
+            return *static_cast< value_type const* >( this );
+        }
+
+        reference operator()()
+        {
+            return *static_cast< value_type* >( this );
+        }
+
+    };
+
+//--
+
+    template< class E1, class E2, std::size_t N, class O, bool L >
+    class vector_binary_expression
+        : public vector_expression< vector_binary_expression< E1,E2,N,O,L >,N >
+    {
+    public:
+
+        typedef vector_binary_expression type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef typename E1::type_const_reference expression1_const_reference;
+        typedef typename E2::type_const_reference expression2_const_reference;
+        typedef E1 expression_type1;
+        typedef E2 expression_type2;
+        typedef O operator_type;
+        typedef typename O::result_type result_type;
+        typedef result_type element_type;
+        typedef element_type const& const_reference;
+        typedef element_type& reference;
+        typedef typename operator_type::size_type size_type;
+        typedef typename operator_type::allocator_type allocator_type;
+
+        using vector_expression< type,N >::operator();
+
+        enum { size = N };
+        enum { linear = ( L & E1::linear & E2::linear ) };
+
+        vector_binary_expression( E1 const&, E2 const& );
+        type_reference operator=( type_const_reference );
+
+        expression_type1 const& expression1() const;
+        expression_type2 const& expression2() const;
+
+        reference operator()( reference, size_type ) const;
+        result_type const operator()( size_type ) const;
+
+        template< class U > 
+        bool const references( scalar< U > const& ) const;
+        template< class U, std::size_t Q, bool J, class B > 
+        bool const references( vector< U,Q,J,B > const& ) const;
+        template< class U, std::size_t P, std::size_t Q, bool J, class B > 
+        bool const references( matrix< U,P,Q,J,B > const& ) const;
+
+    private:
+
+        expression1_const_reference t1;
+        expression2_const_reference t2;
+
+    };
+
+//--
+
+    template< class E1, class E2, std::size_t N, class O, bool L >
+    vector_binary_expression< E1,E2,N,O,L >::vector_binary_expression( E1 const& e1, E2 const& e2 )
+        : t1( e1 ), t2( e2 )
+    {}
+
+    template< class E1, class E2, std::size_t N, class O, bool L >
+    typename vector_binary_expression< E1,E2,N,O,L >::type_reference
+        vector_binary_expression< E1,E2,N,O,L >::operator=( type_const_reference e )
+    {
+        if( &e != this ) { t1 = e.t1; t2 = e.t2; }
+        return *this;
+    }
+
+    template< class E1, class E2, std::size_t N, class O, bool L >
+    typename vector_binary_expression< E1,E2,N,O,L >::expression_type1 const& 
+        vector_binary_expression< E1,E2,N,O,L >::expression1() const
+    {
+        return t1;
+    }
+
+    template< class E1, class E2, std::size_t N, class O, bool L >
+    typename vector_binary_expression< E1,E2,N,O,L >::expression_type2 const& 
+        vector_binary_expression< E1,E2,N,O,L >::expression2() const
+    {
+        return t2;
+    }
+
+    template< class E1, class E2, std::size_t N, class O, bool L >
+    typename vector_binary_expression< E1,E2,N,O,L >::reference 
+        vector_binary_expression< E1,E2,N,O,L >::operator()( reference r, size_type s ) const
+    {
+        return operator_type()( r,t1,t2,s );
+    }
+
+    template< class E1, class E2, std::size_t N, class O, bool L >
+    typename vector_binary_expression< E1,E2,N,O,L >::result_type const 
+        vector_binary_expression< E1,E2,N,O,L >::operator()( size_type s ) const
+    {
+        return operator_type()( t1( s ), t2( s ) );
+    }
+
+    template< class E1, class E2, std::size_t N, class O, bool L > template< class U >
+    bool const vector_binary_expression< E1,E2,N,O,L >::references( scalar< U > const& s ) const
+    {
+        return ( t1().references( s ) || t2().references( s ) );
+    }
+
+    template< class E1, class E2, std::size_t N, class O, bool L > template< class U, std::size_t Q, bool J, class B >
+    bool const vector_binary_expression< E1,E2,N,O,L >::references( vector< U,Q,J,B > const& v ) const
+    {
+        return ( t1().references( v ) || t2().references( v ) );
+    }
+
+    template< class E1, class E2, std::size_t N, class O, bool L > template< class U, std::size_t P, std::size_t Q, bool J, class B >
+    bool const vector_binary_expression< E1,E2,N,O,L >::references( matrix< U,P,Q,J,B > const& m ) const
+    {
+        return ( t1().references( m ) || t2().references( m ) );
+    }
+
+//--
+//--
+
+    template< class T1, class T2 >
+    struct vector_vector_addition
+        : expression_binary_traits< T1,T2 >
+    {
+        typedef typename expression_binary_traits< T1,T2 >::result_type result_type;
+        typedef typename expression_binary_traits< T1,T2 >::type_const_reference1 type_const_reference1;
+        typedef typename expression_binary_traits< T1,T2 >::type_const_reference2 type_const_reference2;
+        typedef typename expression_binary_traits< T1,T2 >::const_reference1 const_reference1;
+        typedef typename expression_binary_traits< T1,T2 >::const_reference2 const_reference2;
+        typedef typename expression_binary_traits< T1,T2 >::size_type size_type;
+
+        result_type& operator()( result_type& r, type_const_reference1 t1, type_const_reference2 t2, size_type s )
+        {
+            return r = t1( s ) + t2( s );
+        }
+
+        result_type operator()( const_reference1 t1, const_reference2 t2 )
+        {
+            return t1 + t2;
+        }
+    };
+
+    template< class T1, class T2 >
+    struct vector_vector_subtraction
+        : expression_binary_traits< T1,T2 >
+    {
+        typedef typename expression_binary_traits< T1,T2 >::result_type result_type;
+        typedef typename expression_binary_traits< T1,T2 >::type_const_reference1 type_const_reference1;
+        typedef typename expression_binary_traits< T1,T2 >::type_const_reference2 type_const_reference2;
+        typedef typename expression_binary_traits< T1,T2 >::const_reference1 const_reference1;
+        typedef typename expression_binary_traits< T1,T2 >::const_reference2 const_reference2;
+        typedef typename expression_binary_traits< T1,T2 >::size_type size_type;
+
+        result_type& operator()( result_type& r, type_const_reference1 t1, type_const_reference2 t2, size_type s )
+        {
+            return r = t1( s ) - t2( s );
+        }
+
+        result_type operator()( const_reference1 t1, const_reference2 t2 )
+        {
+            return t1 - t2;
+        }
+    };
+
+//--
+
+    template< class E1, class E2, std::size_t N >
+    vector_binary_expression< E1,E2,N,vector_vector_addition< E1,E2 >,true >
+    operator+( vector_expression< E1,N > const& e1, vector_expression< E2,N > const& e2 )
+    {
+        return vector_binary_expression< E1,E2,N, 
+            vector_vector_addition< E1,E2 >,true >( e1(), e2() );
+    }
+
+    template< class E1, class E2, std::size_t N >
+    vector_binary_expression< E1,E2,N,vector_vector_subtraction< E1,E2 >,true >
+    operator-( vector_expression< E1,N > const& e1, vector_expression< E2,N > const& e2 )
+    {
+        return vector_binary_expression< E1,E2,N, 
+            vector_vector_subtraction< E1,E2 >,true >( e1(), e2() );
+    }
+
+//--
+
+    template< class T1, class T2 >
+    struct vector_vector_assign
+        : expression_binary_traits< T1,T2 >
+    {
+        typedef typename expression_binary_traits< T1,T2 >::reference1 reference1;
+        typedef typename expression_binary_traits< T1,T2 >::const_reference2 const_reference2;
+
+        void operator()( reference1 t1, const_reference2 t2 )
+        {
+            t1 = t2;
+        }
+    };
+
+//--
+
+    template< class T, class E, std::size_t N, class O, bool L, bool C >
+    struct vector_assign
+    {
+        typedef T type;
+        typedef type& reference;
+        typedef vector_expression< E,N > const& expression_const_reference;
+        typedef O operator_type;
+
+        void operator()( reference v, expression_const_reference e )
+        {
+            if( e().references( v ) )
+            {   type t;
+                for( std::size_t i = 0; i != N; ++i )
+                    operator_type()( t( i ), e()( i ) );
+                t.swap( v );
+            }else
+            {   for( std::size_t i = 0; i != N; ++i )
+                    operator_type()( v( i ), e()( i ) );
+            }
+        }
+    };
+
+//--
+
+    template< class T, class E, std::size_t N, class O, bool C >
+    struct vector_assign< T,E,N,O,true,C >
+    {
+        typedef T& reference;
+        typedef vector_expression< E,N > const& expression_const_reference;
+        typedef O operator_type;
+
+        void operator()( reference v, expression_const_reference e )
+        {
+            for( std::size_t i = 0; i != N; ++i ) 
+                operator_type()( v( i ), e()( i ) );
+        }
+    };
+
+    template< class T, std::size_t N1, bool I1, class A1, std::size_t N, bool I, class A, class E, class O, bool C >
+    struct vector_assign< vector< vector< T,N1,I1,A1 >,N,I,A >,E,N,O,true,C >
+    {
+        typedef vector< vector< T,N1,I1,A1 >,N,I,A >& reference;
+        typedef vector_expression< E,N > const& expression_const_reference;
+
+        void operator()( reference v, expression_const_reference e )
+        {
+            for( std::size_t i = 0; i != N; ++i )
+                e()( v( i ),i );
+        }
+    };
+
+//--
+
+    template< class T, class E, std::size_t N, class O >
+    struct vector_assign< T,E,N,O,false,true >
+    {
+        typedef T& reference;
+        typedef vector_expression< E,N > const& expression_const_reference;
+        typedef O operator_type;
+
+        void operator()( reference v, expression_const_reference e )
+        {
+            for( std::size_t i = 0; i != N; ++i )
+                operator_type()( v( i ), e()( i ) );
+        }
+    };
+
+//--
+//--
+
+    template< class E, std::size_t N, class O, bool L >
+    class vector_unary_expression
+        : public vector_expression< vector_unary_expression< E,N,O,L >,N >
+    {
+    public:
+
+        typedef vector_unary_expression type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef typename E::type_const_reference expression_const_reference;
+        typedef E expression_type;
+        typedef O operator_type;
+        typedef typename O::result_type result_type;
+        typedef result_type element_type;
+        typedef element_type const& const_reference;
+        typedef element_type& reference;
+        typedef typename operator_type::size_type size_type;
+        typedef typename operator_type::allocator_type allocator_type;
+
+        using vector_expression< type,N >::operator();
+
+        enum { size = N };
+        enum { linear = ( L & E::linear ) };
+
+        vector_unary_expression( E const& );
+
+        expression_type const& expression() const;
+
+        result_type const operator()( size_type ) const;
+
+        template< class U > 
+        bool const references( scalar< U > const& ) const;
+        template< class U, std::size_t Q, bool J, class B >
+        bool const references( vector< U,Q,J,B > const& ) const;
+        template< class U, std::size_t P, std::size_t Q, bool J, class B >
+        bool const references( matrix< U,P,Q,J,B > const& ) const;
+
+    private:
+
+        expression_const_reference t;
+
+    };
+
+//--
+
+    template< class E, std::size_t N, class O, bool L >
+    vector_unary_expression< E,N,O,L >::vector_unary_expression( E const& e )
+        : t( e )
+    {}
+
+    template< class E, std::size_t N, class O, bool L >
+    typename vector_unary_expression< E,N,O,L >::expression_type const& 
+        vector_unary_expression< E,N,O,L >::expression() const
+    {
+        return t;
+    }
+
+    template< class E, std::size_t N, class O, bool L >
+    typename vector_unary_expression< E,N,O,L >::result_type const 
+        vector_unary_expression< E,N,O,L >::operator()( size_type s ) const
+    {
+        return operator_type()( t( s ) );
+    }
+
+    template< class E, std::size_t N, class O, bool L > template< class U >
+    bool const vector_unary_expression< E,N,O,L >::references( scalar< U > const& s ) const
+    {
+        return ( t().references( s ) );
+    }
+
+    template< class E, std::size_t N, class O, bool L > template< class U, std::size_t Q, bool J, class B >
+    bool const vector_unary_expression< E,N,O,L >::references( vector< U,Q,J,B > const& v ) const
+    {
+        return ( t().references( v ) );
+    }
+
+    template< class E, std::size_t N, class O, bool L > template< class U, std::size_t P, std::size_t Q, bool J, class B >
+    bool const vector_unary_expression< E,N,O,L >::references( matrix< U,P,Q,J,B > const& m ) const
+    {
+        return ( t().references( m ) );
+    }
+
+//--
+
+    template< class E, std::size_t N >
+    vector_unary_expression< E,N,scalar_negate< E >,true >
+    operator-( vector_expression< E,N > const& e )
+    {
+        return vector_unary_expression< E,N,scalar_negate< E >,true >( e() );
+    }
+
+    template< class E, std::size_t N >
+    vector_unary_expression< E,N,scalar_sin< E >,true >
+    sin( vector_expression< E,N > const& e )
+    {
+        return vector_unary_expression< E,N,scalar_sin< E >,true >( e() );
+    }
+
+    template< class E, std::size_t N >
+    vector_unary_expression< E,N,scalar_cos< E >,true >
+    cos( vector_expression< E,N > const& e )
+    {
+        return vector_unary_expression< E,N,scalar_cos< E >,true >( e() );
+    }
+
+    template< class E, std::size_t N >
+    vector_unary_expression< E,N,scalar_tan< E >,true >
+    tan( vector_expression< E,N > const& e )
+    {
+        return vector_unary_expression< E,N,scalar_tan< E >,true >( e() );
+    }
+
+    template< class E, std::size_t N >
+    vector_unary_expression< E,N,scalar_cosec< E >,true >
+    cosec( vector_expression< E,N > const& e )
+    {
+        return vector_unary_expression< E,N,scalar_cosec< E >,true >( e() );
+    }
+
+    template< class E, std::size_t N >
+    vector_unary_expression< E,N,scalar_sec< E >,true >
+    sec( vector_expression< E,N > const& e )
+    {
+        return vector_unary_expression< E,N,scalar_sec< E >,true >( e() );
+    }
+
+    template< class E, std::size_t N >
+    vector_unary_expression< E,N,scalar_cot< E >,true >
+    cot( vector_expression< E,N > const& e )
+    {
+        return vector_unary_expression< E,N,scalar_cot< E >,true >( e() );
+    }
+
+    template< class E, std::size_t N >
+    vector_unary_expression< E,N,scalar_sinh< E >,true >
+    sinh( vector_expression< E,N > const& e )
+    {
+        return vector_unary_expression< E,N,scalar_sinh< E >,true >( e() );
+    }
+
+    template< class E, std::size_t N >
+    vector_unary_expression< E,N,scalar_cosh< E >,true >
+    cosh( vector_expression< E,N > const& e )
+    {
+        return vector_unary_expression< E,N,scalar_cosh< E >,true >( e() );
+    }
+
+    template< class E, std::size_t N >
+    vector_unary_expression< E,N,scalar_tanh< E >,true >
+    tanh( vector_expression< E,N > const& e )
+    {
+        return vector_unary_expression< E,N,scalar_tanh< E >,true >( e() );
+    }
+
+    template< class E, std::size_t N >
+    vector_unary_expression< E,N,scalar_cosech< E >,true >
+    cosech( vector_expression< E,N > const& e )
+    {
+        return vector_unary_expression< E,N,scalar_cosech< E >,true >( e() );
+    }
+
+    template< class E, std::size_t N >
+    vector_unary_expression< E,N,scalar_sech< E >,true >
+    sech( vector_expression< E,N > const& e )
+    {
+        return vector_unary_expression< E,N,scalar_sech< E >,true >( e() );
+    }
+
+    template< class E, std::size_t N >
+    vector_unary_expression< E,N,scalar_coth< E >,true >
+    coth( vector_expression< E,N > const& e )
+    {
+        return vector_unary_expression< E,N,scalar_coth< E >,true >( e() );
+    }
+
+    template< class E, std::size_t N >
+    vector_unary_expression< E,N,scalar_asin< E >,true >
+    asin( vector_expression< E,N > const& e )
+    {
+        return vector_unary_expression< E,N,scalar_asin< E >,true >( e() );
+    }
+
+    template< class E, std::size_t N >
+    vector_unary_expression< E,N,scalar_acos< E >,true >
+    acos( vector_expression< E,N > const& e )
+    {
+        return vector_unary_expression< E,N,scalar_acos< E >,true >( e() );
+    }
+
+    template< class E, std::size_t N >
+    vector_unary_expression< E,N,scalar_atan< E >,true >
+    atan( vector_expression< E,N > const& e )
+    {
+        return vector_unary_expression< E,N,scalar_atan< E >,true >( e() );
+    }
+
+    template< class E, std::size_t N >
+    vector_unary_expression< E,N,scalar_asinh< E >,true >
+    asinh( vector_expression< E,N > const& e )
+    {
+        return vector_unary_expression< E,N,scalar_asinh< E >,true >( e() );
+    }
+
+    template< class E, std::size_t N >
+    vector_unary_expression< E,N,scalar_acosh< E >,true >
+    acosh( vector_expression< E,N > const& e )
+    {
+        return vector_unary_expression< E,N,scalar_acosh< E >,true >( e() );
+    }
+
+    template< class E, std::size_t N >
+    vector_unary_expression< E,N,scalar_atanh< E >,true >
+    atanh( vector_expression< E,N > const& e )
+    {
+        return vector_unary_expression< E,N,scalar_atanh< E >,true >( e() );
+    }
+
+    template< class E, std::size_t N >
+    vector_unary_expression< E,N,scalar_exp< E >,true >
+    exp( vector_expression< E,N > const& e )
+    {
+        return vector_unary_expression< E,N,scalar_exp< E >,true >( e() );
+    }
+
+    template< class E, std::size_t N >
+    vector_unary_expression< E,N,scalar_log< E >,true >
+    log( vector_expression< E,N > const& e )
+    {
+        return vector_unary_expression< E,N,scalar_log< E >,true >( e() );
+    }
+
+    template< class E, std::size_t N >
+    vector_unary_expression< E,N,scalar_log10< E >,true >
+    log10( vector_expression< E,N > const& e )
+    {
+        return vector_unary_expression< E,N,scalar_log10< E >,true >( e() );
+    }
+
+    template< class E, std::size_t N >
+    vector_unary_expression< E,N,scalar_sqrt< E >,true >
+    sqrt( vector_expression< E,N > const& e )
+    {
+        return vector_unary_expression< E,N,scalar_sqrt< E >,true >( e() );
+    }
+
+    template< class E, std::size_t N >
+    vector_unary_expression< E,N,scalar_abs< E >,true >
+    abs( vector_expression< E,N > const& e )
+    {
+        return vector_unary_expression< E,N,scalar_abs< E >,true >( e() );
+    }
+
+    template< class E, std::size_t N >
+    vector_unary_expression< E,N,scalar_fabs< E >,true >
+    fabs( vector_expression< E,N > const& e )
+    {
+        return vector_unary_expression< E,N,scalar_fabs< E >,true >( e() );
+    }
+
+//--
+//--
+
+    template< class E, std::size_t N, class O, bool L >
+    class vector_vector_expression
+        : public vector_expression< vector_vector_expression< E,N,O,L >,N >
+    {
+    public:
+
+        typedef vector_vector_expression type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef O operator_type;
+        typedef typename O::result_type result_type;
+        typedef result_type element_type;
+        typedef element_type const& const_reference;
+        typedef element_type& reference;
+        typedef typename operator_type::size_type size_type;
+        typedef typename operator_type::allocator_type allocator_type;
+
+        using vector_expression< type,N >::operator();
+
+        enum { size = N };
+        enum { linear = ( L & E::linear ) };
+
+        vector_vector_expression();
+
+        result_type const operator()( size_type ) const;
+
+        template< class U > 
+        bool const references( scalar< U > const& ) const;
+        template< class U, std::size_t Q, bool J, class B > 
+        bool const references( vector< U,Q,J,B > const& ) const;
+        template< class U, std::size_t P, std::size_t Q, bool J, class B > 
+        bool const references( matrix< U,P,Q,J,B > const& ) const;
+
+    };
+
+//--
+
+    template< class E, std::size_t N, class O, bool L > 
+    vector_vector_expression< E,N,O,L >::vector_vector_expression()
+    {}
+
+    template< class E, std::size_t N, class O, bool L >
+    typename vector_vector_expression< E,N,O,L >::result_type const 
+        vector_vector_expression< E,N,O,L >::operator()( size_type s ) const
+    {
+        return operator_type()( s );
+    }
+
+    template< class E, std::size_t N, class O, bool L > template< class U >
+    bool const vector_vector_expression< E,N,O,L >::references( scalar< U > const& ) const
+    {
+        return false;
+    }
+
+    template< class E, std::size_t N, class O, bool L > template< class U, std::size_t Q, bool J, class B >
+    bool const vector_vector_expression< E,N,O,L >::references( vector< U,Q,J,B > const& ) const
+    {
+        return false;
+    }
+
+    template< class E, std::size_t N, class O, bool L > template< class U, std::size_t P, std::size_t Q, bool J, class B >
+    bool const vector_vector_expression< E,N,O,L >::references( matrix< U,P,Q,J,B > const& ) const
+    {
+        return false;
+    }
+
+//--
+
+    template< class T, std::size_t I >
+    struct vector_standard_basis
+        : expression_unary_traits< T >
+    {
+        typedef typename expression_unary_traits< T >::result_type result_type;
+        typedef typename expression_unary_traits< T >::size_type size_type;
+
+        result_type operator()( size_type s )
+        {
+            return s == I ? result_type(1) : result_type(0);
+        }
+    };
+
+//--
+
+    // N = number of elements in (virtual) vector
+    // I ( < N ) is the zero-based index of basis identity component
+    template< class T, std::size_t N, std::size_t I >
+    vector_vector_expression< vector< T,N >,N,vector_standard_basis< vector< T,N >,I >,true >
+    standard_basis()
+    {
+        BOOST_STATIC_ASSERT( I < N );
+        return vector_vector_expression< vector< T,N >,N, 
+            vector_standard_basis< vector< T,N >,I >,true >();
+    }
+
+//--
+
+}} // namespace boost, namespace maps
+
+#endif // BOOST_MAPS_MATH_VECTOR_VECTOR_HPP
\ No newline at end of file
Added: sandbox/maps/boost/maps/support/assigner.hpp
==============================================================================
--- (empty file)
+++ sandbox/maps/boost/maps/support/assigner.hpp	2011-08-08 19:51:30 EDT (Mon, 08 Aug 2011)
@@ -0,0 +1,138 @@
+//--
+// Copyright (c) 2010-2011 Brian Smith
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/maps for documentation.
+//--
+#if !defined( BOOST_MAPS_SUPPORT_ASSIGNER_HPP )
+#define BOOST_MAPS_SUPPORT_ASSIGNER_HPP
+
+namespace boost { namespace maps {
+
+//--
+
+    template< class T, std::size_t N >
+    class assigner 
+    {
+    public:
+
+        typedef assigner type;
+        typedef typename T::iterator iterator;
+        typedef typename T::const_reference const_reference;
+
+        assigner( T&, iterator, const_reference );
+
+        assigner< T,N-1 > operator,( const_reference );
+
+    private:
+
+        friend class assigner< T,N+1 >;
+        assigner( T&, iterator );
+        type& operator=( type const& );
+
+        iterator iter;
+        T& t;
+
+    };
+
+    template< class T >
+    class assigner< T,1 > 
+    {
+    public:
+
+        typedef assigner type;
+        typedef typename T::iterator iterator;
+        typedef typename T::const_reference const_reference;
+
+        assigner( T&, iterator, const_reference );
+
+        T& operator,( const_reference );
+
+    private:
+
+        friend class assigner< T,2 >;
+        assigner( T&, iterator );
+        type& operator=( type const& );
+
+        iterator iter;
+        T& t;
+
+    };
+
+
+    template< class T >
+    class assigner< T,0 > 
+    {
+    public:
+
+        typedef assigner type;
+        typedef typename T::iterator iterator;
+        typedef typename T::const_reference const_reference;
+
+        assigner( T&, iterator, const_reference );
+
+        T& operator,( const_reference );
+
+    private:
+
+        friend class assigner< T,1 >;
+        assigner( T&, iterator );
+
+    };
+
+//--
+//--
+
+    template< class T, std::size_t N >
+    assigner< T,N >::assigner( T& t, iterator i, const_reference x ) 
+        : t( t ), iter( i ) 
+    {
+        *iter++ = x;
+    }
+
+    template< class T, std::size_t N >
+    assigner< T,N-1 > assigner< T,N >::operator,( const_reference x )
+    {
+        *iter = x; return assigner< T,N-1 >( t, ++iter );
+    }
+
+    template< class T, std::size_t N >
+    assigner< T,N >::assigner( T& t, iterator i ) 
+        : t( t ), iter( i )
+    {}
+
+//--
+
+    template< class T >
+    assigner< T,1 >::assigner( T& t, iterator i, const_reference x ) 
+        : t( t ), iter( i )
+    {
+        *iter++ = x;
+    }
+
+    template< class T >
+    T& assigner< T,1 >::operator,( const_reference x ) 
+    {
+        *iter = x; return t;
+    }
+
+    template< class T >
+    assigner< T,1 >::assigner( T& t, iterator i ) 
+        : t( t ), iter( i )
+    {}
+
+//--
+
+    template< class T >
+    assigner< T,0 >::assigner( T&, iterator i, const_reference x ) 
+    {
+        *i = x;
+    }
+
+//--
+
+}} // namespace boost, namespace maps
+
+#endif // BOOST_MAPS_SUPPORT_ASSIGNER_HPP
\ No newline at end of file
Added: sandbox/maps/boost/maps/support/bounds.hpp
==============================================================================
--- (empty file)
+++ sandbox/maps/boost/maps/support/bounds.hpp	2011-08-08 19:51:30 EDT (Mon, 08 Aug 2011)
@@ -0,0 +1,354 @@
+//--
+// Copyright (c) 2010-2011 Brian Smith
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/maps for documentation.
+//--
+#if !defined( BOOST_MAPS_SUPPORT_BOUNDS_HPP )
+#define BOOST_MAPS_SUPPORT_BOUNDS_HPP
+
+#include <boost/maps/support/assigner.hpp>
+
+#ifdef BOOST_MSVC
+# pragma warning( push )
+# pragma warning( disable : 4351 ) // new behavior: elements of array 'array' will be default initialized
+#endif
+
+namespace boost { namespace maps {
+
+//--
+
+    template< std::size_t N > class bounds;
+    template< std::size_t N > struct bounds_assign;
+
+//--
+
+    template< std::size_t N >
+    struct bounds_assigner
+    {
+        typedef assigner< bounds< N >,N-1 > type;
+    };
+
+    template<>
+    struct bounds_assigner< 1 >
+    {
+        typedef bounds< 1 > type;
+    };
+
+//--
+
+    template< std::size_t N >
+    class bounds
+    {
+    public:
+
+        typedef bounds type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef type const* type_const_pointer;
+        typedef type* type_pointer;
+        typedef std::size_t size_type;
+        typedef std::size_t element_type;
+        typedef element_type value_type;
+        typedef value_type const& const_reference;
+        typedef value_type& reference;
+        typedef value_type const* const_iterator;
+        typedef value_type* iterator;
+        typedef typename bounds_assigner< N >::type assigner;
+
+        enum { size = N };
+
+        bounds();
+        explicit bounds( const_reference );
+
+        assigner operator=( const_reference );
+
+        const_reference operator[]( size_type ) const;
+        reference operator[]( size_type );
+
+        void fill( const_reference );
+
+        const_iterator begin() const;
+        iterator begin();
+        const_iterator end() const;
+        iterator end();
+
+    protected:
+
+        typedef typename detail::array_type_< std::size_t,1,N >::type data_type;
+
+        data_type data;
+
+    };
+
+//--
+//--
+
+    template< std::size_t N >
+    bounds< N >::bounds() : data() 
+    {}
+
+    template< std::size_t N >
+    bounds< N >::bounds( const_reference s ) 
+    {
+        std::fill_n( data, N, s ); 
+    }
+
+    template< std::size_t N >
+    typename bounds< N >::assigner bounds< N >::operator=( const_reference x ) 
+    {
+        return bounds_assign< N >()( *this, data, x );
+    }
+
+    template< std::size_t N >
+    typename bounds< N >::const_reference bounds< N >::operator[]( size_type s ) const 
+    {
+        BOOST_ASSERT( s < N ); 
+        return data[s]; 
+    }
+
+    template< std::size_t N >
+    typename bounds< N >::reference bounds< N >::operator[]( size_type s ) 
+    {
+        BOOST_ASSERT( s < N ); 
+        return data[s]; 
+    }
+
+    template< std::size_t N >
+    void bounds< N >::fill( const_reference s )
+    {
+        std::fill_n( data, N, s );
+    }
+
+    template< std::size_t N >
+    typename bounds< N >::const_iterator bounds< N >::begin() const 
+    { 
+        return data; 
+    }
+
+    template< std::size_t N >
+    typename bounds< N >::iterator bounds< N >::begin() 
+    { 
+        return data; 
+    }
+
+    template< std::size_t N >
+    typename bounds< N >::const_iterator bounds< N >::end() const 
+    { 
+        return data+N; 
+    }
+
+    template< std::size_t N >
+    typename bounds< N >::iterator bounds< N >::end() 
+    { 
+        return data+N; 
+    }
+
+//--
+
+    template<>
+    class bounds< 0 >
+    {
+    public:
+
+        typedef bounds< 0 > type;
+        typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef type const* type_const_pointer;
+        typedef type* type_pointer;
+        typedef std::size_t size_type;
+        typedef void element_type;
+        typedef element_type value_type;
+        typedef value_type const_reference;
+        typedef value_type reference;
+        typedef value_type const* const_iterator;
+        typedef value_type* iterator;
+
+        enum { size = 0 };
+
+    };
+
+//--
+//--
+
+    template< std::size_t N >
+    struct bounds_assign
+    {
+        typedef typename bounds< N >::assigner assigner;
+        typedef typename bounds< N >::type_reference type_reference;
+        typedef typename bounds< N >::iterator iterator;
+        typedef typename bounds< N >::const_reference const_reference;
+
+        assigner operator()( type_reference b, iterator i, const_reference x )
+        {
+            return assigner( b, i, x );
+        }
+    };
+
+    template<>
+    struct bounds_assign< 1 >
+    {
+        typedef bounds< 1 >::type_reference type_reference;
+        typedef bounds< 1 >::iterator iterator;
+        typedef bounds< 1 >::const_reference const_reference;
+
+        type_reference operator()( type_reference b, iterator i, const_reference x )
+        {
+            *i = x; return b;
+        }
+    };
+
+//--
+//--
+
+    template< std::size_t N >
+    class dimensions
+        : public bounds< N >
+    {
+    public:
+
+        typedef dimensions type;
+        typedef bounds< N > base_type;
+            typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef type const* type_const_pointer;
+        typedef type* type_pointer;
+        typedef std::size_t size_type;
+        typedef std::size_t element_type;
+        typedef element_type value_type;
+        typedef value_type const& const_reference;
+        typedef value_type& reference;
+        typedef value_type const* const_iterator;
+        typedef value_type* iterator;
+        typedef typename bounds_assigner< N >::type assigner;
+
+        dimensions();
+
+        assigner operator=( const_reference );
+
+    };
+
+//--
+//--
+
+    template< std::size_t N >
+    dimensions< N >::dimensions()
+    {}
+
+    template< std::size_t N >
+    typename dimensions< N >::assigner dimensions< N >::operator=( const_reference x )
+    {
+        return base_type::operator=( x );
+    }
+
+//--
+
+    template<>
+    class dimensions< 0 >
+        : public bounds< 0 >
+    {};
+
+//--
+//--
+
+    template< std::size_t N >
+    class indexes
+        : public bounds< N >
+    {
+    public:
+
+        typedef indexes type;
+        typedef bounds< N > base_type;
+            typedef type const& type_const_reference;
+        typedef type& type_reference;
+        typedef type const* type_const_pointer;
+        typedef type* type_pointer;
+        typedef std::size_t size_type;
+        typedef std::size_t element_type;
+        typedef element_type value_type;
+        typedef value_type const& const_reference;
+        typedef value_type& reference;
+        typedef value_type const* const_iterator;
+        typedef value_type* iterator;
+        typedef typename bounds_assigner< N >::type assigner;
+
+        indexes();
+
+        assigner operator=( const_reference );
+
+    };
+
+//--
+//--
+
+    template< std::size_t N >
+    indexes< N >::indexes() 
+    {}
+
+    template< std::size_t N >
+    typename indexes< N >::assigner indexes< N >::operator=( const_reference x )
+    {
+        return base_type::operator=( x );
+    }
+
+//--
+
+    template<>
+    class indexes< 0 >
+        : public bounds< 0 >
+    {};
+
+//--
+//--
+
+    template< std::size_t N >
+    bool operator==( bounds< N > const& x, bounds< N > const& y )
+    {
+        for( std::size_t i = 0; i != N; ++i ) 
+            if( !( x[i] == y[i] ) ) return false;
+        return true;
+    }
+
+    template< std::size_t N >
+    bool operator<( bounds< N > const& x, bounds< N > const& y )
+    {
+        for( std::size_t i = 0; i != N; ++i ) 
+            if( !( x[i] < y[i] ) ) return false;
+        return true;
+    }
+
+    template< std::size_t N >
+    bool operator!=( bounds< N > const& x, bounds< N > const& y )
+    {
+        return !( x == y );
+    }
+
+    template< std::size_t N >
+    bool operator>( bounds< N > const& x, bounds< N > const& y )
+    {
+        return y < x;
+    }
+
+    template< std::size_t N >
+    bool operator<=( bounds< N > const& x, bounds< N > const& y )
+    {
+        return !( y < x );
+    }
+
+    template< std::size_t N >
+    bool operator>=( bounds< N > const& x, bounds< N > const& y )
+    {
+        return !( x < y );
+    }
+
+//--
+
+}} // namespace boost, namespace maps
+
+#ifdef BOOST_MSVC
+# pragma warning( pop )
+#endif
+
+#endif // BOOST_MAPS_SUPPORT_BOUNDS_HPP
Added: sandbox/maps/boost/maps/support/expression.hpp
==============================================================================
--- (empty file)
+++ sandbox/maps/boost/maps/support/expression.hpp	2011-08-08 19:51:30 EDT (Mon, 08 Aug 2011)
@@ -0,0 +1,122 @@
+//--
+// Copyright (c) 2010-2011 Brian Smith
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/maps for documentation.
+//--
+#if !defined( BOOST_MAPS_SUPPORT_EXPRESSION_HPP )
+#define BOOST_MAPS_SUPPORT_EXPRESSION_HPP
+
+#include <boost/type_traits/common_type.hpp>
+
+namespace boost { namespace maps {
+
+//--
+
+    template< class E >
+    class expression_type
+    {
+    public:
+
+        typedef expression_type type;
+        typedef E value_type;
+        typedef value_type const& const_reference;
+        typedef value_type& reference;
+
+        const_reference operator()() const
+        {
+            return *static_cast< const value_type* >( this );
+        }
+
+        reference operator()()
+        {
+            return *static_cast< value_type* >( this );
+        }
+
+    protected:
+
+        expression_type() {}
+        ~expression_type() {}
+
+    };
+
+//--
+//--
+
+    template< class E >
+    class expression
+        : expression_type< expression< E > >
+    {
+    public:
+
+        typedef expression type;
+        typedef E value_type;
+        typedef value_type const& const_reference;
+        typedef value_type& reference;
+
+        const_reference operator()() const
+        {
+            return *static_cast< const value_type* >( this );
+        }
+
+        reference operator()()
+        {
+            return *static_cast< value_type* >( this );
+        }
+
+    };
+
+//--
+//--
+
+    template< class T >
+    struct expression_traits
+    {
+        typedef T type;
+        typedef typename type::type_const_reference type_const_reference;
+        typedef typename type::type_reference type_reference;
+        typedef typename type::const_reference const_reference;
+        typedef typename type::reference reference;
+        typedef typename type::element_type element_type;
+        typedef typename type::allocator_type allocator_type;
+        typedef typename type::size_type size_type;
+    };
+
+    template< class T1, class T2 >
+    struct expression_binary_traits
+    {
+        typedef typename expression_traits< T1 >::type_const_reference type_const_reference1;
+        typedef typename expression_traits< T2 >::type_const_reference type_const_reference2;
+        typedef typename expression_traits< T1 >::type_reference type_reference1;
+        typedef typename expression_traits< T2 >::type_reference type_reference2;
+        typedef typename expression_traits< T1 >::const_reference const_reference1;
+        typedef typename expression_traits< T2 >::const_reference const_reference2;
+        typedef typename expression_traits< T1 >::reference reference1;
+        typedef typename expression_traits< T2 >::reference reference2;
+        typedef typename expression_traits< T1 >::element_type element_type1;
+        typedef typename expression_traits< T2 >::element_type element_type2;
+        typedef typename common_type< element_type1,element_type2 >::type result_type;
+        typedef typename expression_traits< T1 >::allocator_type allocator_type;
+        typedef typename expression_traits< T1 >::size_type size_type;
+    };
+
+    template< class T >
+    struct expression_unary_traits
+    {
+        typedef typename expression_traits< T >::type_const_reference type_const_reference;
+        typedef typename expression_traits< T >::type_reference type_reference;
+        typedef typename expression_traits< T >::const_reference const_reference;
+        typedef typename expression_traits< T >::reference reference;
+        typedef typename expression_traits< T >::element_type element_type;
+        typedef typename expression_traits< T >::element_type result_type;
+        typedef typename expression_traits< T >::allocator_type allocator_type;
+        typedef typename expression_traits< T >::size_type size_type;
+    };
+
+//--
+
+}} // namespace boost, namespace maps
+
+#endif // BOOST_MAPS_SUPPORT_EXPRESSION_HPP
Added: sandbox/maps/boost/maps/support/generic.hpp
==============================================================================
--- (empty file)
+++ sandbox/maps/boost/maps/support/generic.hpp	2011-08-08 19:51:30 EDT (Mon, 08 Aug 2011)
@@ -0,0 +1,615 @@
+//--
+// Copyright (c) 2010-2011 Brian Smith
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/maps for documentation.
+//--
+#if !defined( BOOST_MAPS_SUPPORT_GENERIC_HPP )
+#define BOOST_MAPS_SUPPORT_GENERIC_HPP
+
+#include <boost/maps/support/preprocessor_bounds.hpp>
+
+#include <boost/type_traits/add_pointer.hpp>
+#include <boost/type_traits/has_trivial_constructor.hpp>
+#include <boost/type_traits/has_trivial_destructor.hpp>
+
+#include <boost/mpl/vector.hpp>
+#include <boost/mpl/size.hpp>
+#include <boost/mpl/front.hpp>
+#include <boost/mpl/back.hpp>
+#include <boost/mpl/at.hpp>
+#include <boost/mpl/push_back.hpp>
+#include <boost/mpl/pop_front.hpp>
+#include <boost/mpl/pop_back.hpp>
+#include <boost/mpl/begin.hpp>
+#include <boost/mpl/deref.hpp>
+#include <boost/mpl/next.hpp>
+#include <boost/mpl/size_t.hpp>
+#include <boost/mpl/integral_c.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/and.hpp>
+#include <boost/mpl/or.hpp>
+#include <boost/mpl/not.hpp>
+#include <boost/mpl/less_equal.hpp>
+#include <boost/mpl/less.hpp>
+#include <boost/mpl/equal.hpp>
+#include <boost/mpl/equal_to.hpp>
+#include <boost/mpl/not_equal_to.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/modulus.hpp>
+#include <boost/mpl/divides.hpp>
+#include <boost/mpl/minus.hpp>
+#include <boost/mpl/assert.hpp>
+
+namespace boost { namespace maps {
+
+//--
+
+    namespace null { 
+
+    struct allocator 
+    {
+        template< class T >
+        struct rebind { typedef allocator other; };
+
+        typedef std::size_t size_type;
+        typedef std::ptrdiff_t difference_type;
+    };
+
+    } // namespace null
+
+//--
+
+    template< class T, std::size_t N >
+    struct pointer_type
+    {
+        typedef typename pointer_type<
+            typename add_pointer< T >::type,N-1
+                >::type type;
+    };
+
+    template< class T >
+    struct pointer_type< T,0 >
+    {
+        typedef T type;
+    };
+
+//--
+//--
+
+    namespace detail {
+
+    template< class T, std::size_t N, class I >
+    struct array_type
+    {
+        typedef typename array_type< 
+            T,N-1,typename mpl::next< I >::type
+                >::type type[ mpl::deref< I >::type::value ];
+    };
+
+    template< class T, class I >
+    struct array_type< T,0,I >
+    {
+        typedef T type;
+    };
+
+//--
+
+    template< class T, std::size_t N, class I >
+    struct array_transverse_type
+    {
+        typedef typename array_transverse_type< 
+            T[ mpl::deref< I >::type::value ],N-1,typename mpl::next< I >::type
+                >::type type;
+    };
+
+    template< class T, class I >
+    struct array_transverse_type< T,0,I >
+    {
+        typedef T type;
+    };
+
+//--
+
+    template< std::size_t N, class I >
+    struct array_size
+    {
+        typedef mpl::size_t< 
+            mpl::deref< I >::type::value * 
+                array_size< N-1,typename mpl::next< I >::type >::type::value 
+                    > type;
+    };
+
+    template< class I >
+    struct array_size< 1,I >
+    {
+        typedef mpl::size_t< 
+            mpl::deref< I >::type::value 
+                > type;
+    };
+
+    } // namespace detail
+
+//--
+//--
+
+    template< class T, std::size_t N, class B, class A >
+    struct array_type
+    {
+        typedef typename pointer_type< T,N >::type type;
+    };
+
+    template< class T, std::size_t N, class B >
+    struct array_type< T,N,B,null::allocator >
+    {
+        typedef typename detail::array_type< T,N,B >::type type;
+    };
+
+//--
+
+    template< class T, class B, class A >
+    struct array_member_type
+    {
+        typedef typename array_type< 
+            T,mpl::size< B >::type::value,typename mpl::begin< B >::type,A 
+                >::type type;
+    };
+
+//--
+
+    template< class T, class B, class A >
+    struct array_value_type
+    {
+        typedef typename array_type< 
+            T,mpl::size< B >::type::value-1,typename mpl::next< typename mpl::begin< B >::type >::type,A 
+                >::type type;
+    };
+
+//--
+
+    template< class B >
+    struct array_size
+    {
+        typedef typename detail::array_size< 
+            mpl::size< B >::type::value,typename mpl::begin< B >::type 
+                >::type type;
+    };
+
+//--
+
+    template< class T, bool I, class A >
+    struct array_initialize
+    {
+        typedef typename mpl::or_< 
+            mpl::not_< has_trivial_constructor< T > >,mpl::bool_< I > 
+                >::type type;
+    };
+
+    template< class T, bool I >
+    struct array_initialize< T,I,null::allocator >
+    {
+        typedef typename mpl::if_<  
+            has_trivial_constructor< T >,mpl::bool_< I >,mpl::bool_< false >
+                >::type type;
+    };
+
+//--
+//--
+
+    namespace detail {
+
+    template< class T, std::size_t N, std::size_t D >
+    struct array_type_
+    {
+        typedef typename array_type_< 
+            T[D],N-1,D 
+                >::type type;
+    };
+
+    template< class T, std::size_t D >
+    struct array_type_< T,0,D >
+    {
+        typedef T type;
+    };
+
+//--
+
+    template< std::size_t N, std::size_t D >
+    struct array_size_
+    {
+        typedef mpl::size_t< 
+            D * array_size_< N-1,D >::type::value
+                > type;
+    };
+
+    template< std::size_t D >
+    struct array_size_< 1, D >
+    {
+        typedef mpl::size_t< D > type;
+    };
+
+//--
+
+    template< class B, std::size_t N, std::size_t D >
+    struct array_bounds_
+    {
+        typedef typename array_bounds_< 
+            typename mpl::push_back< B,mpl::integral_c< std::size_t,D > >::type,N-1,D 
+                >::type type;
+    };
+
+    template< class B, std::size_t D >
+    struct array_bounds_< B,0,D >
+    {
+        typedef B type;
+    };
+
+    } // namespace detail
+
+//--
+
+    template< class T, std::size_t N, std::size_t D, class A >
+    struct array_type_
+    {
+        typedef typename pointer_type< T,N >::type type;
+    };
+
+    template< class T, std::size_t N, std::size_t D >
+    struct array_type_< T,N,D,null::allocator >
+    {
+        typedef typename detail::array_type_< T,N,D >::type type;
+    };
+
+//--
+
+    template< class T, std::size_t N, std::size_t D, class A >
+    struct array_member_type_
+    {
+        typedef typename array_type_< T,N,D,A >::type type;
+    };
+
+//--
+
+    template< class T, std::size_t N, std::size_t D, class A >
+    struct array_value_type_
+    {
+        typedef typename array_type_< T,N-1,D,A >::type type;
+    };
+
+//--
+
+    template< std::size_t N, std::size_t D >
+    struct array_size_
+    {
+        typedef typename detail::array_size_< N,D >::type type;
+    };
+
+//--
+
+    template< std::size_t N, std::size_t D >
+    struct array_bounds_
+    {
+        typedef typename detail::array_bounds_< 
+            mpl::vector0<>,N,D 
+                >::type type;
+    };
+
+//--
+//--
+
+    template< class T, std::size_t N, bool I = false, class A = std::allocator< T > > class pointer;
+    template< class T, class B, bool I = true, class A = null::allocator > class array;
+    template< class T, std::size_t N, std::size_t D, bool I = true, class A = null::allocator > class array_;
+
+//--
+
+    template< class A >
+    struct sub_type
+    {};
+
+//--
+//--
+
+// view
+
+    template< std::size_t F, std::size_t L, std::size_t S = 1 >
+    struct range
+        : bounds3< F,L,S >
+    {};
+
+    template< std::size_t F, std::size_t L >
+    struct range< F,L,0 >
+        : bounds0
+    {};
+
+    template< std::size_t F, std::size_t S >
+    struct range< F,F,S >
+        : bounds0
+    {};
+
+    template< class R >
+    class view_range
+    {
+        typedef typename mpl::deref< R >::type D;
+        typedef typename mpl::begin< D >::type R1;
+        typedef typename mpl::next< R1 >::type R2;
+        typedef typename mpl::next< R2 >::type R3;
+
+    public:
+
+        typedef mpl::integral_c< std::size_t,mpl::deref< R1 >::type::value > first;
+        typedef mpl::integral_c< std::size_t,mpl::deref< R2 >::type::value > last;
+        typedef mpl::integral_c< std::size_t,mpl::deref< R3 >::type::value > step;
+
+        typedef typename mpl::minus< last,first >::type range;
+        typedef typename mpl::minus< last,step >::type last_index;
+
+        typedef typename mpl::eval_if< 
+            mpl::equal_to< mpl::modulus< range,step >,mpl::size_t< 0 > >, 
+            mpl::integral_c< std::size_t,mpl::divides< range,step >::value >, 
+            mpl::integral_c< std::size_t,0 >
+        >::type bound;
+
+    };
+
+//--
+
+    template< class B, class I, class E, bool S >
+    struct view_validate_
+    {
+        typedef typename mpl::and_< 
+            typename mpl::less_equal< 
+                typename view_range< I >::bound, 
+                typename mpl::front< B >::type
+            >::type,
+            typename mpl::less< 
+                typename view_range< I >::last_index, 
+                typename mpl::front< B >::type
+            >::type,
+            typename mpl::less< 
+                typename view_range< I >::first, 
+                typename view_range< I >::last
+            >::type,
+            typename view_validate_< 
+                typename mpl::pop_front< B >::type, 
+                typename mpl::next< I >::type, 
+                E,
+                S
+            >::type
+        >::type type;
+    };
+
+    template< class B, class E, bool S >
+    struct view_validate_< B,E,E,S >
+    {
+        typedef mpl::bool_< true > type;
+    };
+
+    template< class B, class I, class E >
+    struct view_validate_< B,I,E,false >
+    {
+        typedef mpl::bool_< false > type;
+    };
+
+    template< class A, class R >
+    struct view_valid
+    {
+        typedef typename view_validate_< 
+            typename A::limits_type,
+            typename mpl::begin< R >::type,
+            typename mpl::end< R >::type,
+            mpl::equal< mpl::size< typename A::limits_type >,mpl::size< R > >::type::value 
+        >::type type;
+    };
+
+//--
+    
+    namespace detail {
+
+    template< class B, class I, class E >
+    struct view_bounds
+    {
+        typedef typename view_bounds< 
+            typename mpl::push_back< 
+                B, 
+                typename view_range< typename mpl::deref< I >::type >::bound 
+            >::type, 
+            typename mpl::next< I >::type, 
+            E 
+        >::type type;
+    };
+
+    template< class B, class E >
+    struct view_bounds< B,E,E >
+    {
+        typedef B type;
+    };
+    
+    } // namespace detail
+
+    template< class B, class R >
+    struct view_bounds
+    {
+        typedef typename detail::view_bounds< 
+            B,typename mpl::begin< R >::type,typename mpl::end< R >::type
+                >::type type;
+    };
+
+//--
+
+    template< std::size_t N, class R >
+    struct view_ranges
+    {
+        typedef R type;
+    };
+
+    template< class R >
+    struct view_ranges< 1,R >
+    {
+        typedef mpl::vector1< typename mpl::front< R >::type > type;
+    };
+
+//--
+
+    namespace detail {
+
+    template< class R, class B, class E >
+    struct view_size
+    {
+        typedef typename mpl::size_t< 
+            view_range< typename mpl::front< R >::type >::bound::value * 
+                view_size< typename mpl::pop_front< R >::type,typename mpl::next< B >::type,E >::type::value 
+                    >::type type;
+    };
+
+    template< class R, class E >
+    struct view_size< R,E,E >
+    {
+        typedef mpl::size_t< 1 > type;
+    };
+    
+    } // namespace detail
+
+    template< class R >
+    struct view_size
+    {
+        typedef typename detail::view_size< 
+            R,typename mpl::begin< R >::type,typename mpl::end< R >::type 
+                >::type type;
+    };
+
+//--
+
+    template< class A, class R, bool P > struct view_traits_base_ {};
+    template< class A, class R, bool P > struct view_traits_ {};
+
+//--
+
+    template< class T, class B, bool I, class A, class R, bool P >
+    struct view_traits_base_< array< T,B,I,A >,R,P >
+    {
+        typedef typename view_bounds< mpl::vector0<>,R >::type bounds;
+        typedef array< T*,bounds,false,A > array_type;
+    };
+
+    template< class T, class B, bool I, class A, class R >
+    struct view_traits_base_< array< T,B,I,A >,R,false >
+    {
+        typedef typename view_bounds< mpl::vector0<>,R >::type bounds;
+        typedef array< T,bounds,false,A > array_type;
+    };
+
+//--
+
+    template< class T, class B, bool I, class A, class R, bool P >
+    struct view_traits_< array< T,B,I,A >,R,P >
+        : view_traits_base_< array< T,B,I,A >,R,P >
+    {
+        typedef view_traits_base_< array< T,B,I,A >,R,P > base_type;
+        typedef typename base_type::array_type::member_type member_type;
+        typedef typename base_type::array_type::value_type value_type;
+        typedef typename base_type::array_type::const_reference_type const_reference_type;
+        typedef typename base_type::array_type::reference_type reference_type;
+        typedef typename base_type::array_type::const_iterator_type const_iterator_type;
+        typedef typename base_type::array_type::iterator_type iterator_type;
+        typedef typename base_type::array_type::element_type element_type;
+        typedef typename base_type::array_type::const_iterator const_iterator;
+        typedef typename base_type::array_type::iterator iterator;
+        typedef typename base_type::array_type::const_reference const_reference;
+        typedef typename base_type::array_type::reference reference;
+        typedef typename base_type::array_type::allocator_type allocator_type;
+        typedef typename base_type::array_type::size_type size_type;
+        typedef typename base_type::array_type::difference_type difference_type;
+        typedef typename base_type::array_type::bounds_type bounds_type;
+        typedef typename base_type::array_type::bounds_const_reference bounds_const_reference;
+        typedef typename base_type::bounds bounds;
+        typedef typename view_ranges< base_type::array_type::dimensionality,R >::type ranges;
+
+    };
+
+//--
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A, class R, bool P >
+    struct view_traits_< array_< T,N,D,I,A >,R,P >
+        : view_traits_< array< T,typename array_bounds_< N,D >::type,I,A >,R,P >
+    {};
+
+//--
+
+    template< class A, class R, bool B = true > class view_;
+
+//--
+//--
+
+// view
+
+    template< class T, class A > 
+    struct view_allocator_type
+    {
+        typedef typename A::template rebind< T >::other type;
+    };
+
+    template< class T > 
+    struct view_allocator_type< T,null::allocator >
+    {
+        typedef std::allocator< T > type;
+    };
+
+//--
+
+    template< class P, bool B > 
+    struct view_traits_base 
+    {
+        typedef typename P::element_type* T;
+        typedef typename view_allocator_type< T,typename P::allocator_type >::type A;
+        typedef pointer< T,P::dimensionality,P::initialize::value,A > pointer_type;
+    };
+
+    template< class P > 
+    struct view_traits_base< P,false > 
+    {
+        typedef typename P::element_type T;
+        typedef typename view_allocator_type< T,typename P::allocator_type >::type A;
+        typedef pointer< T,P::dimensionality,P::initialize::value,A > pointer_type;
+    };
+
+//--
+
+    template< class P, bool B >
+    struct view_traits
+        : view_traits_base< P,B >
+    {
+        typedef view_traits_base< P,B > base_type;
+        typedef typename base_type::pointer_type::member_type member_type;
+        typedef typename base_type::pointer_type::value_type value_type;
+        typedef typename base_type::pointer_type::const_reference_type const_reference_type;
+        typedef typename base_type::pointer_type::reference_type reference_type;
+        typedef typename base_type::pointer_type::const_iterator_type const_iterator_type;
+        typedef typename base_type::pointer_type::iterator_type iterator_type;
+        typedef typename base_type::pointer_type::element_type element_type;
+        typedef typename base_type::pointer_type::const_iterator const_iterator;
+        typedef typename base_type::pointer_type::iterator iterator;
+        typedef typename base_type::pointer_type::const_reference const_reference;
+        typedef typename base_type::pointer_type::reference reference;
+        typedef typename base_type::pointer_type::allocator_type allocator_type;
+        typedef typename base_type::pointer_type::size_type size_type;
+        typedef typename base_type::pointer_type::difference_type difference_type;
+        typedef typename base_type::pointer_type::bounds_type bounds_type;
+        typedef typename base_type::pointer_type::bounds_const_reference bounds_const_reference;
+        typedef typename P::limits_type limits_type;
+        typedef array< std::size_t, bounds2< P::dimensionality,3 > > ranges;
+        typedef ranges const& ranges_const_reference;
+
+    };
+
+//--
+
+    template< class P, bool B = true > class view;
+
+//--
+
+}} // namespace boost, namespace maps
+
+#endif // BOOST_MAPS_SUPPORT_GENERIC_HPP
Added: sandbox/maps/boost/maps/support/includes.hpp
==============================================================================
--- (empty file)
+++ sandbox/maps/boost/maps/support/includes.hpp	2011-08-08 19:51:30 EDT (Mon, 08 Aug 2011)
@@ -0,0 +1,28 @@
+//--
+// Copyright (c) 2010-2011 Brian Smith
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/maps for documentation.
+//--
+#if !defined( BOOST_MAPS_SUPPORT_INCLUDES_HPP )
+#define BOOST_MAPS_SUPPORT_INCLUDES_HPP
+
+#include <boost/assert.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/detail/workaround.hpp>
+
+#include <boost/maps/support/expression.hpp>
+#include <boost/maps/support/generic.hpp>
+#include <boost/maps/support/bounds.hpp>
+
+#include <utility>
+#include <sstream>
+#include <memory>
+#include <stdexcept>
+#include <algorithm>
+
+#include <string.h>
+
+#endif // BOOST_MAPS_SUPPORT_INCLUDES_HPP
\ No newline at end of file
Added: sandbox/maps/boost/maps/support/math.hpp
==============================================================================
--- (empty file)
+++ sandbox/maps/boost/maps/support/math.hpp	2011-08-08 19:51:30 EDT (Mon, 08 Aug 2011)
@@ -0,0 +1,246 @@
+//--
+// Copyright (c) 2010-2011 Brian Smith
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/maps for documentation.
+//--
+#if !defined( BOOST_MAPS_SUPPORT_MATH_HPP )
+#define BOOST_MAPS_SUPPORT_MATH_HPP
+
+#include <boost/maps/generic/array.hpp>
+#include <boost/maps/generic/array_.hpp>
+
+namespace boost { namespace maps {
+
+//--
+
+    template< class T, std::size_t N, bool I, class A >
+    struct vector_type
+    {
+        typedef array_< T,1,N,I,A > type;
+    };
+
+//--
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A >
+    struct matrix_type
+    {
+        typedef array< T,bounds2< M,N >,I,A > type;
+    };
+
+//--
+
+    template< class T, std::size_t N, std::size_t D, bool I, class A >
+    struct tensor_type
+    {
+        typedef array_< T,N,D,I,A > type;
+    };
+
+//--
+
+    template< class T > class scalar;
+    template< class T, std::size_t N, bool I = true, class A = null::allocator > class vector;
+    template< class T, std::size_t M, std::size_t N, bool I = true, class A = null::allocator > class matrix;
+    template< class T, std::size_t N, std::size_t D, bool I = true, class A = null::allocator > class tensor;
+
+//--
+
+    template< class T1, class T2 >
+    struct matrix_vector_type
+    {
+        typedef typename common_type< T1,T2 >::type type;
+    };
+
+    template< class T1, std::size_t N, bool I1, class A1, class T2, bool I2, class A2 >
+    struct matrix_vector_type< vector< T1,N,I1,A1 >,vector< T2,N,I2,A2 > >
+    {
+        typedef matrix< typename common_type< T1,T2 >::type,N,N,I1,A1 > type;
+    };
+
+    template< class T1, std::size_t N, bool I1, class A1, class T2, std::size_t M, bool I2, class A2 >
+    struct matrix_vector_type< vector< T1,N,I1,A1 >,matrix< T2,N,M,I2,A2 > >
+    {
+        typedef matrix< typename common_type< T1,T2 >::type,N,M,I2,A2 > type;
+    };
+
+    template< class T1, std::size_t M, std::size_t N, bool I1, class A1, class T2, bool I2, class A2 >
+    struct matrix_vector_type< matrix< T1,M,N,I1,A1 >,vector< T2,N,I2,A2 > >
+    {
+        typedef matrix< typename common_type< T1,T2 >::type,M,N,I1,A1 > type;
+    };
+
+    template< class T1, std::size_t N1, bool I1, class A1, std::size_t N, bool I2, class A2, class T2, bool I3, class A3, bool I4, class A4 >
+    struct matrix_vector_type< vector< vector< T1,N1,I1,A1 >,N,I2,A2 >,vector< vector< T2,N1,I3,A3 >,N,I4,A4 > >
+    {
+        typedef matrix< typename matrix_vector_type< vector< T1,N1,I1,A1 >,vector< T2,N1,I3,A3 > >::type,N1,N1,I1,A1 > type;
+    };
+
+    template< class T1, std::size_t N1, bool I1, class A1, std::size_t N, bool I2, class A2, class T2, std::size_t M1, bool I3, class A3, std::size_t M, bool I4, class A4 >
+    struct matrix_vector_type< vector< vector< T1,N1,I1,A1 >,N,I2,A2 >,matrix< matrix< T2,N1,M1,I3,A3 >,N,M,I4,A4 > >
+    {
+        typedef matrix< typename matrix_vector_type< vector< T1,N1,I1,A1 >,matrix< T2,N1,M1,I3,A3 > >::type,N1,M1,I3,A3 > type;
+    };
+
+    template< class T1, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t N, bool I2, class A2, class T2, bool I3, class A3, bool I4, class A4 >
+    struct matrix_vector_type< matrix< matrix< T1,M1,N1,I1,A1 >,M,N,I2,A2 >,vector< vector< T2,N1,I3,A3 >,N,I4,A4 > >
+    {
+        typedef matrix< typename matrix_vector_type< matrix< T1,M1,N1,I1,A1 >,vector< T2,N1,I3,A3 > >::type,M1,N1,I1,A1 > type;
+    };
+
+//--
+
+    template< class T1, class T2 >
+    struct vector_matrix_type
+    {
+        typedef typename common_type< T1,T2 >::type type;
+    };
+
+    template< class T1, std::size_t N1, bool I1, class A1, class T2, std::size_t N2, bool I2, class A2 >
+    struct vector_matrix_type< vector< T1,N1,I1,A1 >,matrix< T2,N1,N2,I2,A2 > >
+    {
+        typedef vector< T1,N2,I1,A1 > type;
+    };
+
+    template< class T1, std::size_t N1, bool I1, class A1, class T2, std::size_t N2, bool I2, class A2 >
+    struct vector_matrix_type< matrix< T2,N1,N2,I2,A2 >,vector< T1,N2,I1,A1 > >
+    {
+        typedef vector< T1,N1,I1,A1 > type;
+    };
+
+    template< class T1, std::size_t N1, bool I1, class A1, std::size_t N, bool I2, class A2, class T2, std::size_t N2, bool I3, class A3, std::size_t M, bool I4, class A4 >
+    struct vector_matrix_type< vector< vector< T1,N1,I1,A1 >,N,I2,A2 >,matrix< matrix< T2,N1,N2,I3,A3 >,N,M,I4,A4 > >
+    {
+        typedef vector< typename vector_matrix_type< vector< T1,N1,I1,A1 >,matrix< T2,N1,N2,I3,A3 > >::type,M,I2,A2 > type;
+    };
+
+    template< class T1, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t N, bool I2, class A2, class T2, bool I3, class A3, bool I4, class A4 >
+    struct vector_matrix_type< matrix< matrix< T1,M1,N1,I1,A1 >,M,N,I2,A2 >,vector< vector< T2,N1,I3,A3 >,N,I4,A4 > >
+    {
+        typedef vector< typename vector_matrix_type< matrix< T1,M1,N1,I1,A1 >,vector< T2,N1,I3,A3 > >::type,M,I4,A4 > type;
+    };
+
+//--
+
+    template< class T1, class T2 >
+    struct matrix_scalar_type
+    {
+        typedef typename common_type< T1,T2 >::type type;
+    };
+
+    template< class T1, class T2, std::size_t M, std::size_t N, bool I, class A >
+    struct matrix_scalar_type< T1,matrix< T2,M,N,I,A > >
+    {
+        typedef matrix< typename common_type< T1,T2 >::type,M,N,I,A > type;
+    };
+
+    template< class T1, std::size_t M, std::size_t N, bool I, class A, class T2 >
+    struct matrix_scalar_type< matrix< T1,M,N,I,A >,T2 >
+    {
+        typedef matrix< typename common_type< T1,T2 >::type,M,N,I,A > type;
+    };
+
+    template< class T1, class T2, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t N, bool I2, class A2 >
+    struct matrix_scalar_type< T1,matrix< matrix< T2,M1,N1,I1,A1 >,M,N,I2,A2 > >
+    {
+        typedef matrix< matrix< T2,M1,N1,I1,A1 >,M,N,I2,A2 > type;
+    };
+
+    template< class T1, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t N, bool I2, class A2, class T2 >
+    struct matrix_scalar_type< matrix< matrix< T1,M1,N1,I1,A1 >,M,N,I2,A2 >,T2 >
+    {
+        typedef matrix< matrix< T1,M1,N1,I1,A1 >,M,N,I2,A2 > type;
+    };
+
+//--
+
+    template< class T1, class T2 >
+    struct vector_scalar_type
+    {
+        typedef typename common_type< T1,T2 >::type type;
+    };
+
+    template< class T1, class T2, std::size_t N, bool I, class A >
+    struct vector_scalar_type< T1,vector< T2,N,I,A > >
+    {
+        typedef vector< typename common_type< T1,T2 >::type,N,I,A > type;
+    };
+
+    template< class T1, std::size_t N, bool I, class A, class T2 >
+    struct vector_scalar_type< vector< T1,N,I,A >,T2 >
+    {
+        typedef vector< typename common_type< T1,T2 >::type,N,I,A > type;
+    };
+
+    template< class T1, class T2, std::size_t N1, bool I1, class A1, std::size_t N, bool I2, class A2 >
+    struct vector_scalar_type< T1,vector< vector< T2,N1,I1,A1 >,N,I2,A2 > >
+    {
+        typedef vector< vector< T2,N1,I1,A1 >,N,I2,A2 > type;
+    };
+
+    template< class T1, std::size_t N1, bool I1, class A1, std::size_t N, bool I2, class A2, class T2 >
+    struct vector_scalar_type< vector< vector< T1,N1,I1,A1 >,N,I2,A2 >,T2 >
+    {
+        typedef vector< vector< T1,N1,I1,A1 >,N,I2,A2 > type;
+    };
+
+//--
+
+    template< class T1, class T2 >
+    struct matrix_product_type
+    {
+        typedef typename common_type< T1,T2 >::type type;
+    };
+
+    template< class T1, std::size_t M, std::size_t P, bool I1, class A1, class T2, std::size_t N, bool I2, class A2 >
+    struct matrix_product_type< matrix< T1,M,P,I1,A1 >,matrix< T2,P,N,I2,A2 > >
+    {
+        typedef matrix< typename common_type< T1,T2 >::type,M,N,true,A1 > type;
+    };
+
+    template< class T1, std::size_t M1, std::size_t P1, bool I1, class A1, std::size_t M, std::size_t P, bool I2, class A2, class T2, std::size_t N1, bool I3, class A3, std::size_t N, bool I4, class A4 >
+    struct matrix_product_type< matrix< matrix< T1,M1,P1,I1,A1 >,M,P,I2,A2 >,matrix< matrix< T2,P1,N1,I3,A3 >,P,N,I4,A4 > >
+    {
+        typedef matrix< typename matrix_product_type< matrix< T1,M1,P1,I1,A1 >,matrix< T2,P1,N1,I3,A3 > >::type,M,N,true,A2 > type;
+    };
+
+//--
+
+    template< class T >
+    struct matrix_transpose_type
+    {
+        typedef T type;
+    };
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A >
+    struct matrix_transpose_type< matrix< T,M,N,I,A > >
+    {
+        typedef matrix< T,N,M,I,A > type;
+    };
+
+    template< class T, std::size_t M1, std::size_t N1, bool I1, class A1, std::size_t M, std::size_t N, bool I, class A >
+    struct matrix_transpose_type< matrix< matrix< T,M1,N1,I1,A1 >,M,N,I,A > >
+    {
+        typedef matrix< typename matrix_transpose_type< matrix< T,M1,N1,I1,A1 > >::type,N,M,I,A > type;
+    };
+
+//--
+
+    template< class T >
+    struct is_matrix
+    {
+        typedef mpl::bool_< false > type;
+    };
+
+    template< class T, std::size_t M, std::size_t N, bool I, class A >
+    struct is_matrix< matrix< T,M,N,I,A > >
+    {
+        typedef mpl::bool_< true > type;
+    };
+
+//--
+
+}} // namespace boost, namespace maps
+
+#endif // BOOST_MAPS_SUPPORT_MATH_HPP
Added: sandbox/maps/boost/maps/support/preprocessor_bounds.hpp
==============================================================================
--- (empty file)
+++ sandbox/maps/boost/maps/support/preprocessor_bounds.hpp	2011-08-08 19:51:30 EDT (Mon, 08 Aug 2011)
@@ -0,0 +1,50 @@
+//--
+// Copyright (c) 2010-2011 Brian Smith
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/maps for documentation.
+//--
+
+#ifndef BOOST_PP_IS_ITERATING
+
+# if !defined( BOOST_MAPS_SUPPORT_PREPROCESSOR_BOUNDS_HPP )
+#  define BOOST_MAPS_SUPPORT_PREPROCESSOR_BOUNDS_HPP
+
+#  include <boost/mpl/vector_c.hpp>
+#  include <boost/preprocessor/cat.hpp>
+#  include <boost/preprocessor/repetition.hpp>
+#  include <boost/preprocessor/iteration/iterate.hpp>
+
+namespace boost { namespace maps {
+
+    // bounds0 definition
+    struct bounds0
+        : mpl::vector0_c< std::size_t >
+    {};
+
+}} // namespace boost, namespace maps
+
+// generate remaining definitions
+#  define BOOST_PP_ITERATION_LIMITS (1, BOOST_MPL_LIMIT_VECTOR_SIZE)
+#  define BOOST_PP_FILENAME_1 <boost/maps/support/preprocessor_bounds.hpp>
+#  include BOOST_PP_ITERATE()
+
+# endif // BOOST_MAPS_SUPPORT_PREPROCESSOR_BOUNDS_HPP
+
+#else // BOOST_PP_IS_ITERATING
+
+namespace boost { namespace maps {
+
+    // boundsN definition
+    template< BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), std::size_t S) >
+    struct BOOST_PP_CAT(bounds,BOOST_PP_ITERATION())
+        : public mpl::BOOST_PP_CAT(BOOST_PP_CAT(vector,BOOST_PP_ITERATION()),_c)< 
+            std::size_t, BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), S) 
+                > 
+    {};
+
+}} // namespace boost, namespace maps
+
+#endif // BOOST_PP_IS_ITERATING
\ No newline at end of file
Added: sandbox/maps/boost/maps/support/preprocessor_ranges.hpp
==============================================================================
--- (empty file)
+++ sandbox/maps/boost/maps/support/preprocessor_ranges.hpp	2011-08-08 19:51:30 EDT (Mon, 08 Aug 2011)
@@ -0,0 +1,50 @@
+//--
+// Copyright (c) 2010-2011 Brian Smith
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/maps for documentation.
+//--
+
+#ifndef BOOST_PP_IS_ITERATING
+
+# if !defined( BOOST_MAPS_SUPPORT_PREPROCESSOR_RANGES_HPP )
+#  define BOOST_MAPS_SUPPORT_PREPROCESSOR_RANGES_HPP
+
+#  include <boost/mpl/vector.hpp>
+#  include <boost/preprocessor/cat.hpp>
+#  include <boost/preprocessor/repetition.hpp>
+#  include <boost/preprocessor/iteration/iterate.hpp>
+
+namespace boost { namespace maps { 
+
+    // ranges0 definition
+    struct ranges0
+        : mpl::vector0<>
+    {};
+
+}} // namespace boost, namespace maps
+
+// generate remaining definitions
+#  define BOOST_PP_ITERATION_LIMITS (1, BOOST_MPL_LIMIT_VECTOR_SIZE)
+#  define BOOST_PP_FILENAME_1 <boost/maps/support/preprocessor_ranges.hpp>
+#  include BOOST_PP_ITERATE()
+
+# endif // BOOST_MAPS_SUPPORT_PREPROCESSOR_RANGES_HPP
+
+#else // BOOST_PP_IS_ITERATING
+
+namespace boost { namespace maps {
+
+    // rangesN definition
+    template< BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), class R) >
+    struct BOOST_PP_CAT(ranges,BOOST_PP_ITERATION())
+        : mpl::BOOST_PP_CAT(vector,BOOST_PP_ITERATION())< 
+            BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), R) 
+                > 
+    {};
+
+}} // namespace boost, namespace maps
+
+#endif // BOOST_PP_IS_ITERATING