MCPcopy Create free account
hub / github.com/Axect/Peroxide / complex_inv_u

Function complex_inv_u

src/complex/matrix.rs:2498–2527  ·  view source on GitHub ↗

Inverse of upper triangular matrix # Examples ```rust #[macro_use] extern crate peroxide; use peroxide::fuga::*; use peroxide::complex::matrix::*; let a = ml_cmatrix("2.0+2.0i 2.0+2.0i; 0.0+0.0i 1.0+1.0i"); let b = cmatrix(vec![C64::new(0.25f64, -0.25f64), C64::new(-0.5f64, 0.5f64), C64::new(0.0f64, 0.0f64), C64::new(0.5f64, -0.5f64)], 2, 2, Row ); assert_eq!(complex_inv_u(a), b); ```

(u: ComplexMatrix)

Source from the content-addressed store, hash-verified

2496/// assert_eq!(complex_inv_u(a), b);
2497/// ```
2498pub fn complex_inv_u(u: ComplexMatrix) -> ComplexMatrix {
2499 let mut w = u.clone();
2500
2501 match u.row {
2502 1 => {
2503 w[(0, 0)] = 1f64 / w[(0, 0)];
2504 w
2505 }
2506 2 => {
2507 let a = w[(0, 0)];
2508 let b = w[(0, 1)];
2509 let c = w[(1, 1)];
2510 let d = a * c;
2511
2512 w[(0, 0)] = 1f64 / a;
2513 w[(0, 1)] = -b / d;
2514 w[(1, 1)] = 1f64 / c;
2515 w
2516 }
2517 _ => {
2518 let (u1, u2, u3, u4) = u.block();
2519 let m1 = complex_inv_u(u1);
2520 let m3 = u3;
2521 let m4 = complex_inv_u(u4);
2522 let m2 = -(m1.clone() * u2 * m4.clone());
2523
2524 complex_combine(m1, m2, m3, m4)
2525 }
2526 }
2527}
2528
2529/// Matrix multiply back-ends
2530pub fn cmatmul(a: &ComplexMatrix, b: &ComplexMatrix) -> ComplexMatrix {

Callers 1

invMethod · 0.85

Calls 2

complex_combineFunction · 0.85
blockMethod · 0.45

Tested by

no test coverage detected