Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling of Double[] #17

Open
sqhuo opened this issue Nov 9, 2022 · 2 comments
Open

Handling of Double[] #17

sqhuo opened this issue Nov 9, 2022 · 2 comments

Comments

@sqhuo
Copy link

sqhuo commented Nov 9, 2022

Tthe C# Array "Double[]" of double type is treated as pointers to array of pointers to double. For example, a[i] (in C#) would be converted to *(a->GetData(i)) instead of a->GetData(i). After adding "double" as a fundamental type in Lib/src/public/System/support/internal/TypeTraits.h, only some of the cases are handled correctly while others are still not correct.

C# Code Example:
...
// Initialize Gaussian data lists
gauss_h = new Double[fit.num_gauss];
gauss_h_cross = new Double[fit.num_gauss];
gauss_p = new Double[fit.num_gauss];
gauss_p_init = new Double[fit.num_gauss];
for (i = 0; i < fit.num_gauss; i++)
{
vec.error_position[i] = Math.Abs(gauss_p_init[i] - gauss_p[i]) >= extend.peak_diff_cutoff;
}

        // Determine the cross-normalized peak heights
        for (i = 0; i < fit.num_gauss; i++)
        {
            vec.normalized_cross_height[i]  = (CROSS_COEFF * metric_cross * Math.Abs(gauss_h[i])) + (metric * Math.Abs(gauss_h_cross[i]));
            vec.normalized_cross_height[i] /= (CROSS_COEFF * metric_cross) + metric;
        }

...
C++ output:
...
Array* array = new Array((int)(fit->num_gauss));
Array* array2 = new Array((int)(fit->num_gauss));
Array* array3 = new Array((int)(fit->num_gauss));
Array* array4 = new Array((int)(fit->num_gauss));
for (uint num = 0u; num < (uint)(fit->num_gauss); num += 1u) {
vec->error_position->SetData((int)(num), Math::Abs(*(array4->GetData((int)(num))) - *(array3->GetData((int)(num)))) >= extend->peak_diff_cutoff);
}
for (uint num = 0u; num < (uint)(fit->num_gauss); num += 1u) {
vec->normalized_cross_height->SetData((int)(num), ((5.0 * metric_cross) * Math::Abs(array->GetData((int)(num)))) + (metric * Math::Abs(array2->GetData((int)(num)))));
vec->normalized_cross_height->SetData((int)(num), (5.0 * metric_cross) + metric);
}
...

@sqhuo
Copy link
Author

sqhuo commented Nov 9, 2022

Is the repository being actively maintained?

@NCLnclNCL
Copy link

Hey

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants