sarah-ek / faer-rs

Linear algebra foundation for the Rust programming language
https://faer-rs.github.io
MIT License
1.75k stars 56 forks source link

After update 0.14.1 -> 0.15.0 result of matmul not unique #134

Closed mg-gebert closed 1 month ago

mg-gebert commented 1 month ago

Hi all,

We encountered the following problem. After updating faer from 0.14.1 -> 0.18.2 the results of some matrix multiplication doesn't seem to be the same in all runs anymore.

Below you find a test which fails on my Windows machine AMD Ryzen 7 Pro 6850U with x86-64 instruction set. The test constitutes of multiplying v_1^T * v_2 for two vectors v_1 and v_2 of length 50 over and over. But before multiplying we always allocate v_1 and v_2 new (that's important). Finally, it checks if the outcome is always the same.

The test fails roughly in 2 out of 3 cases that I run it. Please run the test several times as it can sometimes pass on my machine as well. The syntax of the test is to run with faer version 0.18.2.

On my machine the multiplication gives either -7.011362517610277 or -7.011362517610278

Before with fear 0.14.1 it always returned on my machine -7.011362517610278 and I never encountered any non uniqueness on the same machine.

We also checked on linux x86-64 and there the test also fails with the same ambiguity. Interestingly, on Mac with ARM architecture so far the test has never failed and the multiplication always returned the same value.

I also went through the faer versions and I encountered that the test already fails for version 0.15.0 (after changing mat::from_raw_parts:: -> MatRef::::from_raw_parts in the test below). That's why I think the relevant issue was introduced in the change 0.14.1 -> 0.15.0.

Apologies that the example is this big and looks a bit bizzare but it is already the essence of a much bigger matrix multiplication. It would be really great if you could look into this.

Cheers, Martin

use faer::{linalg::matmul::matmul, mat, Parallelism};

#[test]
fn test_matrix_mult_2() {
    // multiply vec_1^transpose * vec_2
    fn mat_mul(c: &mut Vec<f64>, vec_1: &[f64], vec_2: &[f64]) {
        let (a, b, c) = unsafe {
            let a = mat::from_raw_parts::<f64>(vec_1.as_ptr(), 1, vec_1.len(), vec_1.len() as isize, 1);
            let b = mat::from_raw_parts::<f64>(vec_2.as_ptr(), vec_2.len(), 1, 1, vec_2.len() as isize);
            let c = mat::from_raw_parts_mut::<f64>(c.as_mut_ptr(), 1, 1, 1, 1);

            (a, b, c)
        };
        matmul(c, a, b, None, 1.0, Parallelism::Rayon(0));
    }

    // allocate a specific example vector_1 and vector_2
    // compute for these: vector_1^T * vector_2 several times
    fn allocate_and_multiply() -> Vec<f64> {
        let vector_1 = vec![
            -0.7126436781609196,
            -0.521072796934866,
            -0.4827586206896552,
            -0.46360153256704983,
            0.28352490421455934,
            0.8582375478927202,
            -0.4444444444444445,
            -0.32950191570881227,
            -0.3103448275862069,
            -0.06130268199233722,
            0.07279693486590032,
            0.32183908045977005,
            0.6475095785440612,
            0.18773946360153249,
            0.4942528735632183,
            0.7816091954022988,
            -0.7509578544061303,
            -0.4252873563218391,
            0.5134099616858236,
            0.5708812260536398,
            -0.23371647509578547,
            0.14942528735632177,
            0.16858237547892713,
            0.45593869731800757,
            0.015325670498084235,
            -0.1762452107279694,
            0.45593869731800757,
            0.5517241379310344,
            0.7624521072796934,
            0.8773946360153255,
            -0.8659003831417624,
            -0.7701149425287356,
            -0.3869731800766284,
            -0.36781609195402304,
            -0.3103448275862069,
            0.015325670498084235,
            0.20689655172413787,
            0.5708812260536398,
            0.7624521072796934,
            -0.7126436781609196,
            -0.2720306513409962,
            -0.2145593869731801,
            0.7049808429118772,
            0.7624521072796934,
            -0.003831417624521127,
            -0.8084291187739464,
            -0.521072796934866,
            -0.2720306513409962,
            -0.08045977011494258,
            0.8007662835249041,
        ];
        let vector_2 = vec![
            0.7148970038266844,
            0.9394435693322037,
            0.9706811351049253,
            0.9827805992915406,
            0.3133365952817986,
            0.06854541248590446,
            0.9920073311482962,
            0.9706811351049254,
            0.9561138337572238,
            0.6666680608731084,
            0.5085669071368457,
            0.28530193019436423,
            0.12252595517818116,
            0.39332014547557914,
            0.18412047285075298,
            0.08487057824808716,
            0.666668060873108,
            0.9979126503638616,
            0.17512648773299683,
            0.15047375269300042,
            0.8799341877200165,
            0.42940615581885117,
            0.4110681414128452,
            0.20335807007629372,
            0.4730557499371057,
            0.8114663334994774,
            0.20335807007629372,
            0.1583171193025158,
            0.08948988238658144,
            0.06495529498155232,
            0.8066178947150024,
            0.6428902429506017,
            0.9979126503638616,
            0.9920073311482962,
            0.9561138337572238,
            0.5736722613265167,
            0.376161655945091,
            0.15047375269300042,
            0.08948988238658144,
            0.7148970038266844,
            0.9209986565997597,
            0.8578158417136814,
            0.10480129441854975,
            0.08948988238658144,
            0.4910756096362498,
            0.5963399037568023,
            0.9394435693322037,
            0.9209986565997597,
            0.6906958826399673,
            0.0804761881067157,
        ];

        let mut sub_result = Vec::with_capacity(13);

        for _i in 0..13 {
            let mut c = vec![0.0];
            mat_mul(&mut c, &vector_1, &vector_2);
            sub_result.extend(c.iter());
        }

        sub_result
    }

    // allocate vector 1 and vector 2 and multiply a lot of times
    // check if all results are identical
    let first = allocate_and_multiply();
    for i in 1..10000 {
        let current = allocate_and_multiply();
        assert!(
            current == first,
            "Current multiplication gives (={:?}) but so far multiplications gave (={:?}) at iteration: {:?}",
            current,
            first,
            i
        );
    }
}
sarah-ek commented 1 month ago

will look into it

sarah-ek commented 1 month ago

i pushed a commit that should hopefully fix it, would you mind testing it?

mg-gebert commented 1 month ago

Thanks for looking into it. I checked (with commit 7f7a668)and indeed the particular test that I provided passes now and the ambiguity is resolved for this test.

But I have a bigger integration test which still fails and this internally constitutes of bigger matrix multiplications of roughly size 1000 * 1000. There I still don't have uniqueness of the result but it is very hard to share. I'll try to reduce this big test to make it shareable. Please for now don't close the issue.

mg-gebert commented 1 month ago

Again thanks for looking into the issue. I extracted another example where matrix multiplication is still not unique on my machine. Sadly, it is rather big. It is multiplying two vectors of length 1000. On my machine this gives either -169.51213997770623 or -169.51213997770625. I ran the test with faer commit 32b5044 so after your bug fix.

For completeness: If I run the test with faer 0.14.1 the result of the matrix multiplication is unique and gives the value -169.51213997770625.

use faer::{linalg::matmul::matmul, mat, Parallelism};

#[test]
fn test_matrix_mult_3() {
    // multiply vec_1^transpose * vec_2
    fn mat_mul(c: &mut Vec<f64>, vec_1: &[f64], vec_2: &[f64]) {
        let (a, b, c) = unsafe {
            let a = mat::from_raw_parts::<f64>(vec_1.as_ptr(), 1, vec_1.len(), vec_1.len() as isize, 1);
            let b = mat::from_raw_parts::<f64>(vec_2.as_ptr(), vec_2.len(), 1, 1, vec_2.len() as isize);
            let c = mat::from_raw_parts_mut::<f64>(c.as_mut_ptr(), 1, 1, 1, 1);

            (a, b, c)
        };
        matmul(c, a, b, None, 1.0, Parallelism::None);
    }

    // allocate a specific example vector_1 and vector_2
    // compute for these: vector_1^T * vector_2 several times
    fn allocate_and_multiply() -> Vec<f64> {
        let vector_1 = vec![
            -1.0,
            -0.9808429118773946,
            -0.9616858237547893,
            -0.9425287356321839,
            -0.9233716475095786,
            -0.9042145593869731,
            -0.8850574712643678,
            -0.8659003831417624,
            -0.8467432950191571,
            -0.8275862068965517,
            -0.8084291187739464,
            -0.789272030651341,
            -0.7701149425287356,
            -0.7509578544061303,
            -0.7318007662835249,
            -0.7126436781609196,
            -0.6934865900383141,
            -0.6743295019157088,
            -0.6551724137931034,
            -0.6360153256704981,
            -0.6168582375478927,
            -0.5977011494252874,
            -0.578544061302682,
            -0.5593869731800767,
            -0.5402298850574713,
            -0.521072796934866,
            -0.5019157088122606,
            -0.4827586206896552,
            -0.46360153256704983,
            -0.4444444444444445,
            -0.4252873563218391,
            -0.40613026819923376,
            -0.3869731800766284,
            -0.36781609195402304,
            -0.3486590038314177,
            -0.32950191570881227,
            -0.3103448275862069,
            -0.29118773946360155,
            -0.2720306513409962,
            -0.25287356321839083,
            -0.23371647509578547,
            -0.2145593869731801,
            -0.19540229885057475,
            -0.1762452107279694,
            -0.15708812260536403,
            -0.13793103448275867,
            -0.1187739463601533,
            -0.09961685823754794,
            -0.08045977011494258,
            -0.06130268199233722,
            -0.04214559386973185,
            -0.02298850574712649,
            -0.003831417624521127,
            0.015325670498084235,
            0.0344827586206896,
            0.05363984674329496,
            0.07279693486590032,
            0.09195402298850569,
            0.11111111111111105,
            0.1302681992337164,
            0.14942528735632177,
            0.16858237547892713,
            0.18773946360153249,
            0.20689655172413787,
            0.22605363984674323,
            0.2452107279693486,
            0.2643678160919539,
            0.28352490421455934,
            0.3026819923371647,
            0.32183908045977005,
            0.3409961685823754,
            0.3601532567049808,
            0.37931034482758613,
            0.3984674329501915,
            0.41762452107279685,
            0.4367816091954022,
            0.45593869731800757,
            0.4750957854406129,
            0.4942528735632183,
            0.5134099616858236,
            0.5325670498084291,
            0.5517241379310344,
            0.5708812260536398,
            0.5900383141762451,
            0.6091954022988505,
            0.6283524904214558,
            0.6475095785440612,
            0.6666666666666665,
            0.6858237547892719,
            0.7049808429118772,
            0.7241379310344827,
            0.7432950191570881,
            0.7624521072796934,
            0.7816091954022988,
            0.8007662835249041,
            0.8199233716475095,
            0.8390804597701148,
            0.8582375478927202,
            0.8773946360153255,
            0.8965517241379309,
            -0.04214559386973185,
            -0.02298850574712649,
            -0.003831417624521127,
            0.015325670498084235,
            0.0344827586206896,
            0.05363984674329496,
            -0.8850574712643678,
            -0.8659003831417624,
            -0.8467432950191571,
            -0.8275862068965517,
            -0.8084291187739464,
            -0.789272030651341,
            -0.7701149425287356,
            -0.7509578544061303,
            -0.7318007662835249,
            -0.7126436781609196,
            -0.6934865900383141,
            -0.6743295019157088,
            -0.6551724137931034,
            -0.6360153256704981,
            -0.6168582375478927,
            -0.5977011494252874,
            -0.578544061302682,
            -0.5593869731800767,
            -0.5402298850574713,
            -0.521072796934866,
            -0.5019157088122606,
            -0.4827586206896552,
            -0.46360153256704983,
            -0.4444444444444445,
            -0.4252873563218391,
            -0.40613026819923376,
            -0.3869731800766284,
            -0.36781609195402304,
            -0.3486590038314177,
            -0.32950191570881227,
            -0.3103448275862069,
            -0.29118773946360155,
            -0.2720306513409962,
            -0.25287356321839083,
            -0.23371647509578547,
            -0.2145593869731801,
            -0.19540229885057475,
            -0.1762452107279694,
            -0.15708812260536403,
            -0.13793103448275867,
            -0.1187739463601533,
            -0.09961685823754794,
            -0.08045977011494258,
            -0.06130268199233722,
            -0.04214559386973185,
            -0.02298850574712649,
            -0.003831417624521127,
            0.015325670498084235,
            0.0344827586206896,
            0.05363984674329496,
            0.07279693486590032,
            0.09195402298850569,
            0.11111111111111105,
            0.1302681992337164,
            0.14942528735632177,
            0.16858237547892713,
            0.18773946360153249,
            0.20689655172413787,
            0.22605363984674323,
            0.2452107279693486,
            0.2643678160919539,
            0.28352490421455934,
            0.3026819923371647,
            0.32183908045977005,
            0.3409961685823754,
            0.3601532567049808,
            0.37931034482758613,
            0.3984674329501915,
            0.41762452107279685,
            0.4367816091954022,
            0.45593869731800757,
            0.4750957854406129,
            0.4942528735632183,
            0.5134099616858236,
            0.5325670498084291,
            0.5517241379310344,
            0.5708812260536398,
            0.5900383141762451,
            0.6091954022988505,
            0.6283524904214558,
            0.6475095785440612,
            0.6666666666666665,
            0.6858237547892719,
            0.7049808429118772,
            0.7241379310344827,
            0.7432950191570881,
            0.7624521072796934,
            0.7816091954022988,
            0.8007662835249041,
            0.8199233716475095,
            0.8390804597701148,
            0.8582375478927202,
            0.8773946360153255,
            0.8965517241379309,
            -0.04214559386973185,
            -0.02298850574712649,
            -0.003831417624521127,
            0.015325670498084235,
            0.0344827586206896,
            0.05363984674329496,
            -0.8850574712643678,
            -0.8659003831417624,
            -0.8467432950191571,
            -0.8275862068965517,
            -0.8084291187739464,
            -0.789272030651341,
            -0.7701149425287356,
            -0.7509578544061303,
            -0.7318007662835249,
            -0.7126436781609196,
            -0.6934865900383141,
            -0.6743295019157088,
            -0.6551724137931034,
            -0.6360153256704981,
            -0.6168582375478927,
            -0.5977011494252874,
            -0.578544061302682,
            -0.5593869731800767,
            -0.5402298850574713,
            -0.521072796934866,
            -0.5019157088122606,
            -0.4827586206896552,
            -0.46360153256704983,
            -0.4444444444444445,
            -0.4252873563218391,
            -0.40613026819923376,
            -0.3869731800766284,
            -0.36781609195402304,
            -0.3486590038314177,
            -0.32950191570881227,
            -0.3103448275862069,
            -0.29118773946360155,
            -0.2720306513409962,
            -0.25287356321839083,
            -0.23371647509578547,
            -0.2145593869731801,
            -0.19540229885057475,
            -0.1762452107279694,
            -0.15708812260536403,
            -0.13793103448275867,
            -0.1187739463601533,
            -0.09961685823754794,
            -0.08045977011494258,
            -0.06130268199233722,
            -0.04214559386973185,
            -0.02298850574712649,
            -0.003831417624521127,
            0.015325670498084235,
            0.0344827586206896,
            0.05363984674329496,
            0.07279693486590032,
            0.09195402298850569,
            0.11111111111111105,
            0.1302681992337164,
            0.14942528735632177,
            0.16858237547892713,
            0.18773946360153249,
            0.20689655172413787,
            0.22605363984674323,
            0.2452107279693486,
            0.2643678160919539,
            0.28352490421455934,
            0.3026819923371647,
            0.32183908045977005,
            0.3409961685823754,
            0.3601532567049808,
            0.37931034482758613,
            0.3984674329501915,
            0.41762452107279685,
            0.4367816091954022,
            0.45593869731800757,
            0.4750957854406129,
            0.4942528735632183,
            0.5134099616858236,
            0.5325670498084291,
            0.5517241379310344,
            0.5708812260536398,
            0.5900383141762451,
            0.6091954022988505,
            0.6283524904214558,
            0.6475095785440612,
            0.6666666666666665,
            0.6858237547892719,
            0.7049808429118772,
            0.7241379310344827,
            0.7432950191570881,
            0.7624521072796934,
            0.7816091954022988,
            0.8007662835249041,
            0.8199233716475095,
            0.8390804597701148,
            0.8582375478927202,
            0.8773946360153255,
            0.8965517241379309,
            -0.04214559386973185,
            -0.02298850574712649,
            -0.003831417624521127,
            0.015325670498084235,
            0.0344827586206896,
            0.05363984674329496,
            -0.8850574712643678,
            -0.8659003831417624,
            -0.8467432950191571,
            -0.8275862068965517,
            -0.8084291187739464,
            -0.789272030651341,
            -0.7701149425287356,
            -0.7509578544061303,
            -0.7318007662835249,
            -0.7126436781609196,
            -0.6934865900383141,
            -0.6743295019157088,
            -0.6551724137931034,
            -0.6360153256704981,
            -0.6168582375478927,
            -0.5977011494252874,
            -0.578544061302682,
            -0.5593869731800767,
            -0.5402298850574713,
            -0.521072796934866,
            -0.5019157088122606,
            -0.4827586206896552,
            -0.46360153256704983,
            -0.4444444444444445,
            -0.4252873563218391,
            -0.40613026819923376,
            -0.3869731800766284,
            -0.36781609195402304,
            -0.3486590038314177,
            -0.32950191570881227,
            -0.3103448275862069,
            -0.29118773946360155,
            -0.2720306513409962,
            -0.25287356321839083,
            -0.23371647509578547,
            -0.2145593869731801,
            -0.19540229885057475,
            -0.1762452107279694,
            -0.15708812260536403,
            -0.13793103448275867,
            -0.1187739463601533,
            -0.09961685823754794,
            -0.08045977011494258,
            -0.06130268199233722,
            -0.04214559386973185,
            -0.02298850574712649,
            -0.003831417624521127,
            0.015325670498084235,
            0.0344827586206896,
            0.05363984674329496,
            0.07279693486590032,
            0.09195402298850569,
            0.11111111111111105,
            0.1302681992337164,
            0.14942528735632177,
            0.16858237547892713,
            0.18773946360153249,
            0.20689655172413787,
            0.22605363984674323,
            0.2452107279693486,
            0.2643678160919539,
            0.28352490421455934,
            0.3026819923371647,
            0.32183908045977005,
            0.3409961685823754,
            0.3601532567049808,
            0.37931034482758613,
            0.3984674329501915,
            0.41762452107279685,
            0.4367816091954022,
            0.45593869731800757,
            0.4750957854406129,
            0.4942528735632183,
            0.5134099616858236,
            0.5325670498084291,
            0.5517241379310344,
            0.5708812260536398,
            0.5900383141762451,
            0.6091954022988505,
            0.6283524904214558,
            0.6475095785440612,
            0.6666666666666665,
            0.6858237547892719,
            0.7049808429118772,
            0.7241379310344827,
            0.7432950191570881,
            0.7624521072796934,
            0.7816091954022988,
            0.8007662835249041,
            0.8199233716475095,
            0.8390804597701148,
            0.8582375478927202,
            0.8773946360153255,
            0.8965517241379309,
            -0.04214559386973185,
            -0.02298850574712649,
            -0.003831417624521127,
            0.015325670498084235,
            0.0344827586206896,
            0.05363984674329496,
            -0.8850574712643678,
            -0.8659003831417624,
            -0.8467432950191571,
            -0.8275862068965517,
            -0.8084291187739464,
            -0.789272030651341,
            -0.7701149425287356,
            -0.7509578544061303,
            -0.7318007662835249,
            -0.7126436781609196,
            -0.6934865900383141,
            -0.6743295019157088,
            -0.6551724137931034,
            -0.6360153256704981,
            -0.6168582375478927,
            -0.5977011494252874,
            -0.578544061302682,
            -0.5593869731800767,
            -0.5402298850574713,
            -0.521072796934866,
            -0.5019157088122606,
            -0.4827586206896552,
            -0.46360153256704983,
            -0.4444444444444445,
            -0.4252873563218391,
            -0.40613026819923376,
            -0.3869731800766284,
            -0.36781609195402304,
            -0.3486590038314177,
            -0.32950191570881227,
            -0.3103448275862069,
            -0.29118773946360155,
            -0.2720306513409962,
            -0.25287356321839083,
            -0.23371647509578547,
            -0.2145593869731801,
            -0.19540229885057475,
            -0.1762452107279694,
            -0.15708812260536403,
            -0.13793103448275867,
            -0.1187739463601533,
            -0.09961685823754794,
            -0.08045977011494258,
            -0.06130268199233722,
            -0.04214559386973185,
            -0.02298850574712649,
            -0.003831417624521127,
            0.015325670498084235,
            0.0344827586206896,
            0.05363984674329496,
            0.07279693486590032,
            0.09195402298850569,
            0.11111111111111105,
            0.1302681992337164,
            0.14942528735632177,
            0.16858237547892713,
            0.18773946360153249,
            0.20689655172413787,
            0.22605363984674323,
            0.2452107279693486,
            0.2643678160919539,
            0.28352490421455934,
            0.3026819923371647,
            0.32183908045977005,
            0.3409961685823754,
            0.3601532567049808,
            0.37931034482758613,
            0.3984674329501915,
            0.41762452107279685,
            0.4367816091954022,
            0.45593869731800757,
            0.4750957854406129,
            0.4942528735632183,
            0.5134099616858236,
            0.5325670498084291,
            0.5517241379310344,
            0.5708812260536398,
            0.5900383141762451,
            0.6091954022988505,
            0.6283524904214558,
            0.6475095785440612,
            0.6666666666666665,
            0.6858237547892719,
            0.7049808429118772,
            0.7241379310344827,
            0.7432950191570881,
            0.7624521072796934,
            0.7816091954022988,
            0.8007662835249041,
            0.8199233716475095,
            0.8390804597701148,
            0.8582375478927202,
            0.8773946360153255,
            0.8965517241379309,
            -0.04214559386973185,
            -0.02298850574712649,
            -0.003831417624521127,
            0.015325670498084235,
            0.0344827586206896,
            0.05363984674329496,
            -0.8850574712643678,
            -0.8659003831417624,
            -0.8467432950191571,
            -0.8275862068965517,
            -0.8084291187739464,
            -0.789272030651341,
            -0.7701149425287356,
            -0.7509578544061303,
            -0.7318007662835249,
            -0.7126436781609196,
            -0.6934865900383141,
            -0.6743295019157088,
            -0.6551724137931034,
            -0.6360153256704981,
            -0.6168582375478927,
            -0.5977011494252874,
            -0.578544061302682,
            -0.5593869731800767,
            -0.5402298850574713,
            -0.521072796934866,
            -0.5019157088122606,
            -0.4827586206896552,
            -0.46360153256704983,
            -0.4444444444444445,
            -0.4252873563218391,
            -0.40613026819923376,
            -0.3869731800766284,
            -0.36781609195402304,
            -0.3486590038314177,
            -0.32950191570881227,
            -0.3103448275862069,
            -0.29118773946360155,
            -0.2720306513409962,
            -0.25287356321839083,
            -0.23371647509578547,
            -0.2145593869731801,
            -0.19540229885057475,
            -0.1762452107279694,
            -0.15708812260536403,
            -0.13793103448275867,
            -0.1187739463601533,
            -0.09961685823754794,
            -0.08045977011494258,
            -0.06130268199233722,
            -0.04214559386973185,
            -0.02298850574712649,
            -0.003831417624521127,
            0.015325670498084235,
            0.0344827586206896,
            0.05363984674329496,
            0.07279693486590032,
            0.09195402298850569,
            0.11111111111111105,
            0.1302681992337164,
            0.14942528735632177,
            0.16858237547892713,
            0.18773946360153249,
            0.20689655172413787,
            0.22605363984674323,
            0.2452107279693486,
            0.2643678160919539,
            0.28352490421455934,
            0.3026819923371647,
            0.32183908045977005,
            0.3409961685823754,
            0.3601532567049808,
            0.37931034482758613,
            0.3984674329501915,
            0.41762452107279685,
            0.4367816091954022,
            0.45593869731800757,
            0.4750957854406129,
            0.4942528735632183,
            0.5134099616858236,
            0.5325670498084291,
            0.5517241379310344,
            0.5708812260536398,
            0.5900383141762451,
            0.6091954022988505,
            0.6283524904214558,
            0.6475095785440612,
            0.6666666666666665,
            0.6858237547892719,
            0.7049808429118772,
            0.7241379310344827,
            0.7432950191570881,
            0.7624521072796934,
            0.7816091954022988,
            0.8007662835249041,
            0.8199233716475095,
            0.8390804597701148,
            0.8582375478927202,
            0.8773946360153255,
            0.8965517241379309,
            -0.04214559386973185,
            -0.02298850574712649,
            -0.003831417624521127,
            0.015325670498084235,
            0.0344827586206896,
            0.05363984674329496,
            -0.8850574712643678,
            -0.8659003831417624,
            -0.8467432950191571,
            -0.8275862068965517,
            -0.8084291187739464,
            -0.789272030651341,
            -0.7701149425287356,
            -0.7509578544061303,
            -0.7318007662835249,
            -0.7126436781609196,
            -0.6934865900383141,
            -0.6743295019157088,
            -0.6551724137931034,
            -0.6360153256704981,
            -0.6168582375478927,
            -0.5977011494252874,
            -0.578544061302682,
            -0.5593869731800767,
            -0.5402298850574713,
            -0.521072796934866,
            -0.5019157088122606,
            -0.4827586206896552,
            -0.46360153256704983,
            -0.4444444444444445,
            -0.4252873563218391,
            -0.40613026819923376,
            -0.3869731800766284,
            -0.36781609195402304,
            -0.3486590038314177,
            -0.32950191570881227,
            -0.3103448275862069,
            -0.29118773946360155,
            -0.2720306513409962,
            -0.25287356321839083,
            -0.23371647509578547,
            -0.2145593869731801,
            -0.19540229885057475,
            -0.1762452107279694,
            -0.15708812260536403,
            -0.13793103448275867,
            -0.1187739463601533,
            -0.09961685823754794,
            -0.08045977011494258,
            -0.06130268199233722,
            -0.04214559386973185,
            -0.02298850574712649,
            -0.003831417624521127,
            0.015325670498084235,
            0.0344827586206896,
            0.05363984674329496,
            0.07279693486590032,
            0.09195402298850569,
            0.11111111111111105,
            0.1302681992337164,
            0.14942528735632177,
            0.16858237547892713,
            0.18773946360153249,
            0.20689655172413787,
            0.22605363984674323,
            0.2452107279693486,
            0.2643678160919539,
            0.28352490421455934,
            0.3026819923371647,
            0.32183908045977005,
            0.3409961685823754,
            0.3601532567049808,
            0.37931034482758613,
            0.3984674329501915,
            0.41762452107279685,
            0.4367816091954022,
            0.45593869731800757,
            0.4750957854406129,
            0.4942528735632183,
            0.5134099616858236,
            0.5325670498084291,
            0.5517241379310344,
            0.5708812260536398,
            0.5900383141762451,
            0.6091954022988505,
            0.6283524904214558,
            0.6475095785440612,
            0.6666666666666665,
            0.6858237547892719,
            0.7049808429118772,
            0.7241379310344827,
            0.7432950191570881,
            0.7624521072796934,
            0.7816091954022988,
            0.8007662835249041,
            0.8199233716475095,
            0.8390804597701148,
            0.8582375478927202,
            0.8773946360153255,
            0.8965517241379309,
            -0.04214559386973185,
            -0.02298850574712649,
            -0.003831417624521127,
            0.015325670498084235,
            0.0344827586206896,
            0.05363984674329496,
            -0.8850574712643678,
            -0.8659003831417624,
            -0.8467432950191571,
            -0.8275862068965517,
            -0.8084291187739464,
            -0.789272030651341,
            -0.7701149425287356,
            -0.7509578544061303,
            -0.7318007662835249,
            -0.7126436781609196,
            -0.6934865900383141,
            -0.6743295019157088,
            -0.6551724137931034,
            -0.6360153256704981,
            -0.6168582375478927,
            -0.5977011494252874,
            -0.578544061302682,
            -0.5593869731800767,
            -0.5402298850574713,
            -0.521072796934866,
            -0.5019157088122606,
            -0.4827586206896552,
            -0.46360153256704983,
            -0.4444444444444445,
            -0.4252873563218391,
            -0.40613026819923376,
            -0.3869731800766284,
            -0.36781609195402304,
            -0.3486590038314177,
            -0.32950191570881227,
            -0.3103448275862069,
            -0.29118773946360155,
            -0.2720306513409962,
            -0.25287356321839083,
            -0.23371647509578547,
            -0.2145593869731801,
            -0.19540229885057475,
            -0.1762452107279694,
            -0.15708812260536403,
            -0.13793103448275867,
            -0.1187739463601533,
            -0.09961685823754794,
            -0.08045977011494258,
            -0.06130268199233722,
            -0.04214559386973185,
            -0.02298850574712649,
            -0.003831417624521127,
            0.015325670498084235,
            0.0344827586206896,
            0.05363984674329496,
            0.07279693486590032,
            0.09195402298850569,
            0.11111111111111105,
            0.1302681992337164,
            0.14942528735632177,
            0.16858237547892713,
            0.18773946360153249,
            0.20689655172413787,
            0.22605363984674323,
            0.2452107279693486,
            0.2643678160919539,
            0.28352490421455934,
            0.3026819923371647,
            0.32183908045977005,
            0.3409961685823754,
            0.3601532567049808,
            0.37931034482758613,
            0.3984674329501915,
            0.41762452107279685,
            0.4367816091954022,
            0.45593869731800757,
            0.4750957854406129,
            0.4942528735632183,
            0.5134099616858236,
            0.5325670498084291,
            0.5517241379310344,
            0.5708812260536398,
            0.5900383141762451,
            0.6091954022988505,
            0.6283524904214558,
            0.6475095785440612,
            0.6666666666666665,
            0.6858237547892719,
            0.7049808429118772,
            0.7241379310344827,
            0.7432950191570881,
            0.7624521072796934,
            0.7816091954022988,
            0.8007662835249041,
            0.8199233716475095,
            0.8390804597701148,
            0.8582375478927202,
            0.8773946360153255,
            0.8965517241379309,
            -0.04214559386973185,
            -0.02298850574712649,
            -0.003831417624521127,
            0.015325670498084235,
            0.0344827586206896,
            0.05363984674329496,
            -0.8850574712643678,
            -0.8659003831417624,
            -0.8467432950191571,
            -0.8275862068965517,
            -0.8084291187739464,
            -0.789272030651341,
            -0.7701149425287356,
            -0.7509578544061303,
            -0.7318007662835249,
            -0.7126436781609196,
            -0.6934865900383141,
            -0.6743295019157088,
            -0.6551724137931034,
            -0.6360153256704981,
            -0.6168582375478927,
            -0.5977011494252874,
            -0.578544061302682,
            -0.5593869731800767,
            -0.5402298850574713,
            -0.521072796934866,
            -0.5019157088122606,
            -0.4827586206896552,
            -0.46360153256704983,
            -0.4444444444444445,
            -0.4252873563218391,
            -0.40613026819923376,
            -0.3869731800766284,
            -0.36781609195402304,
            -0.3486590038314177,
            -0.32950191570881227,
            -0.3103448275862069,
            -0.29118773946360155,
            -0.2720306513409962,
            -0.25287356321839083,
            -0.23371647509578547,
            -0.2145593869731801,
            -0.19540229885057475,
            -0.1762452107279694,
            -0.15708812260536403,
            -0.13793103448275867,
            -0.1187739463601533,
            -0.09961685823754794,
            -0.08045977011494258,
            -0.06130268199233722,
            -0.04214559386973185,
            -0.02298850574712649,
            -0.003831417624521127,
            0.015325670498084235,
            0.0344827586206896,
            0.05363984674329496,
            0.07279693486590032,
            0.09195402298850569,
            0.11111111111111105,
            0.1302681992337164,
            0.14942528735632177,
            0.16858237547892713,
            0.18773946360153249,
            0.20689655172413787,
            0.22605363984674323,
            0.2452107279693486,
            0.2643678160919539,
            0.28352490421455934,
            0.3026819923371647,
            0.32183908045977005,
            0.3409961685823754,
            0.3601532567049808,
            0.37931034482758613,
            0.3984674329501915,
            0.41762452107279685,
            0.4367816091954022,
            0.45593869731800757,
            0.4750957854406129,
            0.4942528735632183,
            0.5134099616858236,
            0.5325670498084291,
            0.5517241379310344,
            0.5708812260536398,
            0.5900383141762451,
            0.6091954022988505,
            0.6283524904214558,
            0.6475095785440612,
            0.6666666666666665,
            0.6858237547892719,
            0.7049808429118772,
            0.7241379310344827,
            0.7432950191570881,
            0.7624521072796934,
            0.7816091954022988,
            0.8007662835249041,
            0.8199233716475095,
            0.8390804597701148,
            0.8582375478927202,
            0.8773946360153255,
            0.8965517241379309,
            -0.04214559386973185,
            -0.02298850574712649,
            -0.003831417624521127,
            0.015325670498084235,
            0.0344827586206896,
            0.05363984674329496,
            -0.8850574712643678,
            -0.8659003831417624,
            -0.8467432950191571,
            -0.8275862068965517,
            -0.8084291187739464,
            -0.789272030651341,
            -0.7701149425287356,
            -0.7509578544061303,
            -0.7318007662835249,
            -0.7126436781609196,
            -0.6934865900383141,
            -0.6743295019157088,
            -0.6551724137931034,
            -0.6360153256704981,
            -0.6168582375478927,
            -0.5977011494252874,
            -0.578544061302682,
            -0.5593869731800767,
            -0.5402298850574713,
            -0.521072796934866,
            -0.5019157088122606,
            -0.4827586206896552,
            -0.46360153256704983,
            -0.4444444444444445,
            -0.4252873563218391,
            -0.40613026819923376,
            -0.3869731800766284,
            -0.36781609195402304,
            -0.3486590038314177,
            -0.32950191570881227,
            -0.3103448275862069,
            -0.29118773946360155,
            -0.2720306513409962,
            -0.25287356321839083,
            -0.23371647509578547,
            -0.2145593869731801,
            -0.19540229885057475,
            -0.1762452107279694,
            -0.15708812260536403,
            -0.13793103448275867,
            -0.1187739463601533,
            -0.09961685823754794,
            -0.08045977011494258,
            -0.06130268199233722,
            -0.04214559386973185,
            -0.02298850574712649,
            -0.003831417624521127,
            0.015325670498084235,
            0.0344827586206896,
            0.05363984674329496,
            0.07279693486590032,
            0.09195402298850569,
            0.11111111111111105,
            0.1302681992337164,
            0.14942528735632177,
            0.16858237547892713,
            0.18773946360153249,
            0.20689655172413787,
            0.22605363984674323,
            0.2452107279693486,
            0.2643678160919539,
            0.28352490421455934,
            0.3026819923371647,
            0.32183908045977005,
            0.3409961685823754,
            0.3601532567049808,
            0.37931034482758613,
            0.3984674329501915,
            0.41762452107279685,
            0.4367816091954022,
            0.45593869731800757,
            0.4750957854406129,
            0.4942528735632183,
            0.5134099616858236,
            0.5325670498084291,
            0.5517241379310344,
            0.5708812260536398,
            0.5900383141762451,
            0.6091954022988505,
            0.6283524904214558,
            0.6475095785440612,
            0.6666666666666665,
            0.6858237547892719,
            0.7049808429118772,
            0.7241379310344827,
            0.7432950191570881,
            0.7624521072796934,
            0.7816091954022988,
            0.8007662835249041,
            0.8199233716475095,
            0.8390804597701148,
            0.8582375478927202,
            0.8773946360153255,
            0.8965517241379309,
        ];
        let vector_2 = vec![
            0.8543416030385804,
            0.8543416030385804,
            0.8543416030385804,
            0.8543416030385804,
            0.8543416030385804,
            0.8543416030385804,
            0.8543416030385804,
            0.8553151729076657,
            0.8562191008449869,
            0.8570528297644397,
            0.8578158417136814,
            0.8799341877200164,
            0.9010740337649166,
            0.9209986565997597,
            0.9394435693322037,
            0.9561138337572239,
            0.9706811351049253,
            0.9827805992915406,
            0.9920073311482963,
            0.9979126503638613,
            1.0,
            0.9979126503638616,
            0.9920073311482963,
            0.9827805992915406,
            0.9706811351049254,
            0.9561138337572239,
            0.9394435693322037,
            0.9209986565997595,
            0.9010740337649163,
            0.8799341877200164,
            0.8578158417136814,
            0.8349304238565177,
            0.8114663334994774,
            0.787591021238415,
            0.7634528971103397,
            0.7391830804463252,
            0.7148970038266844,
            0.6906958826399673,
            0.666668060873108,
            0.6428902429506017,
            0.6194286206911865,
            0.5963399037568026,
            0.5736722613265164,
            0.5514661821338862,
            0.5297552594563913,
            0.5085669071368457,
            0.4879230122460787,
            0.46784052956091077,
            0.448332022628867,
            0.4294061558188513,
            0.4110681414128452,
            0.39332014547557936,
            0.37616165594509093,
            0.35958981611538254,
            0.34359972643135095,
            0.32818471728425463,
            0.31333659528179847,
            0.2990458652691222,
            0.28530193019436406,
            0.2720932707439022,
            0.2594076065167967,
            0.2472320403644097,
            0.23555318738874298,
            0.22435728997089133,
            0.2136303200883769,
            0.2033580700762938,
            0.19352623289147977,
            0.184120472850753,
            0.17512648773299674,
            0.16653006306005644,
            0.1583171193025158,
            0.15047375269300042,
            0.14298627027130006,
            0.13584121973190966,
            0.12902541459521918,
            0.12252595517818105,
            0.11633024579856971,
            0.11042600860860997,
            0.10480129441854975,
            0.09944449083842746,
            0.09434432803662529,
            0.08948988238658151,
            0.08487057824808705,
            0.08047618810671575,
            0.0762968312739815,
            0.07232297133163028,
            0.06854541248590446,
            0.06495529498155227,
            0.061544089710662754,
            0.05830359213797924,
            0.0552259156520845,
            0.052303484440658854,
            0.04952902597780559,
            0.04689556320213414,
            0.04439640645581643,
            0.0420251452471234,
            0.03977563989192873,
            0.03764201308330233,
            0.03561864143252639,
            0.03370014701962348,
            0.3346319424403987,
            0.32040155198237974,
            0.3137501275616272,
            0.30021118059206026,
            0.2762446482151977,
            0.2639645026944648,
            0.9768062976122168,
            0.9814544303572138,
            0.8809602086261642,
            0.9019642955897619,
            0.8578158417136814,
            0.8799341877200164,
            0.9010740337649166,
            0.9209986565997597,
            0.9394435693322037,
            0.9561138337572239,
            0.9706811351049253,
            0.9827805992915406,
            0.9920073311482963,
            0.9979126503638613,
            1.0,
            0.9979126503638616,
            0.9920073311482963,
            0.9827805992915406,
            0.9706811351049254,
            0.9561138337572239,
            0.9394435693322037,
            0.9209986565997595,
            0.9010740337649163,
            0.8799341877200164,
            0.8578158417136814,
            0.8349304238565177,
            0.8114663334994774,
            0.787591021238415,
            0.7634528971103397,
            0.7391830804463252,
            0.7148970038266844,
            0.6906958826399673,
            0.666668060873108,
            0.6428902429506017,
            0.6194286206911865,
            0.5963399037568026,
            0.5736722613265164,
            0.5514661821338862,
            0.5297552594563913,
            0.5085669071368457,
            0.4879230122460787,
            0.46784052956091077,
            0.448332022628867,
            0.4294061558188513,
            0.4110681414128452,
            0.39332014547557936,
            0.37616165594509093,
            0.35958981611538254,
            0.34359972643135095,
            0.32818471728425463,
            0.31333659528179847,
            0.2990458652691222,
            0.28530193019436406,
            0.2720932707439022,
            0.2594076065167967,
            0.2472320403644097,
            0.23555318738874298,
            0.22435728997089133,
            0.2136303200883769,
            0.2033580700762938,
            0.19352623289147977,
            0.184120472850753,
            0.17512648773299674,
            0.16653006306005644,
            0.1583171193025158,
            0.15047375269300042,
            0.14298627027130006,
            0.13584121973190966,
            0.12902541459521918,
            0.12252595517818105,
            0.11633024579856971,
            0.11042600860860997,
            0.10480129441854975,
            0.09944449083842746,
            0.09434432803662529,
            0.08948988238658151,
            0.08487057824808705,
            0.08047618810671575,
            0.0762968312739815,
            0.07232297133163028,
            0.06854541248590446,
            0.06495529498155227,
            0.061544089710662754,
            0.05830359213797924,
            0.0552259156520845,
            0.052303484440658854,
            0.04952902597780559,
            0.04689556320213414,
            0.04439640645581643,
            0.0420251452471234,
            0.03977563989192873,
            0.03764201308330233,
            0.03561864143252639,
            0.03370014701962348,
            0.3346319424403987,
            0.32040155198237974,
            0.3137501275616272,
            0.30021118059206026,
            0.2762446482151977,
            0.2639645026944648,
            0.9768062976122168,
            0.9814544303572138,
            0.8809602086261642,
            0.9019642955897619,
            0.8578158417136814,
            0.8799341877200164,
            0.9010740337649166,
            0.9209986565997597,
            0.9394435693322037,
            0.9561138337572239,
            0.9706811351049253,
            0.9827805992915406,
            0.9920073311482963,
            0.9979126503638613,
            1.0,
            0.9979126503638616,
            0.9920073311482963,
            0.9827805992915406,
            0.9706811351049254,
            0.9561138337572239,
            0.9394435693322037,
            0.9209986565997595,
            0.9010740337649163,
            0.8799341877200164,
            0.8578158417136814,
            0.8349304238565177,
            0.8114663334994774,
            0.787591021238415,
            0.7634528971103397,
            0.7391830804463252,
            0.7148970038266844,
            0.6906958826399673,
            0.666668060873108,
            0.6428902429506017,
            0.6194286206911865,
            0.5963399037568026,
            0.5736722613265164,
            0.5514661821338862,
            0.5297552594563913,
            0.5085669071368457,
            0.4879230122460787,
            0.46784052956091077,
            0.448332022628867,
            0.4294061558188513,
            0.4110681414128452,
            0.39332014547557936,
            0.37616165594509093,
            0.35958981611538254,
            0.34359972643135095,
            0.32818471728425463,
            0.31333659528179847,
            0.2990458652691222,
            0.28530193019436406,
            0.2720932707439022,
            0.2594076065167967,
            0.2472320403644097,
            0.23555318738874298,
            0.22435728997089133,
            0.2136303200883769,
            0.2033580700762938,
            0.19352623289147977,
            0.184120472850753,
            0.17512648773299674,
            0.16653006306005644,
            0.1583171193025158,
            0.15047375269300042,
            0.14298627027130006,
            0.13584121973190966,
            0.12902541459521918,
            0.12252595517818105,
            0.11633024579856971,
            0.11042600860860997,
            0.10480129441854975,
            0.09944449083842746,
            0.09434432803662529,
            0.08948988238658151,
            0.08487057824808705,
            0.08047618810671575,
            0.0762968312739815,
            0.07232297133163028,
            0.06854541248590446,
            0.06495529498155227,
            0.061544089710662754,
            0.05830359213797924,
            0.0552259156520845,
            0.052303484440658854,
            0.04952902597780559,
            0.04689556320213414,
            0.04439640645581643,
            0.0420251452471234,
            0.03977563989192873,
            0.03764201308330233,
            0.03561864143252639,
            0.03370014701962348,
            0.3346319424403987,
            0.32040155198237974,
            0.3137501275616272,
            0.30021118059206026,
            0.2762446482151977,
            0.2639645026944648,
            0.9768062976122168,
            0.9814544303572138,
            0.8809602086261642,
            0.9019642955897619,
            0.8578158417136814,
            0.8799341877200164,
            0.9010740337649166,
            0.9209986565997597,
            0.9394435693322037,
            0.9561138337572239,
            0.9706811351049253,
            0.9827805992915406,
            0.9920073311482963,
            0.9979126503638613,
            1.0,
            0.9979126503638616,
            0.9920073311482963,
            0.9827805992915406,
            0.9706811351049254,
            0.9561138337572239,
            0.9394435693322037,
            0.9209986565997595,
            0.9010740337649163,
            0.8799341877200164,
            0.8578158417136814,
            0.8349304238565177,
            0.8114663334994774,
            0.787591021238415,
            0.7634528971103397,
            0.7391830804463252,
            0.7148970038266844,
            0.6906958826399673,
            0.666668060873108,
            0.6428902429506017,
            0.6194286206911865,
            0.5963399037568026,
            0.5736722613265164,
            0.5514661821338862,
            0.5297552594563913,
            0.5085669071368457,
            0.4879230122460787,
            0.46784052956091077,
            0.448332022628867,
            0.4294061558188513,
            0.4110681414128452,
            0.39332014547557936,
            0.37616165594509093,
            0.35958981611538254,
            0.34359972643135095,
            0.32818471728425463,
            0.31333659528179847,
            0.2990458652691222,
            0.28530193019436406,
            0.2720932707439022,
            0.2594076065167967,
            0.2472320403644097,
            0.23555318738874298,
            0.22435728997089133,
            0.2136303200883769,
            0.2033580700762938,
            0.19352623289147977,
            0.184120472850753,
            0.17512648773299674,
            0.16653006306005644,
            0.1583171193025158,
            0.15047375269300042,
            0.14298627027130006,
            0.13584121973190966,
            0.12902541459521918,
            0.12252595517818105,
            0.11633024579856971,
            0.11042600860860997,
            0.10480129441854975,
            0.09944449083842746,
            0.09434432803662529,
            0.08948988238658151,
            0.08487057824808705,
            0.08047618810671575,
            0.0762968312739815,
            0.07232297133163028,
            0.06854541248590446,
            0.06495529498155227,
            0.061544089710662754,
            0.05830359213797924,
            0.0552259156520845,
            0.052303484440658854,
            0.04952902597780559,
            0.04689556320213414,
            0.04439640645581643,
            0.0420251452471234,
            0.03977563989192873,
            0.03764201308330233,
            0.03561864143252639,
            0.03370014701962348,
            0.3346319424403987,
            0.32040155198237974,
            0.3137501275616272,
            0.30021118059206026,
            0.2762446482151977,
            0.2639645026944648,
            0.9768062976122168,
            0.9814544303572138,
            0.8809602086261642,
            0.9019642955897619,
            0.8578158417136814,
            0.8799341877200164,
            0.9010740337649166,
            0.9209986565997597,
            0.9394435693322037,
            0.9561138337572239,
            0.9706811351049253,
            0.9827805992915406,
            0.9920073311482963,
            0.9979126503638613,
            1.0,
            0.9979126503638616,
            0.9920073311482963,
            0.9827805992915406,
            0.9706811351049254,
            0.9561138337572239,
            0.9394435693322037,
            0.9209986565997595,
            0.9010740337649163,
            0.8799341877200164,
            0.8578158417136814,
            0.8349304238565177,
            0.8114663334994774,
            0.787591021238415,
            0.7634528971103397,
            0.7391830804463252,
            0.7148970038266844,
            0.6906958826399673,
            0.666668060873108,
            0.6428902429506017,
            0.6194286206911865,
            0.5963399037568026,
            0.5736722613265164,
            0.5514661821338862,
            0.5297552594563913,
            0.5085669071368457,
            0.4879230122460787,
            0.46784052956091077,
            0.448332022628867,
            0.4294061558188513,
            0.4110681414128452,
            0.39332014547557936,
            0.37616165594509093,
            0.35958981611538254,
            0.34359972643135095,
            0.32818471728425463,
            0.31333659528179847,
            0.2990458652691222,
            0.28530193019436406,
            0.2720932707439022,
            0.2594076065167967,
            0.2472320403644097,
            0.23555318738874298,
            0.22435728997089133,
            0.2136303200883769,
            0.2033580700762938,
            0.19352623289147977,
            0.184120472850753,
            0.17512648773299674,
            0.16653006306005644,
            0.1583171193025158,
            0.15047375269300042,
            0.14298627027130006,
            0.13584121973190966,
            0.12902541459521918,
            0.12252595517818105,
            0.11633024579856971,
            0.11042600860860997,
            0.10480129441854975,
            0.09944449083842746,
            0.09434432803662529,
            0.08948988238658151,
            0.08487057824808705,
            0.08047618810671575,
            0.0762968312739815,
            0.07232297133163028,
            0.06854541248590446,
            0.06495529498155227,
            0.061544089710662754,
            0.05830359213797924,
            0.0552259156520845,
            0.052303484440658854,
            0.04952902597780559,
            0.04689556320213414,
            0.04439640645581643,
            0.0420251452471234,
            0.03977563989192873,
            0.03764201308330233,
            0.03561864143252639,
            0.03370014701962348,
            0.3346319424403987,
            0.32040155198237974,
            0.3137501275616272,
            0.30021118059206026,
            0.2762446482151977,
            0.2639645026944648,
            0.9768062976122168,
            0.9814544303572138,
            0.8809602086261642,
            0.9019642955897619,
            0.8578158417136814,
            0.8799341877200164,
            0.9010740337649166,
            0.9209986565997597,
            0.9394435693322037,
            0.9561138337572239,
            0.9706811351049253,
            0.9827805992915406,
            0.9920073311482963,
            0.9979126503638613,
            1.0,
            0.9979126503638616,
            0.9920073311482963,
            0.9827805992915406,
            0.9706811351049254,
            0.9561138337572239,
            0.9394435693322037,
            0.9209986565997595,
            0.9010740337649163,
            0.8799341877200164,
            0.8578158417136814,
            0.8349304238565177,
            0.8114663334994774,
            0.787591021238415,
            0.7634528971103397,
            0.7391830804463252,
            0.7148970038266844,
            0.6906958826399673,
            0.666668060873108,
            0.6428902429506017,
            0.6194286206911865,
            0.5963399037568026,
            0.5736722613265164,
            0.5514661821338862,
            0.5297552594563913,
            0.5085669071368457,
            0.4879230122460787,
            0.46784052956091077,
            0.448332022628867,
            0.4294061558188513,
            0.4110681414128452,
            0.39332014547557936,
            0.37616165594509093,
            0.35958981611538254,
            0.34359972643135095,
            0.32818471728425463,
            0.31333659528179847,
            0.2990458652691222,
            0.28530193019436406,
            0.2720932707439022,
            0.2594076065167967,
            0.2472320403644097,
            0.23555318738874298,
            0.22435728997089133,
            0.2136303200883769,
            0.2033580700762938,
            0.19352623289147977,
            0.184120472850753,
            0.17512648773299674,
            0.16653006306005644,
            0.1583171193025158,
            0.15047375269300042,
            0.14298627027130006,
            0.13584121973190966,
            0.12902541459521918,
            0.12252595517818105,
            0.11633024579856971,
            0.11042600860860997,
            0.10480129441854975,
            0.09944449083842746,
            0.09434432803662529,
            0.08948988238658151,
            0.08487057824808705,
            0.08047618810671575,
            0.0762968312739815,
            0.07232297133163028,
            0.06854541248590446,
            0.06495529498155227,
            0.061544089710662754,
            0.05830359213797924,
            0.0552259156520845,
            0.052303484440658854,
            0.04952902597780559,
            0.04689556320213414,
            0.04439640645581643,
            0.0420251452471234,
            0.03977563989192873,
            0.03764201308330233,
            0.03561864143252639,
            0.03370014701962348,
            0.3346319424403987,
            0.32040155198237974,
            0.3137501275616272,
            0.30021118059206026,
            0.2762446482151977,
            0.2639645026944648,
            0.9768062976122168,
            0.9814544303572138,
            0.8809602086261642,
            0.9019642955897619,
            0.8578158417136814,
            0.8799341877200164,
            0.9010740337649166,
            0.9209986565997597,
            0.9394435693322037,
            0.9561138337572239,
            0.9706811351049253,
            0.9827805992915406,
            0.9920073311482963,
            0.9979126503638613,
            1.0,
            0.9979126503638616,
            0.9920073311482963,
            0.9827805992915406,
            0.9706811351049254,
            0.9561138337572239,
            0.9394435693322037,
            0.9209986565997595,
            0.9010740337649163,
            0.8799341877200164,
            0.8578158417136814,
            0.8349304238565177,
            0.8114663334994774,
            0.787591021238415,
            0.7634528971103397,
            0.7391830804463252,
            0.7148970038266844,
            0.6906958826399673,
            0.666668060873108,
            0.6428902429506017,
            0.6194286206911865,
            0.5963399037568026,
            0.5736722613265164,
            0.5514661821338862,
            0.5297552594563913,
            0.5085669071368457,
            0.4879230122460787,
            0.46784052956091077,
            0.448332022628867,
            0.4294061558188513,
            0.4110681414128452,
            0.39332014547557936,
            0.37616165594509093,
            0.35958981611538254,
            0.34359972643135095,
            0.32818471728425463,
            0.31333659528179847,
            0.2990458652691222,
            0.28530193019436406,
            0.2720932707439022,
            0.2594076065167967,
            0.2472320403644097,
            0.23555318738874298,
            0.22435728997089133,
            0.2136303200883769,
            0.2033580700762938,
            0.19352623289147977,
            0.184120472850753,
            0.17512648773299674,
            0.16653006306005644,
            0.1583171193025158,
            0.15047375269300042,
            0.14298627027130006,
            0.13584121973190966,
            0.12902541459521918,
            0.12252595517818105,
            0.11633024579856971,
            0.11042600860860997,
            0.10480129441854975,
            0.09944449083842746,
            0.09434432803662529,
            0.08948988238658151,
            0.08487057824808705,
            0.08047618810671575,
            0.0762968312739815,
            0.07232297133163028,
            0.06854541248590446,
            0.06495529498155227,
            0.061544089710662754,
            0.05830359213797924,
            0.0552259156520845,
            0.052303484440658854,
            0.04952902597780559,
            0.04689556320213414,
            0.04439640645581643,
            0.0420251452471234,
            0.03977563989192873,
            0.03764201308330233,
            0.03561864143252639,
            0.03370014701962348,
            0.3346319424403987,
            0.32040155198237974,
            0.3137501275616272,
            0.30021118059206026,
            0.2762446482151977,
            0.2639645026944648,
            0.9768062976122168,
            0.9814544303572138,
            0.8809602086261642,
            0.9019642955897619,
            0.8578158417136814,
            0.8799341877200164,
            0.9010740337649166,
            0.9209986565997597,
            0.9394435693322037,
            0.9561138337572239,
            0.9706811351049253,
            0.9827805992915406,
            0.9920073311482963,
            0.9979126503638613,
            1.0,
            0.9979126503638616,
            0.9920073311482963,
            0.9827805992915406,
            0.9706811351049254,
            0.9561138337572239,
            0.9394435693322037,
            0.9209986565997595,
            0.9010740337649163,
            0.8799341877200164,
            0.8578158417136814,
            0.8349304238565177,
            0.8114663334994774,
            0.787591021238415,
            0.7634528971103397,
            0.7391830804463252,
            0.7148970038266844,
            0.6906958826399673,
            0.666668060873108,
            0.6428902429506017,
            0.6194286206911865,
            0.5963399037568026,
            0.5736722613265164,
            0.5514661821338862,
            0.5297552594563913,
            0.5085669071368457,
            0.4879230122460787,
            0.46784052956091077,
            0.448332022628867,
            0.4294061558188513,
            0.4110681414128452,
            0.39332014547557936,
            0.37616165594509093,
            0.35958981611538254,
            0.34359972643135095,
            0.32818471728425463,
            0.31333659528179847,
            0.2990458652691222,
            0.28530193019436406,
            0.2720932707439022,
            0.2594076065167967,
            0.2472320403644097,
            0.23555318738874298,
            0.22435728997089133,
            0.2136303200883769,
            0.2033580700762938,
            0.19352623289147977,
            0.184120472850753,
            0.17512648773299674,
            0.16653006306005644,
            0.1583171193025158,
            0.15047375269300042,
            0.14298627027130006,
            0.13584121973190966,
            0.12902541459521918,
            0.12252595517818105,
            0.11633024579856971,
            0.11042600860860997,
            0.10480129441854975,
            0.09944449083842746,
            0.09434432803662529,
            0.08948988238658151,
            0.08487057824808705,
            0.08047618810671575,
            0.0762968312739815,
            0.07232297133163028,
            0.06854541248590446,
            0.06495529498155227,
            0.061544089710662754,
            0.05830359213797924,
            0.0552259156520845,
            0.052303484440658854,
            0.04952902597780559,
            0.04689556320213414,
            0.04439640645581643,
            0.0420251452471234,
            0.03977563989192873,
            0.03764201308330233,
            0.03561864143252639,
            0.03370014701962348,
            0.3346319424403987,
            0.32040155198237974,
            0.3137501275616272,
            0.30021118059206026,
            0.2762446482151977,
            0.2639645026944648,
            0.9768062976122168,
            0.9814544303572138,
            0.8809602086261642,
            0.9019642955897619,
            0.8578158417136814,
            0.8799341877200164,
            0.9010740337649166,
            0.9209986565997597,
            0.9394435693322037,
            0.9561138337572239,
            0.9706811351049253,
            0.9827805992915406,
            0.9920073311482963,
            0.9979126503638613,
            1.0,
            0.9979126503638616,
            0.9920073311482963,
            0.9827805992915406,
            0.9706811351049254,
            0.9561138337572239,
            0.9394435693322037,
            0.9209986565997595,
            0.9010740337649163,
            0.8799341877200164,
            0.8578158417136814,
            0.8349304238565177,
            0.8114663334994774,
            0.787591021238415,
            0.7634528971103397,
            0.7391830804463252,
            0.7148970038266844,
            0.6906958826399673,
            0.666668060873108,
            0.6428902429506017,
            0.6194286206911865,
            0.5963399037568026,
            0.5736722613265164,
            0.5514661821338862,
            0.5297552594563913,
            0.5085669071368457,
            0.4879230122460787,
            0.46784052956091077,
            0.448332022628867,
            0.4294061558188513,
            0.4110681414128452,
            0.39332014547557936,
            0.37616165594509093,
            0.35958981611538254,
            0.34359972643135095,
            0.32818471728425463,
            0.31333659528179847,
            0.2990458652691222,
            0.28530193019436406,
            0.2720932707439022,
            0.2594076065167967,
            0.2472320403644097,
            0.23555318738874298,
            0.22435728997089133,
            0.2136303200883769,
            0.2033580700762938,
            0.19352623289147977,
            0.184120472850753,
            0.17512648773299674,
            0.16653006306005644,
            0.1583171193025158,
            0.15047375269300042,
            0.14298627027130006,
            0.13584121973190966,
            0.12902541459521918,
            0.12252595517818105,
            0.11633024579856971,
            0.11042600860860997,
            0.10480129441854975,
            0.09944449083842746,
            0.09434432803662529,
            0.08948988238658151,
            0.08487057824808705,
            0.08047618810671575,
            0.0762968312739815,
            0.07232297133163028,
            0.06854541248590446,
            0.06495529498155227,
            0.061544089710662754,
            0.05830359213797924,
            0.0552259156520845,
            0.052303484440658854,
            0.04952902597780559,
            0.04689556320213414,
            0.04439640645581643,
            0.0420251452471234,
            0.03977563989192873,
            0.03764201308330233,
            0.03561864143252639,
            0.03370014701962348,
            0.3346319424403987,
            0.32040155198237974,
            0.3137501275616272,
            0.30021118059206026,
            0.2762446482151977,
            0.2639645026944648,
            0.9768062976122168,
            0.9814544303572138,
            0.8809602086261642,
            0.9019642955897619,
            0.8578158417136814,
            0.8799341877200164,
            0.9010740337649166,
            0.9209986565997597,
            0.9394435693322037,
            0.9561138337572239,
            0.9706811351049253,
            0.9827805992915406,
            0.9920073311482963,
            0.9979126503638613,
            1.0,
            0.9979126503638616,
            0.9920073311482963,
            0.9827805992915406,
            0.9706811351049254,
            0.9561138337572239,
            0.9394435693322037,
            0.9209986565997595,
            0.9010740337649163,
            0.8799341877200164,
            0.8578158417136814,
            0.8349304238565177,
            0.8114663334994774,
            0.787591021238415,
            0.7634528971103397,
            0.7391830804463252,
            0.7148970038266844,
            0.6906958826399673,
            0.666668060873108,
            0.6428902429506017,
            0.6194286206911865,
            0.5963399037568026,
            0.5736722613265164,
            0.5514661821338862,
            0.5297552594563913,
            0.5085669071368457,
            0.4879230122460787,
            0.46784052956091077,
            0.448332022628867,
            0.4294061558188513,
            0.4110681414128452,
            0.39332014547557936,
            0.37616165594509093,
            0.35958981611538254,
            0.34359972643135095,
            0.32818471728425463,
            0.31333659528179847,
            0.2990458652691222,
            0.28530193019436406,
            0.2720932707439022,
            0.2594076065167967,
            0.2472320403644097,
            0.23555318738874298,
            0.22435728997089133,
            0.2136303200883769,
            0.2033580700762938,
            0.19352623289147977,
            0.184120472850753,
            0.17512648773299674,
            0.16653006306005644,
            0.1583171193025158,
            0.15047375269300042,
            0.14298627027130006,
            0.13584121973190966,
            0.12902541459521918,
            0.12252595517818105,
            0.11633024579856971,
            0.11042600860860997,
            0.10480129441854975,
            0.09944449083842746,
            0.09434432803662529,
            0.08948988238658151,
            0.08487057824808705,
            0.08047618810671575,
            0.0762968312739815,
            0.07232297133163028,
            0.06854541248590446,
            0.06495529498155227,
            0.061544089710662754,
            0.05830359213797924,
            0.0552259156520845,
            0.052303484440658854,
            0.04952902597780559,
            0.04689556320213414,
            0.04439640645581643,
            0.0420251452471234,
            0.03977563989192873,
            0.03764201308330233,
            0.03561864143252639,
            0.03370014701962348,
        ];

        let mut sub_result = Vec::with_capacity(1);

        for _i in 0..1 {
            let mut c = vec![0.0];
            mat_mul(&mut c, &vector_1, &vector_2);
            sub_result.extend(c.iter());
        }

        sub_result
    }

    // allocate vector 1 and vector 2 and multiply a lot of times
    // check if all results are identical
    let first = allocate_and_multiply();
    println!("First:{:?}", first);
    for i in 1..10000 {
        let current = allocate_and_multiply();
        assert!(
            current == first,
            "Current multiplication gives (={:?}) but so far multiplications gave (={:?}) at iteration: {:?}",
            current,
            first,
            i
        );
    }
}
sarah-ek commented 1 month ago

i pushed another fix and added a test that should cover this kind of case (generating a bunch of random vectors and computing the dot products with various alignment offsets)

mg-gebert commented 1 month ago

The issue seems to be resolved with your last commit. All my tests pass. Thank you!