/[escript]/trunk/escript/src/DataC.cpp
ViewVC logotype

Annotation of /trunk/escript/src/DataC.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2199 - (hide annotations)
Thu Jan 8 06:10:52 2009 UTC (10 years, 9 months ago) by jfenwick
File size: 3838 byte(s)
Misc fixes:
Added some svn:ignore properties for output files that were cluttering things up.

Lazy fixes:
Fixed shape calculations for TRACE and TRANSPOSE for rank>2.
Adjusted unit test accordingly.

As a Temporary change to DataC.cpp to test for lazy data in DataC's expanded check.
This is wrong but would only affect people using lazy data.
The proper fix will come when the numarray removal code moves over from the branch.

Made tensor product AUTOLAZY capable.
Fixed some bugs resolving tensor products (incorrect offsets in buffers).
Macro'd some stray couts.

- It appears that AUTOLAZY now passes all unit tests.
- It will not be _really_ safe for general use until I can add COW. 
- (Everything's better with COW)
1 jgs 82
2 ksteube 1312 /*******************************************************
3 ksteube 1811 *
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 ksteube 1312
14 ksteube 1811
15 jgs 82 extern "C" {
16 jgs 474 #include "DataC.h"
17 jgs 82 }
18    
19 jgs 474 #include "Data.h"
20 jfenwick 1796 #include "DataTypes.h"
21 jgs 82
22     int getFunctionSpaceType(struct escriptDataC* data)
23     {
24     escript::Data* temp=(escript::Data*)(data->m_dataPtr);
25     return temp->getFunctionSpace().getTypeCode();
26     }
27    
28    
29     int isDataPointShapeEqual(struct escriptDataC* data, int rank, int* dimensions)
30     {
31     if (data == (struct escriptDataC*)0) {
32     return true;
33     } else {
34     escript::Data* temp=(escript::Data*)(data->m_dataPtr);
35     if (temp->isEmpty()) {
36     return true;
37     } else {
38 jfenwick 1796 escript::DataTypes::ShapeType givenShape(&dimensions[0],&dimensions[rank]);
39     return (temp->getDataPointShape()==givenShape);
40 jgs 82 }
41     }
42     }
43    
44 ksteube 1312 int getNumDataPointsPerSample(struct escriptDataC* data)
45     {
46     if (data == (struct escriptDataC*)0) {
47     return 0;
48     } else {
49     escript::Data* temp=(escript::Data*)(data->m_dataPtr);
50     if (temp->isEmpty()) {
51     return 0;
52     } else {
53     return (temp->getNumDataPointsPerSample());
54     }
55     }
56     }
57    
58 jgs 82 int numSamplesEqual(struct escriptDataC* data, int numDataPointsPerSample,
59     int numSamples)
60     {
61     if (data == (struct escriptDataC*)0) {
62     return true;
63     } else {
64     escript::Data* temp=(escript::Data*)(data->m_dataPtr);
65     if (temp->isEmpty()) {
66     return true;
67     } else {
68     int result=(numDataPointsPerSample==temp->getNumDataPointsPerSample());
69     result=result && (numSamples==temp->getNumSamples());
70     return result;
71     }
72     }
73     }
74    
75     int getDataPointRank(struct escriptDataC* data)
76     {
77 jgs 102 if (data == (struct escriptDataC*)0) {
78     return 0;
79     } else {
80     escript::Data* temp=(escript::Data*)(data->m_dataPtr);
81     return temp->getDataPointRank();
82     }
83 jgs 82 }
84    
85 jgs 113 int getDataPointShape(struct escriptDataC* data,int i)
86 jgs 82 {
87 jgs 113 if (data == (struct escriptDataC*)0) {
88     return 0;
89     } else {
90     escript::Data* temp=(escript::Data*)(data->m_dataPtr);
91     int rank = temp->getDataPointRank();
92     if (i<0 || i>=rank) {
93     return 1;
94     } else {
95 jfenwick 1796 const escript::DataTypes::ShapeType view=temp->getDataPointShape();
96 jgs 113 return view[i];
97     }
98     }
99 jgs 82 }
100    
101     int getDataPointSize(struct escriptDataC* data)
102     {
103     escript::Data* temp=(escript::Data*)(data->m_dataPtr);
104     return temp->getDataPointSize();
105     }
106    
107     int getLength(struct escriptDataC* data)
108     {
109     escript::Data* temp=(escript::Data*)(data->m_dataPtr);
110     return temp->getLength();
111     }
112    
113     int isExpanded(struct escriptDataC* data)
114     {
115     if (data == (struct escriptDataC*)0) {
116     return false;
117     } else {
118     escript::Data* temp=(escript::Data*)(data->m_dataPtr);
119     if (temp->isEmpty()) {
120     return false;
121     } else {
122 jfenwick 2199 return temp->isExpanded() || temp->isLazy(); // THIS IS WRONG!!! we need actsExpanded from the branch
123 jgs 82 }
124     }
125     }
126    
127     int isEmpty(escriptDataC* data)
128     {
129     if (data == (struct escriptDataC*)0) {
130     return true;
131     } else {
132     escript::Data* temp=(escript::Data*)(data->m_dataPtr);
133     return temp->isEmpty();
134     }
135     }
136    
137    
138     double* getSampleData(struct escriptDataC* data, int sampleNo)
139     {
140     if (data == (struct escriptDataC*)0) {
141     return NULL;
142     } else {
143     escript::Data* temp=(escript::Data*)(data->m_dataPtr);
144     if (temp->isEmpty()) {
145     return NULL;
146     } else {
147     return temp->getSampleData(sampleNo);
148     }
149     }
150     }
151 ksteube 1312
152     double* getSampleDataFast(struct escriptDataC* data, int sampleNo)
153     {
154     escript::Data* temp=(escript::Data*)(data->m_dataPtr);
155     return temp->getSampleData(sampleNo);
156     }

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26