Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7745217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:57:29+00:00 2026-06-01T09:57:29+00:00

I have compiled part of boost – the ibeta_inv function – into a .Net

  • 0

I have compiled part of boost – the ibeta_inv function – into a .Net 64 bit assembly and it worked great until I started calling it from multiple threads. Then it occationally return wrong results.

I complied it using this code (C++/CLI):

// Boost.h

#pragma once

#include <boost/math/special_functions/beta.hpp>

using namespace boost::math;

namespace Boost {

    public ref class BoostMath
    {
    public:
        double static InverseIncompleteBeta( double a, double b, double x )
        {
            return ibeta_inv(a,b,x);
        }
    };
}

Has anyone tried this before?

I have NOT tried this outside .Net, so I don’t know if this is the cause, but I really don’t see why, since it works great single threaded.

Usage (C#):

private void calcBoost(List<Val> vals)
{
    //gives WRONG results (sometimes):
    vals.AsParallel().ForAll(v => v.BoostResult = BoostMath.InverseIncompleteBeta(v.A, v.B, v.X));
    //gives CORRECT results:
    vals.ForEach(v => v.BoostResult = BoostMath.InverseIncompleteBeta(v.A, v.B, v.X));
}

UPDATE: As can be seen in my comments below – I’m not sure at all anymore that this is a Boost problem. Maybe it is some weird PLinq to C++/CLI bug??? I’m blaffed and will return with more facts later.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T09:57:30+00:00Added an answer on June 1, 2026 at 9:57 am

    I happen to have encapsulated part of boost in a C++/CLI 64bit project and use it from C# exactly as you do.

    So I threw in your C++ class in my own Boost wrapper and added this code to the C# project:

        private class Val
        {
            public double A;
            public double B;
            public double X;
            public double ParallellResult;
        }
    
        private static void findParallelError()
        {
            var r = new Random();
    
            while (true)
            {
                var vals = new List<Val>();
                for (var i = 0; i < 1000*1000; i++)
                {
                    var val = new Val();
                    val.A = r.NextDouble()*100;
                    val.B = val.A + r.NextDouble()*1000;
                    val.X = r.NextDouble();
                    vals.Add(val);
                }
    
                // parallel calculation
                vals.AsParallel().ForAll(v => v.ParallellResult = Boost.BoostMath.InverseIncompleteBeta(v.A, v.B, v.X));
    
                /sequential verification
                var error = vals.Exists(v => v.ParallellResult != Boost.BoostMath.InverseIncompleteBeta(v.A, v.B, v.X));
                if (error)
                    return;
            }
        }
    

    And it just executes “forever”. The parallel results are equal to the sequential results all the time. No thread unsafety here…

    May I suggest that you download a fresh copy of Boost and include it in a completely new project and try this out?

    I also notice that you called your result “BoostResult”… and mention in the comments something about “our current implementaion”. Exactly what are you comparing your result agains? What is your definition of “correct”?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have compiled a .NET application using Any CPU option. This .NET application uses
I have a small project where I need just part of boost library, boost::regex
I have some C++ projects running through cruisecontrol.net . As a part of the
Many utilities of boost have been included as part of extended C++ TR1 currently.
I have a package I've created in C++ and, have already compiled it into
I have a C++ assembly with both managed and umanaged code compiled to a
I have been using Boost (the header only library part) for sometime now. I
I have found the rand_s function, part of the CRT, to be extremely useful
I have some trouble forward declaring a function that uses boost::enable_if : the following
I have a pre compiled form which i need to insert a button into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.