Skip to main content

A simple Python library for matrix multiplication

Project description

ALUMatrixMath

A simple Python library for matrix multiplication with proper validation.

Installation

pip install alumathgroup3

QuickStart

from alumathgroup3 import Matrix, matrix_multiply

# Create matrices
A = Matrix([[1, 2, 3], [4, 5, 6]])      # 2×3 matrix  
B = Matrix([[7, 8], [9, 10], [11, 12]]) # 3×2 matrix

# Multiply matrices
result = A * B
print(result)
print(f"Result shape: {result.shape()}")  # (2, 2)

Features

✅ Matrix multiplication with dimension validation ✅ Clear error messages for incompatible matrices ✅ Clean display formatting ✅ Support for different matrix dimensions

More example using alumath

    from alumath import Matrix, matrix_multiply

    # Example 1: Compatible matrices
    print("Example 1: 2x3 × 3x2 matrices")
    m1 = Matrix([[1, 2, 3], [4, 5, 6]])
    m2 = Matrix([[7, 8], [9, 10], [11, 12]])

    print(f"Matrix A {m1.shape()}:")
    print(m1)
    print(f"\nMatrix B {m2.shape()}:")
    print(m2)

    result = m1 * m2
    print(f"\nA × B = {result.shape()}:")
    print(result)
    print()

    # Example 2: Different dimensions
    print("Example 2: 3x2 × 2x4 matrices")
    m3 = Matrix([[1, 2], [3, 4], [5, 6]])
    m4 = Matrix([[1, 0, 1, 2], [2, 1, 0, 1]])

    print(f"Matrix C {m3.shape()}:")
    print(m3)
    print(f"\nMatrix D {m4.shape()}:")
    print(m4)

    result2 = matrix_multiply(m3, m4)
    print(f"\nC × D = {result2.shape()}:")
    print(result2)
    print()

    # Example 3: Error case
    print("Example 3: Incompatible matrices (will show error)")
    try:
        m5 = Matrix([[1, 2]])  # 1x2
        m6 = Matrix([[1], [2], [3]])  # 3x1
        print(f"Trying to multiply {m5.shape()} × {m6.shape()}")
        result3 = m5 * m6
    except ValueError as e:
        print(f"Error: {e}")

License

MIT License

LICENSE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

alumathgroup3-1.0.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

alumathgroup3-1.0.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file alumathgroup3-1.0.0.tar.gz.

File metadata

  • Download URL: alumathgroup3-1.0.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for alumathgroup3-1.0.0.tar.gz
Algorithm Hash digest
SHA256 4bcadc08dd4b70efa2af9a05cd558e69f059e15b8834bc045691cea571957c3b
MD5 f4ecbdba90224db38b6a2e2b9d35961d
BLAKE2b-256 3cb90584df91c3ef38adbd5e47c9d0e1ba139bdd1ce870f0b9da0d74e82cc03d

See more details on using hashes here.

File details

Details for the file alumathgroup3-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: alumathgroup3-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for alumathgroup3-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3bea477bd6fea453d7e51e4bba55b5d9a94605f81effe97b8e30c1aaa79aacde
MD5 e3843d590f72c55013fe770470839e6f
BLAKE2b-256 8d537756637c50ccd3efd8132dbb4cd380d090334efe814ebab51ac7f02b17f7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page