<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">"""This module provides functions to manipulate matrices and vectors.

This program uses lists to represent vectors, i.e.,
    my_vector = [1,2,3,4] # 4D vector

This program uses lists of lists to represent matrices, i.e.,
    my_matrix = [ [2,3], 
                  [1,4] ]
The inner lists correspond to rows.

# transpose
# multiply (matrix matrix, matrix vector, vector vector, dot product)
matrix vector
dot product
addition
# subtraction
"""

def addition_vec_2(a, b):
    """Add two 2d vectors and return the sum.

    :param a: The first vector.
    :param b: The second vector.
    :return: The sum of a and b.
    """
    return [ a[0] + b[0], a[1] + b[1] ]

def dot_vec_2(a, b):
    """Compute dot product of two 2d vectors.

    :param a: The first vector.
    :param b: The second vector.
    :return: The dot product of a and b.
    """
    return a[0]*b[0] + a[1]*b[1]

def matrix_vec_2(matrix, vector):
    """Compute product of 2x2 matrix and 2d vector.

    :param matrix: The matrix.
    :param vector: The vector.
    :return: Matrix product, i.e., matrix * vector.
    """
    return [ dot_vec_2(matrix[0], vector), dot_vec_2(matrix[1], vector) ]

def addition_vec_n(a, b):
    """Add two nd vectors and return the sum.

    :param a: The first vector.
    :param b: The second vector.
    :return: The sum of a and b.
    """
    pass


def dot_vec_n(a, b):
    """Compute dot product of two nd vectors.

    :param a: The first vector.
    :param b: The second vector.
    :return: The dot product of a and b.
    """
    pass

def matrix_vec_n(matrix, vector):
    """Compute product of mxn matrix and nd vector.

    :param matrix: The matrix (mxn).
    :param vector: The vector (n).
    :return: Matrix product, i.e., matrix * vector.
    """
    pass


if __name__ == '__main__':
    # test 2D functions
    print(addition_vec_2( [1, 2], [2, 3]))
    print(dot_vec_2( [1, 2], [2, 3]))
    print(matrix_vec_2( [[1, 2], [2, 3]], [3,6]))</pre></body></html>