Skip to content

np.diag() - Create a diagonal matrix #34

@sahil3028

Description

@sahil3028

Syntax:
np.diag(v, k=0)

Arguments:
v: 1D array (to form diagonal) or 2D matrix.
k: Diagonal shift.

Example:
diag_matrix = np.diag([1, 2, 3])

[[1 0 0]
[0 2 0]
[0 0 3]]

diag_shifted = np.diag([4, 5, 6], k=1)

[[0 4 0 0]
[0 0 5 0]
[0 0 0 6]
[0 0 0 0]]

Note: we cant solve this issue rn we need help to take arguments like this -p.diag([4, 5, 6], k=1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions