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