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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1698 - (hide annotations)
Tue Aug 12 01:13:16 2008 UTC (11 years, 6 months ago) by jfenwick
Original Path: branches/arrayview_from_1695_trunk/escript/src/DataTypes.cpp
File size: 1509 byte(s)
Branch commit DO NOT PANIC.

Moved shapeToString and noValues from DataArrayView to 
DataTypes{.h,.cpp}


1 jfenwick 1698 /* $Id:$ */
2    
3     /*******************************************************
4     *
5     * Copyright 2003-2007 by ACceSS MNRF
6     * Copyright 2007 by University of Queensland
7     *
8     * http://esscc.uq.edu.au
9     * Primary Business: Queensland, Australia
10     * Licensed under the Open Software License version 3.0
11     * http://www.opensource.org/licenses/osl-3.0.php
12     *
13     *******************************************************/
14    
15     #include <sstream>
16     #include "DataTypes.h"
17    
18     namespace escript
19     {
20     namespace DataTypes
21     {
22    
23     int
24     noValues(const ShapeType& shape)
25     {
26     ShapeType::const_iterator i;
27     //
28     // An empty shape vector means rank 0 which contains 1 value
29     int noValues=1;
30     for (i=shape.begin();i!=shape.end();i++) {
31     noValues*=(*i);
32     }
33     return noValues;
34     }
35    
36     int
37     noValues(const RegionLoopRangeType& region)
38     {
39     //
40     // An empty region vector means rank 0 which contains 1 value
41     int noValues=1;
42     unsigned int i;
43     for (i=0;i<region.size();i++) {
44     noValues*=region[i].second-region[i].first;
45     }
46     return noValues;
47     }
48    
49     std::string
50     shapeToString(const DataTypes::ShapeType& shape)
51     {
52     std::stringstream temp;
53     temp << "(";
54     unsigned int i;
55     for (i=0;i<shape.size();i++) {
56     temp << shape[i];
57     if (i < shape.size()-1) {
58     temp << ",";
59     }
60     }
61     temp << ")";
62     return temp.str();
63     }
64    
65     } // end namespace DataTypes
66     } // end namespace escript

  ViewVC Help
Powered by ViewVC 1.1.26