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

Contents of /trunk/escript/src/DataBlocks2D.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1811 - (show annotations)
Thu Sep 25 23:11:13 2008 UTC (11 years ago) by ksteube
File size: 2176 byte(s)
Copyright updated in all files

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 #include "DataBlocks2D.h"
16
17 #include "DataException.h"
18 #include "esysUtils/EsysAssert.h"
19
20 using namespace std;
21
22 namespace escript {
23
24 DataBlocks2D::DataBlocks2D():
25 m_numRows(0),
26 m_numCols(0),
27 m_blockSize(0)
28 {
29 }
30
31 DataBlocks2D::DataBlocks2D(const DataBlocks2D& other):
32 m_numRows(other.m_numRows),
33 m_numCols(other.m_numCols),
34 m_blockSize(other.m_blockSize)
35 {
36 m_data=other.m_data;
37 }
38
39 DataBlocks2D::DataBlocks2D(int numRows, int numCols, int blockSize):
40 m_numRows(numRows),
41 m_numCols(numCols),
42 m_blockSize(blockSize)
43 {
44 resize(m_numRows,numCols,blockSize);
45 }
46
47 DataBlocks2D::~DataBlocks2D()
48 {
49 m_numRows=-1;
50 m_numCols=-1;
51 m_blockSize=-1;
52 }
53
54 void
55 DataBlocks2D::resize(int numRows, int numCols, int blockSize)
56 {
57 if (numRows < 1 || numCols < 1 || blockSize < 1) {
58 stringstream temp;
59 temp << "DataBlocks2D: Error - Invalid resize parameter. numRows: " << numRows
60 << " numCols: " << numCols << " blockSize: " << blockSize;
61 throw DataException(temp.str());
62 }
63 ValueType::size_type size=numRows*numCols*blockSize;
64 m_data.resize(size, 0.0, numCols*blockSize);
65 m_numRows=numRows;
66 m_numCols=numCols;
67 m_blockSize=blockSize;
68 }
69
70 void
71 DataBlocks2D::Swap(DataBlocks2D& other)
72 {
73 EsysAssert(((m_numRows >= 0) && (m_numCols >= 0) && (m_blockSize >= 0)), "(DataBlocks2D) Invalid object.");
74 swap(m_data,other.m_data);
75 swap(m_blockSize,other.m_blockSize);
76 swap(m_numRows,other.m_numRows);
77 swap(m_numCols,other.m_numCols);
78 }
79
80 DataBlocks2D&
81 DataBlocks2D::operator=(const DataBlocks2D& other)
82 {
83 EsysAssert(((m_numRows >= 0) && (m_numCols >= 0) && (m_blockSize >= 0)), "(DataBlocks2D) Invalid object.");
84 DataBlocks2D temp(other);
85 Swap(temp);
86 return *this;
87 }
88
89 } // end of namespace

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26