MCPcopy Create free account
hub / github.com/MotrixLab/insactor / _copysign

Function _copysign

data/rotation_utils/conversions.py:84–99  ·  view source on GitHub ↗

Return a tensor where each element has the absolute value taken from the, corresponding element of a, with sign taken from the corresponding element of b. This is like the standard copysign floating-point operation, but is not careful about negative 0 and NaN. Args: a:

(a: torch.Tensor, b: torch.Tensor)

Source from the content-addressed store, hash-verified

82
83
84def _copysign(a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:
85 """
86 Return a tensor where each element has the absolute value taken from the,
87 corresponding element of a, with sign taken from the corresponding
88 element of b. This is like the standard copysign floating-point operation,
89 but is not careful about negative 0 and NaN.
90
91 Args:
92 a: source tensor.
93 b: tensor whose signs will be used, of the same shape as a.
94
95 Returns:
96 Tensor of the same shape as a with the signs of b.
97 """
98 signs_differ = (a < 0) != (b < 0)
99 return torch.where(signs_differ, -a, a)
100
101
102def _sqrt_positive_part(x: torch.Tensor) -> torch.Tensor:

Callers 1

random_quaternionsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected