/[escript]/branches/arrexp_trunk2098/escript/src/WrappedArray.h
ViewVC logotype

Contents of /branches/arrexp_trunk2098/escript/src/WrappedArray.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2116 - (show annotations)
Tue Dec 2 01:58:34 2008 UTC (10 years, 4 months ago) by jfenwick
File MIME type: text/plain
File size: 1822 byte(s)
Initial experiments are successful.
1
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 double getElt(unsigned int i) const;
33 double getElt(unsigned int i, unsigned int j) const;
34 double getElt(unsigned int i, unsigned int j, unsigned int k) const;
35 double getElt(unsigned int i, unsigned int j, unsigned int k, unsigned int m) const;
36 private:
37 const boost::python::object& obj;
38 int rank;
39 DataTypes::ShapeType shape;
40 };
41
42 inline unsigned int
43 WrappedArray::getRank() const
44 {
45 return rank;
46 }
47
48 inline const DataTypes::ShapeType&
49 WrappedArray::getShape() const
50 {
51 return shape;
52 }
53
54 inline double
55 WrappedArray::getElt(unsigned int i) const
56 {
57 return boost::python::extract<double>(obj[i]);
58 }
59
60 inline
61 double
62 WrappedArray::getElt(unsigned int i, unsigned int j) const
63 {
64 return boost::python::extract<double>(obj[i][j]);
65 }
66
67 inline
68 double
69 WrappedArray::getElt(unsigned int i, unsigned int j, unsigned int k) const
70 {
71 return boost::python::extract<double>(obj[i][j][k]);
72 }
73
74 inline
75 double
76 WrappedArray::getElt(unsigned int i, unsigned int j, unsigned int k, unsigned int m) const
77 {
78 return boost::python::extract<double>(obj[i][j][k][m]);
79 }
80
81 }
82
83 #endif

  ViewVC Help
Powered by ViewVC 1.1.26