use num_complex::Complex64; use umfpack::prelude::*; #[allow(non_snake_case)] fn main() { let n: i32 = 162; let Ap: Vec = get_Ap(); let Ai: Vec = get_Ai(); let Ax: Vec = get_Ax(); // real let Az: Vec = Ax.into_iter().map(|re| Complex64 { re, im: 0.0 }).collect(); let Bz: Vec = (0..n) .map(|i| Complex64 { re: i as f64, im: (n - i) as f64, }) .collect(); let mut Xz: Vec = (0..n).map(|_| Complex64 { re: 0.0, im: 0.0 }).collect(); let mut info = Info::new(); let control = Control::new(); let mut symbolic = Symbolic::new(); umfpack_zi_symbolic( n, n, &Ap, &Ai, &Az, &mut symbolic, Some(&control), Some(&mut info), ); println!("symbolic walltime: {}", info.umfpack_symbolic_walltime()); let mut numeric = Numeric::new(); umfpack_zi_numeric( &Ap, &Ai, &Az, &symbolic, &mut numeric, Some(&control), Some(&mut info), ); println!("numeric walltime: {}", info.umfpack_numeric_walltime()); umfpack_zi_solve( UMFPACK::A, &Ap, &Ai, &Az, &mut Xz, &Bz, &numeric, Some(&control), Some(&mut info), ); println!("solve walltime: {}", info.umfpack_solve_walltime()); for i in 0..10 { println!( "x [{}] = {:.1}{}{:.1}j", i, Xz[i].re, if Xz[i].im < 0.0 { "" } else { "+" }, Xz[i].im ); } println!("..."); } #[allow(non_snake_case)] fn get_Ap() -> Vec { vec![ 0, 3, 7, 11, 15, 19, 23, 27, 30, 33, 36, 40, 44, 48, 52, 56, 60, 63, 66, 70, 75, 82, 89, 96, 104, 109, 113, 117, 123, 132, 141, 150, 159, 168, 177, 185, 191, 197, 206, 215, 224, 233, 242, 251, 259, 265, 271, 280, 289, 296, 303, 311, 320, 328, 334, 340, 349, 358, 363, 368, 375, 384, 392, 398, 404, 413, 422, 431, 440, 449, 458, 466, 472, 476, 482, 488, 494, 500, 506, 512, 517, 521, 524, 527, 531, 535, 539, 543, 547, 551, 554, 558, 562, 567, 574, 581, 588, 593, 598, 602, 607, 613, 620, 627, 636, 643, 650, 657, 662, 668, 676, 685, 692, 701, 708, 717, 726, 732, 738, 746, 755, 762, 771, 778, 787, 796, 802, 808, 816, 825, 833, 842, 850, 859, 868, 874, 880, 888, 897, 904, 911, 918, 927, 936, 942, 947, 954, 962, 970, 978, 986, 994, 1002, 1007, 1011, 1016, 1022, 1028, 1034, 1040, 1046, 1052, 1056, ] } #[allow(non_snake_case)] fn get_Ai() -> Vec { vec![ 0, 1, 9, 0, 1, 2, 10, 1, 2, 3, 11, 2, 3, 4, 12, 3, 4, 5, 13, 4, 5, 6, 14, 5, 6, 7, 15, 6, 7, 16, 7, 8, 17, 9, 10, 18, 9, 10, 11, 19, 10, 11, 12, 20, 11, 12, 13, 21, 12, 13, 14, 22, 13, 14, 15, 23, 14, 15, 16, 24, 15, 16, 25, 16, 17, 26, 9, 18, 19, 27, 10, 18, 19, 20, 28, 11, 19, 20, 21, 29, 93, 102, 12, 20, 21, 22, 30, 102, 103, 13, 21, 22, 23, 31, 103, 104, 14, 22, 23, 24, 32, 96, 104, 105, 15, 23, 24, 25, 33, 16, 24, 25, 34, 17, 25, 26, 35, 18, 27, 28, 36, 100, 109, 19, 27, 28, 29, 37, 100, 101, 109, 110, 20, 28, 29, 30, 38, 101, 102, 110, 111, 21, 29, 30, 31, 39, 102, 103, 111, 112, 22, 30, 31, 32, 40, 103, 104, 112, 113, 23, 31, 32, 33, 41, 104, 105, 113, 114, 24, 32, 33, 34, 42, 105, 106, 114, 115, 25, 33, 34, 43, 106, 107, 115, 116, 26, 34, 35, 44, 107, 116, 27, 36, 37, 45, 109, 118, 28, 36, 37, 38, 46, 109, 110, 118, 119, 29, 37, 38, 39, 47, 110, 111, 119, 120, 30, 38, 39, 40, 48, 111, 112, 120, 121, 31, 39, 40, 41, 49, 112, 113, 121, 122, 32, 40, 41, 42, 50, 113, 114, 122, 123, 33, 41, 42, 43, 51, 114, 115, 123, 124, 34, 42, 43, 52, 115, 116, 124, 125, 35, 43, 44, 53, 116, 125, 36, 45, 46, 54, 118, 127, 37, 45, 46, 47, 55, 118, 119, 127, 128, 38, 46, 47, 48, 56, 119, 120, 128, 129, 39, 47, 48, 49, 57, 120, 121, 40, 48, 49, 50, 58, 121, 122, 41, 49, 50, 51, 59, 122, 123, 132, 42, 50, 51, 52, 60, 123, 124, 132, 133, 43, 51, 52, 61, 124, 125, 133, 134, 44, 52, 53, 62, 125, 134, 45, 54, 55, 63, 127, 136, 46, 54, 55, 56, 64, 127, 128, 136, 137, 47, 55, 56, 57, 65, 128, 129, 137, 138, 48, 56, 57, 58, 66, 49, 57, 58, 59, 67, 50, 58, 59, 60, 68, 132, 141, 51, 59, 60, 61, 69, 132, 133, 141, 142, 52, 60, 61, 70, 133, 134, 142, 143, 53, 61, 62, 71, 134, 143, 54, 63, 64, 72, 136, 145, 55, 63, 64, 65, 73, 136, 137, 145, 146, 56, 64, 65, 66, 74, 137, 138, 146, 147, 57, 65, 66, 67, 75, 138, 139, 147, 148, 58, 66, 67, 68, 76, 139, 140, 148, 149, 59, 67, 68, 69, 77, 140, 141, 149, 150, 60, 68, 69, 70, 78, 141, 142, 150, 151, 61, 69, 70, 79, 142, 143, 151, 152, 62, 70, 71, 80, 143, 152, 63, 72, 73, 145, 64, 72, 73, 74, 145, 146, 65, 73, 74, 75, 146, 147, 66, 74, 75, 76, 147, 148, 67, 75, 76, 77, 148, 149, 68, 76, 77, 78, 149, 150, 69, 77, 78, 79, 150, 151, 70, 78, 79, 151, 152, 71, 79, 80, 152, 81, 82, 90, 82, 83, 91, 82, 83, 84, 92, 83, 84, 85, 93, 84, 85, 86, 94, 85, 86, 87, 95, 86, 87, 88, 96, 87, 88, 89, 97, 88, 89, 98, 81, 90, 91, 99, 82, 91, 92, 100, 83, 91, 92, 93, 101, 20, 21, 84, 92, 93, 94, 102, 21, 22, 85, 93, 94, 95, 103, 22, 23, 86, 94, 95, 96, 104, 87, 95, 96, 97, 105, 88, 96, 97, 98, 106, 89, 97, 98, 107, 27, 90, 99, 100, 108, 27, 28, 91, 100, 101, 109, 28, 29, 92, 100, 101, 102, 110, 21, 30, 93, 101, 102, 103, 111, 21, 22, 30, 31, 94, 102, 103, 104, 112, 22, 31, 95, 103, 104, 105, 113, 32, 33, 96, 104, 105, 106, 114, 33, 34, 97, 105, 106, 107, 115, 34, 98, 106, 107, 116, 27, 36, 99, 108, 109, 117, 27, 28, 36, 37, 100, 109, 110, 118, 28, 29, 37, 38, 101, 109, 110, 111, 119, 30, 39, 102, 110, 111, 112, 120, 30, 31, 39, 40, 103, 111, 112, 113, 121, 31, 40, 104, 112, 113, 114, 122, 32, 33, 41, 42, 105, 113, 114, 115, 123, 33, 34, 42, 43, 106, 114, 115, 116, 124, 34, 43, 107, 115, 116, 125, 36, 45, 108, 117, 118, 126, 36, 37, 45, 46, 109, 118, 119, 127, 37, 38, 46, 47, 110, 118, 119, 120, 128, 39, 48, 111, 119, 120, 121, 129, 39, 40, 48, 49, 112, 120, 121, 122, 130, 40, 49, 113, 121, 122, 123, 131, 41, 42, 50, 51, 114, 122, 123, 124, 132, 42, 43, 51, 52, 115, 123, 124, 125, 133, 43, 52, 116, 124, 125, 134, 45, 54, 117, 126, 127, 135, 45, 46, 54, 55, 118, 127, 128, 136, 46, 47, 55, 56, 119, 127, 128, 129, 137, 48, 56, 57, 120, 128, 129, 130, 138, 48, 49, 57, 58, 121, 129, 130, 131, 139, 49, 58, 59, 122, 130, 131, 132, 140, 50, 51, 59, 60, 123, 131, 132, 133, 141, 51, 52, 60, 61, 124, 132, 133, 134, 142, 52, 61, 125, 133, 134, 143, 54, 63, 126, 135, 136, 144, 54, 55, 63, 64, 127, 136, 137, 145, 55, 56, 64, 65, 128, 136, 137, 138, 146, 65, 66, 129, 137, 138, 139, 147, 66, 67, 130, 138, 139, 140, 148, 67, 68, 131, 139, 140, 141, 149, 59, 60, 68, 69, 132, 140, 141, 142, 150, 60, 61, 69, 70, 133, 141, 142, 143, 151, 61, 70, 134, 142, 143, 152, 63, 72, 135, 144, 145, 63, 64, 72, 73, 136, 145, 146, 64, 65, 73, 74, 137, 145, 146, 147, 65, 66, 74, 75, 138, 146, 147, 148, 66, 67, 75, 76, 139, 147, 148, 149, 67, 68, 76, 77, 140, 148, 149, 150, 68, 69, 77, 78, 141, 149, 150, 151, 69, 70, 78, 79, 142, 150, 151, 152, 70, 79, 143, 151, 152, 72, 144, 153, 154, 72, 73, 145, 154, 155, 73, 74, 146, 154, 155, 156, 74, 75, 147, 155, 156, 157, 75, 76, 148, 156, 157, 158, 76, 77, 149, 157, 158, 159, 77, 78, 150, 158, 159, 160, 78, 79, 151, 159, 160, 161, 79, 152, 160, 161, ] } #[allow(non_snake_case)] fn get_Ax() -> Vec { vec![ 32.612, 1.778, 1.778, 1.778, 30.835, 1.778, 1.778, 1.778, 30.835, 1.778, 1.778, 1.778, 30.835, 1.778, 1.778, 1.778, 30.835, 1.778, 1.778, 1.778, 30.835, 1.778, 1.778, 1.778, 30.835, 1.778, 1.778, 1.778, 30.835, 1.778, 1.778, 34.39, 1.778, 29.057, 1.778, 1.778, 1.778, 27.279, 1.778, 1.778, 1.778, 27.279, 1.778, 1.778, 1.778, 27.279, 1.778, 1.778, 1.778, 27.279, 1.778, 1.778, 1.778, 27.279, 1.778, 1.778, 1.778, 27.279, 1.778, 1.778, 1.778, 27.279, 1.778, 1.778, 30.835, 1.778, 1.778, 29.057, 1.778, 1.778, 1.778, 1.778, 27.279, 1.778, 1.778, 1.778, 1.778, 28.755, 0.301, 1.778, 1.476, -1.476, 1.778, 1.778, 195.72, 1.778, 1.778, -0.0, 0.0, 1.778, 1.778, 195.72, 1.778, 1.778, -0.0, 0.0, 1.778, 1.778, 187.013, 10.485, 1.778, -8.707, -0.0, 8.707, 1.778, 1.778, 27.279, 1.778, 1.778, 1.778, 1.778, 27.279, 1.778, 1.778, 1.778, 30.835, 1.778, 1.778, 12.213, 1.778, 1.778, -0.0, 0.0, 1.778, 1.778, 10.435, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 12.059, 0.154, 1.778, 0.0, 1.624, -0.0, -1.624, 1.778, 1.778, 195.72, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 195.72, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 176.947, 20.551, 1.778, 0.0, -18.773, -0.0, 18.773, 1.778, 1.778, 10.435, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 10.435, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 13.99, 1.778, 0.0, -0.0, 1.778, 12.213, 1.778, 1.778, -0.0, 0.0, 1.778, 1.778, 10.435, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 12.059, 0.154, 1.778, 0.0, 1.624, -0.0, -1.624, 1.778, 1.778, 195.72, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 195.72, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 176.947, 20.551, 1.778, 0.0, -18.773, -0.0, 18.773, 1.778, 1.778, 10.435, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 10.435, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 13.99, 1.778, 0.0, -0.0, 1.778, 12.213, 1.778, 1.778, -0.0, 0.0, 1.778, 1.778, 10.435, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 12.059, 0.154, 1.778, 0.0, 1.624, -0.0, -1.624, 1.778, 1.778, 195.72, 1.778, 1.778, 0.0, -0.0, 1.778, 1.778, 195.72, 1.778, 1.778, 0.0, -0.0, 1.778, 1.778, 176.947, 20.551, 1.778, 0.0, -18.773, 18.773, 1.778, 1.778, 10.435, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 10.435, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 13.99, 1.778, 0.0, -0.0, 1.778, 12.213, 1.778, 1.778, -0.0, 0.0, 1.778, 1.778, 10.435, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 11.306, 0.907, 1.778, 0.0, 0.871, -0.0, -0.871, 1.778, 1.778, 27.279, 1.778, 1.778, 1.778, 1.778, 27.279, 1.778, 1.778, 1.778, 1.778, 25.572, 3.484, 1.778, -1.707, 1.707, 1.778, 1.778, 10.435, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 10.435, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 13.99, 1.778, 0.0, -0.0, 1.778, 12.213, 1.778, 1.778, -0.0, 0.0, 1.778, 1.778, 10.435, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 10.435, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 10.435, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 10.435, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 10.435, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 10.435, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 10.435, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 13.99, 1.778, 0.0, -0.0, 1.778, 13.99, 1.778, -0.0, 1.778, 1.778, 12.213, 1.778, 0.0, -0.0, 1.778, 1.778, 12.213, 1.778, 0.0, -0.0, 1.778, 1.778, 12.213, 1.778, 0.0, -0.0, 1.778, 1.778, 12.213, 1.778, 0.0, -0.0, 1.778, 1.778, 12.213, 1.778, 0.0, -0.0, 1.778, 1.778, 12.213, 1.778, 0.0, -0.0, 1.778, 1.778, 12.213, 0.0, -0.0, 1.778, 1.778, 15.768, 0.0, 32.612, 1.778, 1.778, 29.057, 1.778, 1.778, 1.778, 29.057, 1.778, 1.778, 1.778, 29.057, 1.778, 1.778, 1.778, 29.057, 1.778, 1.778, 1.778, 29.057, 1.778, 1.778, 1.778, 29.057, 1.778, 1.778, 1.778, 29.057, 1.778, 1.778, 1.778, 30.835, 1.778, 1.778, 30.835, 1.778, 1.778, 1.778, 27.279, 1.778, 1.778, 1.778, 1.778, 27.279, 1.778, 1.778, 1.476, -1.476, 1.778, 1.778, 28.755, 1.778, 0.301, 1.476, -1.476, 1.778, 1.778, 28.755, 1.778, 0.301, 1.476, -1.476, 1.778, 1.778, 28.755, 1.778, 0.301, 1.778, 1.778, 27.279, 1.778, 1.778, 1.778, 1.778, 27.279, 1.778, 1.778, 1.778, 1.778, 29.057, 1.778, 1.707, 1.778, 29.128, 1.778, 3.484, -1.707, 1.707, 1.778, 25.572, 1.778, 3.484, -1.707, 1.707, 1.778, 1.778, 25.572, 1.778, 3.484, -0.0, 0.0, 1.778, 1.778, 195.72, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 195.72, 1.778, 1.778, 0.0, -0.0, 1.778, 1.778, 195.72, 1.778, 1.778, -1.707, 1.707, 1.778, 1.778, 25.572, 1.778, 3.484, -1.707, 1.707, 1.778, 1.778, 25.572, 1.778, 3.484, -1.707, 1.778, 1.778, 27.35, 3.484, -0.0, 0.0, 1.778, 13.99, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 10.435, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 10.435, 1.778, 1.778, -0.0, 0.0, 1.778, 1.778, 195.72, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 195.72, 1.778, 1.778, 0.0, -0.0, 1.778, 1.778, 195.72, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 10.435, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 10.435, 1.778, 1.778, 0.0, -0.0, 1.778, 1.778, 12.213, 1.778, -0.0, 0.0, 1.778, 13.99, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 10.435, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 10.435, 1.778, 1.778, -0.0, 0.0, 1.778, 1.778, 195.72, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 195.72, 1.778, 1.778, 0.0, -0.0, 1.778, 1.778, 195.72, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 10.435, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 10.435, 1.778, 1.778, 0.0, -0.0, 1.778, 1.778, 12.213, 1.778, -0.0, 0.0, 1.778, 13.99, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 10.435, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 10.435, 1.778, 1.778, -0.0, -8.707, 8.707, 1.778, 1.778, 187.013, 1.778, 10.485, 0.0, -0.0, -8.707, 8.707, 1.778, 1.778, 187.013, 1.778, 10.485, 0.0, -8.707, 8.707, 1.778, 1.778, 187.013, 1.778, 10.485, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 10.435, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 10.435, 1.778, 1.778, 0.0, -0.0, 1.778, 1.778, 12.213, 1.778, -0.0, 0.0, 1.778, 13.99, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 10.435, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 10.435, 1.778, 1.778, -1.707, 1.707, 1.778, 1.778, 25.572, 1.778, 3.484, -1.707, 1.707, 1.778, 1.778, 25.572, 1.778, 3.484, -1.707, 1.707, 1.778, 1.778, 25.572, 1.778, 3.484, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 10.435, 1.778, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 10.435, 1.778, 1.778, 0.0, -0.0, 1.778, 1.778, 12.213, 1.778, -0.0, 0.0, 1.778, 13.99, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 10.435, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 10.435, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 10.435, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 10.435, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 10.435, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 10.435, 1.778, 0.0, -0.0, -0.0, 0.0, 1.778, 1.778, 10.435, 1.778, 0.0, -0.0, 1.778, 1.778, 12.213, -0.0, 1.778, 17.546, 1.778, 0.0, -0.0, 1.778, 13.99, 1.778, 0.0, -0.0, 1.778, 1.778, 13.99, 1.778, 0.0, -0.0, 1.778, 1.778, 13.99, 1.778, 0.0, -0.0, 1.778, 1.778, 13.99, 1.778, 0.0, -0.0, 1.778, 1.778, 13.99, 1.778, 0.0, -0.0, 1.778, 1.778, 13.99, 1.778, 0.0, -0.0, 1.778, 1.778, 13.99, 1.778, 0.0, 1.778, 1.778, 15.768, ] }