added tests for plain data in constructors of vec mat smat

This commit is contained in:
2021-10-28 20:17:32 +02:00
parent b50f9b36b1
commit d96531f340
5 changed files with 52 additions and 16 deletions

18
vec.cc
View File

@@ -443,7 +443,7 @@ NRVec<T>& NRVec<T>::operator=(const T &a){
NOT_GPU(*this);
copyonwrite();
if(a != (T)0){
if(!LA_traits<T>::is_plaindata() || a != (T)0){
for(register int i=0; i<nn; i++) v[i] = a;
}else{
memset(v, 0, nn*sizeof(T));
@@ -883,6 +883,22 @@ for(int cycle=1; cycle<=p.size(); ++cycle)
}
}
template<typename T>
const int NRVec<T>::find(const T &val) const
{
for(int i=0; i<nn; ++i) if(val==v[i]) return i;
return -1;
}
template<typename T>
const int NRVec<T>::findthr(const T &val, const typename LA_traits<T>::normtype &thr) const
{
for(int i=0; i<nn; ++i) if(MYABS(val-v[i])<thr) return i;
return -1;
}
/***************************************************************************//**
* forced instantization in the corespoding object file