MathNet.Numerics.Providers.LinearAlgebra.Mkl.MklLinearAlgebraProvider.InitializeVerify C# (CSharp) Method

InitializeVerify() public method

Initialize and verify that the provided is indeed available. If calling this method fails, consider to fall back to alternatives like the managed provider.
public InitializeVerify ( ) : void
return void
        public override void InitializeVerify()
        {
            // TODO: Choose x86 or x64 based on Environment.Is64BitProcess

            int a, b, linearAlgebra;
            try
            {
                a = SafeNativeMethods.query_capability(0);
                b = SafeNativeMethods.query_capability(1);

                _nativeIX86 = SafeNativeMethods.query_capability(8) > 0;
                _nativeX64 = SafeNativeMethods.query_capability(9) > 0;
                _nativeIA64 = SafeNativeMethods.query_capability(10) > 0;

                _nativeRevision = SafeNativeMethods.query_capability(64);
                linearAlgebra = SafeNativeMethods.query_capability(128);
            }
            catch (DllNotFoundException e)
            {
                throw new NotSupportedException("MKL Native Provider not found.", e);
            }
            catch (BadImageFormatException e)
            {
                throw new NotSupportedException("MKL Native Provider found but failed to load. Please verify that the platform matches (x64 vs x32, Windows vs Linux).", e);
            }
            catch (EntryPointNotFoundException e)
            {
                throw new NotSupportedException("MKL Native Provider does not support capability querying and is therefore not compatible. Consider upgrading to a newer version.", e);
            }

            if (a != 0 || b != -1 || linearAlgebra <=0 || _nativeRevision < 4)
            {
                throw new NotSupportedException("MKL Native Provider too old or not compatible. Consider upgrading to a newer version.");
            }

            // set numerical consistency, precision and accuracy modes, if supported
            if (SafeNativeMethods.query_capability(65) > 0)
            {
                SafeNativeMethods.set_consistency_mode((int)_consistency);
                SafeNativeMethods.set_vml_mode((uint)_precision | (uint)_accuracy);
            }

            // set threading settings, if supported
            if (SafeNativeMethods.query_capability(66) > 0)
            {
                SafeNativeMethods.set_max_threads(Control.MaxDegreeOfParallelism);
            }
        }