working on hash(), also for tensor

This commit is contained in:
jiri committed 2026-11-26 20:35:58 +01:00
1 parent 8b2b413db7
commit ed96821e0a
9 files changed
+126 -1

No files matched your search

+1
View File
@@ -318,6 +318,7 @@ indexing, which is the same as the matrix convention above for \code{x} built by
\begin{lareference}
\lafunc{void put(int fd, bool with_names=false) const; void get(int fd, bool with_names=false)}{binary I/O of shape, auxiliary arrays, data and optionally names (section~\ref{sec:concepts:io}); with \code{with_names} the names are always written (an empty list if the tensor has none), so \code{put} and \code{get} must use the same \code{with_names}.}
\lafunc{uint64\_t hash(uint64\_t h=LA\_HASH\_INIT, bool with\_names=false) const; const typename LA\_traits<T>::scalartype checksum(const uint64\_t seed=0) const}{Hash of the exact contents and numerical checksum of the data (section~\ref{sec:concepts:io}). The shape (number of indices, symmetry, offset and range of every index group) enters both, so that tensors with the same data and different shapes differ; the names of the indices enter the hash only with \code{with\_names} and never the checksum. \code{uint64\_t shapehash(uint64\_t h) const} is the part which depends on the shape.}
\lafunc{template<typename T> std::ostream & operator<<(std::ostream &s, const Tensor<T> &x)}{text output: the shape, the names, then one line per stored element with its flat indices and value.}
\lafunc{template<typename T> std::istream & operator>>(std::istream &s, Tensor<T> &x)}{reads the format written by \code{<<}.}
\lafunc{std::ostream & operator<<(std::ostream &s, const INDEXGROUP &x); std::istream & operator>>(std::istream &s, INDEXGROUP &x)}{\code{number symmetry offset range}.}