NAGs Libraries and Toolbox - PowerPoint PPT Presentation

1 / 44
About This Presentation
Title:

NAGs Libraries and Toolbox

Description:

[aOut, ipiv, bOut, info] = f07aa(a, b,'n',3) Uses the top 3 rows and columns of a. 29 ... [aOut, ipiv, bOut, info] = f07aa(a(1:3,1:3), b(1:3) ... – PowerPoint PPT presentation

Number of Views:118
Avg rating:3.0/5.0
Slides: 45
Provided by: davi1052
Category:
Tags: bout | libraries | nags | toolbox

less

Transcript and Presenter's Notes

Title: NAGs Libraries and Toolbox


1
NAGs Libraries and Toolbox
  • Susan Ing, David Sayers NAG
  • Jan Smit, Cosinus

2
Overview
  • Introduction Jan Smit
  • Product Overview Susan Ing
  • NAGs Numerical Libraries
  • NAG Toolbox for MATLAB
  • NAG Training Session David Sayers

3
Numerical Algorithms Group - What We Do
  • NAG provides mathematical and statistical
    algorithm libraries widely used in industry and
    academia
  • Established in 1970 with offices in Oxford,
    Manchester, Chicago, Taipei and Tokyo
  • Not-for-profit organisation committed to research
    development
  • Library code written and contributed by some of
    the worlds most renowned mathematicians and
    computer scientists
  • NAGs numerical code is embedded within many
    vendor libraries such as AMD and Intel
  • Many collaborative projects e.g. CSE Support to
    the UKs largest supercomputer, HECToR

4
Portfolio
  • Numerical Libraries
  • Highly flexible for use in many computing
    languages, programming environments, hardware
    platforms and for high performance computing
    methods
  • Connector Products for MATLAB and Maple
  • Giving users of the mathematical software
    packages MATLAB and Maple access to NAGs library
    of highly optimized and often superior numerical
    routines
  • NAG Fortran Compiler and GUI based Windows
    Compiler Fortran Builder
  • Visualization and graphics software
  • Build data visualization applications with NAGs
    IRIS Explorer
  • Consultancy services

5
Partnerships with leading academics
  • University of Aachen
  • Prof. Uwe Naumann
  • Automatic Differentiation (AD)
  • K.U. Leuven
  • Prof. Wim Schoutens
  • Option Pricing, Advanced Lévy models
  • University of Manchester
  • Profs. Nick Higham (FRS), Peter Duck and
    Ser-Huang Poon
  • Copulas, EVTs, Nearest Correlation Matrix, PDEs,
    Risk,
  • University of Oxford
  • Profs. Mike Giles, Stephen Roberts
  • Working with NAG to develop a Monte Carlo
    simulation engine with latest mathematics
    implemented on high-end SIMD architectures
    (GPUs).
  • Algorithmic/Automated Trading
  • Universita di Roma I
  • Prof. Peter Laurence
  • University of Warwick
  • Prof. Nick Webber, Prof. Mark Salmon,
  • Bayesian Stats, Copulas, Monte Carlo, Option
    Pricing, Wavelets

6
NAG Libraries Availability
  • Supporting Wide Range of O/S
  • Windows
  • Linux
  • Mac
  • Solaris
  • AIX
  • HPUX
  • ..
  • Support leading compilers
  • (Fortran, C C)
  • NAG
  • Intel, Pathscale, PGI
  • GCC, GFortran
  • Absoft, Lahey, Visual C
  • ..

7
NAG Libraries Ease of Integration
  • C (various)
  • C / .NET
  • Visual Basic
  • Java
  • Borland Delphi
  • Python
  • F
  • and more
  • Excel
  • MATLAB
  • Mathematica
  • Maple
  • LabVIEW
  • R and S-Plus
  • SAS
  • and more

ltstart C\Program Files\NAG\FL21\fldll214ml\doc
user notes gt
8
NAG and Excel..
  • Our libraries are easily accessible from Excel
  • Calling DLLs using VBA
  • NAG provide VB Declaration Statements and
    Examples
  • Excel Add-ins
  • NAGs Statistical Add-in for Excel
  • Sophisticated Add-in offering 76 statistical
    functions
  • Function/ array driven
  • NAG Schools Excel Add-in (N-SEA)
  • Basic statistical functions including graphs
  • Menu Drive

ltstart Excel here - miscgt
9
Case study e04uc vs fmincon
  • A problem from a customer from a European bank.
  • The problem involves 48 variables and has 9
    linear constraints. (No nonlinear constraints.)
  • No derivatives supplied.
  • fmincon required 1890 evaluations of the
    objective function and tool 87.6 seconds
  • e04uc required only 1129 evaluations and took
    49.4 seconds
  • OTHER GOOD REFERENCES www.walkingrandomly.com

10
Other NAG software
  • NAGs High Performance libraries
  • NAG SMP Library (for multi/many core/processor)
  • NAG Parallel Library (for clusters architectures
    - MPI)
  • NAG Library for .NET
  • In beta release
  • NAG Fortran Compiler
  • Windows version with GUI Debugger
  • Automatic Differentiation (AD) enabled
  • In collaboration with RWTH Aachen University
  • Routines for SIMD architectures (GPUs etc)
  • Early successes with RNGs on NVIDIA hardware
  • In collaboration with Professor Mike Giles
  • Monte Carlo simulation engine

11
Summary
  • NAG for Quality, World-leading Numerical Software
    Components
  • accurate, reliable, robust
  • extensively tested, supported and maintained code
  • updated for new architectures and new algorithms

12
NAG Key Contacts
  • www.nag.co.uk
  • http//www.nag.co.uk/downloads/index.asp
  • Technical Support and Help 01865 311 744
  • support_at_nag.co.uk
  • Commercial
  • jan.smit_at_cosinus.nl
  • susan.ing_at_nag.co.uk (BeNeLux Account Manager)
  • NAGNews http//www.nag.co.uk/NAGNews/Index.asp

13
Useful urls
NAG Products http//www.nag.co.uk/products_and_ser
vices.asp NAG C Library http//www.nag.co.uk/num
eric/CL/CLdescription.asp NAG Fortran Library
http//www.nag.co.uk/numeric/fl/FLdescription.asp
NAG Toolbox for MATLAB http//www.nag.co.uk/nume
ric/MB/start.asp NAG Toolbox for MATLAB some
demos can be found via here http//www.nag.co.uk/
numeric/MB/product_demonstrations.asp NAG and
Octave http//www.nag.co.uk/doc/TechRep/html/Tr4_0
9/Tr4_09.asp NAG Data Mining Components
http//www.nag.co.uk/numeric/dr/drdescription.asp
NAG Fortran Builder http//www.nag.co.uk/nagware
/np/fortranbuilder.asp NAG and Excel
http//www.nag.co.uk/numeric/callingDLLsfromotherl
ang.asp NAG and Java http//www.nag.co.uk/doc/Te
chRep/html/Tr1_04/Tr1_04.asp NAG and R
http//www.nag.co.uk/numeric/RunderWindows.asp
NAG and GPUs http//www.nag.co.uk/numeric/GPUs/
NAG Library for .NET (beta) http//www.nag.co.uk/
numeric/DT/DTdescription.asp Calling NAG DLLs
from C http//www.nag.co.uk/numeric/csharp.asp
NAGNews http//www.nag.co.uk/NAGNews/index.asp
technical articles and news
14
The NAG Toolbox for MATLAB
  • David Sayers

15
Agenda
  • Installation of the Toolbox
  • Loading
  • Behind the scenes whats happened
  • Licence
  • Checking installation
  • NAG Toolbox for MATLAB Contents
  • Fortran Library Contents names etc
  • Documentation/Help system
  • Requesting routines

NAG Toolbox for MATLAB
Saturday, 12 December 2009
15
16
Agenda
  • Using the Toolbox
  • Simple Function
  • Linear Algebra
  • Integration, Optimisation
  • Optional Parameters
  • Error Mechanism
  • Data Types
  • User Workspace
  • Whats New?
  • Conclusions/ Questions

17
Installing the Toolbox
  • Insert CD Copies available and rely on
    automatic start.
  • What has been copied ltSee Explorergt
  • A licence is required by the underlying DLL
  • Prompted for this during installation or
    afterwards from the START Menu

18
Installing Toolbox
19
Installing Toolbox
MBW3221DC TRIAL 2009/09/30 "h5pi6kwWpLeoxFiWYay7o4
OoHt"
20
Installing the Toolbox
  • Check successful implementation
  • gtgt a00ac
  • ans
  • 1

21
Installing Toolbox
  • Check version
  • gtgt a00aa
  • NAG Toolbox for MATLAB implementation
    details
  • Implementation title Win32/DLL/Intel Fortran
    9.1
  • Precision FORTRAN double precision
  • Product Code MBW3221DC
  • Mark 21E
  • End of implementation details

22
Toolbox Contents
  • Contains essentially all NAG functionality (1617
    user-callable routines at Mark 22)
  • Not BLAS as these are present anyway
  • Only thread safe versions of NAG routines e.g.
    e04uc is E04UCA not E04UCF.
  • Not routines requiring an external file.

23
Toolbox Contents
  • Each routine has a self-contained document
  • Description of method
  • Specification of each parameter
  • Explanation of error exit
  • Document contains example program
  • To illustrate calling the routine
  • Source, output

NAG Toolbox for MATLAB
Saturday, 12 December 2009
23
24
Toolbox Contents
  • There are contents and an informative
    introduction to each chapter.
  • Each routine in the chapter as its own
    documentation.
  • All documentation is available through the MATLAB
    help system.
  • If equations are difficult to read, use the
    alternative PDF versions of the documents by
    clicking on the links at the top of each page, or
    accessing them via the NAG website.

NAG Toolbox for MATLAB
Saturday, 12 December 2009
24
25
NAG Toolbox for MATLAB
  • Lets take a look ...

lt show help gt lt look for gt lt help
contents gt lt chapter intros gt lt example
prog here gt
NAG Toolbox for MATLAB
Saturday, 12 December 2009
25
26
Using the Toolbox
  • Simple function
  • No array arguments
  • Linear Algebra
  • No sparse array
  • Complex arguments
  • Int32 Integer arguments
  • Integration, Optimisation
  • No anonymous functions
  • Two ways of passing information

27
Optional Parameters
  • Optional parameters are provided after all
    compulsory parameters.
  • Optional parameters appear in pairs a string
    representing the name followed by the value.
  • The pairs can be provided in any order.

NAG Toolbox for MATLAB
Saturday, 12 December 2009
27
28
Optional Parameters
  • Example
  • aOut, ipiv, bOut, info f07aa(a, b,n,3)
  • Uses the top 3 rows and columns of a

NAG Toolbox for MATLAB
Saturday, 12 December 2009
28
29
Optional Parameters
  • Of course a similar outcome can be achieved by
  • aOut, ipiv, bOut, info f07aa(a(13,13),
    b(13))
  • This has the advantage of producing an aOut of
    the right size.

NAG Toolbox for MATLAB
Saturday, 12 December 2009
29
30
Parameter-Setting Routines
  • cwsav,lwsav,iwsav,rwsav,ifail e04wb('e04uc')
  • lwsav, iwsav, rwsav, inform e04ue('Print
    Level 5', lwsav, iwsav, rwsav)
  • ifail x04ad(int32(6)) Close channel 6
  • ifail x04ac(int32(6), 'success.res',
    int32(1))
  • iter, istate, c, cjac, clamda, objf, objgrd, r,
    x ...
  • e04uc(a, bl, bu, 'e04uc_confun',
    'e04uc_objfun', istate, cjac, clamda, r, x,
    lwsav, iwsav, rwsav)

31
Error Mechanism
  • The NAG routines can return with a number of
    errors flagged
  • NAGlicenceError - A valid licence couldnt be
    found.
  • NAGarrayBoundError - Array provided is too
    small.
  • NAGcallBackError - An error occurred when
    executing an M-File passed as a parameter to the
    routine.
  • NAGmissingInputParameters
  • NAGoptionalParameterError - Not in name/value
    pairs, or the name provided is not an optional
    parameter..

NAG Toolbox for MATLAB
Saturday, 12 December 2009
31
32
Error Mechanism
  • NAGtooManyOutputParameters
  • NAGtypeError - A parameter is of the wrong type.
  • NAGvalueError - An incorrect value has been
    provided for a parameter
  • These cannot be trapped in the MATLAB Try Catch
    manner. (Well I havent managed to do so ?)
  • Instead test the relevant ifail/info parameter

33
Error Mechanism
  • In most cases the error message will give more
    precise details of how the error was triggered.
    For example a NAGarrayBoundError might display
    the message
  • ??? The dimension of parameter 2 (A) should be
    at least 4

NAG Toolbox for MATLAB
Saturday, 12 December 2009
33
34
Error Mechanism
  • The NAG routines can produce two warnings
  • NAGtruncationWarning - A string was truncated
    when copying cell array of strings to a Fortran
    data structure.
  • NAGwarning - The NAG routine returned an error
    or warning.
  • The latter is important, and means that on exit
    the value of the parameter ifail /info) was
    non-zero.

NAG Toolbox for MATLAB
Saturday, 12 December 2009
34
35
Error Mechanism
  • If users do not wish to see a warning then they
    can disable it in the usual way, for example
  • warning('off','NAGwarning')
  • In this case it is vital that users check the
    value of ifail or info on exit from the routine.

NAG Toolbox for MATLAB
Saturday, 12 December 2009
35
36
Data Types - Complex
  • The statement c complex(x,y) returns
    the complex result x yi, where x and y are
    identically sized real arrays or scalars of the
    same data type.
  • This is used in the NAG examples

NAG Ltd
December 12, 2009
36
37
Data Types - Integers
  • In general the Toolbox uses int32 integers.
  • Use the int32 function to convert e.g.
  • myint int32(n)
  • 64 bit integers are available (for indexing
    purposes only) under Linux versions of MATLAB.
    NAG is producing a Toolbox to use these.

NAG Ltd
December 12, 2009
37
38
User Workspace
  • Many routines have parameters for user workspace,
    which are passed unchanged to user-supplied
    functions or subroutines.
  • This allows data to be passed to these
    subprograms in a thread-safe way.
  • Typically there are two or three such parameters,
    an integer and real array and, sometimes, a
    character array.
  • In the MATLAB toolbox these are replaced by a
    single MATLAB object, to provide more
    flexibility.

NAG Toolbox for MATLAB
Saturday, 12 December 2009
38
39
User Workspace
  • Cell arrays provide a way to collect arrays of
    different size and types into a single array.
  • We use the curly braces as a constructor
  • gtgtC 13, pi magic(2), A string
  • C
  • 1x3 double 3.1416
  • 2x2 double A string
  • The contents of the cells can be displayed as
    arrays but using the curly braces
  • gtgtC2,1(1,1)

NAG Ltd
December 12, 2009
39
40
User Workspace
  • For example in the following case user is a
    cell array containing three pieces of data
  • x 0.5 1 1.5
  • y 0.14,0.18,0.22, lt snip gt 2.10,4.39
  • t 1.0, 15.0, 1.0,
  • lt snip gt
  • 15.0, 1.0, 1.0
  • user y, t, 3
  • xOut, fsumsq e04fy(int32(15),
    'e04fy_lsfun1', ...
  • x, 'iuser', user)
  • The data is then passed on to e04fy_lsfun1.m

NAG Toolbox for MATLAB
Saturday, 12 December 2009
40
41
User Workspace
  • Another scheme described in
  • http//www.nag.co.uk/techtips/techtip036.asp
  • is less elegant but possibly more efficient.
  • global y t
  • set up y, t
  • lt prog calling routine with lsfun1 as argumentgt
  • function fvecc, user lsfun1(m, n, xc, user)
  • global y t
  • ltetcgt

42
Whats New?
  • Uptodate list of implementations at
  • http//www.nag.co.uk/numeric/MB/product_availabili
    ty.asp
  • Linux systems call already use Mark22 NAG Toolbox
    for MATLAB. Windows systems will have a version
    available very shortly.

43
Whats New?
  • Global Optimisation
  • Nearest Correlation Matrix
  • Wavelet Transforms
  • Partial Least Squares / Ridge Regression
  • Derivative Pricing
  • .
  • http//www.nag.co.uk/numeric/mb/newatmark22.asp
  • Some NAG demos included in Mark 22 release.

44
Conclusions
  • If you can use MATLAB then you can use the NAG
    Toolbox for MATLAB
  • Makes whole areas of mathematics available
    without recourse to additional toolboxes.
  • May obtain the equivalent libraries for use
    outside of MATLAB at no extra cost. (Yes if you
    have the MATLAB compiler this works with the NAG
    Toolbox)

45
Questions?
Write a Comment
User Comments (0)
About PowerShow.com