Repository for mathematical codes ( 2 variants - optimized, non-optimized )
- Overview (NON OPTIMIZED)
- Optimized Experimental (build)
- Overview (OPTIMIZED)
- Table of Contents (OPTIMIZED) still in development
- API
- Last Update
optimized.lineq.lineq_sub
.- add functions for linear equations systems
iter_solve_simple(matrix, vector, eps=1e-12, max_iter=1000, eigen_max_iter=1000, eigen_eps=1e-12)
:Simple iteration to solve a system of linear equations. Need positive definite and symmetric matrix.
- add functions for linear equations systems
Sylvester's criterion states that a
- the upper left 1-by-1 corner of
$M$ , - the upper left 2-by-2 corner of
$M$ , - the upper left 3-by-3 corner of
$M$ , $\quad \vdots$ -
$M$ itself.
In other words, all of the leading principal minors must be positive. By using appropriate permutations of rows and columns of
Important
- Disabled GIL for lowlevel functions.
- Be careful.
- Fixed memory leak in
optimized.lineq.lineq_sub
. - Fixed memory leak in
optimized.lineq.matrix_methods
. - Fixed
random_double
function inoptimized.lineq.matrix_methods
. -> now work correctly. - Fixed
random
inoptimized.lineq.matrix_methods.Module.module
MatrixMethods
class -> now work correctly. - Fixed variables definitions in
.pyx
files inoptimized.lineq.matrix_methods
,optimized.lineq.lineq_sub
,optimized.lineq.generator
,optimized.lineq.checker
.
-
optimized.lineq.lineq_sub
.- development started.
- add functions for linear equations systems:
-
solve_tridiagonal(matrix, vector)
:Solve a system of linear equations with tridiagonal matrix
Matrix must be tridiagonal:
$a_{11}$ $b_{12}$ 0 ... ... ... 0 $c_{21}$ $a_{22}$ $b_{23}$ ... ... ... 0 0 $c_{32}$ $a_{33}$ $b_{34}$ ... ... 0 ... 0 $c_{43}$ $a_{44}$ $b_{45}$ ... 0 ... ... ... ... ... ... 0 0 0 ... 0 $c_{n-1 \ n-2}$ $a_{n-1 \ n-1}$ $b_{n-1 \ n}$ 0 0 ... 0 0 $c_{n \ n-1}$ $a_{nn}$ -
solve_gauss(matrix, vector)
:Solve a system of linear equations with gauss method
-
solve_lu(matrix, vector)
:Solve a system of linear equations with LU method
-
run_api.py
updated.- Argparser added.
Tip
usage: optimized_api [-h] [-r]
optimized_api FLASK app
options:
-h, --help show this help message and exit
-r, --rebuild, -re Rebuild optimized_api
- GUI updated.
- Add dark mode.
- Add new
accordion
fields. - Add new
input
fields. - Add
result copy
button. - Add
global_info
andglobal_info.GlobalRet
return fields. - Add new styles to
statics
. - Add new
.js
files tostatics
.
Note
api_key in config.ini does not work.
- Enjoy 😸
-
Started creating GUI for API. Now you can use only lineq.generator GUI.
-
GUI LOCAL link -> localhost:8000/main (localhost:8000/ works too (without GUI)) after running
run_api.py
. -
Examples -> images.api_gui
- optimized.lineq.matrix_methods.python_interface-API is ready for 100% use.
- optimized.lineq.generator.python_interface-API is ready for 100% use.
- optimized.lineq.checker.python_interface-API is ready for 100% use.
- all API functions you can see in Current Api Support
-
Continued working on API after a break. API for generator, checker will be finished soon. Then I will continue optimizing the rest of the modules, namely lineq.lineq, ( lineq.Utils.Prettier, lineq.Utils.S_R may not be changed, but will be moved to a new module without optimization, or will be completely removed ). lineq.Utils.timer will be definitely removed.
-
optimized.lineq.matrix_methods.python_interface API
is ready for 100% use.- all API functions you can see in Current Api Support
-
Fixed a bug in the
rand
function of theoptimized/lineq/matrix_methods/lowlevel/mm.c
file (file). The function was returning extremely large numbers instead of a random number within the specified range. -
Updated the docstrings in the
optimized.lineq.generator.python_interface
module. optimized.lineq.generator.python_interface -
Added new information to the
API data.json
file. API-DATA. -
Added new API functions. Check the Current Api Support for all functions.
-
New API return system -> Added in each return global_info -> request.headers, host, url, etc...
- some screenshots
Add new API functions Current Api Support Check usage instructions in API-DATA or just run run_api.py and check home page. All info in:
Started developing the API for the optimized codes. Already ready for use determinant function API. Info in data. To run the API, run run_api. Local API is available at http://127.0.0.1:8000/.
-
Use examples:
-
browser list mode
(img1)
:http://127.0.0.1:5000/det/?type=list&matrix=[[1,2,3],[4,5,6],[7,1.2,7]]
-
browser str mode
(img2)
:http://127.0.0.1:5000/det/?matrix=1%202%203\n4%205%206\n7%208%209
-
curl list mode
(img3)
:
curl `http://127.0.0.1:5000/det/?type=list&matrix=%5B%5B1%2C2%2C3%5D%2C%5B4%2C5%2C6%5D%2C%5B7%2C1.2%2C7%5D%5D`
-
Rewritted build.py script.
New Build System
- Build Management: Manages cleaning up previous builds, compiling modules, and organizing build artifacts.
- Dependency Check: Automatically checks for and installs necessary dependencies such as Cython.
- Configuration Loading: Loads build settings and module configurations from the file cfg. If the file does not exist, a default configuration is created.
- Build Result Visualization: Displays a tree structure with icons indicating the success or failure of each module.
- Automated Testing: Runs tests on successfully built libraries to ensure their correctness.
I have rewritten the Checker
module and updated matrix filling in matrix_methods
module.
-
Introduced the Checker class for matrix validation
- Methods included:
- diagonal_domination(matrix) -> bool: Checks matrix diagonal domination
- symmetric_check(matrix) -> bool: Checks matrix symmetry
- sylvesters_criterion(matrix) -> bool: Checks matrix against Sylvester's criterion
- Methods included:
-
I also updated the matrix filling in both the
matrix_methods
andChecker
modules. I replaced the cycle with a for loop and usedmemset(*, 0, sizeof(*))
to set the matrix elements to zero.
The updated Python interface for optimized.lineq.matrix_methods is now ready for use. It is optimized for 100% efficiency.
The new code is significantly faster, with an average improvement of more than 50 times.
The Generator has also been rewritten.
In the lineq/LinEq/Utils/Matrix_methods.py
file, the determinant
function has been fixed.
I have started rewriting the code. In the Optimized-Experimental
directory, you will find experimental versions of the codes with optimizations. These versions are about 50 times faster. However, you need the Cython library for this!
I have rewritten the lineq.matrix_methods
module in the optimized/lineq/matrix_methods/
directory.
Here are the links to the source code:
- The C code can be found in the code file.
- The Python code is available in the code file. This file is ready for 50% use. All functions work if imported from the
build.matrix_methods
file. However, in the Python file, only 50% of the code is implemented.
The source codes are located in the optimized/{module_name}/{util_name}/lowlevel
directory, where {module_name} represents the module name and {util_name} represents the utility name.
To build the optimized version, run the build.bat
[DELETED, use python script]
UPD 02.08.2024 build.py
file from the optimized
directory. Please note that this feature does not work with older versions of the project. Wait for a new version to be ready with all optimizations implemented.