Tensor Operators
Batched linear-algebra and angular operators implemented as CUDA/C++
kernels and exposed via pyc::operators.
pyc::operators Functions
Function |
Description |
|---|---|
|
Batch inner (dot) product of two vector tensors |
|
Cosine of the opening angle between |
|
Sine of the opening angle |
|
Rotation matrix around x-axis for each element in |
|
Rotation matrix around y-axis |
|
Rotation matrix around z-axis |
|
Combined rotation aligning b-quark to z-axis in the lepton rest frame |
|
Cofactor matrix of each \(3\times3\) element in the batch |
|
Determinant of each matrix in the batch |
|
Returns |
|
Returns |
|
Batch 3-vector cross product |
-
namespace operators
Tensor-based matrix/vector operations.
Functions
-
torch::Tensor Dot(torch::Tensor v1, torch::Tensor v2)
Element-wise inner product.
-
torch::Tensor CosTheta(torch::Tensor v1, torch::Tensor v2)
Compute cos θ between two vectors.
-
torch::Tensor SinTheta(torch::Tensor v1, torch::Tensor v2)
Compute sin θ between two vectors.
-
torch::Tensor Rx(torch::Tensor angle)
Batched rotation matrix about x.
-
torch::Tensor Ry(torch::Tensor angle)
Batched rotation matrix about y.
-
torch::Tensor Rz(torch::Tensor angle)
Batched rotation matrix about z.
-
torch::Tensor RT(torch::Tensor pmc_b, torch::Tensor pmc_mu)
Compute the rotation from the b–lepton decay frame to the lab frame.
-
torch::Tensor CoFactors(torch::Tensor matrix)
Compute the cofactor matrix.
-
torch::Tensor Determinant(torch::Tensor matrix)
Compute the determinant.
-
std::tuple<torch::Tensor, torch::Tensor> Inverse(torch::Tensor matrix)
Compute the inverse and a validity mask.
- Returns:
(inverse, valid_mask).
-
std::tuple<torch::Tensor, torch::Tensor> Eigenvalue(torch::Tensor matrix)
Compute eigenvalues and a validity mask.
- Returns:
(eigenvalues, valid_mask).
-
torch::Tensor Cross(torch::Tensor mat1, torch::Tensor mat2)
Batched cross product.
-
torch::Tensor Dot(torch::Tensor v1, torch::Tensor v2)
Internal Kernel Namespace
-
namespace operators_
Internal namespace for batched matrix/vector operators.
Functions
-
torch::Tensor Dot(torch::Tensor *v1, torch::Tensor *v2)
Batched element-wise dot product.
- Parameters:
v1 – [N, D] first vectors.
v2 – [N, D] second vectors.
- Returns:
[N] dot products.
-
torch::Tensor Cross(torch::Tensor *v1, torch::Tensor *v2)
Batched cross product of 3-vectors.
- Parameters:
v1 – [N, 3].
v2 – [N, 3].
- Returns:
[N, 3] cross products.
-
torch::Tensor Determinant(torch::Tensor *matrix)
Batched 3×3 determinant.
- Parameters:
matrix – [N, 3, 3].
- Returns:
[N] determinants.
-
torch::Tensor CosTheta(torch::Tensor *v1, torch::Tensor *v2)
Batched cosine of angle between v1 and v2.
- Returns:
[N] cosines.
-
torch::Tensor SinTheta(torch::Tensor *v1, torch::Tensor *v2)
Batched sine of angle between v1 and v2.
- Returns:
[N] sines.
-
torch::Tensor Pi_2(torch::Tensor *trn)
Compute π/2 - θ for each element.
- Parameters:
trn – [N] angle tensor.
- Returns:
[N] result.
-
torch::Tensor Rx(torch::Tensor *angle)
Batched rotation matrix about x.
- Parameters:
angle – [N].
- Returns:
[N, 3, 3].
-
torch::Tensor Ry(torch::Tensor *angle)
Batched rotation matrix about y.
- Returns:
[N, 3, 3].
-
torch::Tensor Rz(torch::Tensor *angle)
Batched rotation matrix about z.
- Returns:
[N, 3, 3].
-
torch::Tensor RT(torch::Tensor *pmc_b, torch::Tensor *pmc_mu, torch::Tensor *base)
Compute the rotation from the decay frame to the lab frame for each (b, lepton) pair.
- Parameters:
pmc_b – [N, 4] b-quark Cartesian momenta.
pmc_mu – [N, 4] lepton Cartesian momenta.
base – Pre-computed base matrix.
- Returns:
[N, 3, 3] rotation matrices.
-
torch::Tensor CoFactors(torch::Tensor *matrix)
Batched cofactor matrix.
- Parameters:
matrix – [N, 3, 3].
- Returns:
[N, 3, 3] cofactor matrices.
-
std::tuple<torch::Tensor, torch::Tensor> Inverse(torch::Tensor *matrix)
Batched 3×3 matrix inverse.
- Returns:
(inverse [N, 3, 3], valid_mask [N]).
-
std::tuple<torch::Tensor, torch::Tensor> Eigenvalue(torch::Tensor *matrix)
Batched 3×3 eigenvalue computation.
- Returns:
(eigenvalues [N, 3], valid_mask [N]).
-
torch::Tensor Dot(torch::Tensor *v1, torch::Tensor *v2)