dislib.kron(a, b, block_size=None)[source]

Kronecker product of two ds-arrays.

  • a, b (ds-arrays) – Input ds-arrays.

  • block_size (tuple of two ints, optional) – Block size of the resulting array. Defaults to the block size of b.



Return type



NotImplementedError – If a or b are sparse.

dislib.svd(a, compute_uv=True, sort=True, copy=True, eps=1e-09)[source]

Performs singular value decomposition of a ds-array via the one-sided block Jacobi algorithm described in Arbenz and Slapnicar 1 and Dongarra et al. 2.

Singular value decomposition is a factorization of the form A = USV’, where U and V are unitary matrices and S is a rectangular diagonal matrix.

  • a (ds-array, shape=(m, n)) – Input matrix (m >= n). Needs to be partitioned in two column blocks at least due to the design of the block Jacobi algorithm.

  • compute_uv (boolean, optional (default=True)) – Whether or not to compute u and v in addition to s.

  • sort (boolean, optional (default=True)) – Whether to return sorted u, s and v. Sorting requires a significant amount of additional computation.

  • copy (boolean, optional (default=True)) – Whether to create a copy of a or to apply transformations on a directly. Only valid if a is regular (i.e., top left block is of regular shape).

  • eps (float, optional (default=1e-9)) – Tolerance for the convergence criterion.


  • u (ds-array, shape=(m, n)) – U matrix. Only returned if compute_uv is True.

  • s (ds-array, shape=(1, n)) – Diagonal entries of S.

  • v (ds-array, shape=(n, n)) – V matrix. Only returned if compute_uv is True.


ValueError – If a has less than 2 column blocks or m < n.



Arbenz, P. and Slapnicar, A. (1995). An Analysis of Parallel Implementations of the Block-Jacobi Algorithm for Computing the SVD. In Proceedings of the 17th International Conference on Information Technology Interfaces ITI (pp. 13-16).


Dongarra, J., Gates, M., Haidar, A. et al. (2018). The singular value decomposition: Anatomy of optimizing an algorithm for extreme scale. In SIAM review, 60(4) (pp. 808-865).


>>> import dislib as ds
>>> import numpy as np
>>> if __name__ == '__main__':
>>>     x = ds.random_array((10, 6), (2, 2), random_state=7)
>>>     u, s, v = ds.svd(x)
>>>     u = u.collect()
>>>     s = np.diag(s.collect())
>>>     v = v.collect()
>>>     print(np.allclose(x.collect(), u @ s @ v.T))