tminres
SerialExample/testSimpleVector.cpp
Go to the documentation of this file.
00001 // tminres is free software; you can redistribute it and/or modify it under the
00002 // terms of the GNU Lesser General Public License (as published by the Free
00003 // Software Foundation) version 2.1 dated February 1999.
00004 //
00005 // Authors:
00006 // - Umberto Villa, Emory University - uvilla@emory.edu
00007 // - Michael Saunders, Stanford University
00008 // - Santiago Akle, Stanford University
00009 
00017 #include "SimpleVector.hpp"
00018 
00019 /*
00020  * This code checks the implementation of the methods in SimpleVector.
00021  */
00022 int main()
00023 {
00024         int dim(5);
00025         SimpleVector a(dim), b(dim), c(dim), d(dim);
00026         a = 1.0;
00027         std::cout<< "a = ";
00028         a.Print(std::cout);
00029 
00030         b.Randomize(1);
00031         std::cout<< "b = ";
00032         b.Print(std::cout);
00033 
00034         c = b;
00035         std::cout<< "c = b =";
00036         c.Print(std::cout);
00037 
00038         c.Scale(-1.);
00039         std::cout << "c * (-1.) = ";
00040         c.Print(std::cout);
00041 
00042         d.Randomize(2);
00043         std::cout<<"d = ";
00044         d.Print(std::cout);
00045 
00046         subtract(d,b, a);
00047         std::cout << "a = d - b = ";
00048         a.Print(std::cout);
00049 
00050         add(d, 5., b, a);
00051         std::cout<< " a = d + 5.*b = ";
00052         a.Print(std::cout);
00053 
00054         add(0.5, d, 2.5, b, a);
00055         std::cout<< "a = 0.5 * d + 2.5*b = ";
00056         a.Print(std::cout);
00057 
00058         add(2., d, b, a);
00059         std::cout<< "a = 2* (d + b) = ";
00060         a.Print(std::cout);
00061 
00062         add(b,d,c, a);
00063         std::cout << "a = b + c + d = ";
00064         a.Print(std::cout);
00065 
00066         std::cout << "InnerProduct(b,d) = " << InnerProduct(b,d) << "\n";
00067 
00068         return 0;
00069 }
 All Classes Files Functions Friends