Knowledge Base

MtxVec - Under the hood

MtxVec is an object oriented vectorized math library, the core of Dew Lab Studio, featuring a comprehensive set of mathematical and statistical functions executing at impressive speeds.

 

Multi-precision code

The main advantage of using single precision in compare to double, is to halve the memory usage and to double the speed of execution. The major new feature of MtxVec v6 is the capability to select algorithm precision at runtime. When a vector or matrix variable is declared and then sized for the first time:

a.Size(10, TMtxFloatPrecision.mvDouble);

You can optionally specify the storage precision. This storage precision can also be set/read with a property:

a.FloatPrecision

When working with the vector/matrix in expressions, the precision is preserved:

b.Sin(a);

This capability allows:

  • User specified computational precision from the UI of your application.
  • Write initial algorithm in any precision and decide on what is really needed after profiling.

Internally MtxVec will not strictly use only single precision, when the source data is in single precision. However, floating precision conversion is an expensive operation and it will try to avoid anything that might proove to be costly. At the same time, it will not unneccessarily drop the computational precision from double to single, when there is no performance or storage size benefit to be expected. This gives the user the best of both worlds.

For the source code users, it is possible to specify individual external libraries which are to be linked in. These libraries are available separately for single and for double precision floating point computation. If either precision is not used or needed, they can be left out from the distribution of the final application reducing the final package size.

When writing code, which can work with either single or double precision, consider that:

  • The default array property or the indexer for an object a[i], will work with double or single precision of "a" Vector, but there will be some conversion cost, when the storage precision will be single. This coding pattern is meaningfull, when code simplicity helps, but does not affect the performance too much, because it is not used within tight loops.
  • When tight loops are used and performance matters, it is recommend to split the branch between double and single (float) precision by checking the value of:

    a.IsDouble

    and access:

    a.Values[i]

    for double precision and

    a.SValues[i]

    for single precision.

 

Of course, the corresponding properties/values are available also for the complex number flavors:

a.CValues[i]

for double precision and

a.SCValues[i]

for single precision.

Read more

Getting up to speed

Getting up to speed

Code vectorization is where high performance computing starts

Read more

Block processing

Block processing

Second step of code optimization after applying code vectorization is called block processing

Read more

Objects and numerics

Objects and numerics

Simplify the use of numerical algorithms

Read more

MtxVec encapsulates LAPACK

MtxVec encapsulates LAPACK

The computing standard for linear algebra is included

Read more

Math functions and speed

Math functions and speed

MtxVec includes vectorized functions working on complex and real numbers

Read more

Super conductive memory manager

Super conductive memory manager

The way to massively parallel computation

Read more

MtxVec expressions

MtxVec expressions

It was Delphi 2006 that first introduced the ability to overload operators on records. This feature enabled MtxVec to add high performance support for using vectors, matrices and complex numbers in expressions.

Read more

MtxVec scripting

MtxVec scripting

MtxVec expression evaluator can be used to evaluate individual expressions or it can evaluate a list of expressions (a script).

Read more

Debugger visualizer for MtxVec

Debugger visualizer for MtxVec

Display matrices in a grid and draw charts from variables from within the debugger

Read more


© DewResearch 1997 - 2021 All Rights Reserved.

E-mail This email address is being protected from spambots. You need JavaScript enabled to view it..
Delphi & C++ Builder are registered trademarks of Embarcadero Corporation. All other brands and product names are trademarks or registered trademarks of their respective owners.