コード例 #1
0
            public void RunStructFldScenario(SimpleBinaryOpTest__CompareLessThanOrEqualDouble testClass)
            {
                var result = Avx.CompareLessThanOrEqual(_fld1, _fld2);

                Unsafe.Write(testClass._dataTable.outArrayPtr, result);
                testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr);
            }
コード例 #2
0
        public void RunClassFldScenario()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario));

            var result = Avx.CompareLessThanOrEqual(_fld1, _fld2);

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr);
        }
コード例 #3
0
        public void VAll_Case_All_True_Should_Return_True()
        {
            var result = a
                         .Zip(b)
                         .Select(x => Avx.CompareLessThanOrEqual(x.Second, x.First))
                         .All();

            result.Should().BeTrue();
        }
コード例 #4
0
        public void RunClassLclFldScenario()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));

            var test   = new SimpleBinaryOpTest__CompareLessThanOrEqualDouble();
            var result = Avx.CompareLessThanOrEqual(test._fld1, test._fld2);

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr);
        }
コード例 #5
0
        public void RunStructLclFldScenario()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));

            var test   = TestStruct.Create();
            var result = Avx.CompareLessThanOrEqual(test._fld1, test._fld2);

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr);
        }
コード例 #6
0
        public void Vall_Case_Not_All_True_Should_Return_False()
        {
            b[1] = Vector256.Create(3.0, 4, 100, 2);

            a
            .Zip(b)
            .Select(x => Avx.CompareLessThanOrEqual(x.Second, x.First))
            .All()
            .Should().BeFalse();
        }
コード例 #7
0
        public void RunLclVarScenario_LoadAligned()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned));

            var op1    = Avx.LoadAlignedVector256((Double *)(_dataTable.inArray1Ptr));
            var op2    = Avx.LoadAlignedVector256((Double *)(_dataTable.inArray2Ptr));
            var result = Avx.CompareLessThanOrEqual(op1, op2);

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(op1, op2, _dataTable.outArrayPtr);
        }
コード例 #8
0
        public void RunLclVarScenario_UnsafeRead()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead));

            var op1    = Unsafe.Read <Vector256 <Double> >(_dataTable.inArray1Ptr);
            var op2    = Unsafe.Read <Vector256 <Double> >(_dataTable.inArray2Ptr);
            var result = Avx.CompareLessThanOrEqual(op1, op2);

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(op1, op2, _dataTable.outArrayPtr);
        }
コード例 #9
0
        public void RunBasicScenario_UnsafeRead()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead));

            var result = Avx.CompareLessThanOrEqual(
                Unsafe.Read <Vector256 <Single> >(_dataTable.inArray1Ptr),
                Unsafe.Read <Vector256 <Single> >(_dataTable.inArray2Ptr)
                );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
        }
コード例 #10
0
        public void RunBasicScenario_Load()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load));

            var result = Avx.CompareLessThanOrEqual(
                Avx.LoadVector256((Double *)(_dataTable.inArray1Ptr)),
                Avx.LoadVector256((Double *)(_dataTable.inArray2Ptr))
                );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
        }
コード例 #11
0
            public void RunStructFldScenario_Load(SimpleBinaryOpTest__CompareLessThanOrEqualDouble testClass)
            {
                fixed(Vector256 <Double> *pFld1 = &_fld1)
                fixed(Vector256 <Double> *pFld2 = &_fld2)
                {
                    var result = Avx.CompareLessThanOrEqual(
                        Avx.LoadVector256((Double *)(pFld1)),
                        Avx.LoadVector256((Double *)(pFld2))
                        );

                    Unsafe.Write(testClass._dataTable.outArrayPtr, result);
                    testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr);
                }
            }
コード例 #12
0
        public void RunClsVarScenario_Load()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load));

            fixed(Vector256 <Single> *pClsVar1 = &_clsVar1)
            fixed(Vector256 <Single> *pClsVar2 = &_clsVar2)
            {
                var result = Avx.CompareLessThanOrEqual(
                    Avx.LoadVector256((Single *)(pClsVar1)),
                    Avx.LoadVector256((Single *)(pClsVar2))
                    );

                Unsafe.Write(_dataTable.outArrayPtr, result);
                ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr);
            }
        }
