|
Revision 477, 0.7 kB
(checked in by mido, 16 years ago)
|
|
panove, vite, jak jsem peclivej na upravu kodu.. snad se vam bude libit:) konfigurace je v souboru /system/astylerc
|
-
Property svn:eol-style set to
native
|
| Line | |
|---|
| 1 | #include <itpp/itbase.h> |
|---|
| 2 | |
|---|
| 3 | using namespace itpp; |
|---|
| 4 | |
|---|
| 5 | //These lines are needed for use of cout and endl |
|---|
| 6 | using std::cout; |
|---|
| 7 | using std::endl; |
|---|
| 8 | |
|---|
| 9 | int 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 | } |
|---|