Skip to content

Remove separate directory for gaussian_elimination_pivoting.py #11445

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DIRECTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,7 @@
* [Lu Decomposition](linear_algebra/lu_decomposition.py)
* Src
* [Conjugate Gradient](linear_algebra/src/conjugate_gradient.py)
* Gaussian Elimination Pivoting
* [Gaussian Elimination Pivoting](linear_algebra/src/gaussian_elimination_pivoting/gaussian_elimination_pivoting.py)
* [Gaussian Elimination Pivoting](linear_algebra/src/gaussian_elimination_pivoting.py)
* [Lib](linear_algebra/src/lib.py)
* [Polynom For Points](linear_algebra/src/polynom_for_points.py)
* [Power Iteration](linear_algebra/src/power_iteration.py)
Expand Down Expand Up @@ -863,6 +862,7 @@
* [Newtons Second Law Of Motion](physics/newtons_second_law_of_motion.py)
* [Photoelectric Effect](physics/photoelectric_effect.py)
* [Potential Energy](physics/potential_energy.py)
* [Rainfall Intensity](physics/rainfall_intensity.py)
* [Reynolds Number](physics/reynolds_number.py)
* [Rms Speed Of Molecule](physics/rms_speed_of_molecule.py)
* [Shear Stress](physics/shear_stress.py)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
import numpy as np

matrix = np.array(
[
[5.0, -5.0, -3.0, 4.0, -11.0],
[1.0, -4.0, 6.0, -4.0, -10.0],
[-2.0, -5.0, 4.0, -5.0, -12.0],
[-3.0, -3.0, 5.0, -5.0, 8.0],
],
dtype=float,
)


def solve_linear_system(matrix: np.ndarray) -> np.ndarray:
"""
Expand Down Expand Up @@ -87,15 +77,18 @@ def solve_linear_system(matrix: np.ndarray) -> np.ndarray:

if __name__ == "__main__":
from doctest import testmod
from pathlib import Path

testmod()
file_path = Path(__file__).parent / "matrix.txt"
try:
matrix = np.loadtxt(file_path)
except FileNotFoundError:
print(f"Error: {file_path} not found. Using default matrix instead.")

# Example usage:
print(f"Matrix:\n{matrix}")
print(f"{solve_linear_system(matrix) = }")

example_matrix = np.array(
[
[5.0, -5.0, -3.0, 4.0, -11.0],
[1.0, -4.0, 6.0, -4.0, -10.0],
[-2.0, -5.0, 4.0, -5.0, -12.0],
[-3.0, -3.0, 5.0, -5.0, 8.0],
],
dtype=float,
)

print(f"Matrix:\n{example_matrix}")
print(f"{solve_linear_system(example_matrix) = }")
Empty file.
4 changes: 0 additions & 4 deletions linear_algebra/src/gaussian_elimination_pivoting/matrix.txt

This file was deleted.