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) || wrongRow(iRowStart) ||wrongRow(iRowEnd) )
952 return const_raw_vector<T>(&((*this)(iRowStart, iColumn)), iRowEnd-iRowStart+1, m_iLinearMember);
955 const_raw_vector<T>
getrow(
int iRow,
int iColumnStart,
int iColumnEnd)
const 957 if( (iColumnStart>iColumnEnd) || wrongRow(iRow) || wrongColumn(iColumnStart) || wrongColumn(iColumnEnd))
958 return const_raw_vector<T>(0, 0, 1);
960 return const_raw_vector<T>(&((*this)(iRow, iColumnStart)), iColumnEnd-iColumnStart+1, 1);
963 bool wrongRow(
int i)
const {
return i<m_iLow1 || i>m_iHigh1; };
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);
complex & operator+=(const double &v)
const CanonicalForm int const CFList const Variable & y
void setcontent(int iLow1, int iHigh1, int iLow2, int iHigh2, const T *pContent)
int getlowbound(int iBoundNum) const
template_1d_array(const template_1d_array &rhs)
void vmoveneg(raw_vector< T > vdst, const_raw_vector< T > vsrc)
double maxreal(double m1, double m2)
void vsub(raw_vector< T > vdst, const_raw_vector< T > vsrc)
template_2d_array< int > integer_2d_array
complex & operator*=(const complex &z)
template_1d_array< complex > complex_1d_array
const complex operator/(const complex &lhs, const complex &rhs)
const complex operator-(const complex &lhs)
void setbounds(int iLow1, int iHigh1, int iLow2, int iHigh2)
complex & operator+=(const complex &z)
const bool operator==(const complex &lhs, const complex &rhs)
const template_1d_array & operator=(const template_1d_array &rhs)
const double machineepsilon
template_1d_array< double > real_1d_array
static void make_assertion(bool bClause)
template_1d_array< int > integer_1d_array
int randominteger(int maxv)
const T * getcontent() const
template_1d_array< bool > boolean_1d_array
int gethighbound(int iBoundNum=0) const
complex(const double &_x)
const complex operator*(const complex &lhs, const complex &rhs)
template_2d_array< double > real_2d_array
template_2d_array< bool > boolean_2d_array
const T * getcontent() const
template_2d_array(const template_2d_array &rhs)
bool wrongIdx(int i) const
const T & operator()(int i1, int i2) const
const T * GetData() const
void vmul(raw_vector< T > vdst, T2 alpha)
void vadd(raw_vector< T > vdst, const_raw_vector< T > vsrc)
const template_2d_array & operator=(const template_2d_array &rhs)
raw_vector< T > getrow(int iRow, int iColumnStart, int iColumnEnd)
raw_vector< T > getcolumn(int iColumn, int iRowStart, int iRowEnd)
int minint(int m1, int m2)
double minreal(double m1, double m2)
bool wrongRow(int i) const
const double minrealnumber
const_raw_vector< T > getvector(int iStart, int iEnd) const
int maxint(int m1, int m2)
void setbounds(int iLow, int iHigh)
T vdotproduct(const_raw_vector< T > v1, const_raw_vector< T > v2)
raw_vector(T *Data, int Length, int Step)
const Variable & v
< [in] a sqrfree bivariate poly
template_2d_array< complex > complex_2d_array
complex & operator/=(const complex &z)
complex & operator-=(const complex &z)
complex(const double &_x, const double &_y)
const complex csqr(const complex &z)
const_raw_vector< T > getrow(int iRow, int iColumnStart, int iColumnEnd) const
bool wrongColumn(int j) const
const T & operator()(int i) const
int gethighbound(int iBoundNum) const
raw_vector< T > getvector(int iStart, int iEnd)
const double maxrealnumber
complex & operator/=(const double &v)
complex & operator-=(const double &v)
const double abscomplex(const complex &z)
complex(const complex &z)
const_raw_vector(const T *Data, int Length, int Step)
complex & operator*=(const double &v)
void setcontent(int iLow, int iHigh, const T *pContent)
const complex operator+(const complex &lhs)
const_raw_vector< T > getcolumn(int iColumn, int iRowStart, int iRowEnd) const
T & operator()(int i1, int i2)
const bool operator!=(const complex &lhs, const complex &rhs)
const complex conj(const complex &z)
void vmove(raw_vector< T > vdst, const_raw_vector< T > vsrc)
int getlowbound(int iBoundNum=0) const