📄 concepts.hpp
字号:
void constraints () {
function_requires< FieldConcept<value_type> >();
function_requires< AdditiveAbelianGroupConcept<vector_type> >();
bool r;
value_type alpha = value_type (), beta = value_type ();
vector_type a = vector_type (), b = vector_type ();
r = alpha * (a + b) == alpha * a + alpha * b;
r = (alpha + beta) * a == alpha * a + beta * a;
r = (alpha * beta) * a == alpha * (beta * a);
r = OneElement (value_type ()) * a == a;
ignore_unused_variable_warning (r);
}
};
template<class T, class V, class M>
struct LinearOperatorConcept {
typedef T value_type;
typedef V vector_type;
typedef M matrix_type;
void constraints () {
function_requires< VectorSpaceConcept<value_type, vector_type> >();
bool r;
value_type alpha = value_type (), beta = value_type ();
vector_type a = vector_type (), b = vector_type ();
matrix_type A = matrix_type ();
r = prod (A, alpha * a + beta * b) == alpha * prod (A, a) + beta * prod (A, b);
ignore_unused_variable_warning (r);
}
};
void concept_checks () {
// Allow tests to be group to keep down compiler storage requirement
#ifdef INTERAL
#define INTERNAL_STORAGE
#define INTERNAL_VECTOR
#define INTERNAL_MATRIX
#define INTERNAL_SPECIAL
#define INTERNAL_SPARSE
#define INTERNAL_EXPRESSION
#endif
// Element value type for tests
typedef float T;
// Storage Array
#if defined (INTERNAL_STORAGE) || defined (INTERNAL_STORAGE_DENSE)
{
typedef std::vector<T> container_model;
function_requires< Mutable_StorageArrayConcept<container_model> >();
function_requires< RandomAccessIteratorConcept<container_model::const_iterator> >();
function_requires< Mutable_RandomAccessIteratorConcept<container_model::iterator> >();
}
{
typedef bounded_array<T, 1> container_model;
function_requires< Mutable_StorageArrayConcept<container_model> >();
function_requires< RandomAccessIteratorConcept<container_model::const_iterator> >();
function_requires< Mutable_RandomAccessIteratorConcept<container_model::iterator> >();
}
{
typedef unbounded_array<T> container_model;
function_requires< Mutable_StorageArrayConcept<container_model> >();
function_requires< RandomAccessIteratorConcept<container_model::const_iterator> >();
function_requires< Mutable_RandomAccessIteratorConcept<container_model::iterator> >();
}
/* FIXME array_adaptors are in progress
{
typedef array_adaptor<T> container_model;
function_requires< Mutable_StorageArrayConcept<container_model> >();
function_requires< RandomAccessIteratorConcept<container_model::const_iterator> >();
function_requires< Mutable_RandomAccessIteratorConcept<container_model::iterator> >();
}
*/
{
typedef range container_model;
function_requires< IndexSetConcept<range> >();
function_requires< RandomAccessIteratorConcept<range::const_iterator> >();
}
{
typedef slice container_model;
function_requires< IndexSetConcept<range> >();
function_requires< RandomAccessIteratorConcept<range::const_iterator> >();
}
{
typedef indirect_array<> container_model;
function_requires< IndexSetConcept<range> >();
function_requires< RandomAccessIteratorConcept<range::const_iterator> >();
}
#endif
// Storage Sparse
#if defined (INTERNAL_STORAGE) || defined (INTERNAL_STORAGE_SPARSE)
{
typedef map_array<std::size_t, T> container_model;
function_requires< Mutable_StorageSparseConcept<container_model> >();
function_requires< RandomAccessIteratorConcept<container_model::const_iterator> >();
function_requires< RandomAccessIteratorConcept<container_model::iterator> >();
}
{
typedef std::map<std::size_t, T> container_model;
function_requires< Mutable_StorageSparseConcept<container_model > >();
function_requires< BidirectionalIteratorConcept<container_model::const_iterator> >();
function_requires< BidirectionalIteratorConcept<container_model::iterator> >();
}
#endif
// Vector
#if defined (INTERNAL_VECTOR) || defined (INTERNAL_VECTOR_DENSE)
{
typedef vector<T> container_model;
function_requires< RandomAccessContainerConcept<container_model> >();
function_requires< Mutable_VectorConcept<container_model> >();
function_requires< IndexedRandomAccess1DIteratorConcept<container_model::const_iterator> >();
function_requires< Mutable_IndexedRandomAccess1DIteratorConcept<container_model::iterator> >();
function_requires< IndexedRandomAccess1DIteratorConcept<container_model::const_reverse_iterator> >();
function_requires< Mutable_IndexedRandomAccess1DIteratorConcept<container_model::reverse_iterator> >();
}
{
typedef zero_vector<T> container_model;
function_requires< VectorConcept<container_model> >();
function_requires< IndexedBidirectional1DIteratorConcept<container_model::const_iterator> >();
function_requires< IndexedBidirectional1DIteratorConcept<container_model::const_reverse_iterator> >();
}
{
typedef unit_vector<T> container_model;
function_requires< VectorConcept<container_model> >();
function_requires< IndexedBidirectional1DIteratorConcept<container_model::const_iterator> >();
function_requires< IndexedBidirectional1DIteratorConcept<container_model::const_reverse_iterator> >();
}
{
typedef scalar_vector<T> container_model;
function_requires< VectorConcept<container_model> >();
function_requires< IndexedRandomAccess1DIteratorConcept<container_model::const_iterator> >();
function_requires< IndexedRandomAccess1DIteratorConcept<container_model::const_reverse_iterator> >();
}
{
typedef c_vector<T, 1> container_model;
function_requires< Mutable_VectorConcept<container_model> >();
function_requires< IndexedRandomAccess1DIteratorConcept<container_model::const_iterator> >();
function_requires< Mutable_IndexedRandomAccess1DIteratorConcept<container_model::iterator> >();
function_requires< IndexedRandomAccess1DIteratorConcept<container_model::const_reverse_iterator> >();
function_requires< Mutable_IndexedRandomAccess1DIteratorConcept<container_model::reverse_iterator> >();
}
#endif
// Vector Proxies
#if defined (INTERNAL_VECTOR) || defined (INTERNAL_VECTOR_PROXY)
{
typedef vector_range<vector<T> > container_model;
function_requires< Mutable_VectorExpressionConcept<container_model> >();
function_requires< IndexedRandomAccess1DIteratorConcept<container_model::const_iterator> >();
function_requires< Mutable_IndexedRandomAccess1DIteratorConcept<container_model::iterator> >();
function_requires< IndexedRandomAccess1DIteratorConcept<container_model::const_reverse_iterator> >();
function_requires< Mutable_IndexedRandomAccess1DIteratorConcept<container_model::reverse_iterator> >();
}
{
typedef vector_slice<vector<T> > container_model;
function_requires< Mutable_VectorExpressionConcept<container_model> >();
function_requires< IndexedRandomAccess1DIteratorConcept<container_model::const_iterator> >();
function_requires< Mutable_IndexedRandomAccess1DIteratorConcept<container_model::iterator> >();
function_requires< IndexedRandomAccess1DIteratorConcept<container_model::const_reverse_iterator> >();
function_requires< Mutable_IndexedRandomAccess1DIteratorConcept<container_model::reverse_iterator> >();
}
{
typedef vector_indirect<vector<T> > container_model;
function_requires< Mutable_VectorExpressionConcept<container_model> >();
function_requires< IndexedRandomAccess1DIteratorConcept<container_model::const_iterator> >();
function_requires< Mutable_IndexedRandomAccess1DIteratorConcept<container_model::iterator> >();
function_requires< IndexedRandomAccess1DIteratorConcept<container_model::const_reverse_iterator> >();
function_requires< Mutable_IndexedRandomAccess1DIteratorConcept<container_model::reverse_iterator> >();
}
#endif
// Sparse Vector
#if defined (INTERNAL_SPARSE) || defined (INTERNAL_VECTOR_SPARSE)
{
typedef mapped_vector<T> container_model;
function_requires< Mutable_SparseVectorConcept<container_model> >();
function_requires< IndexedBidirectional1DIteratorConcept<container_model::const_iterator> >();
function_requires< Mutable_IndexedBidirectional1DIteratorConcept<container_model::iterator> >();
function_requires< IndexedBidirectional1DIteratorConcept<container_model::const_reverse_iterator> >();
function_requires< Mutable_IndexedBidirectional1DIteratorConcept<container_model::reverse_iterator> >();
}
{
typedef compressed_vector<T> container_model;
function_requires< Mutable_SparseVectorConcept<container_model> >();
function_requires< IndexedBidirectional1DIteratorConcept<container_model::const_iterator> >();
function_requires< Mutable_IndexedBidirectional1DIteratorConcept<container_model::iterator> >();
function_requires< IndexedBidirectional1DIteratorConcept<container_model::const_reverse_iterator> >();
function_requires< Mutable_IndexedBidirectional1DIteratorConcept<container_model::reverse_iterator> >();
}
{
typedef coordinate_vector<T> container_model;
function_requires< Mutable_SparseVectorConcept<container_model> >();
function_requires< IndexedBidirectional1DIteratorConcept<container_model::const_iterator> >();
function_requires< Mutable_IndexedBidirectional1DIteratorConcept<container_model::iterator> >();
function_requires< IndexedBidirectional1DIteratorConcept<container_model::const_reverse_iterator> >();
function_requires< Mutable_IndexedBidirectional1DIteratorConcept<container_model::reverse_iterator> >();
}
#endif
// Matrix
#if defined (INTERNAL_MATRIX) || defined (INTERNAL_MATRIX_DENSE)
{
typedef matrix<T> container_model;
function_requires< Mutable_MatrixConcept<matrix<T> > >();
function_requires< IndexedRandomAccess2DIteratorConcept<container_model::const_iterator1, container_model::const_iterator2> >();
function_requires< Mutable_IndexedRandomAccess2DIteratorConcept<container_model::iterator1, container_model::iterator2> >();
function_requires< IndexedRandomAccess2DIteratorConcept<container_model::const_reverse_iterator1, container_model::const_reverse_iterator2> >();
function_requires< Mutable_IndexedRandomAccess2DIteratorConcept<container_model::reverse_iterator1, container_model::reverse_iterator2> >();
}
{
typedef vector_of_vector<T> container_model;
function_requires< Mutable_MatrixConcept<matrix<T> > >();
function_requires< IndexedRandomAccess2DIteratorConcept<container_model::const_iterator1, container_model::const_iterator2> >();
function_requires< Mutable_IndexedRandomAccess2DIteratorConcept<container_model::iterator1, container_model::iterator2> >();
function_requires< IndexedRandomAccess2DIteratorConcept<container_model::const_reverse_iterator1, container_model::const_reverse_iterator2> >();
function_requires< Mutable_IndexedRandomAccess2DIteratorConcept<container_model::reverse_iterator1, container_model::reverse_iterator2> >();
}
{
typedef zero_matrix<T> container_model;
function_requires< Mutable_MatrixConcept<matrix<T> > >();
function_requires< IndexedBidirectional2DIteratorConcept<container_model::const_iterator1, container_model::const_iterator2> >();
function_requires< IndexedBidirectional2DIteratorConcept<container_model::const_reverse_iterator1, container_model::const_reverse_iterator2> >();
}
{
typedef identity_matrix<T> container_model;
function_requires< Mutable_MatrixConcept<matrix<T> > >();
function_requires< IndexedBidirectional2DIteratorConcept<container_model::const_iterator1, container_model::const_iterator2> >();
function_requires< IndexedBidirectional2DIteratorConcept<container_model::const_reverse_iterator1, container_model::const_reverse_iterator2> >();
}
{
typedef scalar_matrix<T> container_model;
function_requires< Mutable_MatrixConcept<matrix<T> > >();
function_requires< IndexedRandomAccess2DIteratorConcept<container_model::const_iterator1, container_model::const_iterator2> >();
function_requires< IndexedRandomAccess2DIteratorConcept<container_model::const_reverse_iterator1, container_model::const_reverse_iterator2> >();
}
{
typedef c_matrix<T, 1, 1> container_model;
function_requires< Mutable_MatrixConcept<matrix<T> > >();
function_requires< IndexedRandomAccess2DIteratorConcept<container_model::const_iterator1, container_model::const_iterator2> >();
function_requires< Mutable_IndexedRandomAccess2DIteratorConcept<container_model::iterator1, container_model::iterator2> >();
function_requires< IndexedRandomAccess2DIteratorConcept<container_model::const_reverse_iterator1, container_model::const_reverse_iterator2> >();
function_requires< Mutable_IndexedRandomAccess2DIteratorConcept<container_model::reverse_iterator1, container_model::reverse_iterator2> >();
}
#endif
// Matrix Proxies
#if defined (INTERNAL_MATRIX) || defined (INTERNAL_MATRIX_PROXY)
{
typedef matrix_row<matrix<T> > container_model;
function_requires< Mutable_VectorExpressionConcept<container_model> >();
function_requires< IndexedRandomAccess1DIteratorConcept<container_model::const_iterator> >();
function_requires< Mutable_IndexedRandomAccess1DIteratorConcept<container_model::iterator> >();
function_requires< IndexedRandomAccess1DIteratorConcept<container_model::const_reverse_iterator> >();
function_requires< Mutable_IndexedRandomAccess1DIteratorConcept<container_model::reverse_iterator> >();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -