2 * Copyright (c) 2004 Michael Stevens
3 * Use, modification and distribution are subject to the
4 * Boost Software License, Version 1.0. (See accompanying file
5 * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 * Default construct test when possible
13 struct default_construct
18 struct default_construct<boost::numeric::ublas::vector_container<VC> >
23 initialize_vector(default_constuct);
24 std::cout << "default construct = " << default_constuct << std::endl;
28 struct default_construct<boost::numeric::ublas::matrix_container<MC> >
33 initialize_vector(default_constuct);
34 std::cout << "default construct = " << default_constuct << std::endl;
39 * Initialise test values in vector/matrix
43 void initialize_vector(V& v)
45 typename V::size_type size = v.size();
46 for (typename V::size_type i = 0; i < size; ++i)
47 v[i] = typename V::value_type(i + 1.f);
51 void initialize_matrix_impl(M& m, ublas::packed_proxy_tag)
53 typename M::size_type size1 = m.size1();
54 #ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
55 for (typename M::iterator1 i = m.begin1(); i != m.end1(); ++i)
56 for (typename M::iterator2 j = i.begin(); j != i.end(); ++j)
57 *j = typename M::value_type(i.index1() * size1 + j.index2() + 1.f);
59 for (typename M::iterator1 i = m.begin1(); i != m.end1(); ++i)
60 for (typename M::iterator2 j = ublas::begin(i, ublas::iterator1_tag()); j != ublas::end(i, ublas::iterator1_tag()); ++j)
61 *j = typename M::value_type(i.index1() * size1 + j.index2() + 1.f);
66 void initialize_matrix_impl(M& m, ublas::sparse_proxy_tag)
68 typename M::size_type size1 = m.size1();
69 typename M::size_type size2 = m.size2();
70 for (typename M::size_type i = 0; i < size1; ++i)
71 for (typename M::size_type j = 0; j < size2; ++j)
72 m(i, j) = typename M::value_type(i * size1 + j + 1.f);
76 void initialize_matrix(M& m)
78 initialize_matrix_impl(m, typename M::storage_category());
82 void initialize_matrix(M& m, ublas::lower_tag)
84 typename M::size_type size1 = m.size1();
85 typename M::size_type size2 = m.size2();
86 for (typename M::size_type i = 0; i < size1; ++i)
88 typename M::size_type j = 0;
90 m(i, j) = i * size1 + j + 1.f;
91 for (; j < size2; ++j)
96 void initialize_matrix(M& m, ublas::upper_tag)
98 typename M::size_type size1 = m.size1();
99 typename M::size_type size2 = m.size2();
100 for (typename M::size_type i = 0; i < size1; ++i)
102 typename M::size_type j = 0;
105 for (; j < size2; ++j)
106 m(i, j) = i * size1 + j + 1.f;