/*This is testvector.C.  It is an additional test program that shows the
features of the vector class.  The structure is almost identical to that of the
matrix class.  To compile this file type g++ testvector.C at the prompt.*/

#include <iostream.h>
#include "Matrix.h"

void main()
{
	try{
	    Vector<double> v1(5); //define a five element vector
	    v1(0)=1.2; //set the value of each element
	    v1(1)=-2.5;
	    v1(2)=4.6;
	    v1(3)=2.7;
	    v1(4)=2.0;
	    cout<<"Vector 1 = "<<endl;
	    cout<<v1;
	    Vector<double> v2 = 1.5+v1;
	    cout <<endl<<"v2 = 1.5+v1::Vector 2 = "<<endl;
	    cout << v2;
	    cout <<endl<<"The dot product of v1 and v2 is "<<v1*v2<<endl;
	    Vector<double> v3=v2-2.5;
	    cout <<endl<<"v3 = v2-2.5::Vector 3 = "<<endl;
	    cout << v3;
	    Vector<double> v4=2.5*v3+1.5;
	    cout <<endl<<"v4 = 2.5*v3+1.5::Vector 4 = "<<endl;
	    cout << v4;
	    Matrix<double> mat(5,5);
	    mat = 1.0;
	    cout <<endl<<"Mat is a 5x5 matrix of 1's.  v5=v4*mat::Vector 5 = "<<endl;
	    Vector<double> v5=v4*mat;
	    cout << v5;
	    mat.addrow(2, v2); //add v2 to third row of mat
	    cout <<endl<<"mat = mat.addrow(2,v2)::Mat = "<<endl;
	    cout<<mat;
	    mat.subcol(3, v4); //subtract v4 from the fourth column
	    cout <<endl<<"mat = mat.subcol(3,v4)::Mat = "<<endl;
	    cout<<mat;
	    cout<<endl<<"v6 = v4/1.6 + v2::Vector 6 = "<<endl;
	    Vector<double> v6 = v4/1.6 +v2;
	    cout<<v6;
	    cout<<endl<< "v7 = mat * v6::Vector 7 = "<<endl;
	    Vector<double> v7 = mat * v6;
	    cout<<v7;
	    Vector<double> v8 = v6*mat;
	    cout<<endl<<"v8 = v6 * mat::Vector 8 = (not same as v7)"<<endl;
	    cout<<v8;
        }
        
    catch (Exception& x)
    {
        x.display(cerr);
    }
}
	    
		 