コード例 #13
0
        public void RunClassFldScenario_Load()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load));

            fixed(Vector256 <Double> *pFld1 = &_fld1)
            fixed(Vector256 <Double> *pFld2 = &_fld2)
            {
                var result = Avx.CompareLessThanOrEqual(
                    Avx.LoadVector256((Double *)(pFld1)),
                    Avx.LoadVector256((Double *)(pFld2))
                    );

                Unsafe.Write(_dataTable.outArrayPtr, result);
                ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr);
            }
        }
コード例 #14
0
        public void RunClassLclFldScenario_Load()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load));

            var test = new SimpleBinaryOpTest__CompareLessThanOrEqualSingle();

            fixed(Vector256 <Single> *pFld1 = &test._fld1)
            fixed(Vector256 <Single> *pFld2 = &test._fld2)
            {
                var result = Avx.CompareLessThanOrEqual(
                    Avx.LoadVector256((Single *)(pFld1)),
                    Avx.LoadVector256((Single *)(pFld2))
                    );

                Unsafe.Write(_dataTable.outArrayPtr, result);
                ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr);
            }
        }
コード例 #15
0
        public static Vector128 <float> GetBrucePsmeAbgrGrowthEffectiveAge(SiteConstants site, float timeStepInYears, Vector128 <float> treeHeight, out Vector128 <float> potentialHeightGrowth)
        {
            Vector128 <float> B1     = AvxExtensions.BroadcastScalarToVector128(site.B1);
            Vector128 <float> B2     = AvxExtensions.BroadcastScalarToVector128(site.B2);
            Vector128 <float> X2toB2 = AvxExtensions.BroadcastScalarToVector128(site.X2toB2);
            Vector128 <float> siteIndexFromGround128 = AvxExtensions.BroadcastScalarToVector128(site.SiteIndexFromGround);
            Vector128 <float> X1 = AvxExtensions.BroadcastScalarToVector128(site.X1);

            Vector128 <float> XX1                = Avx.Add(Avx.Divide(MathV.Ln(Avx.Divide(treeHeight, siteIndexFromGround128)), B1), X2toB2);
            Vector128 <float> xx1lessThanZero    = Avx.CompareLessThanOrEqual(XX1, Vector128 <float> .Zero);
            Vector128 <float> growthEffectiveAge = Avx.Subtract(MathV.Pow(XX1, Avx.Reciprocal(B2)), X1);

            growthEffectiveAge = Avx.BlendVariable(growthEffectiveAge, AvxExtensions.BroadcastScalarToVector128(500.0F), xx1lessThanZero);

            Vector128 <float> timeStepInYearsPlusX1 = AvxExtensions.BroadcastScalarToVector128(timeStepInYears + site.X1);
            Vector128 <float> potentialHeightPower  = Avx.Multiply(B1, Avx.Subtract(MathV.Pow(Avx.Add(growthEffectiveAge, timeStepInYearsPlusX1), B2), X2toB2));
            Vector128 <float> potentialHeight       = Avx.Multiply(siteIndexFromGround128, MathV.Exp(potentialHeightPower));

            potentialHeightGrowth = Avx.Subtract(potentialHeight, treeHeight);

            return(growthEffectiveAge);
        }
