Understanding principal angles

Viewed 99

I'm trying to understand principle angles better by calculating them, and I found the scipy has an easy function to do that.

Say I have 2 arrays:

from scipy.linalg import subspace_angles as sa
import torch

arr1 = torch.tensor([[1,2],[1.4,2.4]])
arr2 = torch.tensor([[2,3],[11,22]])

I can calculate it using:

sa(arr1,arr2)
>>> array([8.36970078e-08, 3.55122804e-08])

However, I don't quite understand the calculation. For example, why the following works?

arr1 = torch.tensor([[1,0,0,1,0,0], [0,1,0, 1,0,0]])
arr2 = torch.tensor([[1,1,1],[0,0,1]])
sa(arr1,arr2)
>>>array([1.57009246e-16, 0.00000000e+00])

And this one gives an error

arr1 = torch.tensor([[1,0,0,1,0,0], [0,1,0, 1,0,0], [0,1,0, 1,0,0]])
arr2 = torch.tensor([[1,1,1],[0,0,1]])
sa(arr1,arr2)
>>>ValueError: A and B must have the same number of rows, got 3 and 2

And this one gives a 0

arr1 = torch.tensor([[1,9]])
arr2 = torch.tensor([[2,33]])
sa(arr1,arr2)
>>> 0

I may be wrong, but from what I'm seeing it seems like if I have a tensor of size i, I will get i principal angles.

0 Answers
Related