toqito.matrix_props.has_same_dimension ====================================== .. py:module:: toqito.matrix_props.has_same_dimension .. autoapi-nested-parse:: Checks if the dimensions of list of vectors or matrices are equal. Module Contents --------------- .. py:function:: has_same_dimension(items) Check if all vectors or matrices in a list have the same dimension. For a vector (1D array), the dimension is its length. For a matrix, the dimension can be considered as the total number of elements (rows x columns) for non-square matrices, or simply the number of rows (or columns) for square matrices. The function iterates through the provided list and ensures that every item has the same dimension. .. rubric:: Examples Check a list of vectors with the same dimension: ```python exec="1" source="above" import numpy as np from toqito.matrix_props import has_same_dimension vectors = [np.array([1, 2, 3]), np.array([4, 5, 6]), np.array([7, 8, 9])] print(has_same_dimension(vectors)) ``` Check a list of matrices with the same dimension: ```python exec="1" source="above" import numpy as np from toqito.matrix_props import has_same_dimension matrices = [np.array([[1, 0], [0, 1]]), np.array([[2, 3], [4, 5]]), np.array([[6, 7], [8, 9]])] print(has_same_dimension(matrices)) ``` Check a list containing items of different dimensions: ```python exec="1" source="above" import numpy as np from toqito.matrix_props import has_same_dimension mixed = [np.array([1, 2, 3]), np.array([[1, 0], [0, 1]])] print(has_same_dimension(mixed)) ``` :raises ValueError: If the input list is empty. :param items: A list containing vectors or matrices. Vectors are represented as 1D numpy arrays, and matrices are :param represented as 2D numpy arrays.: :returns: Returns `True` if all items in the list have the same dimension, `False` otherwise.