19{
20
21 cout << "\n";
22 cout << "=== Vector: (dense) double/complex Example =========\n";
23 cout << "\n";
24
25 const unsigned N = 1000000;
26
27 cout << " Using vectors of size " << N << " \n";
28
29 const double tol = 1.e-13;
31
33
36
38
39
42
43 const unsigned M = 100;
44 for ( unsigned i = 0; i < M; ++i )
45 {
47 }
48
49 cout << " \nComplex vectors \n";
50 cout << " Testing norms, nearest_index, max/minabs_index\n";
52 tol )
53 {
54 std::cout << " - Failed inf_norm/nearest_index Example" << "\n";
56 }
58 > tol )
59 {
60 std::cout << " - Failed inf_norm/maxabs_index Example" << "\n";
62 }
63
64 CExample.one_norm();
65 CExample.two_norm();
66 CExample.inf_norm();
67
68 cout << "\n";
69 cout << " Double vectors \n";
70
71 cout << " Testing norms, nearest_index, max/minabs_index\n";
73 > tol )
74 {
75 std::cout << " - Failed inf_norm/nearest_index Example" << "\n";
77 }
78 if ( abs( DExample.inf_norm() - *max_element( DExample.begin(), DExample.end(),
abs_predicate<double>() ) )
79 > tol )
80 {
81 std::cout << " - Failed inf_norm/maxabs_index Example" << "\n";
83 }
84
85 DExample.one_norm();
86 DExample.two_norm();
87 DExample.inf_norm();
88
89 if ( failed )
90 {
91 cout << "\033[1;31;48m * FAILED \033[0m\n";
92 return 1;
93 }
94 else
95 {
96 cout << "\033[1;32;48m * PASSED \033[0m\n";
97 return 0;
98 }
99
100}
An DenseVector class – a dense vector object.
A function object predicate that first computes the absolute difference between two elements and a sp...
A function object predicate that compares the absolute value of two elements and returns a true of el...
_Type dot(const DenseVector< _Type > &X, const DenseVector< _Type > &Y)
Templated dot product.
void time_seed()
initialise RNG
void fill_random(CppNoddy::SparseVector< double > &V, const unsigned &num_of_elts)