Commit 1ef8b6c0 by xiaotong

overload of +, -, * and /

parent 55dfe49b
...@@ -454,7 +454,7 @@ XTensor& XTensor::operator= (const XTensor&& tensor) ...@@ -454,7 +454,7 @@ XTensor& XTensor::operator= (const XTensor&& tensor)
} }
/* overloading of the plus-sign */ /* overloading of the plus-sign */
XTensor XTensor::operator+ (const XTensor& tensor) XTensor XTensor::operator+ (const XTensor& tensor) const
{ {
return Sum(*this, tensor); return Sum(*this, tensor);
} }
...@@ -466,37 +466,37 @@ XTensor XTensor::operator+ (const DTYPE shift) const ...@@ -466,37 +466,37 @@ XTensor XTensor::operator+ (const DTYPE shift) const
} }
/* overloading of the multiply-sign */ /* overloading of the multiply-sign */
XTensor XTensor::operator* (const XTensor& tensor) XTensor XTensor::operator* (const XTensor& tensor) const
{ {
return Multiply(*this, tensor); return Multiply(*this, tensor);
} }
/* overloading of the multiply-sign */ /* overloading of the multiply-sign */
XTensor XTensor::operator* (const DTYPE scale) XTensor XTensor::operator* (const DTYPE scale) const
{ {
return ScaleAndShift(*this, scale, 0); return ScaleAndShift(*this, scale, 0);
} }
/* overloading of the minus-sign */ /* overloading of the minus-sign */
XTensor XTensor::operator- (const XTensor& tensor) XTensor XTensor::operator- (const XTensor& tensor) const
{ {
return Sub(*this, tensor); return Sub(*this, tensor);
} }
/* overloading of the minus-sign */ /* overloading of the minus-sign */
XTensor XTensor::operator- (const DTYPE shift) XTensor XTensor::operator- (const DTYPE shift) const
{ {
return ScaleAndShift(*this, 1, -shift); return ScaleAndShift(*this, 1, -shift);
} }
/* overloading of the division-sign */ /* overloading of the division-sign */
XTensor XTensor::operator/ (const XTensor& tensor) XTensor XTensor::operator/ (const XTensor& tensor) const
{ {
return Div(*this, tensor); return Div(*this, tensor);
} }
/* overloading of the division-sign */ /* overloading of the division-sign */
XTensor XTensor::operator/ (const DTYPE scale) XTensor XTensor::operator/ (const DTYPE scale) const
{ {
return ScaleAndShift(*this, (DTYPE)1/scale, 0); return ScaleAndShift(*this, (DTYPE)1/scale, 0);
} }
...@@ -506,7 +506,7 @@ linear transformation b = a * \scale + \shift ...@@ -506,7 +506,7 @@ linear transformation b = a * \scale + \shift
>> scale - the slope >> scale - the slope
>> shift - the intercept >> shift - the intercept
*/ */
XTensor XTensor::Lin(DTYPE scale, DTYPE shift) XTensor XTensor::Lin(DTYPE scale, DTYPE shift) const
{ {
return Linear(*this, scale, shift); return Linear(*this, scale, shift);
} }
......
...@@ -222,31 +222,31 @@ public: ...@@ -222,31 +222,31 @@ public:
#endif #endif
/* overloading of the plus-sign */ /* overloading of the plus-sign */
XTensor operator+ (const XTensor &tensor); XTensor operator+ (const XTensor &tensor) const;
/* overloading of the plus-sign */ /* overloading of the plus-sign */
XTensor operator+ (const DTYPE shift) const; XTensor operator+ (const DTYPE shift) const;
/* overloading of the multiply-sign */ /* overloading of the multiply-sign */
XTensor operator* (const XTensor &tensor); XTensor operator* (const XTensor &tensor) const;
/* overloading of the multiply-sign */ /* overloading of the multiply-sign */
XTensor operator* (const DTYPE scale); XTensor operator* (const DTYPE scale) const;
/* overloading of the minus-sign */ /* overloading of the minus-sign */
XTensor operator- (const XTensor &tensor); XTensor operator- (const XTensor &tensor) const;
/* overloading of the minus-sign */ /* overloading of the minus-sign */
XTensor operator- (const DTYPE shift); XTensor operator- (const DTYPE shift) const;
/* overloading of the division-sign */ /* overloading of the division-sign */
XTensor operator/ (const XTensor &tensor); XTensor operator/ (const XTensor &tensor) const;
/* overloading of the division-sign */ /* overloading of the division-sign */
XTensor operator/ (const DTYPE scale); XTensor operator/ (const DTYPE scale) const;
/* linear transformation */ /* linear transformation */
XTensor Lin(DTYPE scale, DTYPE shift = 0); XTensor Lin(DTYPE scale, DTYPE shift = 0) const;
/* judge whether the two matrices are in the same type and size */ /* judge whether the two matrices are in the same type and size */
static static
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论