コード例 #16
0
ファイル: FiaVolume.cs プロジェクト: OSU-MARS/SEEM
        public static unsafe float GetScribnerBoardFeetPerAcre(Trees trees)
        {
            // for now, assume all trees are of the same species
            if (trees.Species != FiaCode.PseudotsugaMenziesii)
            {
                throw new NotSupportedException();
            }
            if (trees.Units != Units.English)
            {
                throw new NotSupportedException();
            }

            // Douglas-fir
            #if DEBUG
            Vector128 <float> v6p8 = AvxExtensions.BroadcastScalarToVector128(6.8F);
            Vector128 <float> v10k = AvxExtensions.BroadcastScalarToVector128(10.0F * 1000.0F);
            #endif

            // constants
            Vector128 <float> forestersEnglish = AvxExtensions.BroadcastScalarToVector128(Constant.ForestersEnglish);
            Vector128 <float> one = AvxExtensions.BroadcastScalarToVector128(1.0F);
            Vector128 <float> six = AvxExtensions.BroadcastScalarToVector128(6.0F);

            Vector128 <float> vm3p21809   = AvxExtensions.BroadcastScalarToVector128(-3.21809F); // b4
            Vector128 <float> v0p04948    = AvxExtensions.BroadcastScalarToVector128(0.04948F);
            Vector128 <float> vm0p15664   = AvxExtensions.BroadcastScalarToVector128(-0.15664F);
            Vector128 <float> v2p02132    = AvxExtensions.BroadcastScalarToVector128(2.02132F);
            Vector128 <float> v1p63408    = AvxExtensions.BroadcastScalarToVector128(1.63408F);
            Vector128 <float> vm0p16184   = AvxExtensions.BroadcastScalarToVector128(-0.16184F);
            Vector128 <float> v1p033      = AvxExtensions.BroadcastScalarToVector128(1.033F);
            Vector128 <float> v1p382937   = AvxExtensions.BroadcastScalarToVector128(1.382937F);
            Vector128 <float> vm0p4015292 = AvxExtensions.BroadcastScalarToVector128(-0.4015292F);
            Vector128 <float> v0p087266   = AvxExtensions.BroadcastScalarToVector128(0.087266F);
            Vector128 <float> vm0p174533  = AvxExtensions.BroadcastScalarToVector128(-0.174533F);

            Vector128 <float> vm0p6896598794 = AvxExtensions.BroadcastScalarToVector128(-0.6896598794F); // rc6-rs632
            Vector128 <float> v0p993         = AvxExtensions.BroadcastScalarToVector128(0.993F);
            Vector128 <float> v0p174439      = AvxExtensions.BroadcastScalarToVector128(0.174439F);
            Vector128 <float> v0p117594      = AvxExtensions.BroadcastScalarToVector128(0.117594F);
            Vector128 <float> vm8p210585     = AvxExtensions.BroadcastScalarToVector128(-8.210585F);
            Vector128 <float> v0p236693      = AvxExtensions.BroadcastScalarToVector128(0.236693F);
            Vector128 <float> v0p00001345    = AvxExtensions.BroadcastScalarToVector128(0.00001345F);
            Vector128 <float> v0p00001937    = AvxExtensions.BroadcastScalarToVector128(0.00001937F);
            Vector128 <float> v1p001491      = AvxExtensions.BroadcastScalarToVector128(1.001491F);
            Vector128 <float> vm6p924097     = AvxExtensions.BroadcastScalarToVector128(-6.924097F);
            Vector128 <float> v0p912733      = AvxExtensions.BroadcastScalarToVector128(0.912733F);
            Vector128 <float> v0p00001351    = AvxExtensions.BroadcastScalarToVector128(0.00001351F);

            fixed(float *dbh = &trees.Dbh[0], expansionFactors = &trees.LiveExpansionFactor[0], height = &trees.Height[0])
            {
                Vector128 <float> standBoardFeetPerAcre = Vector128 <float> .Zero;

                for (int treeIndex = 0; treeIndex < trees.Count; treeIndex += Constant.Simd128x4.Width)
                {
                    Vector128 <float> dbhInInches  = Avx.LoadVector128(dbh + treeIndex);
                    Vector128 <float> heightInFeet = Avx.LoadVector128(height + treeIndex);

                    Vector128 <float> logDbhInInches  = MathV.Log10(dbhInInches);
                    Vector128 <float> logHeightInFeet = MathV.Log10(heightInFeet);
                    // FiaCode.PseudotsugaMenziesii => -3.21809F + 0.04948F * logHeightInFeet * logDbhInInches - 0.15664F * logDbhInInches * logDbhInInches +
                    //                                  2.02132F * logDbhInInches + 1.63408F * logHeightInFeet - 0.16184F * logHeightInFeet * logHeightInFeet,
                    Vector128 <float> cvtsl = Avx.Add(vm3p21809, Avx.Multiply(v0p04948, Avx.Multiply(logHeightInFeet, logDbhInInches)));
                    cvtsl = Avx.Add(cvtsl, Avx.Multiply(vm0p15664, Avx.Multiply(logDbhInInches, logDbhInInches)));
                    cvtsl = Avx.Add(cvtsl, Avx.Multiply(v2p02132, logDbhInInches));
                    cvtsl = Avx.Add(cvtsl, Avx.Multiply(v1p63408, logHeightInFeet));
                    cvtsl = Avx.Add(cvtsl, Avx.Multiply(vm0p16184, Avx.Multiply(logHeightInFeet, logHeightInFeet)));
                    Vector128 <float> cubicFeet = MathV.Exp10(cvtsl);

                    Vector128 <float> dbhSquared            = Avx.Multiply(dbhInInches, dbhInInches); // could be consolidated by merging other scaling constants with Forester's constant for basal area
                    Vector128 <float> basalAreaInSquareFeet = Avx.Multiply(forestersEnglish, dbhSquared);
                    // b4 = cubicFeet / (1.033F * (1.0F + 1.382937F * MathV.Exp(-4.015292F * dbhInInches / 10.0F)) * (basalAreaInSquareFeet + 0.087266F) - 0.174533F);
                    Vector128 <float> b4 = Avx.Divide(cubicFeet, Avx.Add(Avx.Multiply(v1p033,
                                                                                      Avx.Multiply(Avx.Add(one, Avx.Multiply(v1p382937,
                                                                                                                             MathV.Exp(Avx.Multiply(vm0p4015292,
                                                                                                                                                    dbhInInches)))),
                                                                                                   Avx.Add(basalAreaInSquareFeet, v0p087266))),
                                                                         vm0p174533));
                    Vector128 <float> cv4 = Avx.Multiply(b4, Avx.Subtract(basalAreaInSquareFeet, v0p087266));

                    // conversion to Scribner volumes for 32 foot trees
                    // Waddell 2014:32
                    // rc6 = 0.993F * (1.0F - MathF.Pow(0.62F, dbhInInches - 6.0F));
                    Vector128 <float> rc6   = Avx.Multiply(v0p993, Avx.Subtract(one, MathV.Exp(Avx.Multiply(vm0p6896598794, Avx.Subtract(dbhInInches, six))))); // log2(0.62) = -0.6896598794
                    Vector128 <float> cv6   = Avx.Multiply(rc6, cv4);
                    Vector128 <float> logB4 = MathV.Log10(b4);
                    // float rs616 = MathF.Pow(10.0F, 0.174439F + 0.117594F * logDbhInInches * logB4 - 8.210585F / (dbhInInches * dbhInInches) + 0.236693F * logB4 - 0.00001345F * b4 * b4 - 0.00001937F * dbhInInches * dbhInInches);
                    Vector128 <float> rs616l = Avx.Add(v0p174439, Avx.Multiply(v0p117594, Avx.Multiply(logDbhInInches, logB4)));
                    rs616l = Avx.Add(rs616l, Avx.Divide(vm8p210585, dbhSquared));
                    rs616l = Avx.Add(rs616l, Avx.Multiply(v0p236693, logB4));
                    rs616l = Avx.Subtract(rs616l, Avx.Multiply(v0p00001345, Avx.Multiply(b4, b4)));
                    rs616l = Avx.Subtract(rs616l, Avx.Multiply(v0p00001937, dbhSquared));
                    Vector128 <float> rs616 = MathV.Exp10(rs616l);
                    Vector128 <float> sv616 = Avx.Multiply(rs616, cv6); // Scribner board foot volume to a 6 inch top for 16 foot logs
                    // float rs632 = 1.001491F - 6.924097F / tarif + 0.00001351F * dbhInInches * dbhInInches;
                    Vector128 <float> rs632 = Avx.Add(v1p001491, Avx.Divide(vm6p924097, Avx.Multiply(v0p912733, b4)));
                    rs632 = Avx.Add(rs632, Avx.Multiply(v0p00001351, dbhSquared));
                    Vector128 <float> zeroVolumeMask = Avx.CompareLessThanOrEqual(dbhInInches, six);
                    Vector128 <float> sv632          = Avx.Multiply(rs632, sv616); // Scribner board foot volume to a 6 inch top for 32 foot logs
                    sv632 = Avx.BlendVariable(sv632, Vector128 <float> .Zero, zeroVolumeMask);

                    #if DEBUG
                    DebugV.Assert(Avx.CompareGreaterThanOrEqual(Avx.BlendVariable(rc6, Vector128 <float> .Zero, zeroVolumeMask), Vector128 <float> .Zero));
                    DebugV.Assert(Avx.CompareLessThanOrEqual(rc6, one));
                    DebugV.Assert(Avx.CompareGreaterThanOrEqual(Avx.BlendVariable(rs616, one, zeroVolumeMask), one));
                    DebugV.Assert(Avx.CompareLessThanOrEqual(Avx.BlendVariable(rs616, Vector128 <float> .Zero, zeroVolumeMask), v6p8));
                    DebugV.Assert(Avx.CompareGreaterThanOrEqual(Avx.BlendVariable(rs632, Vector128 <float> .Zero, zeroVolumeMask), Vector128 <float> .Zero));
                    DebugV.Assert(Avx.CompareLessThanOrEqual(Avx.BlendVariable(rs632, Vector128 <float> .Zero, zeroVolumeMask), one));
                    DebugV.Assert(Avx.CompareGreaterThanOrEqual(Avx.BlendVariable(sv632, Vector128 <float> .Zero, zeroVolumeMask), Vector128 <float> .Zero));
                    DebugV.Assert(Avx.CompareLessThanOrEqual(Avx.BlendVariable(sv632, Vector128 <float> .Zero, zeroVolumeMask), v10k));
                    #endif

                    Vector128 <float> expansionFactor = Avx.LoadVector128(expansionFactors + treeIndex);
                    standBoardFeetPerAcre = Avx.Add(standBoardFeetPerAcre, Avx.Multiply(expansionFactor, sv632));
                }

                standBoardFeetPerAcre = Avx.HorizontalAdd(standBoardFeetPerAcre, standBoardFeetPerAcre);
                standBoardFeetPerAcre = Avx.HorizontalAdd(standBoardFeetPerAcre, standBoardFeetPerAcre);
                return(standBoardFeetPerAcre.ToScalar());
            }
        }
