Changeset 477 for library/doc/tutorial/src/vector_and_matrix.cpp
- Timestamp:
- 08/05/09 14:40:03 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
library/doc/tutorial/src/vector_and_matrix.cpp
r278 r477 7 7 using std::endl; 8 8 9 int main() 10 { 11 //Declare vectors and matricies: 12 vec a, b, c; 13 mat A, B; 9 int main() { 10 //Declare vectors and matricies: 11 vec a, b, c; 12 mat A, B; 14 13 15 16 a = linspace(1.0, 2.0, 10);14 //Use the function linspace to define a vector: 15 a = linspace ( 1.0, 2.0, 10 ); 17 16 18 19 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"; 20 19 21 22 20 //Add two vectors: 21 c = a + b; 23 22 24 25 26 27 23 //Print results: 24 cout << "a = " << a << endl; 25 cout << "b = " << b << endl; 26 cout << "c = " << c << endl; 28 27 29 30 28 //Use a string to define a matrix: 29 A = "1.0 2.0;3.0 4.0"; 31 30 32 33 B = inv(A);31 //Calculate the inverse of matrix A: 32 B = inv ( A ); 34 33 35 36 37 34 //Print results: 35 cout << "A = " << A << endl; 36 cout << "B = " << B << endl; 38 37 39 40 38 //Exit program: 39 return 0; 41 40 42 41 }