Changeset 1360 in Sophya for trunk/SophyaLib/Manual


Ignore:
Timestamp:
Dec 20, 2000, 11:59:52 AM (25 years ago)
Author:
ansari
Message:

Suite documentation TArray , Reza 20/12/2000

File:
1 edited

Legend:

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

    r1350 r1360  
    200200SOPHYA persistence services can thus be used to transfer objects
    201201through network links.
     202\item[] The serialisation (reading/writing) for objects for a given class
     203is implemented through a delegate object. The delegate class inherits
     204from {\tt PPersist} class.
    202205\end{itemize}
    203 The example below shows writing of objects through the use of overloaded
    204 operator $ << $ :
     206A complete description of SOPHYA persistence mechanism and guidelines
     207for writing delegate classes for handling object persistence is beyond
     208the scope of this document. The example in the next paragraph shows
     209simple use of SOPHYA persistence.
     210
     211\subsection{\tcls{NDataBlock}}
     212The {\bf \tcls{NDataBlock}} is designed to handle reference counting
     213and sharing of memory blocs (contiguous arrays) for numerical data
     214types. Initialisation, resizing, basic arithmetic operations, as
     215well as persistence handling services are provided.
     216The persistence handler class ({\tt \tcls{FIO\_NDataBlock}}) insures
     217that a single copy of data is written for multiply referenced objects,
     218and the data is shared among objects when reading.
     219\par
     220The example below shows writing of NDataBlock objects through the
     221use of overloaded operator $ << $ :
    205222\begin{verbatim}
    206223#include "fiondblock.h"
     
    261278\end{verbatim}
    262279
     280\subsection{CxxCompilerLinker class}
     281This class provides the services to compile C++ code and building
     282shared libraries, using the same compiler and options which have
     283been used to create the SOPHYA shared library.
     284The sample program below illustrates using this class to build
     285the shared library (myfunc.so) from the source file myfunc.cc :
     286\begin{verbatim}
     287#include "cxxcmplnk.h"
     288// ...
     289string flnm = "myfunc.cc";
     290string oname, soname;
     291int rc;
     292CxxCompilerLinker cxx;
     293// The Compile method provides a default object file name
     294rc = cxx.Compile(flnm, oname);
     295if (rc != 0 ) { // Error when compiling ... }
     296// The BuildSO method provides a default shared object file name
     297rc = cxx.BuildSO(oname, soname);
     298if (rc != 0 ) { // Error when creating shared object ... }
     299\end{verbatim}
     300
    263301\section{Module TArray}
    264302{\bf TArray} module contains template classes for handling standard
     
    273311\caption{partial class diagram for arrays, matrices and vectors}
    274312\end{figure}
     313
    275314
    276315\subsection{Using arrays}
     
    298337  for(int k=w; k<in.Size()-w; k++)
    299338    out(k) = in(Range(k-w, k+w).Sum()/(2.*w+1.);
     339\end{verbatim}
     340
     341\subsection{Memory organisation}
     342{\tt \tcls{TArray} } can handle numerical arrays with various memory
     343organisation, as long as the spacing (steps) along each axis is
     344regular. The five axis are labeled X,Y,Z,T,U. The examples below
     345illustrates the memory location for a 2-dimensional, $N_x=4 \times N_y=3$.
     346The first index is along the X axis and the second index along the Y axis.
     347\begin{verbatim}
     348    | (0,0)  (0,1)  (0,2)  (0,3) |
     349    | (1,0)  (1,1)  (1,2)  (1,3) |
     350    | (2,0)  (2,1)  (2,2)  (2,3) |
     351\end{verbatim}
     352In the first case, the array is completely packed
     353($Step_X=1, Step_Y=N_X=4$), with zero offset,
     354while in the second case, $Step_X=2, Step_Y=10, Offset=10$:
     355\begin{verbatim}
     356    | 0  1  2  3  |         | 10 12 14 16 |
     357Ex1 | 4  5  6  7  |     Ex2 | 20 22 24 26 |
     358    | 8  9  10 11 |         | 30 32 34 36 |
     359\end{verbatim}
     360
     361For matrices and vectors, an optional argument ({\tt MemoryMapping})
     362can be used to select the memory mapping, where two basic schemes
     363are available: \\
     364{\tt CMemoryMapping} and {\tt FortranMemoryMapping}. \\
     365In the case where {\tt CMemoryMapping} is used, a given matrix line
     366is packed in memory, while the columns are packed when
     367{\tt FortranMemoryMapping} is used. The first index when addressing
     368the matrix elements (line number index) runs along
     369the Y-axis if  {\tt CMemoryMapping} is used, and along the X-axis
     370in the case of {\tt FortranMemoryMapping}.
     371Arithmetic operations between matrices
     372with different memory organisation is allowed as long as
     373the two matrices have the same sizes (Number of rows and columns).
     374The following code example and the corresponding output illustrates
     375these two memory mappings.
     376\begin{verbatim}
     377TArray<r_4> X(4,2);
     378X = RegularSequence(1,1);
     379cout << "Array X= " << X << endl;
     380TMatrix<r_4> X_C(X, true, BaseArray::CMemoryMapping);
     381cout << "Matrix X_C (CMemoryMapping) = " << X_C << endl;
     382TMatrix<r_4> X_F(X, true, BaseArray::FortranMemoryMapping);
     383cout << "Matrix X_F (FortranMemoryMapping) = " << X_F << endl;
     384\end{verbatim}
     385This code would produce the following output (X\_F = Transpose(X\_C)) :
     386\begin{verbatim}
     387Array X=
     388--- TArray<f>  ND=2 SizeX*Y*...= 4x2 ---
     3891, 2, 3, 4
     3905, 6, 7, 8
     391
     392Matrix X_C (CMemoryMapping) =
     393--- TMatrix<f>(NRows=2, NCols=4) ND=2 SizeX*Y*...= 4x2 ---
     3941, 2, 3, 4
     3955, 6, 7, 8
     396
     397Matrix X_F (FortranMemoryMapping) =
     398--- TMatrix<f>(NRows=4, NCols=2) ND=2 SizeX*Y*...= 4x2 ---
     3991, 5
     4002, 6
     4013, 7
     4024, 8
    300403\end{verbatim}
    301404
Note: See TracChangeset for help on using the changeset viewer.