Linear-algebra toolkit: vector/matrix-space axioms, subspace checks, basis, norm, dimension, rank-nullity.
Project description
linalgkit-lab2
A clean, well-tested Python library for verifying fundamental linear-algebra properties — vector-space axioms, subspace conditions, basis extraction, norms, dimension, and the rank–nullity theorem.
Installation
pip install linalgkit-lab2
Quick Start
from linalgkit_lab2 import (
check_vector_space,
check_matrix_space,
check_subspace,
find_basis,
find_norm,
find_dimension,
verify_rank_nullity,
print_results,
)
# --- Vector space ---
result = check_vector_space([1, 2], [3, 4], a=2, b=3, zero_vector=[0, 0])
print_results("Vector Space", result)
# --- Matrix space ---
result = check_matrix_space([[1,2],[3,4]], [[5,6],[7,8]], a=2, b=3,
zero_matrix=[[0,0],[0,0]])
print_results("Matrix Space", result)
# --- Subspace ---
result = check_subspace([1, 2], [3, 4], a=2, b=3, zero_vector=[0, 0])
print_results("Subspace", result)
# --- Basis ---
basis = find_basis([[1,0,0],[0,1,0],[1,1,0]])
print("Basis:\n", basis)
# --- Norm ---
print("Norm:", find_norm([3, 4])) # → 5.0
# --- Dimension ---
print("Dim:", find_dimension([[1,0],[0,1],[1,1]])) # → 2
# --- Rank-nullity ---
print(verify_rank_nullity([[1,2,3],[4,5,6]]))
API Reference
check_vector_space(v1, v2, a, b, zero_vector) → dict
Returns a dict mapping each of the 10 standard vector-space axioms to
True / False.
check_matrix_space(A, B, a, b, zero_matrix) → dict
Same as above but for 2-D matrices.
check_subspace(v1, v2, a, b, zero_vector) → dict
Checks the 3 subspace conditions plus an "Is Subspace" verdict key.
| Key | What is checked |
|---|---|
"Contains zero vector" |
zero_vector is all-zeros and acts as additive identity |
"Closed under addition" |
v1 + v2 has correct shape, no NaN/Inf |
"Closed under scalar multiplication" |
a*v1, b*v2 have correct shape, no NaN/Inf |
"Is Subspace" |
All three above pass |
find_basis(vectors) → ndarray
Greedy basis extraction. vectors is a 2-D array whose rows are vectors.
find_norm(vector) → float
Euclidean (L2) norm of a 1-D vector.
find_dimension(vectors) → int
Dimension of the span of the given row vectors (= matrix rank).
verify_rank_nullity(matrix) → dict
Returns {"rank", "nullity", "n_columns", "theorem_holds"}.
print_results(label, results)
Pretty-prints any result dict from the functions above.
Error Handling
All functions raise:
TypeError— non-numeric inputs or non-real scalarsValueError— wrong dimensionality, empty inputs, shape mismatches, NaN/Inf values
License
MIT © manohar100323
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file linalgkit_lab2-1.0.0.tar.gz.
File metadata
- Download URL: linalgkit_lab2-1.0.0.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02d44cb14c17702e458d02f0305e74040c9766c0160ac2ada627c448b0599460
|
|
| MD5 |
3e6841ab0a3a77c9755983b7a753db08
|
|
| BLAKE2b-256 |
ad010f8bff63dbd081eae6354a2ee4a59b35b3af83f7a361aaa297077bc6de6d
|