~ubuntu-branches/ubuntu/maverick/freecad/maverick

« back to all changes in this revision

Viewing changes to src/3rdParty/boost/numeric/bindings/lapack/workspace.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Teemu Ikonen
  • Date: 2009-07-16 18:37:41 UTC
  • Revision ID: james.westby@ubuntu.com-20090716183741-oww9kcxqrk991i1n
Tags: upstream-0.8.2237
ImportĀ upstreamĀ versionĀ 0.8.2237

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * 
 
3
 * Copyright (c) Karl Meerbergen & Kresimir Fresl 2003
 
4
 *
 
5
 * Distributed under the Boost Software License, Version 1.0.
 
6
 * (See accompanying file LICENSE_1_0.txt or copy at
 
7
 * http://www.boost.org/LICENSE_1_0.txt)
 
8
 *
 
9
 * KF acknowledges the support of the Faculty of Civil Engineering, 
 
10
 * University of Zagreb, Croatia.
 
11
 *
 
12
 */
 
13
 
 
14
#ifndef BOOST_NUMERIC_BINDINGS_LAPACK_WORKSPACE_HPP
 
15
#define BOOST_NUMERIC_BINDINGS_LAPACK_WORKSPACE_HPP
 
16
 
 
17
#include <boost/numeric/bindings/traits/detail/array_impl.hpp>
 
18
#include <boost/numeric/bindings/traits/type.hpp>
 
19
#include <boost/numeric/bindings/traits/type_traits.hpp>
 
20
#include <boost/numeric/bindings/traits/vector_traits.hpp>
 
21
#include <memory>
 
22
 
 
23
namespace boost { namespace numeric { namespace bindings { 
 
24
 
 
25
  /*
 
26
   * Organization of workspace in Lapack.
 
27
   * We allow one of the following arguments in a number of Lapack functions
 
28
   * - minimal_workspace() : the function allocates the minimum workspace required for the function
 
29
   * - optimal_workspace() : the function allocates the amount of workspace that allows optimal
 
30
   *                         execution.
 
31
   * - workspace( work )   : the function uses the workspace array in work.
 
32
   * - workspace( rwork, work ) : the function uses a real array rwork and a compolex array work as
 
33
   *                              workspace. (There are Lapack functions for complex matrices
 
34
   *                              that require two workarrays)
 
35
   * */
 
36
 
 
37
  namespace lapack {
 
38
 
 
39
 
 
40
     // Four classes are introduced to distinguish between the different type of memory allocations
 
41
 
 
42
     struct minimal_workspace {} ;
 
43
 
 
44
     struct optimal_workspace {} ;
 
45
 
 
46
     namespace detail {
 
47
 
 
48
        template <typename W>
 
49
        struct workspace1 {
 
50
           W& w_ ;
 
51
 
 
52
           workspace1(W& w)
 
53
           : w_( w )
 
54
           {}
 
55
        }; // struct workspace1
 
56
 
 
57
        template <typename W, typename WR>
 
58
        struct workspace2 {
 
59
           W& w_ ;
 
60
           WR& wr_ ;
 
61
 
 
62
           workspace2(W& w, WR& wr)
 
63
           : w_(w)
 
64
           , wr_(wr)
 
65
           {}
 
66
        }; // struct workspace2
 
67
 
 
68
     }
 
69
 
 
70
     template <typename W>
 
71
     detail::workspace1<W> workspace(W& w) {
 
72
        return detail::workspace1<W>(w) ;
 
73
     } // workspace()
 
74
 
 
75
     template <typename W, typename WR>
 
76
     detail::workspace2<W,WR> workspace(W& w, WR& wr) {
 
77
        return detail::workspace2<W,WR>(w, wr) ;
 
78
     } // workspace()
 
79
 
 
80
 
 
81
     /// Select the number of workspaces depending on the value_type
 
82
     template <typename T>
 
83
     struct n_workspace_args { };
 
84
 
 
85
     template <>
 
86
     struct n_workspace_args< float > {
 
87
        static const int value = 1 ;
 
88
     };
 
89
 
 
90
     template <>
 
91
     struct n_workspace_args< double > {
 
92
        static const int value = 1 ;
 
93
     };
 
94
 
 
95
     template <>
 
96
     struct n_workspace_args< traits::complex_f > {
 
97
        static const int value = 2 ;
 
98
     };
 
99
 
 
100
     template <>
 
101
     struct n_workspace_args< traits::complex_d > {
 
102
        static const int value = 2 ;
 
103
     };
 
104
 
 
105
  }
 
106
 
 
107
}}}
 
108
 
 
109
#endif