mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-12 19:59:05 +08:00
Add arg() to tensor
This commit is contained in:
parent
028ab12586
commit
a9868bd5be
@ -886,6 +886,23 @@ containing the natural logarithms of the original tensor.
|
|||||||
Returns a tensor of the same type and dimensions as the original tensor
|
Returns a tensor of the same type and dimensions as the original tensor
|
||||||
containing the absolute values of the original tensor.
|
containing the absolute values of the original tensor.
|
||||||
|
|
||||||
|
### <Operation> arg()
|
||||||
|
|
||||||
|
Returns a tensor with the same dimensions as the original tensor
|
||||||
|
containing the complex argument (phase angle) of the values of the
|
||||||
|
original tensor.
|
||||||
|
|
||||||
|
### <Operation> real()
|
||||||
|
|
||||||
|
Returns a tensor with the same dimensions as the original tensor
|
||||||
|
containing the real part of the complex values of the original tensor.
|
||||||
|
|
||||||
|
### <Operation> imag()
|
||||||
|
|
||||||
|
Returns a tensor with the same dimensions as the orginal tensor
|
||||||
|
containing the imaginary part of the complex values of the original
|
||||||
|
tensor.
|
||||||
|
|
||||||
### <Operation> pow(Scalar exponent)
|
### <Operation> pow(Scalar exponent)
|
||||||
|
|
||||||
Returns a tensor of the same type and dimensions as the original tensor
|
Returns a tensor of the same type and dimensions as the original tensor
|
||||||
|
@ -311,6 +311,12 @@ class TensorBase<Derived, ReadOnlyAccessors>
|
|||||||
return unaryExpr(internal::scalar_abs_op<Scalar>());
|
return unaryExpr(internal::scalar_abs_op<Scalar>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
EIGEN_STRONG_INLINE const TensorCwiseUnaryOp<internal::scalar_arg_op<Scalar>, const Derived>
|
||||||
|
arg() const {
|
||||||
|
return unaryExpr(internal::scalar_arg_op<Scalar>());
|
||||||
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC
|
EIGEN_DEVICE_FUNC
|
||||||
EIGEN_STRONG_INLINE const TensorCwiseUnaryOp<internal::scalar_clamp_op<Scalar>, const Derived>
|
EIGEN_STRONG_INLINE const TensorCwiseUnaryOp<internal::scalar_clamp_op<Scalar>, const Derived>
|
||||||
clip(Scalar min, Scalar max) const {
|
clip(Scalar min, Scalar max) const {
|
||||||
|
@ -47,6 +47,20 @@ static void test_abs()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_arg()
|
||||||
|
{
|
||||||
|
Tensor<std::complex<float>, 1> data1(3);
|
||||||
|
Tensor<std::complex<double>, 1> data2(3);
|
||||||
|
data1.setRandom();
|
||||||
|
data2.setRandom();
|
||||||
|
|
||||||
|
Tensor<float, 1> arg1 = data1.arg();
|
||||||
|
Tensor<double, 1> arg2 = data2.arg();
|
||||||
|
for (int i = 0; i < 3; ++i) {
|
||||||
|
VERIFY_IS_APPROX(arg1(i), std::arg(data1(i)));
|
||||||
|
VERIFY_IS_APPROX(arg2(i), std::arg(data2(i)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void test_conjugate()
|
static void test_conjugate()
|
||||||
{
|
{
|
||||||
@ -98,6 +112,7 @@ EIGEN_DECLARE_TEST(cxx11_tensor_of_complex)
|
|||||||
{
|
{
|
||||||
CALL_SUBTEST(test_additions());
|
CALL_SUBTEST(test_additions());
|
||||||
CALL_SUBTEST(test_abs());
|
CALL_SUBTEST(test_abs());
|
||||||
|
CALL_SUBTEST(test_arg());
|
||||||
CALL_SUBTEST(test_conjugate());
|
CALL_SUBTEST(test_conjugate());
|
||||||
CALL_SUBTEST(test_contractions());
|
CALL_SUBTEST(test_contractions());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user