58 |
private double[] data; |
private double[] data; |
59 |
private double[][] bankData; |
private double[][] bankData; |
60 |
|
|
61 |
|
/** |
62 |
|
* Creates a new data buffer with a single data bank containing the |
63 |
|
* specified number of <code>double</code> elements. |
64 |
|
* |
65 |
|
* @param size the number of elements in the data bank. |
66 |
|
*/ |
67 |
public DataBufferDouble(int size) |
public DataBufferDouble(int size) |
68 |
{ |
{ |
69 |
super(TYPE_DOUBLE, size); |
super(TYPE_DOUBLE, size); |
70 |
data = new double[size]; |
data = new double[size]; |
71 |
} |
} |
72 |
|
|
73 |
|
/** |
74 |
|
* Creates a new data buffer with the specified number of data banks, |
75 |
|
* each containing the specified number of <code>double</code> elements. |
76 |
|
* |
77 |
|
* @param size the number of elements in the data bank. |
78 |
|
* @param numBanks the number of data banks. |
79 |
|
*/ |
80 |
public DataBufferDouble(int size, int numBanks) |
public DataBufferDouble(int size, int numBanks) |
81 |
{ |
{ |
82 |
super(TYPE_DOUBLE, size, numBanks); |
super(TYPE_DOUBLE, size, numBanks); |
84 |
data = bankData[0]; |
data = bankData[0]; |
85 |
} |
} |
86 |
|
|
87 |
|
/** |
88 |
|
* Creates a new data buffer backed by the specified data bank. |
89 |
|
* <p> |
90 |
|
* Note: there is no exception when <code>dataArray</code> is |
91 |
|
* <code>null</code>, but in that case an exception will be thrown |
92 |
|
* later if you attempt to access the data buffer. |
93 |
|
* |
94 |
|
* @param dataArray the data bank. |
95 |
|
* @param size the number of elements in the data bank. |
96 |
|
*/ |
97 |
public DataBufferDouble(double[] dataArray, int size) |
public DataBufferDouble(double[] dataArray, int size) |
98 |
{ |
{ |
99 |
super(TYPE_DOUBLE, size); |
super(TYPE_DOUBLE, size); |
100 |
data = dataArray; |
data = dataArray; |
101 |
} |
} |
102 |
|
|
103 |
|
/** |
104 |
|
* Creates a new data buffer backed by the specified data bank, with |
105 |
|
* the specified offset to the first element. |
106 |
|
* <p> |
107 |
|
* Note: there is no exception when <code>dataArray</code> is |
108 |
|
* <code>null</code>, but in that case an exception will be thrown |
109 |
|
* later if you attempt to access the data buffer. |
110 |
|
* |
111 |
|
* @param dataArray the data bank. |
112 |
|
* @param size the number of elements in the data bank. |
113 |
|
* @param offset the offset to the first element in the array. |
114 |
|
*/ |
115 |
public DataBufferDouble(double[] dataArray, int size, int offset) |
public DataBufferDouble(double[] dataArray, int size, int offset) |
116 |
{ |
{ |
117 |
super(TYPE_DOUBLE, size, 1, offset); |
super(TYPE_DOUBLE, size, 1, offset); |
118 |
data = dataArray; |
data = dataArray; |
119 |
} |
} |
120 |
|
|
121 |
|
/** |
122 |
|
* Creates a new data buffer backed by the specified data banks. |
123 |
|
* |
124 |
|
* @param dataArray the data banks. |
125 |
|
* @param size the number of elements in the data bank. |
126 |
|
* |
127 |
|
* @throws NullPointerException if <code>dataArray</code> is |
128 |
|
* <code>null</code>. |
129 |
|
*/ |
130 |
public DataBufferDouble(double[][] dataArray, int size) |
public DataBufferDouble(double[][] dataArray, int size) |
131 |
{ |
{ |
132 |
super(TYPE_DOUBLE, size, dataArray.length); |
super(TYPE_DOUBLE, size, dataArray.length); |
134 |
data = bankData[0]; |
data = bankData[0]; |
135 |
} |
} |
136 |
|
|
137 |
|
/** |
138 |
|
* Creates a new data buffer backed by the specified data banks, with |
139 |
|
* the specified offsets to the first element in each bank. |
140 |
|
* |
141 |
|
* @param dataArray the data banks. |
142 |
|
* @param size the number of elements in the data bank. |
143 |
|
* @param offsets the offsets to the first element in each data bank. |
144 |
|
* |
145 |
|
* @throws NullPointerException if <code>dataArray</code> is |
146 |
|
* <code>null</code>. |
147 |
|
*/ |
148 |
public DataBufferDouble(double[][] dataArray, int size, int[] offsets) |
public DataBufferDouble(double[][] dataArray, int size, int[] offsets) |
149 |
{ |
{ |
150 |
super(TYPE_DOUBLE, size, dataArray.length, offsets); |
super(TYPE_DOUBLE, size, dataArray.length, offsets); |
152 |
data = bankData[0]; |
data = bankData[0]; |
153 |
} |
} |
154 |
|
|
155 |
|
/** |
156 |
|
* Returns the first data bank. |
157 |
|
* |
158 |
|
* @return The first data bank. |
159 |
|
*/ |
160 |
public double[] getData() |
public double[] getData() |
161 |
{ |
{ |
162 |
return data; |
return data; |
163 |
} |
} |
164 |
|
|
165 |
|
/** |
166 |
|
* Returns a data bank. |
167 |
|
* |
168 |
|
* @param bank the bank index. |
169 |
|
* @return A data bank. |
170 |
|
*/ |
171 |
public double[] getData(int bank) |
public double[] getData(int bank) |
172 |
{ |
{ |
173 |
return bankData[bank]; |
return bankData[bank]; |
174 |
} |
} |
175 |
|
|
176 |
|
/** |
177 |
|
* Returns the array underlying this <code>DataBuffer</code>. |
178 |
|
* |
179 |
|
* @return The data banks. |
180 |
|
*/ |
181 |
public double[][] getBankData() |
public double[][] getBankData() |
182 |
{ |
{ |
183 |
return bankData; |
return bankData; |
184 |
} |
} |
185 |
|
|
186 |
|
/** |
187 |
|
* Returns an element from the first data bank. The offset (specified in |
188 |
|
* the constructor) is added to <code>i</code> before accessing the |
189 |
|
* underlying data array. |
190 |
|
* |
191 |
|
* @param i the element index. |
192 |
|
* @return The element. |
193 |
|
*/ |
194 |
public int getElem(int i) |
public int getElem(int i) |
195 |
{ |
{ |
196 |
return (int) data[i+offset]; |
return (int) data[i+offset]; |
197 |
} |
} |
198 |
|
|
199 |
|
/** |
200 |
|
* Returns an element from a particular data bank. The offset (specified in |
201 |
|
* the constructor) is added to <code>i</code> before accessing the |
202 |
|
* underlying data array. |
203 |
|
* |
204 |
|
* @param bank the bank index. |
205 |
|
* @param i the element index. |
206 |
|
* @return The element. |
207 |
|
*/ |
208 |
public int getElem(int bank, int i) |
public int getElem(int bank, int i) |
209 |
{ |
{ |
210 |
return (int) bankData[bank][i+offsets[bank]]; |
return (int) bankData[bank][i+offsets[bank]]; |
211 |
} |
} |
212 |
|
|
213 |
|
/** |
214 |
|
* Sets an element in the first data bank. The offset (specified in the |
215 |
|
* constructor) is added to <code>i</code> before updating the underlying |
216 |
|
* data array. |
217 |
|
* |
218 |
|
* @param i the element index. |
219 |
|
* @param val the new element value. |
220 |
|
*/ |
221 |
public void setElem(int i, int val) |
public void setElem(int i, int val) |
222 |
{ |
{ |
223 |
data[i+offset] = (double) val; |
data[i+offset] = (double) val; |
224 |
} |
} |
225 |
|
|
226 |
|
/** |
227 |
|
* Sets an element in a particular data bank. The offset (specified in the |
228 |
|
* constructor) is added to <code>i</code> before updating the underlying |
229 |
|
* data array. |
230 |
|
* |
231 |
|
* @param bank the data bank index. |
232 |
|
* @param i the element index. |
233 |
|
* @param val the new element value. |
234 |
|
*/ |
235 |
public void setElem(int bank, int i, int val) |
public void setElem(int bank, int i, int val) |
236 |
{ |
{ |
237 |
bankData[bank][i+offsets[bank]] = (double) val; |
bankData[bank][i+offsets[bank]] = (double) val; |