MtxVec v3 - Dew Research ¢â‚¬¢ Many routines are multi-threaded, including 1D FFT, sparse matrix solvers,

  • View
    0

  • Download
    0

Embed Size (px)

Text of MtxVec v3 - Dew Research ¢â‚¬¢ Many routines are multi-threaded, including...

  • MtxVec v3 Users Guide to MtxVec for Delphi W32 MtxVec version v3, rev 1.6 © 1999-2008 Dew Research www.dewresearch.com

  • Programming with MtxVec

    MtxVec v3 ......................................................................................................................................................... 2 Users Guide to MtxVec for Delphi W32................................................................................................................ 2 1 Introduction.................................................................................................................................................... 5

    1.1 Why MtxVec ........................................................................................................................................ 5 1.2 How fast is MtxVec.............................................................................................................................. 6

    2 Organization................................................................................................................................................... 6 2.1 Compiler support................................................................................................................................. 6

    3 Quick start ...................................................................................................................................................... 7 4 MtxVec programming interface..................................................................................................................... 8

    4.1 Object hierarchy.................................................................................................................................. 8 4.2 Mathematical expressions and operator overloading....................................................................... 8

    4.2.1 Element by element Vector/Matrix expression types........................................................................ 9 4.2.2 Linear algebra Vector/Matrix expression types .............................................................................. 10 4.2.3 Linear algebra with TVec and TMtx types...................................................................................... 10 4.2.4 Implicit type conversions ................................................................................................................ 11

    4.3 Method conventions........................................................................................................................... 11 4.4 Range checking .................................................................................................................................. 12 4.5 Making use of the abstract class....................................................................................................... 12

    4.5.1 Writing abstract class code.............................................................................................................. 13 4.6 Function parameters ......................................................................................................................... 13 4.7 Indexes, ranges and subranges ......................................................................................................... 14 4.8 TVec and TMtx methods as functions ............................................................................................. 15 4.9 Create and Free ................................................................................................................................. 16 4.10 Complex data ..................................................................................................................................... 16 4.11 MtxVec types...................................................................................................................................... 17

    4.11.1 TSample...................................................................................................................................... 17 4.11.2 TCplx .......................................................................................................................................... 17 4.11.3 TSampleArray, TCplxArray ....................................................................................................... 17

    5 Accessing values of Vector and Matrix ....................................................................................................... 18 5.1 Array property access ....................................................................................................................... 18 5.2 Direct dynamic array pointer. .......................................................................................................... 18

    6 Memory management................................................................................................................................... 19 6.1 Introduction ....................................................................................................................................... 19 6.2 In-place/not-in-place operations....................................................................................................... 20

    7 Range checking ............................................................................................................................................ 20 8 Why and how NAN and INF ....................................................................................................................... 20 9 Serializing and streaming ............................................................................................................................ 21

    9.1 Streaming with TMtxComponent .................................................................................................... 21 9.2 Streaming of TVec, TMtx and TSparseMtx.................................................................................... 21 9.3 Write TMtx/Matrix to a text file ...................................................................................................... 22 9.4 Read TMtx/Matrix from a text file .................................................................................................. 22

    10 Input-output interface............................................................................................................................. 22

    2

  • Programming with MtxVec

    10.1 Reading and writing raw data .......................................................................................................... 22 10.2 Formatting floating point values – FloatToString .......................................................................... 23 10.3 Printing current values of variables................................................................................................. 23 10.4 Displaying the contents of the TVec and TMtx............................................................................... 24

    10.4.1 As a delimited text ...................................................................................................................... 24 10.4.2 Within a grid. .............................................................................................................................. 24

    10.5 Charting and drawing ....................................................................................................................... 24 11 Programming style .................................................................................................................................. 26

    11.1 Mixing TVec/TMtx and Matrix/Vector types. ................................................................................ 26 11.2 Inlining of functions that use Vector and Matrix types.................................................................. 26 11.3 Try-finally blocks............................................................................................................................... 26 11.4 Raising exceptions ............................................................................................................................. 27

    11.4.1 Invalid parameter passed: ........................................................................................................... 27 11.4.2 Reformat the exception............................................................................................................... 27

    11.5 Indent the code................................................................................................................................... 27 11.6 Do not create objects within procedures and return them as result: ............................................ 28 11.7 Use CreateIt/FreeIt only for dynamically allocated objects whose lifetime is limited only to the procedure being executed. .............................................................................................................................. 28

    12 Getting up to speed.................................................................................................................................. 29 12.1 Floating point code vectorization ..................................................................................................... 29 12.2 Block based processing...................................................................................................................... 30 12.3 Common pitfalls................................................................................................................................. 31 12.4 Code vectorization methods...........................