copapy.matrix#

class copapy.matrix(values)#

Bases: Generic[TNum]

Mathematical matrix class supporting basic operations and interactions with values.

Create a matrix with given values.

Parameters:

values (Iterable[Iterable[TypeVar(TNum, int, float) | value[TypeVar(TNum, int, float)]]] | vector[TypeVar(TNum, int, float)]) – iterable of iterable of constant values

property T: matrix[TNum]#
col(index)#

Get a column as a vector.

Return type:

vector[TypeVar(TNum, int, float)]

homogenize()#

Convert all elements to copapy values if any element is a copapy value.

Return type:

matrix[TypeVar(TNum, int, float)]

map(func)#

Applies a function to each element of the matrix and returns a new matrix.

Return type:

matrix[TypeVar(U, int, float)]

row(index)#

Get a row as a vector.

Return type:

vector[TypeVar(TNum, int, float)]

property shape: tuple[int, int]#

Return the shape of the matrix as (rows, cols).

sum()#

Calculate the sum of all elements.

Return type:

Any

trace()#

Calculate the trace (sum of diagonal elements).

Return type:

Any

transpose()#

Return the transpose of the matrix.

Return type:

matrix[TypeVar(TNum, int, float)]