Changeset 2919 in Sophya for trunk/SophyaLib/Manual


Ignore:
Timestamp:
Feb 23, 2006, 6:35:27 PM (20 years ago)
Author:
ansari
Message:

MAJ doc sophya oveview pour modifs Range() - Reza 23/02/2006

Location:
trunk/SophyaLib/Manual
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/Manual/modifs.tex

    r2911 r2919  
    134134\begin{itemize}
    135135
    136 \item[\rond] Janvier 2006  \\
     136\item[\rond] Janvier, FŽvrier 2006  \\
     137- AmŽlioration des fonctionalitŽs de la classe {\bf Range} et  des mŽthodes d'extraction
     138de sous-tableaux (+ correction bugs et amŽlioration documentation) \\
    137139- Ajout de la methode BaseArray::ValueAtPositionDB() pour corriger un gros bug au
    138140niveau de la conversion de type (r\_4 r\_8 ...) des tableaux \\
  • trunk/SophyaLib/Manual/sophya.tex

    r2835 r2919  
    4343\vspace{1cm}
    4444\begin{center}
    45 {\bf \Large Sophya Version: 1.9 (V\_Mai2005) }
     45{\bf \Large Sophya Version: 1.929 (V\_Fev2006) }
    4646% Document revision 1.0 }
    4747\end{center}
     
    494494\end{figure}
    495495
     496The development of this module started around 1999-2000,
     497after evaluation of a number of publicly  available
     498C++ array hadling packages, including TNT, Lapack++, Blitz++,
     499as well as commercial packages from RogueWave (math.h++ \ldots).
     500Most of these packages provide interesting functionalities, however,
     501not any one package seemed to fulfill most of our requirements.
     502\begin{itemize}
     503\item Capability to handle {\bf large - multidimensional - dense}
     504arrays, for numerical data types. Although we have used templates, for
     505data type specialisation, the actual code, apart inline functions is
     506not in header files. Instead, we use explicit instanciation, and the
     507compiled code for the various numerical types of arrays is the
     508library .
     509\item The shape and size of the arrays can be defined and changed
     510at run time. The classes ensure the memory management of the
     511created objets, with reference sharing for the array data.
     512The default behaviour of the copy constructor is to share the data,
     513avoiding expensive memory copies.
     514\item The package provides transparent management of sub-arrays
     515and slices, in an intuitive way, somehow similar to what is
     516available in Mathlab or Scilab.
     517\item The memory organisation for arrays, specially matrices
     518(row-major or column major) can be
     519controled. This provide compatibility when using existing C or
     520Fortran coded numerical libraries.
     521\item The classes provide efficient methods to perform basic arithmetic
     522and mathematical operations on arrays. In addition, operator overload
     523provides intuitive programming for element acces and most basic
     524arithmetic operations.
     525\item Conversion can be performed between arrays with different
     526data types. Copy and arithmetic operations can be done transparently
     527between arrays with different memory organisation patterns.   
     528\item This module does not provide more complex operations
     529such as FFT or linear algebra. Additional libraries are used, with interface
     530classes for these operations.
     531\item ASCII formatted I/O, for printing and read/write operations to/from text files.
     532\item Efficient binary I/O for object persistence (PPF format), or import/export
     533to other data formats, such as FITS are provided by helper or handler classes.
     534\end{itemize}
    496535
    497536\subsection{Using arrays}
     
    594633\end{verbatim}
    595634
     635{\bf Warning: } The operations defined in {\tt sopemtx.h}, such as
     636matrix inversion and linear system solver use a basic Gauss pivot
     637algorithm which are not adapted for large matrices ($>\sim 100x100$).
     638The services provided in other modules, such as {\bf LinAlg} should
     639be preferred in such cases.
     640
    596641\subsection{Working with sub-arrays and Ranges}
    597642\index{Range}
     
    601646range can be specified, using the {\tt start} and {\tt end} index
    602647and an optional step (or stride). It is also possible to specify
    603 the {\tt start} index and the number of elements:
     648the {\tt start} index and the number of elements.
     649\begin{itemize}
     650\item {\bf Range::all()} {\tt = Range(Range::firstIndex(), Range::lastIndex())}  \\
     651return a Range objects representing all  valid indexes along the
     652corresponding axe.
     653\item {\bf Range::first()} {\tt = Range(Range::firstIndex())}  \\
     654return a Range object representing the first valid index
     655\item {\bf Range::last()} {\tt = Range(Range::lastIndex())}
     656return a Range object representing the last valid index
     657\item {\bf Range(idx)} represents a single index ({\bf = idx})
     658\item {\bf Range(first, last)} represents the range of indices
     659{\bf first} $\leq$ index $\leq$ {\bf last}.
     660The static method {\tt Range::lastIndex()} can be used
     661to specify the last valid index.
     662\item {\bf Range(first, last, step)} represents the range of index
     663which is equivalent to \\  {\tt for(index=first; index <= last; index += step) }
     664\item { \bf Range (first, last, size, step) } the general form can be used
     665to specify an index range, using the number of elements.
     666It is possible to specify a range of index, ending with the last valid index.
     667For example \\
     668\hspace*{5mm}
     669{\tt Range(Range::lastIndex(), Range::lastIndex(), 3, 2) }  \\
     670defines  the index range: \hspace*{5mm}  last-4, last-2, last.
     671
    604672\begin{center}
    605 
    606673\begin{tabular}{ll}
    607 \multicolumn{2}{c}{ {\bf Range} {\tt (start=0, end=0, size=1, step=1) } } \\[2mm]
     674\multicolumn{2}{c}{ {\bf Range} {\tt (start, end, size, step) } } \\[2mm]
    608675\hline \\
    609 {\bf Range} {\tt r(3,6); } &  index range 3,4,5,6 \\
    610 {\bf Range} {\tt r(7,0,3); } &  index range 7,8,9 \\
    611 {\bf Range} {\tt r(10,0,3,5); } &  index range 10,12,14,16,18 \\
     676{\bf Range} {\tt r(3,6); } &  index range:  \hspace{2mm} 3,4,5,6 \\
     677{\bf Range} {\tt r(3,6,0,1); } &  index range: \hspace{2mm} 3,4,5,6 \\
     678{\bf Range} {\tt r(7,0,3,1); } &  index range: \hspace{2mm} 7,8,9 \\
     679{\bf Range} {\tt r(10,0,5,2); } &  index range: \hspace{2mm} 10,12,14,16,18 \\
    612680\end{tabular}
    613681\end{center}
     682\end{itemize}
     683
     684The method {\tt TArray<T>SubArray(Range ...)} can be used
     685to extract subarrays and slices. The operator {\tt operator() (Range rx, Range ry ...)}
     686is also overloaded for sub-array extraction.
     687For matrices, {\tt TMatrix<T>::Row()} and {\tt TMatrix<T>::Column()}
     688extract selected matrix rows and columns.
     689
     690The example illustrates the sub-array extraction using Range objects:
     691\begin{verbatim}
     692  // Creating and initialising a 2-D (6 x 4) array of integers
     693  TArray<int> iaa(6, 4);
     694  iaa = RegularSequence(1,2);
     695  cout << "Array<int> iaa = \n" << iaa;
     696  // We extract a sub-array - data is shared with iaa
     697  TArray<int> iae = iaa(Range(1, Range::lastIndex(), 3) ,
     698                        Range::all(), Range::first() );
     699  cout << "Array<int> iae=subarray(iaa) = \n" << iae;
     700  // Changing iae elements changes corresponding iaa elements
     701  iae = 0;
     702  cout << "Array<int> iae=0 --> iaa = \n" << iaa;
     703
     704\end{verbatim}
    614705
    615706In the following example, a simple low-pass filter, on a one
     
    668759\end{verbatim}
    669760The execution of this sample code creates the file {\tt aas.ppf} and
    670 its output is reproduced here. Notice that the array hierarch is
     761its output is reproduced here. Notice that the array hierarchy is
    671762recovered. BS is a sub-array of B, and modifying BS changes also
    672763the corresponding element in B.
Note: See TracChangeset for help on using the changeset viewer.