Initial commit.

This commit is contained in:
2018-12-06 16:01:56 +01:00
parent 10867b60c2
commit 18eb3f6047
1011 changed files with 345688 additions and 10 deletions

View File

@@ -0,0 +1,84 @@
//
// Copyright (c) 2009--2010
// Thomas Klimpel and Rutger ter Borg
//
// 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)
//
#ifndef BOOST_NUMERIC_BINDINGS_GLAS_COMPRESSED_HPP
#define BOOST_NUMERIC_BINDINGS_GLAS_COMPRESSED_HPP
#include <boost/numeric/bindings/begin.hpp>
#include <boost/numeric/bindings/end.hpp>
#include <boost/numeric/bindings/detail/adaptor.hpp>
#include <boost/numeric/bindings/detail/copy_const.hpp>
#include <boost/numeric/bindings/glas/detail/convert_to.hpp>
#include <boost/numeric/bindings/glas/dense_vector.hpp>
#include <boost/numeric/bindings/std/vector.hpp>
#include <glas/sparse/compressed.hpp>
namespace boost {
namespace numeric {
namespace bindings {
namespace detail {
template< typename T, typename O, typename IndexType, typename NNZType, int IB, typename Id, typename Enable >
struct adaptor< glas::sparse_matrix< T, glas::compressed_sparse_structure<O, IndexType, NNZType, IB> >, Id, Enable > {
typedef typename copy_const< Id, T >::type value_type;
typedef typename copy_const< Id, IndexType >::type index_type;
typedef typename convert_to< tag::data_order, O >::type data_order;
typedef mpl::map<
mpl::pair< tag::value_type, value_type >,
mpl::pair< tag::index_type, index_type >,
mpl::pair< tag::entity, tag::matrix >,
mpl::pair< tag::size_type<1>, std::ptrdiff_t >,
mpl::pair< tag::size_type<2>, std::ptrdiff_t >,
mpl::pair< tag::matrix_type, tag::general >,
mpl::pair< tag::data_structure, tag::compressed_sparse >,
mpl::pair< tag::data_order, data_order >,
mpl::pair< tag::index_base, mpl::int_<IB> >
> property_map;
static std::ptrdiff_t size1( const Id& id ) {
return id.num_rows();
}
static std::ptrdiff_t size2( const Id& id ) {
return id.num_columns();
}
static value_type* begin_value( Id& id ) {
return bindings::begin_value( id.value_array() );
}
static value_type* end_value( Id& id ) {
return bindings::begin_value( id.value_array() ) + id.nnz();
}
static index_type* begin_compressed_index_major( Id& id ) {
return bindings::begin_value( id.sparse_structure().compressed_index_array() );
}
static index_type* end_compressed_index_major( Id& id ) {
return bindings::end_value( id.sparse_structure().compressed_index_array() );
}
static index_type* begin_index_minor( Id& id ) {
return bindings::begin_value( id.sparse_structure().index_array() );
}
static index_type* end_index_minor( Id& id ) {
return bindings::begin_value( id.sparse_structure().index_array() ) + id.nnz();
}
};
} // namespace detail
} // namespace bindings
} // namespace numeric
} // namespace boost
#endif

View File

@@ -0,0 +1,71 @@
//
// Copyright (c) 2009 Rutger ter Borg
//
// 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)
//
#ifndef BOOST_NUMERIC_BINDINGS_GLAS_DENSE_MATRIX_HPP
#define BOOST_NUMERIC_BINDINGS_GLAS_DENSE_MATRIX_HPP
#include <boost/numeric/bindings/detail/adaptor.hpp>
#include <boost/numeric/bindings/detail/if_row_major.hpp>
#include <boost/numeric/bindings/glas/detail/convert_to.hpp>
#include <glas/container/dense_matrix.hpp>
namespace boost {
namespace numeric {
namespace bindings {
namespace detail {
template< typename T, typename O, typename Id, typename Enable >
struct adaptor< glas::dense_matrix< T, O >, Id, Enable > {
typedef typename copy_const< Id, T >::type value_type;
typedef typename convert_to< tag::data_order, O >::type data_order;
typedef mpl::map<
mpl::pair< tag::value_type, value_type >,
mpl::pair< tag::entity, tag::matrix >,
mpl::pair< tag::size_type<1>, std::ptrdiff_t >,
mpl::pair< tag::size_type<2>, std::ptrdiff_t >,
mpl::pair< tag::data_structure, tag::linear_array >,
mpl::pair< tag::data_order, data_order >,
mpl::pair< tag::stride_type<1>,
typename if_row_major< data_order, std::ptrdiff_t, tag::contiguous >::type >,
mpl::pair< tag::stride_type<2>,
typename if_row_major< data_order, tag::contiguous, std::ptrdiff_t >::type >
> property_map;
static std::ptrdiff_t size1( const Id& id ) {
return id.num_rows();
}
static std::ptrdiff_t size2( const Id& id ) {
return id.num_columns();
}
static value_type* begin_value( Id& id ) {
return id.storage_ptr();
}
static value_type* end_value( Id& id ) {
return id.storage_ptr() + id.num_rows() * id.num_columns();
}
static std::ptrdiff_t stride1( const Id& id ) {
return id.num_columns();
}
static std::ptrdiff_t stride2( const Id& id ) {
return id.num_rows();
}
};
} // namespace detail
} // namespace bindings
} // namespace numeric
} // namespace boost
#endif

