64 complex(
const double &_x,
const double &_y):
x(_x),
y(_y){};
82 if( fabs(z.
y)<fabs(z.
x) )
103 const complex
operator/(
const complex& lhs,
const complex& rhs);
104 const bool operator==(
const complex& lhs,
const complex& rhs);
181 T vdotproduct(const_raw_vector<T> v1, const_raw_vector<T> v2)
184 if( v1.GetStep()==1 && v2.GetStep()==1 )
190 const T *p1 = v1.GetData();
191 const T *p2 = v2.GetData();
192 int imax = v1.GetLength()/4;
194 for(
i=imax;
i!=0;
i--)
196 r += (*p1)*(*p2) + p1[1]*p2[1] + p1[2]*p2[2] + p1[3]*p2[3];
200 for(
i=0;
i<v1.GetLength()%4;
i++)
201 r += (*(p1++))*(*(p2++));
209 int offset11 = v1.GetStep(), offset12 = 2*offset11, offset13 = 3*offset11, offset14 = 4*offset11;
210 int offset21 = v2.GetStep(), offset22 = 2*offset21, offset23 = 3*offset21, offset24 = 4*offset21;
212 const T *p1 = v1.GetData();
213 const T *p2 = v2.GetData();
214 int imax = v1.GetLength()/4;
216 for(
i=0;
i<imax;
i++)
218 r += (*p1)*(*p2) + p1[offset11]*p2[offset21] + p1[offset12]*p2[offset22] + p1[offset13]*p2[offset23];
222 for(
i=0;
i<v1.GetLength()%4;
i++)
237 void vmove(raw_vector<T> vdst, const_raw_vector<T> vsrc)
240 if( vdst.GetStep()==1 && vsrc.GetStep()==1 )
245 T *p1 = vdst.GetData();
246 const T *p2 = vsrc.GetData();
247 int imax = vdst.GetLength()/2;
249 for(
i=imax;
i!=0;
i--)
256 if(vdst.GetLength()%2 != 0)
265 int offset11 = vdst.GetStep(), offset12 = 2*offset11, offset13 = 3*offset11, offset14 = 4*offset11;
266 int offset21 = vsrc.GetStep(), offset22 = 2*offset21, offset23 = 3*offset21, offset24 = 4*offset21;
267 T *p1 = vdst.GetData();
268 const T *p2 = vsrc.GetData();
269 int imax = vdst.GetLength()/4;
271 for(
i=0;
i<imax;
i++)
274 p1[offset11] = p2[offset21];
275 p1[offset12] = p2[offset22];
276 p1[offset13] = p2[offset23];
280 for(
i=0;
i<vdst.GetLength()%4;
i++)
283 p1 += vdst.GetStep();
284 p2 += vsrc.GetStep();
295 void vmoveneg(raw_vector<T> vdst, const_raw_vector<T> vsrc)
298 if( vdst.GetStep()==1 && vsrc.GetStep()==1 )
303 T *p1 = vdst.GetData();
304 const T *p2 = vsrc.GetData();
305 int imax = vdst.GetLength()/2;
307 for(
i=0;
i<imax;
i++)
314 if(vdst.GetLength()%2 != 0)
323 int offset11 = vdst.GetStep(), offset12 = 2*offset11, offset13 = 3*offset11, offset14 = 4*offset11;
324 int offset21 = vsrc.GetStep(), offset22 = 2*offset21, offset23 = 3*offset21, offset24 = 4*offset21;
325 T *p1 = vdst.GetData();
326 const T *p2 = vsrc.GetData();
327 int imax = vdst.GetLength()/4;
329 for(
i=imax;
i!=0;
i--)
332 p1[offset11] = -p2[offset21];
333 p1[offset12] = -p2[offset22];
334 p1[offset13] = -p2[offset23];
338 for(
i=0;
i<vdst.GetLength()%4;
i++)
341 p1 += vdst.GetStep();
342 p2 += vsrc.GetStep();
352 template<
class T,
class T2>
353 void vmove(raw_vector<T> vdst, const_raw_vector<T> vsrc,
T2 alpha)
356 if( vdst.GetStep()==1 && vsrc.GetStep()==1 )
361 T *p1 = vdst.GetData();
362 const T *p2 = vsrc.GetData();
363 int imax = vdst.GetLength()/4;
365 for(
i=imax;
i!=0;
i--)
374 for(
i=0;
i<vdst.GetLength()%4;
i++)
375 *(p1++) =
alpha*(*(p2++));
383 int offset11 = vdst.GetStep(), offset12 = 2*offset11, offset13 = 3*offset11, offset14 = 4*offset11;
384 int offset21 = vsrc.GetStep(), offset22 = 2*offset21, offset23 = 3*offset21, offset24 = 4*offset21;
385 T *p1 = vdst.GetData();
386 const T *p2 = vsrc.GetData();
387 int imax = vdst.GetLength()/4;
389 for(
i=0;
i<imax;
i++)
392 p1[offset11] =
alpha*p2[offset21];
393 p1[offset12] =
alpha*p2[offset22];
394 p1[offset13] =
alpha*p2[offset23];
398 for(
i=0;
i<vdst.GetLength()%4;
i++)
401 p1 += vdst.GetStep();
402 p2 += vsrc.GetStep();
413 void vadd(raw_vector<T> vdst, const_raw_vector<T> vsrc)
416 if( vdst.GetStep()==1 && vsrc.GetStep()==1 )
421 T *p1 = vdst.GetData();
422 const T *p2 = vsrc.GetData();
423 int imax = vdst.GetLength()/4;
425 for(
i=imax;
i!=0;
i--)
434 for(
i=0;
i<vdst.GetLength()%4;
i++)
443 int offset11 = vdst.GetStep(), offset12 = 2*offset11, offset13 = 3*offset11, offset14 = 4*offset11;
444 int offset21 = vsrc.GetStep(), offset22 = 2*offset21, offset23 = 3*offset21, offset24 = 4*offset21;
445 T *p1 = vdst.GetData();
446 const T *p2 = vsrc.GetData();
447 int imax = vdst.GetLength()/4;
449 for(
i=0;
i<imax;
i++)
452 p1[offset11] += p2[offset21];
453 p1[offset12] += p2[offset22];
454 p1[offset13] += p2[offset23];
458 for(
i=0;
i<vdst.GetLength()%4;
i++)
461 p1 += vdst.GetStep();
462 p2 += vsrc.GetStep();
472 template<
class T,
class T2>
473 void vadd(raw_vector<T> vdst, const_raw_vector<T> vsrc,
T2 alpha)
476 if( vdst.GetStep()==1 && vsrc.GetStep()==1 )
481 T *p1 = vdst.GetData();
482 const T *p2 = vsrc.GetData();
483 int imax = vdst.GetLength()/4;
485 for(
i=imax;
i!=0;
i--)
488 p1[1] +=
alpha*p2[1];
489 p1[2] +=
alpha*p2[2];
490 p1[3] +=
alpha*p2[3];
494 for(
i=0;
i<vdst.GetLength()%4;
i++)
495 *(p1++) +=
alpha*(*(p2++));
503 int offset11 = vdst.GetStep(), offset12 = 2*offset11, offset13 = 3*offset11, offset14 = 4*offset11;
504 int offset21 = vsrc.GetStep(), offset22 = 2*offset21, offset23 = 3*offset21, offset24 = 4*offset21;
505 T *p1 = vdst.GetData();
506 const T *p2 = vsrc.GetData();
507 int imax = vdst.GetLength()/4;
509 for(
i=0;
i<imax;
i++)
512 p1[offset11] +=
alpha*p2[offset21];
513 p1[offset12] +=
alpha*p2[offset22];
514 p1[offset13] +=
alpha*p2[offset23];
518 for(
i=0;
i<vdst.GetLength()%4;
i++)
521 p1 += vdst.GetStep();
522 p2 += vsrc.GetStep();
533 void vsub(raw_vector<T> vdst, const_raw_vector<T> vsrc)
536 if( vdst.GetStep()==1 && vsrc.GetStep()==1 )
541 T *p1 = vdst.GetData();
542 const T *p2 = vsrc.GetData();
543 int imax = vdst.GetLength()/4;
545 for(
i=imax;
i!=0;
i--)
554 for(
i=0;
i<vdst.GetLength()%4;
i++)
563 int offset11 = vdst.GetStep(), offset12 = 2*offset11, offset13 = 3*offset11, offset14 = 4*offset11;
564 int offset21 = vsrc.GetStep(), offset22 = 2*offset21, offset23 = 3*offset21, offset24 = 4*offset21;
565 T *p1 = vdst.GetData();
566 const T *p2 = vsrc.GetData();
567 int imax = vdst.GetLength()/4;
569 for(
i=0;
i<imax;
i++)
572 p1[offset11] -= p2[offset21];
573 p1[offset12] -= p2[offset22];
574 p1[offset13] -= p2[offset23];
578 for(
i=0;
i<vdst.GetLength()%4;
i++)
581 p1 += vdst.GetStep();
582 p2 += vsrc.GetStep();
592 template<
class T,
class T2>
593 void vsub(raw_vector<T> vdst, const_raw_vector<T> vsrc,
T2 alpha)
602 template<
class T,
class T2>
613 for(
i=imax;
i!=0;
i--)
630 int offset11 = vdst.
GetStep(), offset12 = 2*offset11, offset13 = 3*offset11, offset14 = 4*offset11;
634 for(
i=0;
i<imax;
i++)
637 p1[offset11] *=
alpha;
638 p1[offset12] *=
alpha;
639 p1[offset13] *=
alpha;
656 class template_1d_array
679 #ifndef UNSAFE_MEM_COPY
704 #ifndef UNSAFE_MEM_COPY
746 void setcontent(
int iLow,
int iHigh,
const T *pContent )
749 for(
int i=iLow;
i<=iHigh;
i++)
750 (*
this)(
i) = pContent[
i-iLow];
833 #ifndef UNSAFE_MEM_COPY
860 #ifndef UNSAFE_MEM_COPY
890 void setbounds(
int iLow1,
int iHigh1,
int iLow2,
int iHigh2 )
894 m_iVecSize = (iHigh1-iLow1+1)*(iHigh2-iLow2+1);
904 void setcontent(
int iLow1,
int iHigh1,
int iLow2,
int iHigh2,
const T *pContent )
944 return raw_vector<T>(&((*
this)(iRow, iColumnStart)), iColumnEnd-iColumnStart+1, 1);
998 double sqr(
double x);
999 int maxint(
int m1,
int m2);
1000 int minint(
int m1,
int m2);
1001 double maxreal(
double m1,
double m2);
1002 double minreal(
double m1,
double m2);