コード例 #17
0
        public static IEnumerable <(double, double[])> Rk45(
            Func <Vector256 <double>, IEnumerable <Vector256 <double> >, IEnumerable <Vector256 <double> > > func,
            double[] y0,
            double t0,
            double tEnd,
            double[] tOut,
            double h,
            double hMax,
            double[] epsilon)
        {
#if VALIDATION
            // Argument validation
            if (y0.Length < 1)
            {
                throw new ArgumentException("The initial state array must contain at least one item", nameof(y0));
            }

            if (tEnd <= t0)
            {
                throw new ArgumentException("The end time must be larger than the start time", nameof(tEnd));
            }

            tOut = tOut.OrderBy(v => v).ToArray();
            if (tOut.Length > 0 && (tOut.First() <= t0 || tOut.Last() >= tEnd))
            {
                throw new ArgumentException(
                          $"The output times must be in the range ({nameof(t0)}, {nameof(tEnd)})]",
                          nameof(tOut));
            }

            if (epsilon.Length < 1 || (epsilon.Length > 1 && epsilon.Length != y0.Length))
            {
                throw new ArgumentException(
                          $"{nameof(epsilon)} must either contain a single element "
                          + "or have the same length as {nameof(y0)}.",
                          nameof(epsilon));
            }
#endif

            // Initialization
            var y    = y0.Load().ToArray();
            var t    = t0;
            var veps = epsilon.Load(epsilon[0]).ToArray();

            // Output at t0
            yield return(t, y.Unpack().ToArray());

#if DENSE_OUTPUT
            // Construct enumerator for output points
            var tOutEnum = tOut.Concat(
                Enumerable.Repeat(double.NegativeInfinity, int.MaxValue)).GetEnumerator();
            tOutEnum.MoveNext();
            var tNextOut = tOutEnum.Current;
            var doOutput = false;
#endif

            // Perform iterations
            do
            {
                // Clamp h to not exceed hmax and not overshoot tend
                h = Math.Min(Math.Min(h, hMax), tEnd - t);

#if DENSE_OUTPUT
                // Clamp h in case it would overshoot next output time.
                // Note that this can (and should) be improved in such a way
                // that the step size is not adapted but the intermediate value
                // for the output instant is interpolated using a cubic Hermite
                // spline constructed from y(t), y(t+h), f(t, y(t)) and
                // f(t+h, y(t+h)).
                var dtOut = tNextOut - t;
                if (dtOut > 0 && dtOut < h)
                {
                    h        = dtOut;
                    doOutput = true;
                }
#endif

                var vh = Vector256.Create(h);
                // Calculate k1 through k6
                var k1 = func(V(t + h * A1), y).Mul(vh).ToArray();
                var k2 = func(V(t + h * A2), k1.MulAdd(VB21, y)).Mul(vh).ToArray();
                var k3 = func(V(t + h * A3), k2.MulAdd(VB32, k1.MulAdd(VB31, y))).Mul(vh).ToArray();
                var k4 = func(V(t + h * A4), k3.MulAdd(VB43, k2.MulAdd(VB42, k1.MulAdd(VB41, y)))).Mul(vh).ToArray();
                var k5 = func(V(t + h * A5), k4.MulAdd(VB54, k3.MulAdd(VB53, k2.MulAdd(VB52, k1.MulAdd(VB51, y))))).Mul(vh).ToArray();
                var k6 = func(V(t + h * A6), k5.MulAdd(VB65, k4.MulAdd(VB64, k3.MulAdd(VB63, k2.MulAdd(VB62, k1.MulAdd(VB61, y)))))).Mul(vh).ToArray();

                // Calculate error estimate for each component
                var te = k1.MulAdd(VCt1,
                                   k2.MulAdd(VCt2,
                                             k3.MulAdd(VCt3,
                                                       k4.MulAdd(VCt4,
                                                                 k5.MulAdd(VCt5,
                                                                           k6.Mul(VCt6)))))).Select(v => v.Abs());

                // If only single epsilon given, reduce
                if (epsilon.Length == 1)
                {
                    te = new[] { V(te.Max()) };
                }

                // If error criterion is fulfilled, perform increment
                if (te.Zip(veps).Select(x =>
                                        Avx.CompareLessThanOrEqual(x.First, x.Second)).All())
                {
                    y = k6.MulAdd(VCh6,
                                  k5.MulAdd(VCh5,
                                            k4.MulAdd(VCh4,
                                                      k3.MulAdd(VCh3,
                                                                k2.MulAdd(VCh2,
                                                                          k1.MulAdd(VCh1, y)))))).ToArray();
                    t += h;

#if DENSE_OUTPUT
                    // If required, yield result
                    if (doOutput)
                    {
                        doOutput = false;
                        tOutEnum.MoveNext();
                        tNextOut = tOutEnum.Current;
                        yield return(t, y.Unpack().ToArray());
                    }
#endif
                }

                // Adapt step size
                h *= 0.9 * Math.Pow(veps.Div(te).Min(), 1.0 / 5);
            } while (t < tEnd);

            // Output at tend
            yield return(t, y.Unpack().ToArray());
        }
コード例 #18
0
 public static m32 LessThanOrEqual(f32 lhs, f32 rhs) => Avx.CompareLessThanOrEqual(lhs, rhs).AsInt32();