*** empty log message ***
This commit is contained in:
		
							parent
							
								
									d7b55e9846
								
							
						
					
					
						commit
						4bdb1ffa00
					
				
							
								
								
									
										99
									
								
								mat.cc
									
									
									
									
									
								
							
							
						
						
									
										99
									
								
								mat.cc
									
									
									
									
									
								
							@ -6,6 +6,8 @@
 | 
				
			|||||||
//// forced instantization in the corresponding object file
 | 
					//// forced instantization in the corresponding object file
 | 
				
			||||||
template NRMat<double>;
 | 
					template NRMat<double>;
 | 
				
			||||||
template NRMat< complex<double> >;
 | 
					template NRMat< complex<double> >;
 | 
				
			||||||
 | 
					template NRMat<int>;
 | 
				
			||||||
 | 
					template NRMat<char>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
@ -376,6 +378,21 @@ NRMat< complex<double> >::operator*=(const complex<double> &a)
 | 
				
			|||||||
	return *this;
 | 
						return *this;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//and for general type
 | 
				
			||||||
 | 
					template <typename T>
 | 
				
			||||||
 | 
					NRMat<T> & NRMat<T>::operator*=(const T &a)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					        copyonwrite();
 | 
				
			||||||
 | 
					#ifdef MATPTR
 | 
				
			||||||
 | 
					         for (int i=0; i< nn*nn; i++) v[0][i] *= a;
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					         for (int i=0; i< nn*nn; i++) v[i] *= a;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					        return *this;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Mat += Mat
 | 
					// Mat += Mat
 | 
				
			||||||
NRMat<double> & NRMat<double>::operator+=(const NRMat<double>  &rhs)
 | 
					NRMat<double> & NRMat<double>::operator+=(const NRMat<double>  &rhs)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -399,6 +416,24 @@ NRMat< complex<double> >::operator+=(const NRMat< complex<double> >  &rhs)
 | 
				
			|||||||
	 return *this;
 | 
						 return *this;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//and for general type
 | 
				
			||||||
 | 
					template <typename T>
 | 
				
			||||||
 | 
					NRMat<T> & NRMat<T>::operator+=(const NRMat<T>  &rhs)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					#ifdef DEBUG
 | 
				
			||||||
 | 
					        if (nn != rhs.nn || mm!= rhs.mm)
 | 
				
			||||||
 | 
					                laerror("Mat -= Mat of incompatible matrices");
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					        copyonwrite();
 | 
				
			||||||
 | 
					#ifdef MATPTR
 | 
				
			||||||
 | 
					         for (int i=0; i< nn*nn; i++) v[0][i] += rhs.v[0][i] ;
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					         for (int i=0; i< nn*nn; i++) v[i] += rhs.v[i] ;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					        return *this;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Mat -= Mat
 | 
					// Mat -= Mat
 | 
				
			||||||
NRMat<double> & NRMat<double>::operator-=(const NRMat<double>  &rhs)
 | 
					NRMat<double> & NRMat<double>::operator-=(const NRMat<double>  &rhs)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -422,6 +457,24 @@ NRMat< complex<double> >::operator-=(const NRMat< complex<double> >  &rhs)
 | 
				
			|||||||
	 return *this;
 | 
						 return *this;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//and for general type
 | 
				
			||||||
 | 
					template <typename T>
 | 
				
			||||||
 | 
					NRMat<T> & NRMat<T>::operator-=(const NRMat<T>  &rhs)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					#ifdef DEBUG
 | 
				
			||||||
 | 
					        if (nn != rhs.nn || mm!= rhs.mm)
 | 
				
			||||||
 | 
					                laerror("Mat -= Mat of incompatible matrices");
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					        copyonwrite();
 | 
				
			||||||
 | 
					#ifdef MATPTR
 | 
				
			||||||
 | 
					         for (int i=0; i< nn*nn; i++) v[0][i] -= rhs.v[0][i] ;
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					         for (int i=0; i< nn*nn; i++) v[i] -= rhs.v[i] ;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					        return *this;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Mat += SMat
 | 
					// Mat += SMat
 | 
				
			||||||
