Changeset 3417 in Sophya for trunk/SophyaLib


Ignore:
Timestamp:
Dec 6, 2007, 7:33:22 PM (18 years ago)
Author:
ansari
Message:

suite maj sophya.tex (overview) pour V=2.1 , Reza 06/12/2007

File:
1 edited

Legend:

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

    r3415 r3417  
    4949\vspace{1cm}
    5050\begin{center}
    51 {\bf \Large Sophya Version: 2.1 (V\_Sep2007) }
     51{\bf \Large Sophya Version: 2.1 (V\_Nov2007) }
    5252\end{center}
    5353\titrebp{1}
     
    987987\end{verbatim}
    988988
    989 \centerline{\bf Warning: }
    990 
     989{\bf Warning: }
    991990There is a drawback in this behaviour: only a single
    992991copy of an array is written to a file, even if the array is modified,
    993 without being resized and written to a PPF stream.
     992without being resized and written (dumped) again to the same  PPF stream.
     993However, this behavior can be changed using the {\tt RenewObjId()} method,
     994as illustrated below.
    994995\begin{verbatim}
    995996{
     
    997998TArray<int_4> ia(5,3);
    998999ia = 8;
    999 pos << ia;
     1000pos << ia;                 // (1)
    10001001ia = 16;
    1001 pos << ia;
     1002pos << ia;                 // (2) Only a reference to the previously ia array is written
    10021003ia = 32;
    1003 pos << ia;
     1004ia.RenewObjId();    // We change the object Id
     1005pos << ia;                 //  (3) The complete array is dumped again
    10041006}
    10051007\end{verbatim}
    10061008
    10071009Only a single copy of the data is effectively written to the output
    1008 PPF file, corresponding to the value 8 for array elements. When we
     1010PPF file, corresponding to the value 8 for array elements, for the first two
     1011write operations. When we
    10091012read the three array from the file mca.ppf, the same array elements
    1010 are obtained three times (all elements equal to 8):
     1013are obtained two times (all elements equal to 8), and a different array is obtained
     1014the third time
    10111015\begin{verbatim}
    10121016{
     
    10491053\end{verbatim}
    10501054
     1055\subsection{Cast without conversion}
     1056Data conversion between arrays with different data type is handled transparently,
     1057through the copy constructor or the assignment (=) operator . However, in rare cases,
     1058one wants to access the same memory locations, without data type conversion.
     1059The template functions defined in {\tt arrctcast.h} can be used to access the same
     1060memory locations, by arrays with different data types. The SOPHYA/NDataBlock
     1061reference sharing mechanism is effective When using these functions.
     1062Notice that the array size or stride may change during these cast operations. \\
     1063 {\tt arrctcast.h} has been introduced in version V=2.1 (Nov 2007), and has not been
     1064 fully tested for non packed arrays.
     1065\begin{verbatim}
     1066// We define and initialize a  real array :
     1067TArray<r_4> fa(5);
     1068fa = RegularSequence(1.25,0.5);
     1069cout << " fa= " << fa;
     1070// We construct an integer array from fa, where the floating point values
     1071// are converted to integer values
     1072TArray<uint_2> ia(fa);
     1073cout << "  ia= " << ia;
     1074cout << "  ia (in hex)= " << hex << ia << dec;
     1075// We can also access the fa memory locations interpreted as short integers
     1076uint_2 ui2;
     1077// Note that sfia size is double the fa size
     1078TArray<uint_2> sfia = ArrayCast(fa, ui2);
     1079cout << "  sfia= " << sfia;
     1080cout << "  sfia (in hex)= " << hex << sfia << dec;
     1081\end{verbatim}
     1082One of the most useful case of these array type cast without conversion
     1083correspond to accessing the real or imaginary part of a complex array.
     1084Two specific template functions {\tt SDRealPart()} and {\tt SDImagPart()}
     1085are also defined in  {\tt arrctcast.h}. Two other functions {\tt ArrCastR2C()}
     1086and {\tt ArrCastC2R() } are also defined for real to complex, and
     1087complex to real cast.
     1088Their usage is shown in the next  paragraph on complex arrays.
    10511089
    10521090\subsection{Complex arrays}
     
    10591097\item[\bul] Functions returning arrays corresponding to real and imaginary
    10601098parts of a complex array: {\tt real(za) , imag(za) }
    1061 ({\bf Warning:} Note that the present implementation does not provide
     1099({\bf Warning:} Note that the these functions do not provide
    10621100shared memory access to real and imaginary parts.)
    10631101\item[\bul] Functions returning arrays corresponding to the module,
     
    10981136\end{verbatim}
    10991137
    1100 \subsection{Cast without conversion}
     1138\noindent {\bf Shared data access :} It is possible to access a complex array
     1139elements (real and imaginary parts) through the template functions defined
     1140in {\tt arrctcast.h} and discussed above. The example below shows how to use
     1141these functions.
     1142
     1143\begin{verbatim}
     1144// We define a complex array
     1145TArray< complex<r_4> > za(5);
     1146cout << " za= " << za;
     1147// And two real arrays, corresponding to the real and imaginary parts
     1148TArray<r_4> rza = SDRealPart(za);
     1149TArray<r_4> iza = SDImagPart(za);
     1150// We initialize the real and imaginary parts of the complex array
     1151rza = RegularSequence(10.,2.);
     1152iza = RegularSequence(5.,0.75);
     1153cout << " rza=..., iza=... ----> za = " << za;
     1154// The complex array seen as a real array (double size)
     1155TArray<r_4> aza = ArrCastC2R(za);
     1156cout << " za --> aza= " << aza;
     1157\end{verbatim}
    11011158
    11021159\subsection{Memory organisation}
Note: See TracChangeset for help on using the changeset viewer.