@@ -385,6 +385,106 @@ <h1>PyClassify Module Documentation<a class="headerlink" href="#pyclassify-modul
385
385
</ section >
386
386
< section id ="submodule-helpers-secular ">
387
387
< h1 > Submodule: helpers_secular< a class ="headerlink " href ="#submodule-helpers-secular " title ="Link to this heading "> </ a > </ h1 >
388
+ < dl class ="py function " id ="module-pyclassify.zero_finder ">
389
+ < dt class ="sig sig-object py " id ="pyclassify.zero_finder.bisection ">
390
+ < span class ="sig-prename descclassname "> < span class ="pre "> pyclassify.zero_finder.</ span > </ span > < span class ="sig-name descname "> < span class ="pre "> bisection</ span > </ span > < span class ="sig-paren "> (</ span > < em class ="sig-param "> < span class ="n "> < span class ="pre "> f</ span > </ span > </ em > , < em class ="sig-param "> < span class ="n "> < span class ="pre "> a</ span > </ span > </ em > , < em class ="sig-param "> < span class ="n "> < span class ="pre "> b</ span > </ span > </ em > , < em class ="sig-param "> < span class ="n "> < span class ="pre "> tol</ span > </ span > </ em > , < em class ="sig-param "> < span class ="n "> < span class ="pre "> max_iter</ span > </ span > </ em > < span class ="sig-paren "> )</ span > < a class ="headerlink " href ="#pyclassify.zero_finder.bisection " title ="Link to this definition "> </ a > </ dt >
391
+ < dd > < p > Standard bisection method to find a root of the function f in the interval [a, b].</ p >
392
+ < p > This implementation is used in < cite > compute_outer_zero</ cite > to locate the outer eigenvalue.</ p >
393
+ < p > Parameters:
394
+ f (callable): A continuous function for which f(a) * f(b) < 0.
395
+ a (float): Left endpoint of the interval.
396
+ b (float): Right endpoint of the interval.
397
+ tol (float): Tolerance for convergence. The method stops when the interval is smaller than tol or when f(c) is sufficiently small.
398
+ max_iter (int): Maximum number of iterations before stopping.</ p >
399
+ < p > Returns:
400
+ float: Approximation of the root within the specified tolerance.</ p >
401
+ </ dd > </ dl >
402
+
403
+ < dl class ="py function ">
404
+ < dt class ="sig sig-object py " id ="pyclassify.zero_finder.compute_Psi ">
405
+ < span class ="sig-prename descclassname "> < span class ="pre "> pyclassify.zero_finder.</ span > </ span > < span class ="sig-name descname "> < span class ="pre "> compute_Psi</ span > </ span > < span class ="sig-paren "> (</ span > < em class ="sig-param "> < span class ="n "> < span class ="pre "> i</ span > </ span > </ em > , < em class ="sig-param "> < span class ="n "> < span class ="pre "> v</ span > </ span > </ em > , < em class ="sig-param "> < span class ="n "> < span class ="pre "> d</ span > </ span > </ em > , < em class ="sig-param "> < span class ="n "> < span class ="pre "> rho</ span > </ span > </ em > < span class ="sig-paren "> )</ span > < a class ="headerlink " href ="#pyclassify.zero_finder.compute_Psi " title ="Link to this definition "> </ a > </ dt >
406
+ < dd > < p > This function computes the functions Psi1, and Psi2 and their derivative, accordingly to the equation described
407
+ by the notes chapter 5-6 contained in the shared folders.
408
+ The equation utilized are the equation 5.27, 5.25 and 5.29.
409
+ d is assumed to be already a vector whose elements are already sorted.
410
+ Inputs:</ p >
411
+ < blockquote >
412
+ < div > < p > -i: It is the index of the i-th smallest eigenvalue that is being computed
413
+ -v: Rank one correction
414
+ -d: Diagonal element of the Diagonal matrix described in equation 5.7
415
+ -rho: off diagonal element used for the splitting.</ p >
416
+ </ div > </ blockquote >
417
+ < dl class ="simple ">
418
+ < dt > Output:</ dt > < dd > < p > Psi1: Lamoba function that returns the value of Psi1 at the point x
419
+ Psi2: Lamoba function that returns the value of Psi2 at the point x
420
+ dPsi1: Lamoba function that returns the value of the derivative dPsi1/dx at the point x
421
+ dPsi2: Lamoba function that returns the value of the derivative dPsi2/dx at the point x</ p >
422
+ </ dd >
423
+ </ dl >
424
+ </ dd > </ dl >
425
+
426
+ < dl class ="py function ">
427
+ < dt class ="sig sig-object py " id ="pyclassify.zero_finder.compute_outer_zero ">
428
+ < span class ="sig-prename descclassname "> < span class ="pre "> pyclassify.zero_finder.</ span > </ span > < span class ="sig-name descname "> < span class ="pre "> compute_outer_zero</ span > </ span > < span class ="sig-paren "> (</ span > < em class ="sig-param "> < span class ="n "> < span class ="pre "> v</ span > </ span > </ em > , < em class ="sig-param "> < span class ="n "> < span class ="pre "> d</ span > </ span > </ em > , < em class ="sig-param "> < span class ="n "> < span class ="pre "> rho</ span > </ span > </ em > , < em class ="sig-param "> < span class ="n "> < span class ="pre "> interval_end</ span > </ span > </ em > , < em class ="sig-param "> < span class ="n "> < span class ="pre "> tol</ span > </ span > < span class ="o "> < span class ="pre "> =</ span > </ span > < span class ="default_value "> < span class ="pre "> 1e-12</ span > </ span > </ em > , < em class ="sig-param "> < span class ="n "> < span class ="pre "> max_iter</ span > </ span > < span class ="o "> < span class ="pre "> =</ span > </ span > < span class ="default_value "> < span class ="pre "> 1000</ span > </ span > </ em > < span class ="sig-paren "> )</ span > < a class ="headerlink " href ="#pyclassify.zero_finder.compute_outer_zero " title ="Link to this definition "> </ a > </ dt >
429
+ < dd > < p > Computes the outer eigenvalue (lambda[0] if rho < 0, lambda[n-1] if rho > 0) of a rank-one modified diagonal matrix.</ p >
430
+ < dl class ="simple ">
431
+ < dt > The secular function behaves such that:</ dt > < dd > < ul class ="simple ">
432
+ < li > < p > If rho > 0, the outer eigenvalue lies in (d[n-1], infty), and f is increasing in this interval.</ p > </ li >
433
+ < li > < p > If rho < 0, the outer eigenvalue lies in (-infty, d[0]), and f is decreasing in this interval.</ p > </ li >
434
+ </ ul >
435
+ </ dd >
436
+ </ dl >
437
+ < p > This function:
438
+ 1. Determines the direction to search based on the sign of rho.
439
+ 2. Finds an upper bound (or lower bound for rho < 0) where the secular function changes sign.
440
+ 3. Uses the bisection method to find the root in the determined interval.</ p >
441
+ < p > Returns:
442
+ float: Approximation of the outer eigenvalue.</ p >
443
+ </ dd > </ dl >
444
+
445
+ < dl class ="py function ">
446
+ < dt class ="sig sig-object py " id ="pyclassify.zero_finder.find_root ">
447
+ < span class ="sig-prename descclassname "> < span class ="pre "> pyclassify.zero_finder.</ span > </ span > < span class ="sig-name descname "> < span class ="pre "> find_root</ span > </ span > < span class ="sig-paren "> (</ span > < em class ="sig-param "> < span class ="n "> < span class ="pre "> i</ span > </ span > </ em > , < em class ="sig-param "> < span class ="n "> < span class ="pre "> left_center</ span > </ span > </ em > , < em class ="sig-param "> < span class ="n "> < span class ="pre "> v</ span > </ span > </ em > , < em class ="sig-param "> < span class ="n "> < span class ="pre "> d</ span > </ span > </ em > , < em class ="sig-param "> < span class ="n "> < span class ="pre "> rho</ span > </ span > </ em > , < em class ="sig-param "> < span class ="n "> < span class ="pre "> lam_0</ span > </ span > </ em > , < em class ="sig-param "> < span class ="n "> < span class ="pre "> tol</ span > </ span > < span class ="o "> < span class ="pre "> =</ span > </ span > < span class ="default_value "> < span class ="pre "> 1e-15</ span > </ span > </ em > , < em class ="sig-param "> < span class ="n "> < span class ="pre "> maxiter</ span > </ span > < span class ="o "> < span class ="pre "> =</ span > </ span > < span class ="default_value "> < span class ="pre "> 100</ span > </ span > </ em > < span class ="sig-paren "> )</ span > < a class ="headerlink " href ="#pyclassify.zero_finder.find_root " title ="Link to this definition "> </ a > </ dt >
448
+ < dd > < p > Find the roots of the secular equation contained inside the interval min(d)=d[0] and max(d)=d[-1].
449
+ Inputs:</ p >
450
+ < blockquote >
451
+ < div > < p > -i: It is the index of the i-th smallest eigenvalue that is being computed
452
+ -left_center: boolen variable. True if the left extreme is the center od the new - shifted reference system.
453
+ -v: Rank one correction
454
+ -d: Diagonal element of the Diagonal matrix described in equation 5.7
455
+ -rho: off diagonal element used for the splitting.
456
+ -lam_0: initial guess of the i-th root of the secular equation
457
+ -tol: absolute or relative tollerence. For lamba value below 1e-6, tols refers to the absolute tolerance (avoiding division by zero). For</ p >
458
+ < blockquote >
459
+ < div > < p > lambda value greater than 1e-6, tol is the absolute tolerance.</ p >
460
+ </ div > </ blockquote >
461
+ < p > -maxiter: Maximum number of iteration of the iterative solver.</ p >
462
+ </ div > </ blockquote >
463
+ < dl class ="simple ">
464
+ < dt > Outputs:</ dt > < dd > < p > -shift + lam_0: i-th smallest eigenvalue
465
+ -lam_0: difference between the i-th eigenvalue and the nearest diagonal element.</ p >
466
+ </ dd >
467
+ </ dl >
468
+ </ dd > </ dl >
469
+
470
+ < dl class ="py function ">
471
+ < dt class ="sig sig-object py " id ="pyclassify.zero_finder.secular_solver_python ">
472
+ < span class ="sig-prename descclassname "> < span class ="pre "> pyclassify.zero_finder.</ span > </ span > < span class ="sig-name descname "> < span class ="pre "> secular_solver_python</ span > </ span > < span class ="sig-paren "> (</ span > < em class ="sig-param "> < span class ="n "> < span class ="pre "> rho</ span > </ span > </ em > , < em class ="sig-param "> < span class ="n "> < span class ="pre "> d</ span > </ span > </ em > , < em class ="sig-param "> < span class ="n "> < span class ="pre "> v</ span > </ span > </ em > < span class ="sig-paren "> )</ span > < a class ="headerlink " href ="#pyclassify.zero_finder.secular_solver_python " title ="Link to this definition "> </ a > </ dt >
473
+ < dd > < p > Computes all the roots of the secular equation.
474
+ Inputs:</ p >
475
+ < blockquote >
476
+ < div > < p > -v: Rank one correction
477
+ -d: Diagonal element of the Diagonal matrix described in equation 5.7
478
+ -rho: off diagonal element used for the splitting.</ p >
479
+ </ div > </ blockquote >
480
+ < dl class ="simple ">
481
+ < dt > Outputs:</ dt > < dd > < p > -eig_val: vector of the roots of the secular equation
482
+ -index: vector of the index of the center of the shifted frame of reference associated to the i-ith root
483
+ -delta: vector of difference between the i-th eigenvalue and the nearest diagonal element.</ p >
484
+ </ dd >
485
+ </ dl >
486
+ </ dd > </ dl >
487
+
388
488
</ section >
389
489
390
490
@@ -434,7 +534,14 @@ <h1 class="logo"><a href="index.html">final_project</a></h1>
434
534
< li class ="toctree-l2 "> < a class ="reference internal " href ="#pyclassify.utils.read_config "> < code class ="docutils literal notranslate "> < span class ="pre "> read_config()</ span > </ code > </ a > </ li >
435
535
</ ul >
436
536
</ li >
437
- < li class ="toctree-l1 "> < a class ="reference internal " href ="#submodule-helpers-secular "> Submodule: helpers_secular</ a > </ li >
537
+ < li class ="toctree-l1 "> < a class ="reference internal " href ="#submodule-helpers-secular "> Submodule: helpers_secular</ a > < ul >
538
+ < li class ="toctree-l2 "> < a class ="reference internal " href ="#pyclassify.zero_finder.bisection "> < code class ="docutils literal notranslate "> < span class ="pre "> bisection()</ span > </ code > </ a > </ li >
539
+ < li class ="toctree-l2 "> < a class ="reference internal " href ="#pyclassify.zero_finder.compute_Psi "> < code class ="docutils literal notranslate "> < span class ="pre "> compute_Psi()</ span > </ code > </ a > </ li >
540
+ < li class ="toctree-l2 "> < a class ="reference internal " href ="#pyclassify.zero_finder.compute_outer_zero "> < code class ="docutils literal notranslate "> < span class ="pre "> compute_outer_zero()</ span > </ code > </ a > </ li >
541
+ < li class ="toctree-l2 "> < a class ="reference internal " href ="#pyclassify.zero_finder.find_root "> < code class ="docutils literal notranslate "> < span class ="pre "> find_root()</ span > </ code > </ a > </ li >
542
+ < li class ="toctree-l2 "> < a class ="reference internal " href ="#pyclassify.zero_finder.secular_solver_python "> < code class ="docutils literal notranslate "> < span class ="pre "> secular_solver_python()</ span > </ code > </ a > </ li >
543
+ </ ul >
544
+ </ li >
438
545
</ ul >
439
546
440
547
< div class ="relations ">
0 commit comments