initial implementation of hash and checksum
This commit is contained in:
1 parent
f028a2e0fc
commit
8b2b413db7
12 files changed
+228
No files matched your search
@@ -393,6 +393,25 @@ public:
|
||||
//! compute the sum of the vector elements
|
||||
const T sum() const;
|
||||
|
||||
//! hash of the dimension and of the exact binary contents, continuing from h (see miscfunc.h)
|
||||
uint64_t hash(uint64_t h=LA_HASH_INIT) const
|
||||
{
|
||||
NOT_GPU(*this);
|
||||
return LA_traits<T>::hash(v,nn,hash_mix(nn,h));
|
||||
}
|
||||
|
||||
//! numerical checksum: sum of the elements with pseudorandom weights given by the seed and the dimension (see miscfunc.h)
|
||||
//it is a template only in order not to require scalartype in the traits of every type of elements
|
||||
template<typename U=T>
|
||||
const typename LA_traits<U>::scalartype checksum(const uint64_t seed=0) const
|
||||
{
|
||||
NOT_GPU(*this);
|
||||
const uint64_t s=hash_mix(nn,seed);
|
||||
typename LA_traits<U>::scalartype r=0;
|
||||
for(int i=0; i<nn; ++i) r+=LA_traits<U>::checksum(v[i],hash_mix(i,s));
|
||||
return r;
|
||||
}
|
||||
|
||||
//! compute the sum of squares the vector elements
|
||||
inline const T sumsqr() const {
|
||||
if(nn==0) return (T)0;
|
||||
|
||||
Reference in new issue
Block a user