Unary.h 5.49 KB
Newer Older
1
/* NiuTrans.Tensor - an open-source tensor library
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
 * Copyright (C) 2017, Natural Language Processing Lab, Northestern University.
 * All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

18 19

/*
20 21
 * $Created by: Xu Chen (email: hello_master1954@163.com) 2018-07-31
 */
22 23 24 25 26 27 28 29 30 31

#ifndef __UNARY_H__
#define __UNARY_H__

#include "../../XTensor.h"

namespace nts{

/* set every entry to its absolute value */
void _Absolute(const XTensor * a, XTensor * b);
32 33
/* set every entry to its absolute value (do it on site)
keep the result in the input tensor a and return nothing */
34
void _AbsoluteMe(XTensor * a);
35 36
/* set every entry to its absolute value (return a XTensor structure)
make a new tensor to keep the result and return it */
37 38
XTensor Absolute(const XTensor & a);

39 40 41 42 43 44 45 46 47
/* set every entry to its ceil value */
void _Ceil(const XTensor * a, XTensor * b);
/* set every entry to its ceil value (do it on site)
keep the result in the input tensor a and return nothing */
void _CeilMe(XTensor * a);
/* set every entry to its ceil value (return a XTensor structure)
make a new tensor to keep the result and return it */
XTensor Ceil(const XTensor & a);

48 49
/* set every entry to its exponent value */
void _Exp(const XTensor * a, XTensor * b);
50 51
/* set every entry to its exponent value (do it on site)
keep the result in the input tensor a and return nothing */
52
void _ExpMe(XTensor * a);
53 54
/* set every entry to its exponent value (return a XTensor structure)
make a new tensor to keep the result and return it */
55 56
XTensor Exp(const XTensor & a);

57 58 59 60 61 62 63 64 65
/* set every entry to its floor value */
void _Floor(const XTensor * a, XTensor * b);
/* set every entry to its floor value (do it on site)
keep the result in the input tensor a and return nothing */
void _FloorMe(XTensor * a);
/* set every entry to its floor value (return a XTensor structure)
make a new tensor to keep the result and return it */
XTensor Floor(const XTensor & a);

66 67 68 69 70 71 72 73 74
/* if source entry is zero, set target entry to be one, otherwise zero */
void _IsZero(const XTensor *a, XTensor *b);
/* if source entry is zero, set target entry to be one, otherwise zero (do it on site)
keep the result in the input tensor a and return nothing */
void _IsZeroMe(XTensor *a);
/* if source entry is zero, set target entry to be one, otherwise zero (return a XTensor structure)
make a new tensor to keep the result and return it */
XTensor IsZero(const XTensor &a);

75 76
/* set every entry to its logarithm value */
void _Log(const XTensor * a, XTensor * b);
77 78
/* set every entry to its logarithm value (do it on site)
keep the result in the input tensor a and return nothing */
79
void _LogMe(XTensor * a);
80 81
/* set every entry to its logarithm value (return a XTensor structure)
make a new tensor to keep the result and return it */
82 83
XTensor Log(const XTensor & a);

84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
/* set every entry to its round value */
void _Round(const XTensor * a, XTensor * b);
/* set every entry to its round value (do it on site)
keep the result in the input tensor a and return nothing */
void _RoundMe(XTensor * a);
/* set every entry to its round value (return a XTensor structure)
make a new tensor to keep the result and return it */
XTensor Round(const XTensor & a);

/* set every entry to its sqrt value */
void _Sqrt(const XTensor * a, XTensor * b);
/* set every entry to its sqrt value (do it on site)
keep the result in the input tensor a and return nothing */
void _SqrtMe(XTensor * a);
/* set every entry to its sqrt value (return a XTensor structure)
make a new tensor to keep the result and return it */
XTensor Sqrt(const XTensor & a);

/* set every entry to its square value */
void _Square(const XTensor * a, XTensor * b);
/* set every entry to its square value (do it on site)
keep the result in the input tensor a and return nothing */
void _SquareMe(XTensor * a);
/* set every entry to its square value (return a XTensor structure)
make a new tensor to keep the result and return it */
XTensor Square(const XTensor & a);


112 113
/* set every entry to its sine value */
void _Sin(const XTensor * a, XTensor * b);
114 115
/* set every entry to its sine value (do it on site)
keep the result in the input tensor a and return nothing */
116
void _SinMe(XTensor * a);
117 118
/* set every entry to its sine value (return a XTensor structure)
make a new tensor to keep the result and return it */
119 120 121 122
XTensor Sin(const XTensor & a);

/* set every entry to its cosine value */
void _Cos(const XTensor * a, XTensor * b);
123 124
/* set every entry to its cosine value (do it on site)
keep the result in the input tensor a and return nothing */
125
void _CosMe(XTensor * a);
126 127
/* set every entry to its cosine value (return a XTensor structure)
make a new tensor to keep the result and return it */
128 129 130 131
XTensor Cos(const XTensor & a);

/* set every entry to its tangent value */
void _Tan(const XTensor * a, XTensor * b);
132 133
/* set every entry to its tangent value (do it on site)
keep the result in the input tensor a and return nothing */
134
void _TanMe(XTensor * a);
135 136
/* set every entry to its tangent value (return a XTensor structure)
make a new tensor to keep the result and return it */
137 138 139 140
XTensor Tan(const XTensor & a);

}
#endif //end __UNARY_H__