Cyclops Tensor Framework
parallel arithmetic on multidimensional arrays
untyped_tensor_tmpl.h
Go to the documentation of this file.
1 #include "../interface/functions.h"
2 #include <math.h>
3 #include <cmath>
4 namespace CTF_int {
5 
6  template <typename dtype_A, typename dtype_B>
8  char str[this->order];
9  for (int i=0; i<this->order; i++){
10  str[i] = 'a'+i;
11  }
12  assert(this->order == B->order);
13  B->operator[](str) = CTF::Function<dtype_A,dtype_B>([](dtype_A a){ return (dtype_B)a; })(this->operator[](str));
14 
15  }
16 
17  template <typename dtype_A, typename dtype_B>
19  char str[this->order];
20  for (int i=0; i<this->order; i++){
21  str[i] = 'a'+i;
22  }
23  this->operator[](str) = CTF::Function<dtype_A,dtype_B>([](dtype_A a){ return (dtype_B)exp(a); })(A->operator[](str));
24  }
25 
26  template <typename dtype>
28  char str[this->order];
29  for (int i=0; i<this->order; i++){
30  str[i] = 'a'+i;
31  }
32  assert(this->order >= A->order);
33  assert(this->order >= B->order);
34  assert(A->sr->el_size == B->sr->el_size);
35  this->operator[](str) = CTF::Function<dtype,dtype,bool>([](dtype a, dtype b){ return a==b; })(A->operator[](str),B->operator[](str));
36  }
37 
38  template <typename dtype>
40  char str[this->order];
41  for (int i=0; i<this->order; i++){
42  str[i] = 'a'+i;
43  }
44  assert(A->order == B->order);
45  assert(A->sr->el_size == B->sr->el_size);
46  assert(A->order == this->order);
47  this->operator[](str) = CTF::Function<dtype,dtype,bool>([](dtype a, dtype b){ return a != b;})(A->operator[](str),B->operator[](str));
48  }
49 
50  template <typename dtype>
52  char str[this->order];
53  for (int i=0; i<this->order; i++){
54  str[i] = 'a'+i;
55  }
56  assert(A->order == B->order);
57  assert(A->sr->el_size == B->sr->el_size);
58  assert(A->order == this->order);
59  this->operator[](str) = CTF::Function<dtype,dtype,bool>([](dtype a, dtype b){ return a < b;})(A->operator[](str),B->operator[](str));
60  }
61 
62  template <typename dtype>
64  char str[this->order];
65  for (int i=0; i<this->order; i++){
66  str[i] = 'a'+i;
67  }
68  assert(A->order == B->order);
69  assert(A->sr->el_size == B->sr->el_size);
70  assert(A->order == this->order);
71  this->operator[](str) = CTF::Function<dtype,dtype,bool>([](dtype a, dtype b){ return a <= b;})(A->operator[](str),B->operator[](str));
72  }
73 
74  template <typename dtype>
76  char str[this->order];
77  for (int i=0; i<this->order; i++){
78  str[i] = 'a'+i;
79  }
80  assert(A->order == B->order);
81  assert(A->sr->el_size == B->sr->el_size);
82  assert(A->order == this->order);
83  this->operator[](str) = CTF::Function<dtype,dtype,bool>([](dtype a, dtype b){ return a > b;})(A->operator[](str),B->operator[](str));
84  }
85 
86  template <typename dtype>
88  char str[this->order];
89  for (int i=0; i<this->order; i++){
90  str[i] = 'a'+i;
91  }
92  assert(A->order == B->order);
93  assert(A->sr->el_size == B->sr->el_size);
94  assert(A->order == this->order);
95  this->operator[](str) = CTF::Function<dtype,dtype,bool>([](dtype a, dtype b){ return a >= b;})(A->operator[](str),B->operator[](str));
96  }
97 
98  template <typename dtype>
100  char str[this->order];
101  for (int i=0; i<this->order; i++){
102  str[i] = 'a'+i;
103  }
104  assert(A->order == this->order);
105  this->operator[](str) = CTF::Function<dtype,dtype>([](dtype a){ return ((dtype)1)/a;})(A->operator[](str));
106  }
107 
108 /*
109  template <typename dtype>
110  void tensor::pow_helper_int(tensor * A, int p){
111  char str[this->order];
112  for (int i=0; i<this->order; i++){
113  str[i] = 'a'+i;
114  }
115  assert(A->order == this->order);
116  this->operator[](str) = CTF::Function<dtype,dtype>([](dtype a){ return std::pow(a, p);})(A->operator[](str));
117  }*/
118 }
void smaller_equal_than(tensor *A, tensor *B)
do an elementwise comparison(<=) of two tensors with elements of type dtype (primarily needed for pyt...
void smaller_than(tensor *A, tensor *B)
do an elementwise comparison(<) of two tensors with elements of type dtype (primarily needed for pyth...
CTF::Idx_Tensor operator[](char const *idx_map)
associated an index map with the tensor for future operation
void larger_equal_than(tensor *A, tensor *B)
do an elementwise comparison(>=) of two tensors with elements of type dtype (primarily needed for pyt...
void conv_type(tensor *B)
convert this tensor from dtype_A to dtype_B and store the result in B (primarily needed for python in...
int order
number of tensor dimensions
void compare_elementwise(tensor *A, tensor *B)
do an elementwise comparison(==) of two tensors with elements of type dtype (primarily needed for pyt...
void not_equals(tensor *A, tensor *B)
do an elementwise comparison(!=) of two tensors with elements of type dtype (primarily needed for pyt...
algstrct * sr
algstrct on which tensor elements and operations are defined
void larger_than(tensor *A, tensor *B)
do an elementwise comparison(>) of two tensors with elements of type dtype (primarily needed for pyth...
def exp(init_x, out=None, where=True, casting='same_kind', order='F', dtype=None, subok=True)
Definition: core.pyx:3954
void true_divide(tensor *A)
int el_size
size of each element of algstrct in bytes
Definition: algstrct.h:16
internal distributed tensor class
void exp_helper(tensor *A)