Changeset 1411 in Sophya for trunk/SophyaLib


Ignore:
Timestamp:
Feb 20, 2001, 7:28:26 PM (25 years ago)
Author:
ansari
Message:

MAJ documentation - Reza 20/2/2001

Location:
trunk/SophyaLib/Manual
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/Manual/defsophya.sty

    r1362 r1411  
    3434{
    3535\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 }
    3839\vspace{2cm}
    3940\begin{center}
  • trunk/SophyaLib/Manual/sophya.tex

    r1387 r1411  
    432432arrays {\tt (int, float, double, complex, \ldots)}. The include
    433433file {\tt array.h} declares all the classes and definitions
    434 in module TArray. 
     434in module TArray. {\bf Array} is a typdef for arrays
     435with double precision floating value elements. \\
     436{\tt typedef TArray$<$r\_8$>$ Array ; }
    435437
    436438\begin{figure}[hbt]
     
    445447The example below shows basic usage of arrays, creation, initialization
    446448and arithmetic operations. Different kind of {\bf Sequence} objects
    447 can be used for initializing arrays.
     449can be used for initializing arrays.
     450
    448451\begin{figure}[hbt]
    449452\dclsbb{Sequence}{RandomSequence}
     
    460463ia = es;
    461464cout << "Array<int> ia = " << ia;
    462 // 2-D array of float filled with random numbers 
    463465// 2-D array of floats
    464466TArray<r_4> b(6,4), c(6,4);
     
    489491\end{verbatim}
    490492
    491 \subsection{Working with sub-arrays and Ranges}
    492 
    493 
    494493\subsection{Matrices and vectors}
    495494\index{\tcls{TMatrix}}  \index{\tcls{TVector}}
     
    500499along one dimension is equal 1 for vectors. Column vectors
    501500have {\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)
     501Mathematical expressions involving matrices and vectors can easily
     502be translated into C++ code using {\tt TMatrix} and
     503{\tt TVector} objects. {\bf Matrix} and {\bf Vector} are
     504typedefs for double precision float matrices and vectors.
     505The operator {\bf *} beteween matrices is redefined to
     506perform 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
     517This module contains also simple Gauss matrix inversion algorithm
     518which can be used to solve linear systems, as illustrated by the
     519example below:
     520\begin{verbatim}
     521#include "sopemtx.h"
     522// ...
     523// Creation of a random 5x5 matrix
     524Matrix A(5,5);
     525A = RandomSequence(RandomSequence::Flat);
     526Vector X0(5);
     527X0 = RandomSequence(RandomSequence::Gaussian);
     528// Computing B = A*X0
     529Vector B = A*X0;
     530// Solving the system A*X = B
     531Vector X;
     532LinSolve(A, B, X);
     533// Checking the result
     534Vector diff = X-X0;
     535cout << "X-X0= " << diff ;
     536double min,max;
     537diff.MinMax(min, max);
     538cout << " Min(X-X0) = " << min << " Max(X-X0) = " << max << endl;
     539\end{verbatim}
     540
     541\subsection{Working with sub-arrays and Ranges}
     542A powerful mechanism is included in array classes for working with
     543sub-arrays. The class {\bf Range} can be used to specify range of array
     544indexes in any of the array dimensions. Any regularly spaced index
     545range can be specified, using the {\tt start} and {\tt end} index
     546and an optional step (or stride). It is also possible to specify
     547the {\tt start} index and the number of elements.
     548In the following example, a simple low-pas filter, on a one
     549dimensional stream (Vector) has been written using sub-arrays: 
     550
    504551\begin{verbatim}
    505552// Input Vector containing a noisy periodic signal
Note: See TracChangeset for help on using the changeset viewer.