SyTen
sparse.h File Reference

Implements SparseTensor and related functions. More...

#include <mutex>
#include <vector>
#include <boost/container/flat_map.hpp>
#include <boost/serialization/split_member.hpp>
#include "inc/util/boost_serialise_flat_map.h"
#include "inc/util/backtrace.h"
#include "inc/util/output.h"
#include "inc/util/closeness.h"
#include "inc/util/boost_versioning.h"
#include "inc/util/memory_size.h"
#include "inc/util/macros.h"
#include "inc/util/scalars.h"
#include "inc/util/toggle_enums.h"
+ Include dependency graph for sparse.h:
+ This graph shows which files directly or indirectly include this file:

Classes

struct  syten::SparseTensor< rank, Scalar >::FullData
 Struct holding the data for a full, non-singleton sparse tensors. More...
 
struct  syten::SparseCoordComparator< rank >
 Comparator for the flatmap used by the Sparse tensor to compare elements. More...
 
class  syten::SparseTensor< rank, Scalar >
 Sparse tensor of specified rank and scalar type. More...
 

Namespaces

namespace  syten
 Syten namespace.
 

Functions

template<Rank rank, typename Scalar >
ScalarBase< Scalar >::type syten::abs (SparseTensor< rank, Scalar > const &a)
 norm of a sparse tensor, i.e. the 2-norm were the tensor reshaped into a vector More...
 
template<Rank rank, typename Scalar , typename RetScalar = Scalar>
ScalarBase< RetScalar >::type syten::absSqd (SparseTensor< rank, Scalar > const &a)
 Squared norm of a sparse tensor, i.e. the squared 2-norm were the tensor reshaped into a vector. More...
 
template<Rank rank, typename Scalar >
std::pair< std::size_t, typename ScalarBase< Scalar >::type > syten::avgAbs (SparseTensor< rank, Scalar > const &a)
 Returns the sum of the absolute non-zero values and the total number of entries of the sparse tensor. More...
 
SparseTensor< rank-1, Scalar > ::type syten::dropDummy (SparseTensor< rank, Scalar > const &a, Rank position)
 Drops a one-dimensional dummy index at the specified position, i.e. for \( a \in [2, 3, 1] \), dropDummy(a, 3) = b` with \( b \in [2, 3] \). More...
 
template<Rank rank, typename Scalar , typename RetScalar = Scalar>
SparseTensor< rank, RetScalar > syten::elem_abs (SparseTensor< rank, Scalar > const &a)
 Returns a sparse tensor \( R \) such that for all \( i \), \( R_i = |a_i| \). More...
 
template<Rank rank, typename Scalar >
SparseTensor< rank+1, Scalar > syten::insertDummy (SparseTensor< rank, Scalar > const &a, Rank position)
 Inserts a 1-dimensional dummy index at the specified position, i.e. for \( a \in [2, 3, 4] \), insertDummy(a, 2) = b with \( b \in [2, 1, 3, 4] \). More...
 
template<typename Scalar >
void syten::invertDiagonal (SparseTensor< 2, Scalar > &a)
 Inverts the diagonal data.first of a square matrix in place, leaving zeros untouched. More...
 
template<Rank rank, typename Scalar >
std::tuple< ParallelKind, Scalar, Scalar > syten::isParallel (SparseTensor< rank, Scalar > const &a, SparseTensor< rank, Scalar > const &b)
 Checks if two tensors are parallel, i.e. \( a_i = c \; b_i \quad \forall i \). More...
 
template<typename Scalar >
void syten::makeIdentity (SparseTensor< 2, Scalar > &a)
 Makes a into a two-dimensional identity matrix. More...
 
template<Rank rank, typename Scalar >
ScalarBase< Scalar >::type syten::max (SparseTensor< rank, Scalar > const &a)
 Returns the element with the greatest magnitude in the sparse tensor. More...
 
template<Rank rank, typename Scalar >
ScalarBase< Scalar >::type syten::norm (SparseTensor< rank, Scalar > const &a)
 norm of a sparse tensor, i.e. the 2-norm were the tensor reshaped into a vector More...
 
template<Rank rank, typename Scalar , typename RetScalar = Scalar>
ScalarBase< RetScalar >::type syten::normSqd (SparseTensor< rank, Scalar > const &a)
 Squared norm of a sparse tensor, i.e. the squared 2-norm were the tensor reshaped into a vector. More...
 
template<Rank rank, typename Scalar >
std::ostreamsyten::operator<< (std::ostream &out, SparseTensor< rank, Scalar > const &t)
 Pretty output of sparse tensors. More...
 
template<Rank summed, Rank frank, typename Scalar >
std::enable_if< frank==summed, Scalar >::type syten::prodS (SparseTensor< frank, Scalar > const &a, SparseTensor< frank, Scalar > const &b, bool conjugate=true)
 Scalar product/full contraction of two sparse tensors, again see syten::prodD for a full discussion. More...
 
template<Rank summed, Rank frank, Rank srank, typename Scalar >
SparseTensor< frank+srank - 2 *summed, Scalar > syten::prodS (SparseTensor< frank, Scalar > const &a, SparseTensor< srank, Scalar > const &b, std::array< int, frank > const &c_a, std::array< int, srank > const &c_b, bool conjugate=false, bool calc_abs=true)
 Product of two sparse tensors, see syten::prodD for a detailed discussion of the arguments. More...
 
template<Rank r, typename Scalar >
Scalar syten::prodS (SparseTensor< r, Scalar > const &a, SparseTensor< r, Scalar > const &b, std::array< int, r > const &c_a, std::array< int, r > const &c_b, bool conjugate=false, bool=true)
 Complete product of two unordered sparse tensors. More...
 
template<typename Scalar >
Scalar syten::trace (SparseTensor< 2, Scalar > const &a)
 Trace of a sparse matrix. More...
 
bool syten::validateCGCContraction (SparseTensor< 2 > const &input)
 Returns true if input is proportional to the identity matrix. More...
 
template<Rank rank, typename Scalar >
bool syten::validateCGCTensor (SparseTensor< rank, Scalar > const &a)
 CGC tensors are supposed to give the identity whenever contracted with themselves over all but one leg. More...
 

Detailed Description

Implements SparseTensor and related functions.