/[escript]/trunk/escript/src/WrappedArray.h
ViewVC logotype

Annotation of /trunk/escript/src/WrappedArray.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2677 - (hide annotations)
Tue Sep 22 00:48:00 2009 UTC (10 years, 6 months ago) by jfenwick
File MIME type: text/plain
File size: 2378 byte(s)
Removed stuff in user guide about needing to make table larger to allow
boundary points.
The table interpolation is now OMP parallel.


1 jfenwick 2116
2     /*******************************************************
3     *
4 jfenwick 2548 * Copyright (c) 2003-2009 by University of Queensland
5 jfenwick 2116 * 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 jfenwick 2677 ~WrappedArray();
31 jfenwick 2116 unsigned int getRank() const;
32     const DataTypes::ShapeType& getShape() const;
33 jfenwick 2119 double getElt() const;
34 jfenwick 2116 double getElt(unsigned int i) const;
35     double getElt(unsigned int i, unsigned int j) const;
36     double getElt(unsigned int i, unsigned int j, unsigned int k) const;
37     double getElt(unsigned int i, unsigned int j, unsigned int k, unsigned int m) const;
38 jfenwick 2677 void convertArray() const;
39 jfenwick 2116 private:
40     const boost::python::object& obj;
41     int rank;
42 jfenwick 2119 escript::DataTypes::ShapeType shape;
43     double m_scalar;
44 jfenwick 2677 mutable double* dat;
45 jfenwick 2116 };
46    
47     inline unsigned int
48     WrappedArray::getRank() const
49     {
50     return rank;
51     }
52    
53     inline const DataTypes::ShapeType&
54     WrappedArray::getShape() const
55     {
56     return shape;
57     }
58    
59     inline double
60 jfenwick 2119 WrappedArray::getElt() const
61 jfenwick 2116 {
62 jfenwick 2119 return m_scalar;
63     }
64    
65    
66     inline double
67     WrappedArray::getElt(unsigned int i) const
68 jfenwick 2455 { // __float__ added to deal with numpy. If this causes problems we may have to register a custom converter
69 jfenwick 2677 return (dat!=0)?dat[i]:(boost::python::extract<double>(obj[i].attr("__float__")()));
70 jfenwick 2116 }
71    
72     inline
73     double
74     WrappedArray::getElt(unsigned int i, unsigned int j) const
75     {
76 jfenwick 2677 return (dat!=0)?dat[DataTypes::getRelIndex(shape,i,j)]:(boost::python::extract<double>(obj[i][j].attr("__float__")()));
77 jfenwick 2116 }
78    
79     inline
80     double
81     WrappedArray::getElt(unsigned int i, unsigned int j, unsigned int k) const
82     {
83 jfenwick 2677 return (dat!=0)?dat[DataTypes::getRelIndex(shape,i,j,k)]:(boost::python::extract<double>(obj[i][j][k].attr("__float__")()));
84 jfenwick 2116 }
85    
86     inline
87     double
88     WrappedArray::getElt(unsigned int i, unsigned int j, unsigned int k, unsigned int m) const
89     {
90 jfenwick 2677 return (dat!=0)?dat[DataTypes::getRelIndex(shape,i,j,k,m)]:(boost::python::extract<double>(obj[i][j][k][m].attr("__float__")()));
91 jfenwick 2116 }
92    
93     }
94    
95 gross 2278 #endif
96    

  ViewVC Help
Powered by ViewVC 1.1.26