コード例 #1
0
        private InnerResult[] CalculateByPlan(ScalarPlan plan, Transmitter transmitter, Receiver receiver)
        {
            var items            = plan.Items;
            var separatedResults = new InnerResult[items.Length];

            for (int i = 0; i < separatedResults.Length; i++)
            {
                var calculator = GetPlanCalculator(items[i]);

                if (_ftof == FieldToField.J2E)
                {
                    separatedResults[i] = calculator.CalculateForE(transmitter, receiver);
                }

                if (_ftof == FieldToField.J2H)
                {
                    separatedResults[i] = calculator.CalculateForH(transmitter, receiver);
                }
            }

            if (plan.CalculateZeroRho)
            {
                CalculateZeroRho(separatedResults, plan);
            }

            return(separatedResults);
        }
コード例 #2
0
        public GreenScalars Calculate(ScalarPlan plan, IEnumerable <Transceiver> transceivers)
        {
            if (plan == null)
            {
                throw new ArgumentNullException(nameof(plan));
            }
            var trans = transceivers.ToArray();

            var notCombined = new InnerResult[trans.Length][]; //new Dictionary<Transceiver, List<InnerResult>>();

            IterateParallel(trans, i =>
            {
                notCombined[i] = CalculateByPlan(plan, trans[i].Transmitter, trans[i].Receiver);
            });

            var rho = plan.GetSortedRho();

            if (notCombined.Length == 0)
            {
                return(new GreenScalars(rho, new SingleGreenScalar[0]));
            }

            var combined = InnerResultsCombiner.CreateFromSample(plan, notCombined[0])
                           .CombineSeparatedScalars(trans, notCombined);

            return(new GreenScalars(rho, combined));
        }
コード例 #3
0
 public SingleGreenScalar(ScalarPlan plan, Transceiver transceiver, int length)
 {
     Transceiver = transceiver;
     I1          = plan.CalculateI1 ? new Complex[length] : new Complex[0];
     I2          = plan.CalculateI2 ? new Complex[length] : new Complex[0];
     I3          = plan.CalculateI3 ? new Complex[length] : new Complex[0];
     I4          = plan.CalculateI4 ? new Complex[length] : new Complex[0];
     I5          = plan.CalculateI5 ? new Complex[length] : new Complex[0];
 }
コード例 #4
0
        private ScalarPlan CreateFor(double rhoMin, double rhoMax, bool addZeroRho)
        {
            if (rhoMin <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(rhoMin));
            }

            float rhoStep = _hankel.GetLog10RhoStep();
            var   result  = new ScalarPlan(addZeroRho);

            AddLog10Plans(result, _hankel, rhoMin, rhoMax, rhoStep, _numberOfHankels);

            return(result);
        }
コード例 #5
0
        private void CalculateZeroRho(InnerResult[] separatedResults, ScalarPlan plan)
        {
            var target  = separatedResults[0];
            var rhoStep = plan.Items.First().HankelCoefficients.GetLog10RhoStep();

            if (_ftof == FieldToField.J2E)
            {
                ScalarMathUtils.CalculateZeroRhoForE(target, rhoStep);
            }

            if (_ftof == FieldToField.J2H)
            {
                ScalarMathUtils.CalculateZeroRhoForH(target, rhoStep);
            }
        }
コード例 #6
0
        public static ScalarSegments ReUseScalarSegments(Complex *ptr, ScalarPlan plan, GreenScalars scalars, int length)
        {
            var radii = scalars.Radii;
            int nComp = scalars.GetNumberOfAvailableIs(plan);
            int nRho  = radii.Length - 1;

            var  segments       = new SingleScalarSegment[nRho];
            long oneSegmentSize = length * nComp * 2L;

            for (int i = 0; i < segments.Length; i++)
            {
                var startPtr = ptr + oneSegmentSize * i;
                segments[i] = new SingleScalarSegment(plan, startPtr, length, nComp);
            }

            return(new ScalarSegments(ptr, radii, segments));
        }
