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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1796 - (hide annotations)
Wed Sep 17 01:45:46 2008 UTC (10 years, 11 months ago) by jfenwick
File size: 2211 byte(s)
Merged noarrayview branch onto trunk.


1 jgs 117
2 ksteube 1312 /* $Id$ */
3    
4     /*******************************************************
5     *
6     * Copyright 2003-2007 by ACceSS MNRF
7     * Copyright 2007 by University of Queensland
8     *
9     * http://esscc.uq.edu.au
10     * Primary Business: Queensland, Australia
11     * Licensed under the Open Software License version 3.0
12     * http://www.opensource.org/licenses/osl-3.0.php
13     *
14     *******************************************************/
15    
16 jgs 474 #include "DataBlocks2D.h"
17 jgs 82
18 jgs 478 #include "DataException.h"
19 robwdcock 682 #include "esysUtils/EsysAssert.h"
20 jgs 478
21 jgs 82 using namespace std;
22    
23     namespace escript {
24    
25     DataBlocks2D::DataBlocks2D():
26 jgs 151 m_numRows(0),
27     m_numCols(0),
28     m_blockSize(0)
29     {
30 jgs 117 }
31 jgs 82
32     DataBlocks2D::DataBlocks2D(const DataBlocks2D& other):
33 jgs 151 m_numRows(other.m_numRows),
34     m_numCols(other.m_numCols),
35     m_blockSize(other.m_blockSize)
36 jgs 117 {
37 jgs 82 m_data=other.m_data;
38 jgs 117 }
39 jgs 82
40     DataBlocks2D::DataBlocks2D(int numRows, int numCols, int blockSize):
41 jgs 151 m_numRows(numRows),
42     m_numCols(numCols),
43     m_blockSize(blockSize)
44 jgs 117 {
45 jgs 82 resize(m_numRows,numCols,blockSize);
46 jgs 117 }
47 jgs 82
48     DataBlocks2D::~DataBlocks2D()
49 jgs 151 {
50     m_numRows=-1;
51     m_numCols=-1;
52     m_blockSize=-1;
53 jgs 117 }
54 jgs 82
55     void
56     DataBlocks2D::resize(int numRows, int numCols, int blockSize)
57 jgs 117 {
58 jgs 151 if (numRows < 1 || numCols < 1 || blockSize < 1) {
59     stringstream temp;
60     temp << "DataBlocks2D: Error - Invalid resize parameter. numRows: " << numRows
61 jgs 82 << " numCols: " << numCols << " blockSize: " << blockSize;
62 jgs 151 throw DataException(temp.str());
63 jgs 82 }
64     ValueType::size_type size=numRows*numCols*blockSize;
65 jgs 151 m_data.resize(size, 0.0, numCols*blockSize);
66 jgs 82 m_numRows=numRows;
67     m_numCols=numCols;
68     m_blockSize=blockSize;
69 jgs 117 }
70 jgs 82
71     void
72     DataBlocks2D::Swap(DataBlocks2D& other)
73 jgs 117 {
74 jgs 151 EsysAssert(((m_numRows >= 0) && (m_numCols >= 0) && (m_blockSize >= 0)), "(DataBlocks2D) Invalid object.");
75 jgs 82 swap(m_data,other.m_data);
76     swap(m_blockSize,other.m_blockSize);
77     swap(m_numRows,other.m_numRows);
78     swap(m_numCols,other.m_numCols);
79 jgs 117 }
80 jgs 82
81     DataBlocks2D&
82     DataBlocks2D::operator=(const DataBlocks2D& other)
83 jgs 117 {
84 jgs 151 EsysAssert(((m_numRows >= 0) && (m_numCols >= 0) && (m_blockSize >= 0)), "(DataBlocks2D) Invalid object.");
85 jgs 82 DataBlocks2D temp(other);
86     Swap(temp);
87     return *this;
88 jgs 117 }
89    
90 jgs 82 } // end of namespace

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26