3
* Copyright (c) Karl Meerbergen & Kresimir Fresl 2003
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)
9
* KF acknowledges the support of the Faculty of Civil Engineering,
10
* University of Zagreb, Croatia.
14
#ifndef BOOST_NUMERIC_BINDINGS_LAPACK_WORKSPACE_HPP
15
#define BOOST_NUMERIC_BINDINGS_LAPACK_WORKSPACE_HPP
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>
23
namespace boost { namespace numeric { namespace bindings {
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
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)
40
// Four classes are introduced to distinguish between the different type of memory allocations
42
struct minimal_workspace {} ;
44
struct optimal_workspace {} ;
55
}; // struct workspace1
57
template <typename W, typename WR>
62
workspace2(W& w, WR& wr)
66
}; // struct workspace2
71
detail::workspace1<W> workspace(W& w) {
72
return detail::workspace1<W>(w) ;
75
template <typename W, typename WR>
76
detail::workspace2<W,WR> workspace(W& w, WR& wr) {
77
return detail::workspace2<W,WR>(w, wr) ;
81
/// Select the number of workspaces depending on the value_type
83
struct n_workspace_args { };
86
struct n_workspace_args< float > {
87
static const int value = 1 ;
91
struct n_workspace_args< double > {
92
static const int value = 1 ;
96
struct n_workspace_args< traits::complex_f > {
97
static const int value = 2 ;
101
struct n_workspace_args< traits::complex_d > {
102
static const int value = 2 ;