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); }
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)); }
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]; }
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); }
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); } }
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)); }
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); } }
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(); } }
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; }
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)); }
private static ScalarSegments AllocateScalarSegments(INativeMemoryProvider memoryProvider, ScalarPlan plan, GreenScalars scalars) => AllocateScalarSegments(memoryProvider, plan, scalars, scalars.SingleScalars.Length);
public static ScalarSegments AllocateAndConvert(INativeMemoryProvider memoryProvider, ScalarPlan plan, GreenScalars scalars) { var segments = AllocateScalarSegments(memoryProvider, plan, scalars); ConvertScalarsToSegments(scalars, segments); return(segments); }