# matrix.py
from pyvelora.core.array_base import ArrayBase
import numpy as np


class Matrix(ArrayBase):

    def __init__(self, data):
        super().__init__(data)

        if self.ndim != 2:
            raise ValueError("Matrix must be 2D")

    def det(self):
        return np.linalg.det(self.data)

    def inv(self):
        return Matrix(np.linalg.inv(self.data))
    
    def transpose(self):
        return Matrix(self.data.T)
    
    def trace(self):
        return np.trace(self.data)
    
    def rank(self):
        return np.linalg.matrix_rank(self.data)
    
    def svd(self):
        return np.linalg.svd(self.data)
    
    def eigen_values(self):
        return np.linalg.eigvals(self.data)
    
    def eigen_vectors(self):
        return Matrix(np.linalg.eig(self.data)[1])