Cyclops Tensor Framework
parallel arithmetic on multidimensional arrays
sparse_tensor.h
Go to the documentation of this file.
1 #ifndef __SPARSE_TENSOR_H__
2 #define __SPARSE_TENSOR_H__
3 
4 namespace CTF {
13  template<typename dtype=double>
14  class Sparse_Tensor {
15  public:
19  std::vector<int64_t > indices;
22 
26  Sparse_Tensor();
27 
33  Sparse_Tensor(std::vector<int64_t > indices,
34  Tensor<dtype> * parent);
35 
42  Sparse_Tensor(int64_t n,
43  int64_t * indices,
44  Tensor<dtype> * parent);
45 
53  void write(dtype alpha,
54  dtype * values,
55  dtype beta);
56 
57  // C++ overload special-cases of above method
58  void operator=(std::vector<dtype> values);
59  void operator+=(std::vector<dtype> values);
60  void operator-=(std::vector<dtype> values);
61  void operator=(dtype * values);
62  void operator+=(dtype * values);
63  void operator-=(dtype * values);
64 
72  void read(dtype alpha,
73  dtype * values,
74  dtype beta);
75 
76  // C++ overload special-cases of above method
77  operator std::vector<dtype>();
78  operator dtype*();
79  };
83 }
84 
85 #include "sparse_tensor.cxx"
86 #endif
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] = a...
Tensor< dtype > * parent
dense tensor whose subset this sparse tensor is of
Definition: sparse_tensor.h:17
Sparse_Tensor()
base constructor
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] = be...
void operator-=(std::vector< dtype > values)
a sparse subset of a tensor
Definition: sparse_tensor.h:14
void operator=(std::vector< dtype > values)
void operator+=(std::vector< dtype > values)
std::vector< int64_t > indices
indices of the sparse elements of this tensor
Definition: sparse_tensor.h:19
Definition: apsp.cxx:17
an instance of a tensor within a CTF world
Definition: tensor.h:74
dtype scale
scaling factor by which to scale the tensor elements
Definition: sparse_tensor.h:21