📄 concepts.hpp
字号:
// Beginning of reverse range const vector_type cv = vector_type (); const_reverse_iterator_type crit_begin (cv.rbegin ()); // End of reverse range const_reverse_iterator_type crit_end (cv.rend ()); // Element access t = v (i); ignore_unused_variable_warning (n); ignore_unused_variable_warning (cit); ignore_unused_variable_warning (cit_begin); ignore_unused_variable_warning (cit_end); ignore_unused_variable_warning (crit_begin); ignore_unused_variable_warning (crit_end); ignore_unused_variable_warning (t); } }; template<class V> struct MutableVectorExpressionConcept { typedef V vector_type; typedef typename V::size_type size_type; typedef typename V::value_type value_type; typedef typename V::iterator iterator_type; typedef typename V::reverse_iterator reverse_iterator_type; static void constraints () { AssignableConcept<vector_type>::constraints (vector_type ()); VectorExpressionConcept<vector_type>::constraints (); vector_type v = vector_type (), v1 = vector_type (), v2 = vector_type (); size_type i (0); value_type t = value_type (); // Find (internal?) iterator_type it (v.find (i)); // Beginning of range iterator_type it_begin (v.begin ()); // End of range iterator_type it_end (v.end ()); // Swap v1.swap (v2); // Beginning of reverse range reverse_iterator_type rit_begin (v.rbegin ()); // End of reverse range reverse_iterator_type rit_end (v.rend ()); // Assignments v2 = v1; v2.assign (v1); v2 += v1; v2.plus_assign (v1); v2 -= v1; v2.minus_assign (v1); v *= t; ignore_unused_variable_warning (it); ignore_unused_variable_warning (it_begin); ignore_unused_variable_warning (it_end); ignore_unused_variable_warning (rit_begin); ignore_unused_variable_warning (rit_end); } }; template<class M> struct MatrixExpressionConcept { typedef M matrix_type; typedef typename M::type_category type_category; typedef typename M::size_type size_type; typedef typename M::value_type value_type; typedef typename M::const_iterator1 const_iterator1_type; typedef typename M::const_iterator2 const_iterator2_type; typedef typename M::const_reverse_iterator1 const_reverse_iterator1_type; typedef typename M::const_reverse_iterator2 const_reverse_iterator2_type; static void constraints () { DefaultConstructibleConcept<matrix_type>::constraints (); matrix_type m = matrix_type (); size_type n (0), i (0), j (0); value_type t; // Find (internal?) const_iterator1_type cit1 (m.find1 (0, i, j)); const_iterator2_type cit2 (m.find2 (0, i, j)); // Beginning of range const_iterator1_type cit1_begin (m.begin1 ()); const_iterator2_type cit2_begin (m.begin2 ()); // End of range const_iterator1_type cit1_end (m.end1 ()); const_iterator2_type cit2_end (m.end2 ()); // Size n = m.size1 (); n = m.size2 (); // Beginning of reverse range const matrix_type cm = matrix_type (); const_reverse_iterator1_type crit1_begin (cm.rbegin1 ()); const_reverse_iterator2_type crit2_begin (cm.rbegin2 ()); // End of reverse range const_reverse_iterator1_type crit1_end (cm.rend1 ()); const_reverse_iterator2_type crit2_end (cm.rend2 ()); // Element access t = m (i, j); ignore_unused_variable_warning (n); ignore_unused_variable_warning (cit1); ignore_unused_variable_warning (cit2); ignore_unused_variable_warning (cit1_begin); ignore_unused_variable_warning (cit2_begin); ignore_unused_variable_warning (cit1_end); ignore_unused_variable_warning (cit2_end); ignore_unused_variable_warning (crit1_begin); ignore_unused_variable_warning (crit2_begin); ignore_unused_variable_warning (crit1_end); ignore_unused_variable_warning (crit2_end); ignore_unused_variable_warning (t); } }; template<class M> struct MutableMatrixExpressionConcept { typedef M matrix_type; typedef typename M::size_type size_type; typedef typename M::value_type value_type; typedef typename M::iterator1 iterator1_type; typedef typename M::iterator2 iterator2_type; typedef typename M::reverse_iterator1 reverse_iterator1_type; typedef typename M::reverse_iterator2 reverse_iterator2_type; static void constraints () { AssignableConcept<matrix_type>::constraints (matrix_type ()); MatrixExpressionConcept<matrix_type>::constraints (); matrix_type m = matrix_type (), m1 = matrix_type (), m2 = matrix_type (); size_type i (0), j (0); value_type t = value_type (); // Find (internal?) iterator1_type it1 (m.find1 (0, i, j)); iterator2_type it2 (m.find2 (0, i, j)); // Beginning of range iterator1_type it1_begin (m.begin1 ()); iterator2_type it2_begin (m.begin2 ()); // End of range iterator1_type it1_end (m.end1 ()); iterator2_type it2_end (m.end2 ()); // Swap m1.swap (m2); // Beginning of reverse range reverse_iterator1_type rit1_begin (m.rbegin1 ()); reverse_iterator2_type rit2_begin (m.rbegin2 ()); // End of reverse range reverse_iterator1_type rit1_end (m.rend1 ()); reverse_iterator2_type rit2_end (m.rend2 ()); // Assignments m2 = m1; m2.assign (m1); m2 += m1; m2.plus_assign (m1); m2 -= m1; m2.minus_assign (m1); m *= t; ignore_unused_variable_warning (it1); ignore_unused_variable_warning (it2); ignore_unused_variable_warning (it1_begin); ignore_unused_variable_warning (it2_begin); ignore_unused_variable_warning (it1_end); ignore_unused_variable_warning (it2_end); ignore_unused_variable_warning (rit1_begin); ignore_unused_variable_warning (rit2_begin); ignore_unused_variable_warning (rit1_end); ignore_unused_variable_warning (rit2_end); } }; template<class V> struct VectorConcept { typedef V vector_type; typedef typename V::size_type size_type; static void constraints () { VectorExpressionConcept<vector_type>::constraints (); size_type n (0); // Sizing constructor vector_type v (n); } }; template<class V> struct MutableVectorConcept { typedef V vector_type; typedef typename V::size_type size_type; typedef typename V::value_type value_type; static void constraints () { VectorConcept<vector_type>::constraints (); MutableVectorExpressionConcept<vector_type>::constraints (); size_type n (0); value_type t = value_type (); size_type i (0); // Sizing constructor vector_type v (n); // Insert v.insert (i, t); // Erase v.erase (i); // Clear v.clear (); // Resize v.resize (n); } }; template<class M> struct MatrixConcept { typedef M matrix_type; typedef typename M::size_type size_type; static void constraints () { MatrixExpressionConcept<matrix_type>::constraints (); size_type n (0); // Sizing constructor matrix_type m (n, n); } }; template<class M> struct MutableMatrixConcept { typedef M matrix_type; typedef typename M::size_type size_type; typedef typename M::value_type value_type; static void constraints () { MatrixConcept<matrix_type>::constraints (); MutableMatrixExpressionConcept<matrix_type>::constraints (); size_type n (0); value_type t = value_type (); size_type i (0), j (0); // Sizing constructor matrix_type m (n, n); // Insert m.insert (i, j, t); // Erase m.erase (i, j); // Clear m.clear (); // Resize m.resize (n, n); m.resize (n, n, false); } }; template<class T> T ZeroElement (T); template<> float ZeroElement (float) { return 0.f; } template<> double ZeroElement (double) { return 0.; } template<> vector<float> ZeroElement (vector<float>) { return zero_vector<float> (); } template<> vector<double> ZeroElement (vector<double>) { return zero_vector<double> (); } template<> matrix<float> ZeroElement (matrix<float>) { return zero_matrix<float> (); } template<> matrix<double> ZeroElement (matrix<double>) { return zero_matrix<double> (); }#if !(defined(BOOST_MSVC) && BOOST_MSVC <= 1300) template<> std::complex<float> ZeroElement (std::complex<float>) { return std::complex<float> (0.f); } template<> std::complex<double> ZeroElement (std::complex<double>) { return std::complex<double> (0.); } template<>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -