*My post explains real(), frac(), view_as_real() and view_as_complex().
conj() or conj_physical() can get the 0D or more D tensor of zero or more conjugated elements from the 0D or more D tensor of zero or more elements as shown below:
*Memos:
-
conj()
orconj_physical()
can be used with torch or a tensor. - The 1st argument(
input
) withtorch
or using a tensor(Required-Type:tensor
ofint
,float
,complex
orbool
). *If it's notcomplex
type, the original tensor is just returned. - For
conj_physical()
, there isout
argument withtorch
(Optional-Default:None
-Type:tensor
): *Memos:-
out=
must be used. -
My post explains
out
argument.
-
-
conj()
can work with is_conj() and resolve_conj which I explain later whileconj_physical()
cannot work with them.
import torch
my_tensor = torch.tensor(4.7352+6.1584j)
torch.conj(input=my_tensor)
my_tensor.conj()
torch.conj_physical(input=my_tensor)
my_tensor.conj_physical()
# tensor(4.7352-6.1584j)
my_tensor = torch.tensor([4.7352+6.1584j,
2.3706-8.4339j,
-9.1648-3.0342j])
torch.conj(input=my_tensor)
torch.conj_physical(input=my_tensor)
# tensor([4.7352-6.1584j,
# 2.3706+8.4339j,
# -9.1648+3.0342j])
my_tensor = torch.tensor([[4.7352+6.1584j,
2.3706-8.4339j,
-9.1648-3.0342j],
[1.5885+7.2316j,
-6.4314+3.9501j,
5.7923-4.1148j]])
torch.conj(input=my_tensor)
torch.conj_physical(input=my_tensor)
# tensor([[4.7352-6.1584j,
# 2.3706+8.4339j,
# -9.1648+3.0342j],
# [1.5885-7.2316j,
# -6.4314-3.9501j,
# 5.7923+4.1148j]])
my_tensor = torch.tensor([[4, 2, -9], [1, -6, 5]])
torch.conj(input=my_tensor)
torch.conj_physical(input=my_tensor)
# tensor([[4, 2, -9], [1, -6, 5]])
my_tensor = torch.tensor([[4., 2., -9.], [1., -6., 5.]])
torch.conj(input=my_tensor)
torch.conj_physical(input=my_tensor)
# tensor([[4., 2., -9.], [1., -6., 5.]])
my_tensor = torch.tensor([[True, False, True], [False, True, False]])
torch.conj(input=my_tensor)
torch.conj_physical(input=my_tensor)
# tensor([[True, False, True], [False, True, False]])
is_conj() can check if the 0D or more D tensor of zero or more elements outputted by conj()
is conjugated, getting the scalar of True
of False
as shown below:
*Memos:
-
is_conj()
can be used withtorch
or a tensor. - The 1st argument(
input
) withtorch
or using a tensor(Required-Type:tensor
ofint
,float
,complex
orbool
).
import torch
my_tensor = torch.tensor(4.7352+6.1584j)
torch.is_conj(input=my_tensor)
my_tensor.is_conj()
# False
""" conj() """
c_tensor = torch.conj(input=my_tensor)
c_tensor
# tensor(4.7352-6.1584j)
torch.is_conj(input=c_tensor)
# True
c_c_tensor = torch.conj(input=c_tensor)
c_c_tensor
# tensor(4.7352+6.1584j)
torch.is_conj(input=c_c_tensor)
# False
""" End """
""" conj_physical """
cp_tensor = torch.conj_physical(input=my_tensor)
cp_tensor
# tensor(4.7352-6.1584j)
torch.is_conj(input=cp_tensor)
# False
cp_cp_tensor = torch.conj_physical(input=cp_tensor)
cp_cp_tensor
# tensor(4.7352+6.1584j)
torch.is_conj(input=cp_cp_tensor)
# False
""" End """
my_tensor = torch.tensor([4.7352+6.1584j,
2.3706-8.4339j,
-9.1648-3.0342j])
torch.is_conj(input=my_tensor)
# False
my_tensor = torch.tensor([[4.7352+6.1584j,
2.3706-8.4339j,
-9.1648-3.0342j],
[1.5885+7.2316j,
-6.4314+3.9501j,
5.7923-4.1148j]])
torch.is_conj(input=my_tensor)
# False
my_tensor = torch.tensor([[4, 2, -9], [1, -6, 5]])
torch.is_conj(input=my_tensor)
# False
my_tensor = torch.tensor([[4., 2., -9.], [1., -6., 5.]])
torch.is_conj(input=my_tensor)
# False
my_tensor = torch.tensor([[True, False, True], [False, True, False]])
torch.is_conj(input=my_tensor)
# False
resolve_conj() can get the new 0D or more D tensor of zero or more elements from the 0D or more D tensor of the zero or more elements conjugated from conj()
as shown below:
*Memos:
-
resolve_conj()
can be used withtorch
or a tensor. - The 1st argument(
input
) withtorch
or using a tensor(Required-Type:tensor
ofint
,float
,complex
orbool
). *If it's not conjugated byconj()
, the original tensor is just returned.
import torch
my_tensor = torch.tensor(4.7352+6.1584j)
torch.resolve_conj(input=my_tensor)
my_tensor.resolve_conj()
# tensor(4.7352+6.1584j)
c_tensor = torch.conj(input=my_tensor)
c_tensor
# tensor(4.7352-6.1584j)
torch.is_conj(input=c_tensor)
# True
rc_tensor = torch.resolve_conj(input=c_tensor)
rc_tensor
# tensor(4.7352-6.1584j)
rc_tensor.is_conj(input=rc_tensor)
# False
my_tensor = torch.tensor([4.7352+6.1584j,
2.3706-8.4339j,
-9.1648-3.0342j])
torch.resolve_conj(input=my_tensor)
# tensor([4.7352+6.1584j,
# 2.3706-8.4339j,
# -9.1648-3.0342j])
my_tensor = torch.tensor([[4.7352+6.1584j,
2.3706-8.4339j,
-9.1648-3.0342j],
[1.5885+7.2316j,
-6.4314+3.9501j,
5.7923-4.1148j]])
torch.resolve_conj(input=my_tensor)
# tensor([[4.7352+6.1584j,
# 2.3706-8.4339j,
# -9.1648-3.0342j],
# [1.5885+7.2316j,
# -6.4314+3.9501j,
# 5.7923-4.1148j]])
my_tensor = torch.tensor([[4, 2, -9], [1, -6, 5]])
torch.resolve_conj(input=my_tensor)
# tensor([[4, 2, -9], [1, -6, 5]])
my_tensor = torch.tensor([[4., 2., -9.], [1., -6., 5.]])
torch.resolve_conj(input=my_tensor)
# tensor([[4., 2., -9.], [1., -6., 5.]])
my_tensor = torch.tensor([[True, False, True], [False, True, False]])
torch.resolve_conj(input=my_tensor)
# tensor([[True, False, True], [False, True, False]])
Top comments (0)