Commit 1ef8b6c0 by xiaotong

overload of +, -, * and /

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