RMOL Logo Get Revenue Management Optimisation Library at SourceForge.net. Fast, secure and Free Open Source software downloads

vector_and_matrix.cpp

Go to the documentation of this file.
00001 #include <itpp/itbase.h>
00002 
00003 using namespace itpp;
00004 
00005 //These lines are needed for use of cout and endl
00006 using std::cout;
00007 using std::endl;
00008 
00009 int main()
00010 {
00011   //Declare vectors and matricies:
00012   vec a, b, c;
00013   mat A, B;
00014 
00015   //Use the function linspace to define a vector:
00016   a = linspace(1.0,2.0,10);
00017 
00018   //Use a string of values to define a vector:
00019   b = "0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0";
00020 
00021   //Add two vectors:
00022   c = a + b;
00023 
00024   //Print results:
00025   cout << "a = " << a << endl;
00026   cout << "b = " << b << endl;
00027   cout << "c = " << c << endl;
00028 
00029   //Use a string to define a matrix:
00030   A = "1.0 2.0;3.0 4.0";
00031 
00032   //Calculate the inverse of matrix A:
00033   B = inv(A);
00034 
00035   //Print results:
00036   cout << "A = " << A << endl;
00037   cout << "B = " << B << endl;
00038 
00039   //Exit program:
00040   return 0;
00041 
00042 }
SourceForge Logo

Generated on Sun Mar 7 13:11:09 2010 for RMOL by Doxygen 1.6.1