Changeset 1411 in Sophya
- Timestamp:
- Feb 20, 2001, 7:28:26 PM (25 years ago)
- Location:
- trunk/SophyaLib/Manual
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/Manual/defsophya.sty
r1362 r1411 34 34 { 35 35 \vspace{1cm} 36 \makebox[30mm][c]{\includegraphics[width=3cm]{hfi_icon_vsmall.eps}} 37 \hspace{5mm} \raisebox{12mm}{\rule{85 mm}{0.5 mm}\makebox[40 mm]{\bf Sophya }} 36 \makebox[160mm][c]{\includegraphics[width=6cm]{blue_sophya_400.eps}} 37 % \hspace{7mm} \raisebox{6mm}{\rule{100 mm}{0.5 mm} } 38 % \makebox[40 mm]{\bf Sophya } 38 39 \vspace{2cm} 39 40 \begin{center} -
trunk/SophyaLib/Manual/sophya.tex
r1387 r1411 432 432 arrays {\tt (int, float, double, complex, \ldots)}. The include 433 433 file {\tt array.h} declares all the classes and definitions 434 in module TArray. 434 in module TArray. {\bf Array} is a typdef for arrays 435 with double precision floating value elements. \\ 436 {\tt typedef TArray$<$r\_8$>$ Array ; } 435 437 436 438 \begin{figure}[hbt] … … 445 447 The example below shows basic usage of arrays, creation, initialization 446 448 and arithmetic operations. Different kind of {\bf Sequence} objects 447 can be used for initializing arrays. 449 can be used for initializing arrays. 450 448 451 \begin{figure}[hbt] 449 452 \dclsbb{Sequence}{RandomSequence} … … 460 463 ia = es; 461 464 cout << "Array<int> ia = " << ia; 462 // 2-D array of float filled with random numbers463 465 // 2-D array of floats 464 466 TArray<r_4> b(6,4), c(6,4); … … 489 491 \end{verbatim} 490 492 491 \subsection{Working with sub-arrays and Ranges}492 493 494 493 \subsection{Matrices and vectors} 495 494 \index{\tcls{TMatrix}} \index{\tcls{TVector}} … … 500 499 along one dimension is equal 1 for vectors. Column vectors 501 500 have {\tt NCols() = 1} and row vectors have {\tt NRows() = 1}. 502 503 Example of a simple low-pass filter on a one dimensional array (Vector) 501 Mathematical expressions involving matrices and vectors can easily 502 be translated into C++ code using {\tt TMatrix} and 503 {\tt TVector} objects. {\bf Matrix} and {\bf Vector} are 504 typedefs for double precision float matrices and vectors. 505 The operator {\bf *} beteween matrices is redefined to 506 perform matrix multiplication. One can then write: \\ 507 \begin{verbatim} 508 // We create a row vector 509 Vector v(1000, BaseArray::RowVector); 510 // Initialize values with a random sequence 511 v = RandomSequence(); 512 // Compute the vector length (norm) 513 double norm = (v*v.Transpose()).toScalar(); 514 cout << "Norm(v) = " << norm << endl; 515 \end{verbatim} 516 517 This module contains also simple Gauss matrix inversion algorithm 518 which can be used to solve linear systems, as illustrated by the 519 example below: 520 \begin{verbatim} 521 #include "sopemtx.h" 522 // ... 523 // Creation of a random 5x5 matrix 524 Matrix A(5,5); 525 A = RandomSequence(RandomSequence::Flat); 526 Vector X0(5); 527 X0 = RandomSequence(RandomSequence::Gaussian); 528 // Computing B = A*X0 529 Vector B = A*X0; 530 // Solving the system A*X = B 531 Vector X; 532 LinSolve(A, B, X); 533 // Checking the result 534 Vector diff = X-X0; 535 cout << "X-X0= " << diff ; 536 double min,max; 537 diff.MinMax(min, max); 538 cout << " Min(X-X0) = " << min << " Max(X-X0) = " << max << endl; 539 \end{verbatim} 540 541 \subsection{Working with sub-arrays and Ranges} 542 A powerful mechanism is included in array classes for working with 543 sub-arrays. The class {\bf Range} can be used to specify range of array 544 indexes in any of the array dimensions. Any regularly spaced index 545 range can be specified, using the {\tt start} and {\tt end} index 546 and an optional step (or stride). It is also possible to specify 547 the {\tt start} index and the number of elements. 548 In the following example, a simple low-pas filter, on a one 549 dimensional stream (Vector) has been written using sub-arrays: 550 504 551 \begin{verbatim} 505 552 // Input Vector containing a noisy periodic signal
Note:
See TracChangeset
for help on using the changeset viewer.