64 complex(
const double &_x,
const double &_y):
x(_x),
y(_y){};
67 complex& operator= (
const double&
v){
x =
v;
y = 0.0;
return *
this; };
82 if( fabs(z.
y)<fabs(z.
x) )
86 result.
x = (z.
x+z.
y*e)/f;
87 result.
y = (z.
y-z.
x*e)/f;
93 result.
x = (z.
y+z.
x*e)/f;
94 result.
y = (-z.
x+z.
y*e)/f;
140 pData(const_cast<
T*>(Data)),iLength(Length),iStep(Step){};
194 for(i=imax; i!=0; i--)
196 r += (*p1)*(*p2) + p1[1]*p2[1] + p1[2]*p2[2] + p1[3]*p2[3];
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;
216 for(i=0; i<imax; i++)
218 r += (*p1)*(*p2) + p1[offset11]*p2[offset21] + p1[offset12]*p2[offset22] + p1[offset13]*p2[offset23];
249 for(i=imax; i!=0; i--)
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;
271 for(i=0; i<imax; i++)
274 p1[offset11] = p2[offset21];
275 p1[offset12] = p2[offset22];
276 p1[offset13] = p2[offset23];
307 for(i=0; i<imax; i++)
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;
329 for(i=imax; i!=0; i--)
332 p1[offset11] = -p2[offset21];
333 p1[offset12] = -p2[offset22];
334 p1[offset13] = -p2[offset23];
352 template<
class T,
class T2>
365 for(i=imax; i!=0; 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;
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];
425 for(i=imax; i!=0; 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;
449 for(i=0; i<imax; i++)
452 p1[offset11] += p2[offset21];
453 p1[offset12] += p2[offset22];
454 p1[offset13] += p2[offset23];
472 template<
class T,
class T2>
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];
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;
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];
545 for(i=imax; i!=0; 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;
569 for(i=0; i<imax; i++)
572 p1[offset11] -= p2[offset21];
573 p1[offset12] -= p2[offset22];
574 p1[offset13] -= p2[offset23];
592 template<
class T,
class T2>
595 vadd(vdst, vsrc, -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;
678 m_Vec =
new T[m_iVecSize];
679 #ifndef UNSAFE_MEM_COPY 680 for(
int i=0;
i<m_iVecSize;
i++)
683 memcpy(m_Vec, rhs.
m_Vec, m_iVecSize*
sizeof(
T));
703 m_Vec =
new T[m_iVecSize];
704 #ifndef UNSAFE_MEM_COPY 705 for(
int i=0;
i<m_iVecSize;
i++)
708 memcpy(m_Vec, rhs.
m_Vec, m_iVecSize*
sizeof(
T));
722 return m_Vec[ i-m_iLow ];
731 return m_Vec[ i-m_iLow ];
741 m_iVecSize = iHigh-iLow+1;
742 m_Vec =
new T[m_iVecSize];
748 setbounds(iLow, iHigh);
749 for(
int i=iLow;
i<=iHigh;
i++)
750 (*
this)(
i) = pContent[
i-iLow];
778 if( iStart>iEnd || wrongIdx(iStart) || wrongIdx(iEnd) )
787 if( iStart>iEnd || wrongIdx(iStart) || wrongIdx(iEnd) )
793 bool wrongIdx(
int i)
const {
return i<m_iLow || i>m_iHigh; };
832 m_Vec =
new T[m_iVecSize];
833 #ifndef UNSAFE_MEM_COPY 834 for(
int i=0;
i<m_iVecSize;
i++)
837 memcpy(m_Vec, rhs.
m_Vec, m_iVecSize*
sizeof(
T));
859 m_Vec =
new T[m_iVecSize];
860 #ifndef UNSAFE_MEM_COPY 861 for(
int i=0;
i<m_iVecSize;
i++)
864 memcpy(m_Vec, rhs.
m_Vec, m_iVecSize*
sizeof(
T));
878 return m_Vec[ m_iConstOffset + i2 +i1*m_iLinearMember];
887 return m_Vec[ m_iConstOffset + i2 +i1*m_iLinearMember];
890 void setbounds(
int iLow1,
int iHigh1,
int iLow2,
int iHigh2 )
894 m_iVecSize = (iHigh1-iLow1+1)*(iHigh2-iLow2+1);
895 m_Vec =
new T[m_iVecSize];
900 m_iConstOffset = -m_iLow2-m_iLow1*(m_iHigh2-m_iLow2+1);
901 m_iLinearMember = (m_iHigh2-m_iLow2+1);
904 void setcontent(
int iLow1,
int iHigh1,
int iLow2,
int iHigh2,
const T *pContent )
906 setbounds(iLow1, iHigh1, iLow2, iHigh2);
907 for(
int i=0;
i<m_iVecSize;
i++)
908 m_Vec[
i]=pContent[
i];
923 return iBoundNum==1 ? m_iLow1 : m_iLow2;
928 return iBoundNum==1 ? m_iHigh1 : m_iHigh2;
933 if( (iRowStart>iRowEnd) || wrongColumn(iColumn) || wrongRow(iRowStart) ||wrongRow(iRowEnd) )
936 return raw_vector<T>(&((*this)(iRowStart, iColumn)), iRowEnd-iRowStart+1, m_iLinearMember);
939 raw_vector<T>
getrow(
int iRow,
int iColumnStart,
int iColumnEnd)
941 if( (iColumnStart>iColumnEnd) || wrongRow(iRow) || wrongColumn(iColumnStart) || wrongColumn(iColumnEnd))
942 return raw_vector<T>(0, 0, 1);
944 return raw_vector<T>(&((*this)(iRow, iColumnStart)), iColumnEnd-iColumnStart+1, 1);
949 if( (iRowStart>iRowEnd) || wrongColumn(iColumn) || w