CppNoddy  0.92
Loading...
Searching...
No Matches
Functions
SparseVector.cpp File Reference
#include <SparseVector.h>
#include "../Utils_Fill.h"

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

◆ main()

int main ( )

Definition at line 13 of file SparseVector.cpp.

14{
15
16 cout << "\n";
17 cout << "=== Vector: sparse class example ===================\n";
18 cout << "\n";
19
20 SparseVector<double> vecA( 100 );
21 Utils_Fill::fill_random( vecA, 25 );
22 double oneA = vecA.one_norm();
23
24 SparseVector<double> vecB( 100 );
25 Utils_Fill::fill_random( vecB, 25 );
26 double oneB = vecB.one_norm();
27
28 SparseVector<double> vecC( 100 );
29 vecC = vecA * 2. + vecB * 2.;
30
31 double tol = 1.e-13;
32 if ( vecC.one_norm() - ( 2 * oneA + 2 * oneB ) > tol )
33 {
34 cout << "\033[1;31;48m * FAILED \033[0m\n";
35 return 1;
36 }
37 cout << "\033[1;32;48m * PASSED \033[0m\n";
38 return 0;
39
40}
An SparseVector class – a sparse vector object.
Definition: SparseVector.h:20
void fill_random(CppNoddy::SparseVector< double > &V, const unsigned &num_of_elts)
Definition: Utils_Fill.h:53

References Utils_Fill::fill_random(), and CppNoddy::SparseVector< _Type >::one_norm().

© 2012

R.E. Hewitt