コード例 #7
0
        private static void AddLog10Plans(ScalarPlan plan, HankelCoefficients hankel, double rhoMin, double rhoMax, double rhoStep, int n)
        {
            var rho1 = CreateRhoFromMin(rhoMin, rhoMax, rhoStep);

            var r2 = rho1[rho1.Length - 1];
            var r1 = rho1[rho1.Length - 2];

            var step = (r2 - r1) / n;


            plan.AddNewLog10PlanItem(hankel, rho1);

            for (int i = 1; i < n; i++)
            {
                var rhoN = CreateRhoFromMax(rhoMin, r2 - i * step, rhoStep);
                plan.AddNewLog10PlanItem(hankel, rhoN);
            }
        }
コード例 #8
0
        public SingleScalarSegment(ScalarPlan plan, Complex *startPtr, int length, int nComp)
        {
            int counter = 0;

            I1A = plan.CalculateI1 ? startPtr + length * counter++ : null;
            I2A = plan.CalculateI2 ? startPtr + length * counter++ : null;
            I3A = plan.CalculateI3 ? startPtr + length * counter++ : null;
            I4A = plan.CalculateI4 ? startPtr + length * counter++ : null;
            I5A = plan.CalculateI5 ? startPtr + length * counter++ : null;

            I1B = plan.CalculateI1 ? startPtr + length * counter++ : null;
            I2B = plan.CalculateI2 ? startPtr + length * counter++ : null;
            I3B = plan.CalculateI3 ? startPtr + length * counter++ : null;
            I4B = plan.CalculateI4 ? startPtr + length * counter++ : null;
            I5B = plan.CalculateI5 ? startPtr + length * counter++ : null;;

            if (counter != nComp * 2)
            {
                throw new InvalidOperationException();
            }
        }
コード例 #9
0
ファイル: ScalarPlanItem.cs プロジェクト: prisae/extreme
        public ScalarPlanItem(ScalarPlan parent, HankelCoefficients hankelCoefficients, double[] rho, double[] lambdas)
        {
            if (parent == null)
            {
                throw new ArgumentNullException(nameof(parent));
            }
            if (hankelCoefficients == null)
            {
                throw new ArgumentNullException(nameof(hankelCoefficients));
            }
            if (rho == null)
            {
                throw new ArgumentNullException(nameof(rho));
            }
            if (lambdas == null)
            {
                throw new ArgumentNullException(nameof(lambdas));
            }

            _parent            = parent;
            Lambdas            = lambdas;
            HankelCoefficients = hankelCoefficients;
            Rho = rho;
        }
コード例 #10
0
        public static ScalarSegments AllocateScalarSegments(INativeMemoryProvider memoryProvider, ScalarPlan plan, GreenScalars scalars, int length)
        {
            var radii    = scalars.Radii;
            int nRho     = radii.Length - 1;
            var segments = new SingleScalarSegment[nRho];

            int nComp = scalars.GetNumberOfAvailableIs(plan);
            var ptr   = memoryProvider.AllocateComplex(length * nComp * 2L * nRho);

            long oneSegmentSize = length * nComp * 2L;

            for (int i = 0; i < segments.Length; i++)
            {
                var startPtr = ptr + oneSegmentSize * i;
                segments[i] = new SingleScalarSegment(plan, startPtr, length, nComp);
            }

            return(new ScalarSegments(memoryProvider, ptr, radii, segments));
        }
コード例 #11
0
 private static ScalarSegments AllocateScalarSegments(INativeMemoryProvider memoryProvider, ScalarPlan plan, GreenScalars scalars)
 => AllocateScalarSegments(memoryProvider, plan, scalars, scalars.SingleScalars.Length);
コード例 #12
0
        public static ScalarSegments AllocateAndConvert(INativeMemoryProvider memoryProvider, ScalarPlan plan, GreenScalars scalars)
        {
            var segments = AllocateScalarSegments(memoryProvider, plan, scalars);

            ConvertScalarsToSegments(scalars, segments);
            return(segments);
        }