root/library/doc/tutorial/src/vector_and_matrix.cpp @ 1276

Revision 1064, 0.8 kB (checked in by mido, 14 years ago)

astyle applied all over the library

  • Property svn:eol-style set to native
Line 
1#include <itpp/itbase.h>
2
3using namespace itpp;
4
5//These lines are needed for use of cout and endl
6using std::cout;
7using std::endl;
8
9int main() {
10    //Declare vectors and matricies:
11    vec a, b, c;
12    mat A, B;
13
14    //Use the function linspace to define a vector:
15    a = linspace ( 1.0, 2.0, 10 );
16
17    //Use a string of values to define a vector:
18    b = "0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0";
19
20    //Add two vectors:
21    c = a + b;
22
23    //Print results:
24    cout << "a = " << a << endl;
25    cout << "b = " << b << endl;
26    cout << "c = " << c << endl;
27
28    //Use a string to define a matrix:
29    A = "1.0 2.0;3.0 4.0";
30
31    //Calculate the inverse of matrix A:
32    B = inv ( A );
33
34    //Print results:
35    cout << "A = " << A << endl;
36    cout << "B = " << B << endl;
37
38    //Exit program:
39    return 0;
40
41}
Note: See TracBrowser for help on using the browser.