7 template<
typename dtype>
15 Y.
write(n_X, inds_X, vals_X);
20 template<
typename dtype>
28 factor_inds[0] = idx_map[0];
29 factor_inds[1] = int_inds[0];
32 factor_inds[0] = idx_map[i];
33 factor_inds[1] = int_inds[i];
44 template<
typename dtype>
50 int transformed_lens[T.
order];
51 char transformed_arg[T.
order];
52 for (
int i = 0; i < T.
order; i++) {
54 transformed_arg[i] =
'i' + i;
55 transformed_lens[i] = T.
lens[i];
58 for (
int i = 0; i < T.
order; i++) {
59 for (
int j = i; j > 0; j--) {
60 transformed_lens[j] = T.
lens[j-1];
63 transformed_lens[0] = T.
lens[i];
64 for (
int j = 0; j < i; j++) {
65 transformed_arg[j] = arg[j+1];
67 transformed_arg[i] = arg[0];
70 unfold_lens[0] = T.
lens[i];
73 for (
int j = 0; j < T.
order; j++) {
77 unfold_lens[1] = ncol;
80 transformed_T[arg] = T[transformed_arg];
89 M.
svd(U, S, VT, ranks[i]);
90 factor_matrices[i] = U;
96 template<
typename dtype>
99 std::vector< Tensor <> > core_tensors(T.
order+1);
102 for (
int i = 0; i < T.
order; i++) {
105 for (
int i = 1; i < T.
order+1; i++) {
106 lens[i-1] = ranks[i-1];
108 core_tensors[i] = core;
113 char core_arg[T.
order];
114 for (
int i = 0; i < T.
order; i++) {
116 core_arg[i] =
'i' + i;
120 for (
int i = 0; i < T.
order; i++) {
122 matrix_arg[1] = arg[i];
125 core_tensors[i+1][core_arg] = transpose[matrix_arg] * core_tensors[i][arg];
126 core_arg[i] = arg[i];
128 return core_tensors[T.
order];
131 template<
typename dtype>
137 template<
typename dtype>
Tensor< dtype > core_tensor
Contract_Term operator[](char const *idx_map)
associated an index map with the tensor decomposition for algebra
Matrix class which encapsulates a 2D tensor.
std::vector< Matrix< dtype > > factor_matrices
Vector class which encapsulates a 1D tensor.
int order
number of tensor dimensions
void read_local(int64_t *npair, int64_t **global_idx, dtype **data, bool unpack_sym=false) const
Using get_local_data(), which returns an array that must be freed with delete [], is more efficient...
CTF::World * wrld
distributed processor context on which tensor is defined
int * lens
unpadded tensor edge lengths
void svd(Matrix< dtype > &U, Vector< dtype > &S, Matrix< dtype > &VT, int rank=0)
Tensor< dtype > get_core_tensor(Tensor< dtype > &T, std::vector< Matrix< dtype > > factor_matrices, int *ranks)
def transpose(init_A, axes=None)
std::vector< Matrix< dtype > > get_factor_matrices(Tensor< dtype > &T, int *ranks)
HoSVD(Tensor< dtype > T, int *ranks)
an instance of a tensor within a CTF world
void fold_unfold(Tensor< dtype > &X, Tensor< dtype > &Y)
void write(int64_t npair, int64_t const *global_idx, dtype const *data)
writes in values associated with any set of indices The sparse data is defined in coordinate format...