- // Unary vector operations resulting in a vector
- initialize_vector (v1);
- v2 = - v1;
- std::cout << "- v1 = " << v2 << std::endl;
- v2 = ublas::conj (v1);
- std::cout << "conj (v1) = " << v2 << std::endl;
-
- // Binary vector operations resulting in a vector
- initialize_vector (v1);
- initialize_vector (v2);
- v3 = v1 + v2;
- std::cout << "v1 + v2 = " << v3 << std::endl;
- v3 = v1 - v2;
- std::cout << "v1 - v2 = " << v3 << std::endl;
- v3 = ublas::element_prod (v1, v2);
- std::cout << "element_prod (v1, v2) = " << v3 << std::endl;
-
- // Scaling a vector
- t = N;
- initialize_vector (v1);
- v2 = value_type (1.) * v1;
- std::cout << "1. * v1 = " << v2 << std::endl;
- v2 = t * v1;
- std::cout << "N * v1 = " << v2 << std::endl;
- initialize_vector (v1);
- v2 = v1 * value_type (1.);
- std::cout << "v1 * 1. = " << v2 << std::endl;
- v2 = v1 * t;
- std::cout << "v1 * value_type(N) = " << v2 << std::endl;
- // test interop with integer
- v2 = v1 * N;
-
- std::cout << "v1 * N = " << v2 << std::endl;
-
- // Some assignments
- initialize_vector (v1);
- initialize_vector (v2);
- v2 += v1;
- std::cout << "v2 += v1 = " << v2 << std::endl;
- v2 -= v1;
- std::cout << "v2 -= v1 = " << v2 << std::endl;
- v2 = v2 + v1;
- std::cout << "v2 = v2 + v1 = " << v2 << std::endl;
- v2 = v2 - v1;
- std::cout << "v2 = v2 - v1 = " << v2 << std::endl;
- v1 *= value_type (1.);
- std::cout << "v1 *= 1. = " << v1 << std::endl;
- v1 *= t;
- std::cout << "v1 *= value_type(N) = " << v1 << std::endl;
- // test interop with integer
- v1 *= N;
- std::cout << "v1 *= N = " << v1 << std::endl;
-
- // Unary vector operations resulting in a scalar
- initialize_vector (v1);
- t = ublas::sum (v1);
- std::cout << "sum (v1) = " << t << std::endl;
- n = ublas::norm_1 (v1);
- std::cout << "norm_1 (v1) = " << n << std::endl;
- n = ublas::norm_2 (v1);
- std::cout << "norm_2 (v1) = " << n << std::endl;
- n = ublas::norm_inf (v1);
- std::cout << "norm_inf (v1) = " << n << std::endl;
-
- i = ublas::index_norm_inf (v1);
- std::cout << "index_norm_inf (v1) = " << i << std::endl;
-
- // Binary vector operations resulting in a scalar
- initialize_vector (v1);
- initialize_vector (v2);
- t = ublas::inner_prod (v1, v2);
- std::cout << "inner_prod (v1, v2) = " << t << std::endl;
-
- // Scalar and Binary vector expression resulting in a vector
- initialize_vector (v1);
- initialize_vector (v2);
- v1 = v1 * ublas::inner_prod (v1, v2);
- std::cout << "v1 * inner_prod (v1, v2) = " << v1 << std::endl;
- }
-
- void operator () () const {
- V v1 (N), v2 (N), v3 (N);
- test_expression_with (v1, v2, v3);
- test_container_with (v1);
+ // Unary vector operations resulting in a vector
+ initialize_vector(v1);
+ v2 = -v1;
+ std::cout << "- v1 = " << v2 << std::endl;
+ v2 = ublas::conj(v1);
+ std::cout << "conj (v1) = " << v2 << std::endl;
+
+ // Binary vector operations resulting in a vector
+ initialize_vector(v1);
+ initialize_vector(v2);
+ v3 = v1 + v2;
+ std::cout << "v1 + v2 = " << v3 << std::endl;
+ v3 = v1 - v2;
+ std::cout << "v1 - v2 = " << v3 << std::endl;
+ v3 = ublas::element_prod(v1, v2);
+ std::cout << "element_prod (v1, v2) = " << v3 << std::endl;
+
+ // Scaling a vector
+ t = N;
+ initialize_vector(v1);
+ v2 = value_type(1.) * v1;
+ std::cout << "1. * v1 = " << v2 << std::endl;
+ v2 = t * v1;
+ std::cout << "N * v1 = " << v2 << std::endl;
+ initialize_vector(v1);
+ v2 = v1 * value_type(1.);
+ std::cout << "v1 * 1. = " << v2 << std::endl;
+ v2 = v1 * t;
+ std::cout << "v1 * value_type(N) = " << v2 << std::endl;
+ // test interop with integer
+ v2 = v1 * N;
+
+ std::cout << "v1 * N = " << v2 << std::endl;
+
+ // Some assignments
+ initialize_vector(v1);
+ initialize_vector(v2);
+ v2 += v1;
+ std::cout << "v2 += v1 = " << v2 << std::endl;
+ v2 -= v1;
+ std::cout << "v2 -= v1 = " << v2 << std::endl;
+ v2 = v2 + v1;
+ std::cout << "v2 = v2 + v1 = " << v2 << std::endl;
+ v2 = v2 - v1;
+ std::cout << "v2 = v2 - v1 = " << v2 << std::endl;
+ v1 *= value_type(1.);
+ std::cout << "v1 *= 1. = " << v1 << std::endl;
+ v1 *= t;
+ std::cout << "v1 *= value_type(N) = " << v1 << std::endl;
+ // test interop with integer
+ v1 *= N;
+ std::cout << "v1 *= N = " << v1 << std::endl;
+
+ // Unary vector operations resulting in a scalar
+ initialize_vector(v1);
+ t = ublas::sum(v1);
+ std::cout << "sum (v1) = " << t << std::endl;
+ n = ublas::norm_1(v1);
+ std::cout << "norm_1 (v1) = " << n << std::endl;
+ n = ublas::norm_2(v1);
+ std::cout << "norm_2 (v1) = " << n << std::endl;
+ n = ublas::norm_inf(v1);
+ std::cout << "norm_inf (v1) = " << n << std::endl;
+
+ i = ublas::index_norm_inf(v1);
+ std::cout << "index_norm_inf (v1) = " << i << std::endl;
+
+ // Binary vector operations resulting in a scalar
+ initialize_vector(v1);
+ initialize_vector(v2);
+ t = ublas::inner_prod(v1, v2);
+ std::cout << "inner_prod (v1, v2) = " << t << std::endl;
+
+ // Scalar and Binary vector expression resulting in a vector
+ initialize_vector(v1);
+ initialize_vector(v2);
+ v1 = v1 * ublas::inner_prod(v1, v2);
+ std::cout << "v1 * inner_prod (v1, v2) = " << v1 << std::endl;
+ }
+
+ void operator()() const
+ {
+ V v1(N), v2(N), v3(N);
+ test_expression_with(v1, v2, v3);
+ test_container_with(v1);