File tree 2 files changed +27
-2
lines changed
2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -214,6 +214,19 @@ class Tensor{
214
214
215
215
// / @}
216
216
217
+
218
+ // / @name Trigonometric
219
+ // / @{
220
+
221
+ // / @brief Get element-wise sin of a tensor
222
+ // / @param t The tensor
223
+ static Tensor sin (const Tensor &t);
224
+
225
+ // / @brief Get element-wise cosine of a tensor
226
+ // / @param t The tensor
227
+ static Tensor cos (const Tensor &t);
228
+
229
+ // / @}
217
230
218
231
// / @brief Overwrite the << operator to print this tensor out to the command line
219
232
friend std::ostream &operator << (std::ostream &stream, const Tensor &tensor) {
Original file line number Diff line number Diff line change 1
1
2
2
#include < nuTens/tensors/tensor.hpp>
3
- #include < torch/torch.h>
4
3
5
4
6
5
// map between the data types used in nuTens and those used by pytorch
@@ -312,7 +311,7 @@ Tensor Tensor::operator- () const {
312
311
313
312
Tensor Tensor::cumsum (int dim) const {
314
313
Tensor ret;
315
- ret._tensor = _tensor. cumsum (dim);
314
+ ret._tensor = torch:: cumsum (_tensor, dim);
316
315
return ret;
317
316
}
318
317
@@ -332,6 +331,19 @@ Tensor Tensor::grad() const {
332
331
return ret;
333
332
}
334
333
334
+
335
+ Tensor Tensor::sin (const Tensor &t) {
336
+ Tensor ret;
337
+ ret._tensor = torch::sin (t._tensor );
338
+ return ret;
339
+ }
340
+
341
+ Tensor Tensor::cos (const Tensor &t) {
342
+ Tensor ret;
343
+ ret._tensor = torch::cos (t._tensor );
344
+ return ret;
345
+ }
346
+
335
347
std::string Tensor::toString () const {
336
348
std::ostringstream stream;
337
349
stream << _tensor;
You can’t perform that action at this time.
0 commit comments