torch.linalg.matrix_exp#
- torch.linalg.matrix_exp(A) Tensor#
計算方陣的矩陣指數。
令 為 或 ,此函式計算 的矩陣指數,定義為
如果矩陣 的特徵值為 ,則 的特徵值為 .
支援 bfloat16、float、double、cfloat 和 cdouble 資料型別的輸入。也支援矩陣的批處理,如果
A是矩陣的批處理,則輸出具有相同的批處理維度。- 引數
A (Tensor) – 形狀為 (*, n, n) 的張量,其中 * 是零個或多個批次維度。
示例
>>> A = torch.empty(2, 2, 2) >>> A[0, :, :] = torch.eye(2, 2) >>> A[1, :, :] = 2 * torch.eye(2, 2) >>> A tensor([[[1., 0.], [0., 1.]], [[2., 0.], [0., 2.]]]) >>> torch.linalg.matrix_exp(A) tensor([[[2.7183, 0.0000], [0.0000, 2.7183]], [[7.3891, 0.0000], [0.0000, 7.3891]]]) >>> import math >>> A = torch.tensor([[0, math.pi/3], [-math.pi/3, 0]]) # A is skew-symmetric >>> torch.linalg.matrix_exp(A) # matrix_exp(A) = [[cos(pi/3), sin(pi/3)], [-sin(pi/3), cos(pi/3)]] tensor([[ 0.5000, 0.8660], [-0.8660, 0.5000]])