View File

@@ -0,0 +1,51 @@
//
// Copyright (c) 2009 Rutger ter Borg
//
// 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)
//
#ifndef BOOST_NUMERIC_BINDINGS_GLAS_DENSE_VECTOR_HPP
#define BOOST_NUMERIC_BINDINGS_GLAS_DENSE_VECTOR_HPP
#include <boost/numeric/bindings/detail/adaptor.hpp>
#include <glas/container/dense_vector.hpp>
namespace boost {
namespace numeric {
namespace bindings {
namespace detail {
template< typename T, typename Id, typename Enable >
struct adaptor< glas::dense_vector< T >, Id, Enable > {
typedef typename copy_const< Id, T >::type value_type;
typedef mpl::map<
mpl::pair< tag::value_type, value_type >,
mpl::pair< tag::entity, tag::vector >,
mpl::pair< tag::size_type<1>, std::ptrdiff_t >,
mpl::pair< tag::data_structure, tag::linear_array >,
mpl::pair< tag::stride_type<1>, tag::contiguous >
> property_map;
static std::ptrdiff_t size1( const Id& id ) {
return id.size();
}
static value_type* begin_value( Id& id ) {
return id.storage_ptr();
}
static value_type* end_value( Id& id ) {
return id.storage_ptr() + id.size();
}
};
} // namespace detail
} // namespace bindings
} // namespace numeric
} // namespace boost
#endif

View File

@@ -0,0 +1,84 @@
//
// Copyright (c) 2009 Rutger ter Borg
//
// 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)
//
#ifndef BOOST_NUMERIC_BINDINGS_GLAS_DENSE_VECTOR_COLLECTION_HPP
#define BOOST_NUMERIC_BINDINGS_GLAS_DENSE_VECTOR_COLLECTION_HPP
#include <boost/numeric/bindings/detail/adaptor.hpp>
#include <boost/numeric/bindings/detail/offset.hpp>
#include <glas/concept/dense_vector_collection.hpp>
#include <glas/concept/fixed_size_vector_expression.hpp>
#include <glas/concept/fixed_size.hpp>
#include <glas/concept/value_type.hpp>
#include <glas/concept/size.hpp>
#include <glas/concept/stride.hpp>
#include <glas/concept/storage_ptr.hpp>
namespace boost {
namespace numeric {
namespace bindings {
namespace detail {
// Need a helper type here, because
// glas::fixed_size<T> doesn't work for any T
template< typename T, typename Enable = void >
struct glas_vector_size_type {
typedef std::ptrdiff_t type;
};
template< typename T >
struct glas_vector_size_type<
T, typename boost::enable_if< glas::FixedSizeVectorExpression<T> >::type > {
typedef mpl::int_< glas::fixed_size<T>::value > type;
};
template< typename T, typename Id >
struct adaptor< T, Id, typename boost::enable_if< glas::DenseVectorCollection<T> >::type > {
typedef typename copy_const< Id, typename glas::value_type<T>::type >::type value_type;
typedef typename glas_vector_size_type< T >::type size_type1;
typedef typename mpl::if_<
glas::ContiguousDenseVectorCollection<T>,
tag::contiguous,
std::ptrdiff_t
>::type stride_type1;
typedef mpl::map<
mpl::pair< tag::value_type, value_type >,
mpl::pair< tag::entity, tag::vector >,
mpl::pair< tag::size_type<1>, size_type1 >,
mpl::pair< tag::data_structure, tag::linear_array >,
mpl::pair< tag::stride_type<1>, stride_type1 >
> property_map;
// Only called in case of dynamic sizes
static std::ptrdiff_t size1( const Id& id ) {
return glas::size( id );
}
static value_type* begin_value( Id& id ) {
return glas::storage_ptr( id );
}
static value_type* end_value( Id& id ) {
return glas::storage_ptr( id ) + offset( id, bindings::size1( id ) );
}
// Only called in case of dynamic strides
static std::ptrdiff_t stride1( const Id& id ) {
return glas::stride( id );
}
};
} // namespace detail
} // namespace bindings
} // namespace numeric
} // namespace boost
#endif

View File

@@ -0,0 +1,36 @@
//
// Copyright (c) 2009 Rutger ter Borg
//
// 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)
//
#ifndef BOOST_NUMERIC_BINDINGS_GLAS_DETAIL_CONVERT_TO_HPP
#define BOOST_NUMERIC_BINDINGS_GLAS_DETAIL_CONVERT_TO_HPP
#include <boost/numeric/bindings/detail/convert_to.hpp>
#include <boost/numeric/bindings/tag.hpp>
#include <glas/concept/orientation.hpp>
namespace boost {
namespace numeric {
namespace bindings {
namespace detail {
template<>
struct convert_to< bindings::tag::data_order, glas::row_orientation > {
typedef bindings::tag::row_major type;
};
template<>
struct convert_to< bindings::tag::data_order, glas::column_orientation > {
typedef bindings::tag::column_major type;
};
} // namespace detail
} // namespace bindings
} // namespace numeric
} // namespace boost
#endif