/[escript]/branches/trilinos_from_5897/escriptcore/src/DataVectorAlt.cpp
ViewVC logotype

Contents of /branches/trilinos_from_5897/escriptcore/src/DataVectorAlt.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5963 - (show annotations)
Mon Feb 22 06:59:27 2016 UTC (3 years, 3 months ago) by caltinay
File size: 2695 byte(s)
sync and fix.

1 #include "DataVectorAlt.h"
2
3 /* This file exists to provide a custom implementation of complex methods for DataVectorAlt
4 It also explicitly instantiates the complex version of the template to ensure linkage
5 */
6
7 namespace escript
8 {
9
10 namespace DataTypes
11 {
12
13 // Please make sure that any implementation changes here are reflected in the generic version in the .h file
14 template<>
15 void
16 DataVectorAlt<DataTypes::cplx_t>::copyFromArrayToOffset(const WrappedArray& value, size_type offset, size_type copies)
17 {
18 const DataTypes::ShapeType& tempShape=value.getShape();
19 size_type len=DataTypes::noValues(tempShape);
20 if (offset+len*copies>size())
21 {
22 std::ostringstream ss;
23 ss << "Error - not enough room for that DataPoint at that offset. (";
24 ss << "offset=" << offset << " + " << " len=" << len << " >= " << size();
25 throw DataException(ss.str());
26 }
27 size_type si=0,sj=0,sk=0,sl=0;
28 switch (value.getRank())
29 {
30 case 0:
31 for (size_type z=0;z<copies;++z)
32 {
33 m_array_data[offset+z]=value.getEltC();
34 }
35 break;
36 case 1:
37 for (size_type z=0;z<copies;++z)
38 {
39 for (size_t i=0;i<tempShape[0];++i)
40 {
41 m_array_data[offset+i]=value.getEltC(i);
42 }
43 offset+=len;
44 }
45 break;
46 case 2:
47 si=tempShape[0];
48 sj=tempShape[1];
49 for (size_type z=0;z<copies;++z)
50 {
51 for (size_type i=0;i<si;i++)
52 {
53 for (size_type j=0;j<sj;j++)
54 {
55 m_array_data[offset+DataTypes::getRelIndex(tempShape,i,j)]=value.getEltC(i,j);
56 }
57 }
58 offset+=len;
59 }
60 break;
61 case 3:
62 si=tempShape[0];
63 sj=tempShape[1];
64 sk=tempShape[2];
65 for (size_type z=0;z<copies;++z)
66 {
67 for (size_type i=0;i<si;i++)
68 {
69 for (size_type j=0;j<sj;j++)
70 {
71 for (size_type k=0;k<sk;k++)
72 {
73 m_array_data[offset+DataTypes::getRelIndex(tempShape,i,j,k)]=value.getEltC(i,j,k);
74 }
75 }
76 }
77 offset+=len;
78 }
79 break;
80 case 4:
81 si=tempShape[0];
82 sj=tempShape[1];
83 sk=tempShape[2];
84 sl=tempShape[3];
85 for (size_type z=0;z<copies;++z)
86 {
87 for (size_type i=0;i<si;i++)
88 {
89 for (size_type j=0;j<sj;j++)
90 {
91 for (size_type k=0;k<sk;k++)
92 {
93 for (size_type l=0;l<sl;l++)
94 {
95 m_array_data[offset+DataTypes::getRelIndex(tempShape,i,j,k,l)]=value.getEltC(i,j,k,l);
96 }
97 }
98 }
99 }
100 offset+=len;
101 }
102 break;
103 default:
104 std::ostringstream oss;
105 oss << "Error - unknown rank. Rank=" << value.getRank();
106 throw DataException(oss.str());
107 }
108 }
109
110 template class DataVectorAlt<DataTypes::cplx_t>;
111
112 } // end namespace
113 } // end namespace

  ViewVC Help
Powered by ViewVC 1.1.26