NRMat<double> & NRMat<double>::operator+=(const NRSMat<double> &rhs)
 | 
					NRMat<double> & NRMat<double>::operator+=(const NRSMat<double> &rhs)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -461,6 +514,28 @@ NRMat< complex<double> >::operator+=(const NRSMat< complex<double> > &rhs)
 | 
				
			|||||||
	return *this;
 | 
						return *this;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//and for general type
 | 
				
			||||||
 | 
					template <typename T>
 | 
				
			||||||
 | 
					NRMat<T> & NRMat<T>::operator+=(const NRSMat<T> &rhs)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					#ifdef DEBUG
 | 
				
			||||||
 | 
					        if (nn!=mm || nn!=rhs.nrows()) laerror("incompatible matrix size in Mat+=SMat");
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					        const T *p = rhs;
 | 
				
			||||||
 | 
					        copyonwrite();
 | 
				
			||||||
 | 
					        for (int i=0; i<nn; i++) {
 | 
				
			||||||
 | 
							for(int j=0; j<i+1; ++j) *((*this)[i]+j) += p[j];
 | 
				
			||||||
 | 
					                p += i+1;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        p = rhs; p++;
 | 
				
			||||||
 | 
					        for (int i=1; i<nn; i++) {
 | 
				
			||||||
 | 
							for(int j=0; j<i; ++j) *((*this)[i]+i+nn*j) += p[j];
 | 
				
			||||||
 | 
					                p += i+1;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return *this;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Mat -= SMat
 | 
					// Mat -= SMat
 | 
				
			||||||
NRMat<double> & NRMat<double>::operator-=(const NRSMat<double> &rhs)
 | 
					NRMat<double> & NRMat<double>::operator-=(const NRSMat<double> &rhs)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -500,6 +575,28 @@ NRMat< complex<double> >::operator-=(const NRSMat< complex<double> > &rhs)
 | 
				
			|||||||
	return *this;
 | 
						return *this;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//and for general type
 | 
				
			||||||
 | 
					template <typename T>
 | 
				
			||||||
 | 
					NRMat<T> & NRMat<T>::operator-=(const NRSMat<T> &rhs)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					#ifdef DEBUG
 | 
				
			||||||
 | 
					        if (nn!=mm || nn!=rhs.nrows()) laerror("incompatible matrix size in Mat+=SMat");
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					        const T *p = rhs;
 | 
				
			||||||
 | 
					        copyonwrite();
 | 
				
			||||||
 | 
					        for (int i=0; i<nn; i++) {
 | 
				
			||||||
 | 
							for(int j=0; j<i+1; ++j) *((*this)[i]+j) -= p[j];
 | 
				
			||||||
 | 
					                p += i+1;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        p = rhs; p++;
 | 
				
			||||||
 | 
					        for (int i=1; i<nn; i++) {
 | 
				
			||||||
 | 
							for(int j=0; j<i; ++j) *((*this)[i]+i+nn*j) -= p[j];
 | 
				
			||||||
 | 
					                p += i+1;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return *this;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Mat.Mat - scalar product
 | 
					// Mat.Mat - scalar product
 | 
				
			||||||
const double NRMat<double>::dot(const NRMat<double> &rhs) const
 | 
					const double NRMat<double>::dot(const NRMat<double> &rhs) const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -801,6 +898,8 @@ template istream & operator>>(istream  &s, NRMat< T > &x); \
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
INSTANTIZE(double)
 | 
					INSTANTIZE(double)
 | 
				
			||||||
INSTANTIZE(complex<double>)
 | 
					INSTANTIZE(complex<double>)
 | 
				
			||||||
 | 
					INSTANTIZE(int)
 | 
				
			||||||
 | 
					INSTANTIZE(char)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export template <class T>
 | 
					export template <class T>
 | 
				
			||||||
 | 
				
			|||||||
@ -15,6 +15,8 @@ template void lawritemat(FILE *file,const T *a,int r,int c,const char *form0, \
 | 
				
			|||||||
		int nodim,int modulo, int issym);
 | 
							int nodim,int modulo, int issym);
 | 
				
			||||||
INSTANTIZE(double)
 | 
					INSTANTIZE(double)
 | 
				
			||||||
INSTANTIZE(complex<double>)
 | 
					INSTANTIZE(complex<double>)
 | 
				
			||||||
 | 
					INSTANTIZE(int)
 | 
				
			||||||
 | 
					INSTANTIZE(char)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
template <typename T>
 | 
					template <typename T>
 | 
				
			||||||
void lawritemat(FILE *file,const T *a,int r,int c,const char *form0,
 | 
					void lawritemat(FILE *file,const T *a,int r,int c,const char *form0,
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										20
									
								
								smat.cc
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								smat.cc
									
									
									
									
									
								
							@ -7,6 +7,8 @@
 | 
				
			|||||||
////// forced instantization in the corresponding object file
 | 
					////// forced instantization in the corresponding object file
 | 
				
			||||||
template NRSMat<double>;
 | 
					template NRSMat<double>;
 | 
				
			||||||
template NRSMat< complex<double> >;
 | 
					template NRSMat< complex<double> >;
 | 
				
			||||||
 | 
					template NRSMat<int>;
 | 
				
			||||||
 | 
					template NRSMat<char>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -27,7 +29,7 @@ NRSMat<T>::NRSMat(const NRMat<T> &rhs)
 | 
				
			|||||||
	v = new T[NN2];
 | 
						v = new T[NN2];
 | 
				
			||||||
	int i, j, k=0;
 | 
						int i, j, k=0;
 | 
				
			||||||
	for (i=0; i<nn; i++)
 | 
						for (i=0; i<nn; i++)
 | 
				
			||||||
		for (j=0; j<=i;j++) v[k++] = 0.5 * (rhs[i][j] + rhs[j][i]);
 | 
							for (j=0; j<=i;j++) v[k++] = (rhs[i][j] + rhs[j][i])/((T)2);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -387,6 +389,20 @@ istream& operator>>(istream  &s, NRSMat<T> &x)
 | 
				
			|||||||
                return s;
 | 
					                return s;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//not implemented yet
 | 
				
			||||||
 | 
					const NRVec<int> NRSMat<int>::operator*(NRVec<int> const&rhs) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					laerror("NRSMat<int>::operator*(NRVec<int> const&) not implemented yet");
 | 
				
			||||||
 | 
					return rhs;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const NRVec<char> NRSMat<char>::operator*(NRVec<char> const&rhs) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					laerror("NRSMat<char>::operator*(NRVec<char> const&) not implemented yet");
 | 
				
			||||||
 | 
					return rhs;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//////////////////////////////////////////////////////////////////////////////
 | 
					//////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
//// forced instantization in the corespoding object file
 | 
					//// forced instantization in the corespoding object file
 | 
				
			||||||
@ -396,4 +412,6 @@ template istream & operator>>(istream  &s, NRSMat< T > &x); \
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
INSTANTIZE(double)
 | 
					INSTANTIZE(double)
 | 
				
			||||||
INSTANTIZE(complex<double>)
 | 
					INSTANTIZE(complex<double>)
 | 
				
			||||||
 | 
					INSTANTIZE(int)
 | 
				
			||||||
 | 
					INSTANTIZE(char)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										34
									
								
								smat.h
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								smat.h
									
									
									
									
									
								
							@ -120,9 +120,17 @@ inline NRSMat< complex<double> > &
 | 
				
			|||||||
NRSMat< complex<double> >::operator*=(const complex<double> & a)
 | 
					NRSMat< complex<double> >::operator*=(const complex<double> & a)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	copyonwrite();
 | 
						copyonwrite();
 | 
				
			||||||
	cblas_zscal(nn, (void *)(&a), (void *)v, 1);
 | 
						cblas_zscal(NN2, (void *)(&a), (void *)v, 1);
 | 
				
			||||||
	return *this;
 | 
						return *this;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					template <typename T>
 | 
				
			||||||
 | 
					inline NRSMat<T> & NRSMat<T>::operator*=(const T & a)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					        copyonwrite();
 | 
				
			||||||
 | 
						for(int i=0; i<NN2; ++i) v[i]*=a;
 | 
				
			||||||
 | 
					        return *this;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// S += D
 | 
					// S += D
 | 
				
			||||||
@ -165,6 +173,18 @@ NRSMat< complex<double> >::operator+=(const NRSMat< complex<double> > & rhs)
 | 
				
			|||||||
	return *this;
 | 
						return *this;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					template <typename T>
 | 
				
			||||||
 | 
					inline NRSMat<T> & NRSMat<T>::operator+=(const NRSMat<T> & rhs)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					#ifdef DEBUG
 | 
				
			||||||
 | 
					        if (nn != rhs.nn) laerror("incompatible SMats in SMat::operator+=");
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					        copyonwrite();
 | 
				
			||||||
 | 
						for(int i=0; i<NN2; ++i) v[i] += rhs.v[i];
 | 
				
			||||||
 | 
					        return *this;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// S -= S
 | 
					// S -= S
 | 
				
			||||||
inline NRSMat<double> &
 | 
					inline NRSMat<double> &
 | 
				
			||||||
NRSMat<double>::operator-=(const NRSMat<double> & rhs)
 | 
					NRSMat<double>::operator-=(const NRSMat<double> & rhs)
 | 
				
			||||||
@ -187,6 +207,18 @@ NRSMat< complex<double> >::operator-=(const NRSMat< complex<double> > & rhs)
 | 
				
			|||||||
	return *this;
 | 
						return *this;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					template <typename T>
 | 
				
			||||||
 | 
					inline NRSMat<T> & NRSMat<T>::operator-=(const NRSMat<T> & rhs)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					#ifdef DEBUG
 | 
				
			||||||
 | 
					        if (nn != rhs.nn) laerror("incompatible SMats in SMat::operator-=");
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					        copyonwrite();
 | 
				
			||||||
 | 
					        for(int i=0; i<NN2; ++i) v[i] -= rhs.v[i];
 | 
				
			||||||
 | 
					        return *this;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// SMat + Mat
 | 
					// SMat + Mat
 | 
				
			||||||
template <typename T>
 | 
					template <typename T>
 | 
				
			||||||
inline const NRMat<T> NRSMat<T>::operator+(const NRMat<T> &rhs) const
 | 
					inline const NRMat<T> NRSMat<T>::operator+(const NRMat<T> &rhs) const
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										10
									
								
								vec.cc
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								vec.cc
									
									
									
									
									
								
							@ -9,8 +9,12 @@ template istream & operator>>(istream  &s, NRVec< T > &x); \
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
INSTANTIZE(double)
 | 
					INSTANTIZE(double)
 | 
				
			||||||
INSTANTIZE(complex<double>)
 | 
					INSTANTIZE(complex<double>)
 | 
				
			||||||
 | 
					INSTANTIZE(int)
 | 
				
			||||||
 | 
					INSTANTIZE(char)
 | 
				
			||||||
template NRVec<double>;
 | 
					template NRVec<double>;
 | 
				
			||||||
template NRVec< complex<double> >;
 | 
					template NRVec< complex<double> >;
 | 
				
			||||||
 | 
					template NRVec<int>;
 | 
				
			||||||
 | 
					template NRVec<char>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
@ -281,6 +285,12 @@ NRVec< complex<double> > & NRVec< complex<double> >::normalize()
 | 
				
			|||||||
	return *this;
 | 
						return *this;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//and for these types it does not make sense to normalize but we have them for linkage
 | 
				
			||||||
 | 
					NRVec<int> &  NRVec<int>::normalize() {laerror("normalize() impossible for integer types"); return *this;}
 | 
				
			||||||
 | 
					NRVec<char> &  NRVec<char>::normalize() {laerror("normalize() impossible for integer types"); return *this;}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// gemv call 
 | 
					// gemv call 
 | 
				
			||||||
void NRVec<double>::gemv(const double beta, const NRMat<double> &A, 
 | 
					void NRVec<double>::gemv(const double beta, const NRMat<double> &A, 
 | 
				
			||||||
		const char trans, const double alpha, const NRVec &x)
 | 
							const char trans, const double alpha, const NRVec &x)
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										62
									
								
								vec.h
									
									
									
									
									
								
							
							
						
						
									
										62
									
								
								vec.h
									
									
									
									
									
								
							@ -160,6 +160,7 @@ inline NRVec<double> & NRVec<double>::operator+=(const double &a)
 | 
				
			|||||||
	cblas_daxpy(nn, 1.0, &a, 0, v, 1);
 | 
						cblas_daxpy(nn, 1.0, &a, 0, v, 1);
 | 
				
			||||||
	return *this;
 | 
						return *this;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
inline NRVec< complex<double> > &
 | 
					inline NRVec< complex<double> > &
 | 
				
			||||||
NRVec< complex<double> >::operator+=(const complex<double> &a)
 | 
					NRVec< complex<double> >::operator+=(const complex<double> &a)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -168,6 +169,17 @@ NRVec< complex<double> >::operator+=(const complex<double> &a)
 | 
				
			|||||||
	return *this;
 | 
						return *this;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//and for general type
 | 
				
			||||||
 | 
					template <typename T>
 | 
				
			||||||
 | 
					inline NRVec<T> & NRVec<T>::operator+=(const T &a)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					        copyonwrite();
 | 
				
			||||||
 | 
						int i;
 | 
				
			||||||
 | 
						for(i=0; i<nn; ++i) v[i]+=a;
 | 
				
			||||||
 | 
					        return *this;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// x -= a
 | 
					// x -= a
 | 
				
			||||||
inline NRVec<double> & NRVec<double>::operator-=(const double &a)
 | 
					inline NRVec<double> & NRVec<double>::operator-=(const double &a)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -183,6 +195,17 @@ NRVec< complex<double> >::operator-=(const complex<double> &a)
 | 
				
			|||||||
	return *this;
 | 
						return *this;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//and for general type
 | 
				
			||||||
 | 
					template <typename T>
 | 
				
			||||||
 | 
					inline NRVec<T> & NRVec<T>::operator-=(const T &a)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					        copyonwrite();
 | 
				
			||||||
 | 
					        int i;
 | 
				
			||||||
 | 
					        for(i=0; i<nn; ++i) v[i]-=a;
 | 
				
			||||||
 | 
					        return *this;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// x += x
 | 
					// x += x
 | 
				
			||||||
inline NRVec<double> & NRVec<double>::operator+=(const NRVec<double> &rhs)
 | 
					inline NRVec<double> & NRVec<double>::operator+=(const NRVec<double> &rhs)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -204,6 +227,20 @@ NRVec< complex<double> >::operator+=(const NRVec< complex<double> > &rhs)
 | 
				
			|||||||
	return *this;
 | 
						return *this;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//and for general type
 | 
				
			||||||
 | 
					template <typename T>
 | 
				
			||||||
 | 
					inline NRVec<T> & NRVec<T>::operator+=(const NRVec<T> &rhs)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					#ifdef DEBUG
 | 
				
			||||||
 | 
					        if (nn != rhs.nn) laerror("daxpy of incompatible vectors");
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					        copyonwrite();
 | 
				
			||||||
 | 
						int i;
 | 
				
			||||||
 | 
						for(i=0; i<nn; ++i) v[i]+=rhs.v[i];
 | 
				
			||||||
 | 
					        return *this;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// x -= x
 | 
					// x -= x
 | 
				
			||||||
inline NRVec<double> & NRVec<double>::operator-=(const NRVec<double> &rhs)
 | 
					inline NRVec<double> & NRVec<double>::operator-=(const NRVec<double> &rhs)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -225,6 +262,20 @@ NRVec< complex<double> >::operator-=(const NRVec< complex<double> > &rhs)
 | 
				
			|||||||
	return *this;
 | 
						return *this;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//and for general type
 | 
				
			||||||
 | 
					template <typename T>
 | 
				
			||||||
 | 
					inline NRVec<T> & NRVec<T>::operator-=(const NRVec<T> &rhs)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					#ifdef DEBUG
 | 
				
			||||||
 | 
					        if (nn != rhs.nn) laerror("daxpy of incompatible vectors");
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					        copyonwrite();
 | 
				
			||||||
 | 
					        int i;
 | 
				
			||||||
 | 
					        for(i=0; i<nn; ++i) v[i]-=rhs.v[i];
 | 
				
			||||||
 | 
					        return *this;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// x *= a
 | 
					// x *= a
 | 
				
			||||||
inline NRVec<double> & NRVec<double>::operator*=(const double &a)
 | 
					inline NRVec<double> & NRVec<double>::operator*=(const double &a)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -240,6 +291,17 @@ NRVec< complex<double> >::operator*=(const complex<double> &a)
 | 
				
			|||||||
	return *this;
 | 
						return *this;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//and for general type
 | 
				
			||||||
 | 
					template <typename T>
 | 
				
			||||||
 | 
					inline NRVec<T> & NRVec<T>::operator*=(const T &a)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					        copyonwrite();
 | 
				
			||||||
 | 
					        int i;
 | 
				
			||||||
 | 
					        for(i=0; i<nn; ++i) v[i]*=a;
 | 
				
			||||||
 | 
					        return *this;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// scalar product x.y
 | 
					// scalar product x.y
 | 
				
			||||||
inline const double NRVec<double>::operator*(const NRVec<double> &rhs) const
 | 
					inline const double NRVec<double>::operator*(const NRVec<double> &rhs) const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user