C-XSC - A C++ Class Library for Extended Scientific Computing 2.5.4
lx_civector.inl
1/*
2** CXSC is a C++ library for eXtended Scientific Computing (V 2.5.4)
3**
4** Copyright (C) 1990-2000 Institut fuer Angewandte Mathematik,
5** Universitaet Karlsruhe, Germany
6** (C) 2000-2014 Wiss. Rechnen/Softwaretechnologie
7** Universitaet Wuppertal, Germany
8**
9** This library is free software; you can redistribute it and/or
10** modify it under the terms of the GNU Library General Public
11** License as published by the Free Software Foundation; either
12** version 2 of the License, or (at your option) any later version.
13**
14** This library is distributed in the hope that it will be useful,
15** but WITHOUT ANY WARRANTY; without even the implied warranty of
16** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17** Library General Public License for more details.
18**
19** You should have received a copy of the GNU Library General Public
20** License along with this library; if not, write to the Free
21** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22*/
23
24namespace cxsc {
25
29 inline lx_civector::lx_civector () noexcept:dat(NULL),l(1),u(0),size(0)
30 { }
31
37 inline lx_civector::lx_civector(int i) noexcept:l(1),u(i),size(i)
38 {
39 dat=new lx_cinterval[i];
40 }
41
48 inline lx_civector::lx_civector(int i1, int i2)
49#if(CXSC_INDEX_CHECK)
50 :
51 l(i1),u(i2),size(i2-i1+1)
52#else
53 noexcept:l(i1),u(i2),size(i2-i1+1)
54#endif
55 {
56#if(CXSC_INDEX_CHECK)
57 if(i1>i2) cxscthrow(ERROR_IVECTOR_WRONG_BOUNDARIES(
58 "lx_civector(const int &i1,const int &i2)"));
59#endif
60 dat=new lx_cinterval[size];
61 }
62
63 inline lx_civector::lx_civector(const lx_cinterval &r) noexcept:l(1),u(1),size(1)
64 {
65 dat=new lx_cinterval[1];
66 *dat=r;
67 }
68
69 inline lx_civector::lx_civector(const l_cinterval &r) noexcept:l(1),u(1),size(1)
70 {
71 dat=new lx_cinterval[1];
72 *dat=r;
73 }
74
75 inline lx_civector::lx_civector(const cinterval &r) noexcept:l(1),u(1),size(1)
76 {
77 dat=new lx_cinterval[1];
78 *dat=r;
79 }
80
81 inline lx_civector::lx_civector(const lx_complex &r) noexcept:l(1),u(1),size(1)
82 {
83 dat=new lx_cinterval[1];
84 *dat=r;
85 }
86
87 inline lx_civector::lx_civector(const l_complex &r) noexcept:l(1),u(1),size(1)
88 {
89 dat=new lx_cinterval[1];
90 *dat=r;
91 }
92
93 inline lx_civector::lx_civector(const complex &r) noexcept:l(1),u(1),size(1)
94 {
95 dat=new lx_cinterval[1];
96 *dat=r;
97 }
98
99 inline lx_civector::lx_civector(const lx_interval &r) noexcept:l(1),u(1),size(1)
100 {
101 dat=new lx_cinterval[1];
102 *dat=r;
103 }
104
105 inline lx_civector::lx_civector(const l_interval &r) noexcept:l(1),u(1),size(1)
106 {
107 dat=new lx_cinterval[1];
108 *dat=r;
109 }
110
111 inline lx_civector::lx_civector(const interval &r) noexcept:l(1),u(1),size(1)
112 {
113 dat=new lx_cinterval[1];
114 *dat=r;
115 }
116
117 inline lx_civector::lx_civector(const lx_real &r) noexcept:l(1),u(1),size(1)
118 {
119 dat=new lx_cinterval[1];
120 *dat=r;
121 }
122
123 inline lx_civector::lx_civector(const l_real &r) noexcept:l(1),u(1),size(1)
124 {
125 dat=new lx_cinterval[1];
126 *dat=r;
127 }
128
129 inline lx_civector::lx_civector(const real &r) noexcept:l(1),u(1),size(1)
130 {
131 dat=new lx_cinterval[1];
132 *dat=r;
133 }
134
136 noexcept:l(v.l),u(v.u),size(v.size)
137 {
138 dat=new lx_cinterval[size];
139 for (int i=0;i<size;i++)
140 dat[i]=v.dat[i];
141 }
142
144 {
145 l = rv.l; u = rv.u; size = rv.size;
146 dat=new lx_cinterval[size];
147 for (int i=0;i<size;i++)
148 dat[i]=rv.dat[i];
149 return *this;
150 }
151
152 inline lx_civector &lx_civector::operator =(const lx_cinterval &r) noexcept
153 {
154 lx_cinterval *newdat = new lx_cinterval[size];
155 for (int i=0;i<size;i++)
156 newdat[i] = r;
157 delete [] dat;
158 dat = newdat;
159 return *this;
160 }
161
163 {
164 lx_cinterval *newdat = new lx_cinterval[size];
165 for (int i=0;i<size;i++)
166 newdat[i] = r;
167 delete [] dat;
168 dat = newdat;
169 return *this;
170 }
171
173 {
174 lx_cinterval *newdat = new lx_cinterval[size];
175 for (int i=0;i<size;i++)
176 newdat[i] = r;
177 delete [] dat;
178 dat = newdat;
179 return *this;
180 }
181
182 inline lx_civector &lx_civector::operator =(const lx_complex &r) noexcept
183 {
184 lx_cinterval *newdat = new lx_cinterval[size];
185 for (int i=0;i<size;i++)
186 newdat[i] = r;
187 delete [] dat;
188 dat = newdat;
189 return *this;
190 }
191
193 {
194 lx_cinterval *newdat = new lx_cinterval[size];
195 for (int i=0;i<size;i++)
196 newdat[i] = r;
197 delete [] dat;
198 dat = newdat;
199 return *this;
200 }
201
202 inline lx_civector &lx_civector::operator =(const complex &r) noexcept
203 {
204 lx_cinterval *newdat = new lx_cinterval[size];
205 for (int i=0;i<size;i++)
206 newdat[i] = r;
207 delete [] dat;
208 dat = newdat;
209 return *this;
210 }
211
212 inline lx_civector &lx_civector::operator =(const lx_interval &r) noexcept
213 {
214 lx_cinterval *newdat = new lx_cinterval[size];
215 for (int i=0;i<size;i++)
216 newdat[i] = r;
217 delete [] dat;
218 dat = newdat;
219 return *this;
220 }
221
223 {
224 lx_cinterval *newdat = new lx_cinterval[size];
225 for (int i=0;i<size;i++)
226 newdat[i] = r;
227 delete [] dat;
228 dat = newdat;
229 return *this;
230 }
231
233 {
234 lx_cinterval *newdat = new lx_cinterval[size];
235 for (int i=0;i<size;i++)
236 newdat[i] = r;
237 delete [] dat;
238 dat = newdat;
239 return *this;
240 }
241
242 inline lx_civector &lx_civector::operator =(const lx_real &r) noexcept
243 {
244 lx_cinterval *newdat = new lx_cinterval[size];
245 for (int i=0;i<size;i++)
246 newdat[i] = r;
247 delete [] dat;
248 dat = newdat;
249 return *this;
250 }
251
252 inline lx_civector &lx_civector::operator =(const l_real &r) noexcept
253 {
254 lx_cinterval *newdat = new lx_cinterval[size];
255 for (int i=0;i<size;i++)
256 newdat[i] = r;
257 delete [] dat;
258 dat = newdat;
259 return *this;
260 }
261
262 inline lx_civector &lx_civector::operator =(const real &r) noexcept
263 {
264 lx_cinterval *newdat = new lx_cinterval[size];
265 for (int i=0;i<size;i++)
266 newdat[i] = r;
267 delete [] dat;
268 dat = newdat;
269 return *this;
270 }
271
272 inline lx_cinterval & lx_civector::operator [](const int &i)
273#if(CXSC_INDEX_CHECK)
274
275#else
276 noexcept
277#endif
278 {
279#if(CXSC_INDEX_CHECK)
280 if(i<l||i>u) cxscthrow(ERROR_IVECTOR_ELEMENT_NOT_IN_VEC(
281 "lx_cinterval & lx_civector::operator [](const int &i)"));
282#endif
283 return dat[i-l];
284 }
285
286 inline const lx_cinterval & lx_civector::operator [](const int &i) const
287#if(CXSC_INDEX_CHECK)
288
289#else
290 noexcept
291#endif
292 {
293#if(CXSC_INDEX_CHECK)
294 if(i<l || i>u) cxscthrow(ERROR_IVECTOR_ELEMENT_NOT_IN_VEC(
295 "lx_cinterval & lx_civector::operator [](const int &i)"));
296#endif
297 return dat[i-l];
298 }
299
300inline void Resize(lx_civector &rv, int len)
301#if(CXSC_INDEX_CHECK)
302 ;
303#else
304 noexcept
305#endif
306 {
307 if (rv.size == len)
308 SetLb(rv,1);
309 else
310 {
311#if(CXSC_INDEX_CHECK)
312 if (len<0)
313 cxscthrow(ERROR__WRONG_BOUNDARIES(
314 "Resize(lx_civector &rv, int len)"));
315#endif
316 lx_cinterval *ndat = new lx_cinterval[len];
317 int beg, end;
318 beg = (rv.l>1)? rv.l : 1;
319 end = (rv.u<len)? rv.u : len;
320 for(int i=beg-1;i<end;i++)
321 ndat[i]=rv.dat[i-rv.l+1];
322 delete [] rv.dat;
323 rv.dat=ndat;
324 rv.size=rv.u=len;
325 rv.l=1;
326 }
327 }
328
329inline void Resize(lx_civector &rv, int lb, int ub)
330#if(CXSC_INDEX_CHECK)
331
332#else
333 noexcept
334#endif
335{
336 if (rv.size == ub-lb+1)
337 SetUb(rv,ub);
338 else
339 {
340 rv.size = ub-lb+1;
341#if(CXSC_INDEX_CHECK)
342 if (rv.size<0)
343 cxscthrow(ERROR__WRONG_BOUNDARIES(
344 "Resize(lx_civector &rv, int lb, int ub)"));
345#endif
346 lx_cinterval *ndat = new lx_cinterval[rv.size];
347 int beg, end;
348 beg = (rv.l>lb)? rv.l : lb;
349 end = (rv.u<ub)? rv.u : ub;
350 for(int i=0;i<=rv.size-1;i++)
351 ndat[i]=interval(0);
352 for(int i=beg;i<=end;i++)
353 ndat[i-lb]=rv.dat[i-rv.l];
354 delete [] rv.dat;
355 rv.dat=ndat;
356 rv.l=lb;
357 rv.u=ub;
358 }
359}
360
361inline void DoubleSize(lx_civector& x) noexcept
362{
363 int n = Lb(x);
364 Resize(x,n,2*Ub(x)-n+1);
365}
366
367} // namespace cxsc
The Scalar Type cinterval.
Definition cinterval.hpp:55
The Scalar Type complex.
Definition complex.hpp:50
The Scalar Type interval.
Definition interval.hpp:55
The Multiple-Precision Data Type l_cinterval.
The Multiple-Precision Data Type l_complex.
Definition l_complex.hpp:46
The Multiple-Precision Data Type l_interval.
The Multiple-Precision Data Type l_real.
Definition l_real.hpp:78
The Multiple-Precision Data Type lx_civector.
lx_civector & operator=(const lx_civector &) noexcept
Implementation of standard assigning operator.
lx_cinterval & operator[](const int &i) noexcept
Operator for accessing the single elements of the vector.
lx_civector() noexcept
Constructor of class lx_civector.
The Scalar Type real.
Definition real.hpp:114
The namespace cxsc, providing all functionality of the class library C-XSC.
Definition cdot.cpp:29
int Ub(const cimatrix &rm, const int &i) noexcept
Returns the upper bound index.
cimatrix & SetLb(cimatrix &m, const int &i, const int &j) noexcept
Sets the lower bound index.
void DoubleSize(cimatrix &A)
Doubles the size of the matrix.
Definition cimatrix.cpp:83
void Resize(cimatrix &A) noexcept
Resizes the matrix.
cimatrix & SetUb(cimatrix &m, const int &i, const int &j) noexcept
Sets the upper bound index.
int Lb(const cimatrix &rm, const int &i) noexcept
Returns the lower bound index.