def test_ajd():
 (n_times, n_channels) = (10, 3)
 seed = np.random.RandomState(0)
 diags = (2.0 + (0.1 * seed.randn(n_times, n_channels)))
 A = ((2 * seed.rand(n_channels, n_channels)) - 1)
 A /= np.atleast_2d(np.sqrt(np.sum((A ** 2), 1))).T
 covmats = np.empty((n_times, n_channels, n_channels))
 for i in range(n_times):
  covmats[i] = np.dot(np.dot(A, np.diag(diags[i])), A.T)
 (V, D) = _ajd_pham(covmats)
 V_matlab = [[(-3.507280775058041), (-5.498189967306344), 7.720624541198574], [0.69468901323461, 0.775690358505945, (-1.162043086446043)], [(-0.592603135588066), (-0.59899692569626), 1.009550086271192]]
 assert_array_almost_equal(V, V_matlab)

def test_ajd ( ) : ( n_times , n_channels ) = ( 10 , 3 ) seed = np . random . RandomState ( 0 ) diags = ( 2.0 + ( 0.1 * seed . randn ( n_times , n_channels ) ) ) A = ( ( 2 * seed . rand ( n_channels , n_channels ) ) - 1 ) A /= np . atleast_2d ( np . sqrt ( np . sum ( ( A ** 2 ) , 1 ) ) ) . T covmats = np . empty ( ( n_times , n_channels , n_channels ) ) for i in range ( n_times ) : covmats [ i ] = np . dot ( np . dot ( A , np . diag ( diags [ i ] ) ) , A . T ) ( V , D ) = _ajd_pham ( covmats ) V_matlab = [ [ ( - 3.507280775058041 ) , ( - 5.498189967306344 ) , 7.720624541198574 ] , [ 0.69468901323461 , 0.775690358505945 , ( - 1.162043086446043 ) ] , [ ( - 0.592603135588066 ) , ( - 0.59899692569626 ) , 1.009550086271192 ] ] assert_array_almost_equal ( V , V_matlab )
test if approximate joint diagonalization implementation obtains same results as the matlab implementation by pham dinh-tuan .