mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-15 21:00:47 +00:00
Summary: All pretty minor. I avoided renaming `class DestructableMock` to `class DestructibleMock` and similar such symbol renames (in this PR). Pull Request resolved: https://github.com/pytorch/pytorch/pull/49815 Reviewed By: VitalyFedyunin Differential Revision: D25734507 Pulled By: mruberry fbshipit-source-id: bbe8874a99d047e9d9814bf92ea8c036a5c6a3fd
34 lines
644 B
C++
34 lines
644 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
|