Cyclops Tensor Framework
parallel arithmetic on multidimensional arrays
CTF::Sparse_Tensor< dtype > Class Template Reference

a sparse subset of a tensor More...

#include <sparse_tensor.h>

Public Member Functions

 Sparse_Tensor ()
 base constructor More...
 
 Sparse_Tensor (std::vector< int64_t > indices, Tensor< dtype > *parent)
 initialize a tensor which corresponds to a set of indices More...
 
 Sparse_Tensor (int64_t n, int64_t *indices, Tensor< dtype > *parent)
 initialize a tensor which corresponds to a set of indices More...
 
void write (dtype alpha, dtype *values, dtype beta)
 set the sparse set of indices on the parent tensor to values forall(j) i = indices[j]; parent[i] = beta*parent[i] + alpha*values[j]; More...
 
void operator= (std::vector< dtype > values)
 
void operator+= (std::vector< dtype > values)
 
void operator-= (std::vector< dtype > values)
 
void operator= (dtype *values)
 
void operator+= (dtype *values)
 
void operator-= (dtype *values)
 
void read (dtype alpha, dtype *values, dtype beta)
 read the sparse set of indices on the parent tensor to values forall(j) i = indices[j]; values[j] = alpha*parent[i] + beta*values[j]; More...
 
 operator std::vector< dtype > ()
 
 operator dtype * ()
 

Data Fields

Tensor< dtype > * parent
 dense tensor whose subset this sparse tensor is of More...
 
std::vector< int64_t > indices
 indices of the sparse elements of this tensor More...
 
dtype scale
 scaling factor by which to scale the tensor elements More...
 

Detailed Description

template<typename dtype = double>
class CTF::Sparse_Tensor< dtype >

a sparse subset of a tensor

Definition at line 14 of file sparse_tensor.h.

Constructor & Destructor Documentation

template<typename dtype >
CTF::Sparse_Tensor< dtype >::Sparse_Tensor ( )

base constructor

Definition at line 8 of file sparse_tensor.cxx.

template<typename dtype >
CTF::Sparse_Tensor< dtype >::Sparse_Tensor ( std::vector< int64_t >  indices,
Tensor< dtype > *  parent 
)

initialize a tensor which corresponds to a set of indices

Parameters
[in]indicesa vector of global indices to tensor values
[in]parentdense distributed tensor to which this sparse tensor belongs to

Definition at line 13 of file sparse_tensor.cxx.

References ctf.core::dtype, ctf.core::scale(), and CTF_int::tensor::sr.

template<typename dtype >
CTF::Sparse_Tensor< dtype >::Sparse_Tensor ( int64_t  n,
int64_t *  indices,
Tensor< dtype > *  parent 
)

initialize a tensor which corresponds to a set of indices

Parameters
[in]nnumber of values this sparse tensor will have locally
[in]indicesan array of global indices to tensor values
[in]parentdense distributed tensor to which this sparse tensor belongs to

Definition at line 21 of file sparse_tensor.cxx.

References ctf.core::dtype, ctf.core::scale(), and CTF_int::tensor::sr.

Member Function Documentation

template<typename dtype >
CTF::Sparse_Tensor< dtype >::operator dtype * ( )

Definition at line 80 of file sparse_tensor.cxx.

References ctf.core::dtype.

template<typename dtype >
CTF::Sparse_Tensor< dtype >::operator std::vector< dtype > ( )

Definition at line 73 of file sparse_tensor.cxx.

template<typename dtype >
void CTF::Sparse_Tensor< dtype >::operator+= ( std::vector< dtype >  values)

Definition at line 47 of file sparse_tensor.cxx.

References ctf.core::dtype.

template<typename dtype >
void CTF::Sparse_Tensor< dtype >::operator+= ( dtype *  values)

Definition at line 52 of file sparse_tensor.cxx.

References ctf.core::dtype.

template<typename dtype >
void CTF::Sparse_Tensor< dtype >::operator-= ( std::vector< dtype >  values)

Definition at line 57 of file sparse_tensor.cxx.

References ctf.core::dtype.

template<typename dtype >
void CTF::Sparse_Tensor< dtype >::operator-= ( dtype *  values)

Definition at line 62 of file sparse_tensor.cxx.

References ctf.core::dtype.

template<typename dtype >
void CTF::Sparse_Tensor< dtype >::operator= ( std::vector< dtype >  values)

Definition at line 38 of file sparse_tensor.cxx.

References ctf.core::dtype.

template<typename dtype >
void CTF::Sparse_Tensor< dtype >::operator= ( dtype *  values)

Definition at line 42 of file sparse_tensor.cxx.

References ctf.core::dtype.

template<typename dtype >
void CTF::Sparse_Tensor< dtype >::read ( dtype  alpha,
dtype *  values,
dtype  beta 
)

read the sparse set of indices on the parent tensor to values forall(j) i = indices[j]; values[j] = alpha*parent[i] + beta*values[j];

Parameters
[in]alphascaling factor on parent array
[in]valuesdata, should be preallocated to the same size as the number of indices (n)
[in]betascaling factor to apply to previously existing data in values

Definition at line 67 of file sparse_tensor.cxx.

Referenced by ctf.core.tensor::__getitem__().

template<typename dtype >
void CTF::Sparse_Tensor< dtype >::write ( dtype  alpha,
dtype *  values,
dtype  beta 
)

set the sparse set of indices on the parent tensor to values forall(j) i = indices[j]; parent[i] = beta*parent[i] + alpha*values[j];

Parameters
[in]alphascaling factor on values array
[in]valuesdata, should be of same size as the number of indices (n)
[in]betascaling factor to apply to previously existing data

Definition at line 30 of file sparse_tensor.cxx.

Referenced by ctf.core.tensor::__setitem__(), and ctf.core.tensor::from_nparray().

Field Documentation

template<typename dtype = double>
std::vector<int64_t > CTF::Sparse_Tensor< dtype >::indices

indices of the sparse elements of this tensor

Definition at line 19 of file sparse_tensor.h.

template<typename dtype = double>
Tensor<dtype>* CTF::Sparse_Tensor< dtype >::parent

dense tensor whose subset this sparse tensor is of

Definition at line 17 of file sparse_tensor.h.

template<typename dtype = double>
dtype CTF::Sparse_Tensor< dtype >::scale

scaling factor by which to scale the tensor elements

Definition at line 21 of file sparse_tensor.h.


The documentation for this class was generated from the following files: