mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 00:21:07 +01:00
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/56830 Opt into formatting on GitHub and format everything. This is a trial run before turning on formatting for more and eventually all of the codebase. Test Plan: CI Reviewed By: zertosh Differential Revision: D27979080 fbshipit-source-id: a80f0c48691c08ae8ca0af06377b87e6a2351151
37 lines
656 B
C++
37 lines
656 B
C++
#include <c10/core/Scalar.h>
|
|
|
|
namespace c10 {
|
|
|
|
Scalar Scalar::operator-() const {
|
|
TORCH_CHECK(
|
|
!isBoolean(),
|
|
"torch boolean negative, the `-` operator, is not supported.");
|
|
if (isFloatingPoint()) {
|
|
return Scalar(-v.d);
|
|
} else if (isComplex()) {
|
|
return Scalar(-v.z);
|
|
} else {
|
|
return Scalar(-v.i);
|
|
}
|
|
}
|
|
|
|
Scalar Scalar::conj() const {
|
|
if (isComplex()) {
|
|
return Scalar(std::conj(v.z));
|
|
} else {
|
|
return *this;
|
|
}
|
|
}
|
|
|
|
Scalar Scalar::log() const {
|
|
if (isComplex()) {
|
|
return std::log(v.z);
|
|
} else if (isFloatingPoint()) {
|
|
return std::log(v.d);
|
|
} else {
|
|
return std::log(v.i);
|
|
}
|
|
}
|
|
|
|
} // namespace c10
|