/[escript]/branches/subworld2/escriptcore/src/WrappedArray.h
ViewVC logotype

Annotation of /branches/subworld2/escriptcore/src/WrappedArray.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2213 - (hide annotations)
Wed Jan 14 00:23:39 2009 UTC (10 years, 4 months ago) by jfenwick
Original Path: branches/arrexp_2137_win_merge/escript/src/WrappedArray.h
File MIME type: text/plain
File size: 1939 byte(s)
In preparation for merging to trunk

1 jfenwick 2116
2     /*******************************************************
3     *
4     * Copyright (c) 2003-2008 by University of Queensland
5     * Earth Systems Science Computational Center (ESSCC)
6     * http://www.uq.edu.au/esscc
7     *
8     * Primary Business: Queensland, Australia
9     * Licensed under the Open Software License version 3.0
10     * http://www.opensource.org/licenses/osl-3.0.php
11     *
12     *******************************************************/
13    
14    
15     /** \file WrappedArray.h */
16    
17     #ifndef WrappedArray_20081202_H
18     #define WrappedArray_20081202_H
19     #include "system_dep.h"
20     #include "DataTypes.h"
21     #include "boost/python/extract.hpp"
22    
23     namespace escript
24     {
25    
26     class WrappedArray
27     {
28     public:
29     WrappedArray(const boost::python::object& obj_in);
30     unsigned int getRank() const;
31     const DataTypes::ShapeType& getShape() const;
32 jfenwick 2119 double getElt() const;
33 jfenwick 2116 double getElt(unsigned int i) const;
34     double getElt(unsigned int i, unsigned int j) const;
35     double getElt(unsigned int i, unsigned int j, unsigned int k) const;
36     double getElt(unsigned int i, unsigned int j, unsigned int k, unsigned int m) const;
37     private:
38     const boost::python::object& obj;
39     int rank;
40 jfenwick 2119 escript::DataTypes::ShapeType shape;
41     double m_scalar;
42 jfenwick 2116 };
43    
44     inline unsigned int
45     WrappedArray::getRank() const
46     {
47     return rank;
48     }
49    
50     inline const DataTypes::ShapeType&
51     WrappedArray::getShape() const
52     {
53     return shape;
54     }
55    
56     inline double
57 jfenwick 2119 WrappedArray::getElt() const
58 jfenwick 2116 {
59 jfenwick 2119 return m_scalar;
60     }
61    
62    
63     inline double
64     WrappedArray::getElt(unsigned int i) const
65     {
66 jfenwick 2116 return boost::python::extract<double>(obj[i]);
67     }
68    
69     inline
70     double
71     WrappedArray::getElt(unsigned int i, unsigned int j) const
72     {
73     return boost::python::extract<double>(obj[i][j]);
74     }
75    
76     inline
77     double
78     WrappedArray::getElt(unsigned int i, unsigned int j, unsigned int k) const
79     {
80     return boost::python::extract<double>(obj[i][j][k]);
81     }
82    
83     inline
84     double
85     WrappedArray::getElt(unsigned int i, unsigned int j, unsigned int k, unsigned int m) const
86     {
87     return boost::python::extract<double>(obj[i][j][k][m]);
88     }
89    
90     }
91    
92     #endif

  ViewVC Help
Powered by ViewVC 1.1.26