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

« back to all changes in this revision

Viewing changes to src/3rdParty/boost/numeric/bindings/traits/tnt.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) 2002, 2003 Kresimir Fresl, Toon Knapen and Karl Meerbergen
 
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_TRAITS_TNT_H
 
15
#define BOOST_NUMERIC_BINDINGS_TRAITS_TNT_H
 
16
 
 
17
// Roldan Pozo's TNT (Template Numerical Toolkit)
 
18
// see: http://math.nist.gov/tnt/index.html
 
19
 
 
20
#include <boost/numeric/bindings/traits/config.hpp> 
 
21
 
 
22
#ifndef BOOST_NUMERIC_BINDINGS_POOR_MANS_TRAITS 
 
23
 
 
24
#include <boost/numeric/bindings/traits/traits.hpp>
 
25
#include <tnt/tnt_array1d.h>
 
26
#include <tnt/tnt_fortran_array1d.h>
 
27
#include <tnt/tnt_array2d.h>
 
28
#include <tnt/tnt_fortran_array2d.h>
 
29
 
 
30
namespace boost { namespace numeric { namespace bindings { namespace traits {
 
31
 
 
32
  // TNT::Array1D<>
 
33
  template <typename T, typename V>
 
34
  struct vector_detail_traits<TNT::Array1D<T>, V> 
 
35
  {
 
36
#ifndef BOOST_NUMERIC_BINDINGS_NO_SANITY_CHECK
 
37
    BOOST_STATIC_ASSERT( 
 
38
      (boost::is_same< 
 
39
         TNT::Array1D<T>, typename boost::remove_const<V>::type 
 
40
       >::value) );
 
41
#endif
 
42
 
 
43
    typedef TNT::Array1D<T> identifier_type; 
 
44
    typedef V vector_type;
 
45
    typedef T value_type; 
 
46
    typedef typename detail::generate_const<V,T>::type* pointer; 
 
47
 
 
48
    static pointer storage (vector_type& v) { return &v[0]; }
 
49
    static int size (vector_type& v) { return v.dim(); } 
 
50
    static int stride (vector_type& v) { return 1; } 
 
51
  }; 
 
52
 
 
53
  // TNT::Fortran_Array1D<>
 
54
  template <typename T, typename V>
 
55
  struct vector_detail_traits<TNT::Fortran_Array1D<T>, V> 
 
56
  {
 
57
#ifndef BOOST_NUMERIC_BINDINGS_NO_SANITY_CHECK
 
58
    BOOST_STATIC_ASSERT( 
 
59
      (boost::is_same< 
 
60
         TNT::Fortran_Array1D<T>, typename boost::remove_const<V>::type 
 
61
       >::value) );
 
62
#endif
 
63
 
 
64
    typedef TNT::Fortran_Array1D<T> identifier_type; 
 
65
    typedef V vector_type;
 
66
    typedef T value_type; 
 
67
    typedef typename detail::generate_const<V,T>::type* pointer; 
 
68
 
 
69
    static pointer storage (vector_type& v) { return &v(1); }
 
70
    static int size (vector_type& v) { return v.dim(); } 
 
71
    static int stride (vector_type& v) { return 1; } 
 
72
  }; 
 
73
 
 
74
 
 
75
  // TNT::Array2D<>
 
76
  template <typename T, typename M>
 
77
  struct matrix_detail_traits<TNT::Array2D<T>, M> 
 
78
  {
 
79
#ifndef BOOST_NUMERIC_BINDINGS_NO_SANITY_CHECK
 
80
    BOOST_STATIC_ASSERT( 
 
81
      (boost::is_same< 
 
82
         TNT::Array2D<T>, typename boost::remove_const<M>::type 
 
83
       >::value) );
 
84
#endif
 
85
 
 
86
    typedef TNT::Array2D<T> identifier_type; 
 
87
    typedef M matrix_type;
 
88
    typedef general_t matrix_structure; 
 
89
    typedef row_major_t ordering_type; 
 
90
 
 
91
    typedef T value_type; 
 
92
    typedef typename detail::generate_const<M,T>::type* pointer; 
 
93
 
 
94
    static pointer storage (matrix_type& m) { return m[0]; }
 
95
    static int size1 (matrix_type& m) { return m.dim1(); } 
 
96
    static int size2 (matrix_type& m) { return m.dim2(); } 
 
97
    static int storage_size (matrix_type& m) { 
 
98
      return size1 (m) * size2 (m); 
 
99
    }
 
100
    static int leading_dimension (matrix_type& m) { return m.dim2(); } 
 
101
  }; 
 
102
 
 
103
  // TNT::Fortran_Array2D<>
 
104
  template <typename T, typename M>
 
105
  struct matrix_detail_traits<TNT::Fortran_Array2D<T>, M> {
 
106
#ifndef BOOST_NUMERIC_BINDINGS_NO_SANITY_CHECK
 
107
    BOOST_STATIC_ASSERT( 
 
108
      (boost::is_same< 
 
109
         TNT::Fortran_Array2D<T>, typename boost::remove_const<M>::type 
 
110
       >::value) );
 
111
#endif
 
112
 
 
113
    typedef TNT::Fortran_Array2D<T> identifier_type; 
 
114
    typedef M matrix_type;
 
115
    typedef general_t matrix_structure; 
 
116
    typedef column_major_t ordering_type; 
 
117
 
 
118
    typedef T value_type; 
 
119
    typedef typename detail::generate_const<M,T>::type* pointer; 
 
120
 
 
121
    static pointer storage (matrix_type& m) { return &m(1, 1); }
 
122
    static int size1 (matrix_type& m) { return m.dim1(); } 
 
123
    static int size2 (matrix_type& m) { return m.dim2(); } 
 
124
    static int storage_size (matrix_type& m) { 
 
125
      return size1 (m) * size2 (m); 
 
126
    }
 
127
    static int leading_dimension (matrix_type& m) { return m.dim1(); } 
 
128
  }; 
 
129
 
 
130
}}}}  
 
131
 
 
132
#else // BOOST_NUMERIC_BINDINGS_POOR_MANS_TRAITS 
 
133
 
 
134
#error with your compiler TNT cannot be used in bindings
 
135
 
 
136
#endif // BOOST_NUMERIC_BINDINGS_POOR_MANS_TRAITS 
 
137
 
 
138
#endif // BOOST_NUMERIC_BINDINGS_TRAITS_TNT_H