vec2sym
#
- hypercoil.functional.matrix.vec2sym(vec: Tensor, offset: int = 1) Tensor #
Convert a block of ravelled vectors into symmetric matrices.
The ordering of the input vectors should follow the upper triangle of the matrices to be formed.
- Parameters:
- vectensor
Block of vectors to convert. Input vectors should be of length (n choose 2), where n is the number of elements on the offset diagonal, plus 1.
- offsetint (default 1)
Offset from the main diagonal where the upper triangle begins. By default, the main diagonal is not included. Set this to 0 to place elements along the main diagonal.
- Returns:
- symtensor
Block of symmetric matrices formed by first populating the offset upper triangle with the elements from the input vec, then symmetrising.