|
// iobind library
//
// author: Jonathan de Halleux, 2003
#ifndef IOBIND_UBLAS_DIMENSION_POLICY_HPP
#define IOBIND_UBLAS_DIMENSION_POLICY_HPP
#include <iobind/policy.hpp>
#include <iobind/dimension_decorators_property.hpp>
#include <iobind/sequence_container_parser.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/banded.hpp>
namespace iobind{
namespace detail{
struct fill_dimensions_matrix1
{
template<typename Matrix>
void fill_dimensions(Matrix const& m, std::vector<size_t>& dims) const
{
dims.clear();
dims.push_back(m.size());
};
};
struct fill_dimensions_matrix2
{
template<typename Matrix>
void fill_dimensions(Matrix const& m, std::vector<size_t>& dims) const
{
dims.clear();
dims.push_back(m.size1());
dims.push_back(m.size2());
};
};
struct fill_dimensions_matrix4
{
template<typename Matrix>
void fill_dimensions(Matrix const& m, std::vector<size_t>& dims) const
{
dims.clear();
dims.push_back(m.size1());
dims.push_back(m.size2());
dims.push_back(m.lower());
dims.push_back(m.upper());
};
};
struct resize1_matrix
{
template<typename Matrix>
bool resize(Matrix & m, std::vector<size_t> const& dims ) const
{
if (dims.size() < 1)
return false;
m.resize(dims[0]);
return true;
}
};
struct resize2_matrix
{
template<typename Matrix>
bool resize(Matrix & m, std::vector<size_t> const& dims ) const
{
if (dims.size() < 2)
return false;
m.resize(dims[0],dims[1]);
return true;
}
};
struct resize4_matrix
{
template<typename Matrix>
bool resize(Matrix & m, std::vector<size_t> const& dims ) const
{
if (dims.size() < 4)
return false;
m.resize(dims[0],dims[1],dims[2],dims[3]);
return true;
}
};
};//detail
};//iobind
#endif
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
Jonathan de Halleux is Civil Engineer in Applied Mathematics. He finished his PhD in 2004 in the rainy country of Belgium. After 2 years in the Common Language Runtime (i.e. .net), he is now working at Microsoft Research on Pex (http://research.microsoft.com/pex).