Changeset 2919 in Sophya
- Timestamp:
- Feb 23, 2006, 6:35:27 PM (20 years ago)
- Location:
- trunk/SophyaLib/Manual
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/Manual/modifs.tex
r2911 r2919 134 134 \begin{itemize} 135 135 136 \item[\rond] Janvier 2006 \\ 136 \item[\rond] Janvier, Fvrier 2006 \\ 137 - Amlioration des fonctionalits de la classe {\bf Range} et des mthodes d'extraction 138 de sous-tableaux (+ correction bugs et amlioration documentation) \\ 137 139 - Ajout de la methode BaseArray::ValueAtPositionDB() pour corriger un gros bug au 138 140 niveau de la conversion de type (r\_4 r\_8 ...) des tableaux \\ -
trunk/SophyaLib/Manual/sophya.tex
r2835 r2919 43 43 \vspace{1cm} 44 44 \begin{center} 45 {\bf \Large Sophya Version: 1.9 (V\_Mai2005) }45 {\bf \Large Sophya Version: 1.929 (V\_Fev2006) } 46 46 % Document revision 1.0 } 47 47 \end{center} … … 494 494 \end{figure} 495 495 496 The development of this module started around 1999-2000, 497 after evaluation of a number of publicly available 498 C++ array hadling packages, including TNT, Lapack++, Blitz++, 499 as well as commercial packages from RogueWave (math.h++ \ldots). 500 Most of these packages provide interesting functionalities, however, 501 not any one package seemed to fulfill most of our requirements. 502 \begin{itemize} 503 \item Capability to handle {\bf large - multidimensional - dense} 504 arrays, for numerical data types. Although we have used templates, for 505 data type specialisation, the actual code, apart inline functions is 506 not in header files. Instead, we use explicit instanciation, and the 507 compiled code for the various numerical types of arrays is the 508 library . 509 \item The shape and size of the arrays can be defined and changed 510 at run time. The classes ensure the memory management of the 511 created objets, with reference sharing for the array data. 512 The default behaviour of the copy constructor is to share the data, 513 avoiding expensive memory copies. 514 \item The package provides transparent management of sub-arrays 515 and slices, in an intuitive way, somehow similar to what is 516 available in Mathlab or Scilab. 517 \item The memory organisation for arrays, specially matrices 518 (row-major or column major) can be 519 controled. This provide compatibility when using existing C or 520 Fortran coded numerical libraries. 521 \item The classes provide efficient methods to perform basic arithmetic 522 and mathematical operations on arrays. In addition, operator overload 523 provides intuitive programming for element acces and most basic 524 arithmetic operations. 525 \item Conversion can be performed between arrays with different 526 data types. Copy and arithmetic operations can be done transparently 527 between arrays with different memory organisation patterns. 528 \item This module does not provide more complex operations 529 such as FFT or linear algebra. Additional libraries are used, with interface 530 classes 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 533 to other data formats, such as FITS are provided by helper or handler classes. 534 \end{itemize} 496 535 497 536 \subsection{Using arrays} … … 594 633 \end{verbatim} 595 634 635 {\bf Warning: } The operations defined in {\tt sopemtx.h}, such as 636 matrix inversion and linear system solver use a basic Gauss pivot 637 algorithm which are not adapted for large matrices ($>\sim 100x100$). 638 The services provided in other modules, such as {\bf LinAlg} should 639 be preferred in such cases. 640 596 641 \subsection{Working with sub-arrays and Ranges} 597 642 \index{Range} … … 601 646 range can be specified, using the {\tt start} and {\tt end} index 602 647 and an optional step (or stride). It is also possible to specify 603 the {\tt start} index and the number of elements: 648 the {\tt start} index and the number of elements. 649 \begin{itemize} 650 \item {\bf Range::all()} {\tt = Range(Range::firstIndex(), Range::lastIndex())} \\ 651 return a Range objects representing all valid indexes along the 652 corresponding axe. 653 \item {\bf Range::first()} {\tt = Range(Range::firstIndex())} \\ 654 return a Range object representing the first valid index 655 \item {\bf Range::last()} {\tt = Range(Range::lastIndex())} 656 return 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}. 660 The static method {\tt Range::lastIndex()} can be used 661 to specify the last valid index. 662 \item {\bf Range(first, last, step)} represents the range of index 663 which 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 665 to specify an index range, using the number of elements. 666 It is possible to specify a range of index, ending with the last valid index. 667 For example \\ 668 \hspace*{5mm} 669 {\tt Range(Range::lastIndex(), Range::lastIndex(), 3, 2) } \\ 670 defines the index range: \hspace*{5mm} last-4, last-2, last. 671 604 672 \begin{center} 605 606 673 \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] 608 675 \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 \\ 612 680 \end{tabular} 613 681 \end{center} 682 \end{itemize} 683 684 The method {\tt TArray<T>SubArray(Range ...)} can be used 685 to extract subarrays and slices. The operator {\tt operator() (Range rx, Range ry ...)} 686 is also overloaded for sub-array extraction. 687 For matrices, {\tt TMatrix<T>::Row()} and {\tt TMatrix<T>::Column()} 688 extract selected matrix rows and columns. 689 690 The 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} 614 705 615 706 In the following example, a simple low-pass filter, on a one … … 668 759 \end{verbatim} 669 760 The execution of this sample code creates the file {\tt aas.ppf} and 670 its output is reproduced here. Notice that the array hierarch is761 its output is reproduced here. Notice that the array hierarchy is 671 762 recovered. BS is a sub-array of B, and modifying BS changes also 672 763 the corresponding element in B.
Note:
See TracChangeset
for help on using the changeset viewer.