/// <summary> /// Creates statistics for the np-chart. /// </summary> /// <param name="DefectCountInSample">Count of failed samples per-sample.</param> /// <param name="SampleSize">Size of each sample</param> /// <param name="Stds">Number of standard deviations, either 1, 2, or 3 to use for control limits</param> /// <param name="ChartTitle">Title of chart.</param> /// <param name="TimeStart">The start time of the data.</param> /// <param name="TimeInterval">Time interval between each sample group.</param> /// <param name="TimeAxisLabel">Horizontal axis label.</param> /// <param name="StatisticsLabel">Vertical axis label.</param> public Stats_np(DoubleVector DefectCountInSample, int SampleSize, Double Stds, String ChartTitle, Double TimeStart, Double TimeInterval, String TimeAxisLabel, String StatisticsLabel) { double pbar; if (Stds == 1 || Stds == 2 || Stds == 3) { pbar = StatsFunctions.Sum(DefectCountInSample) / (SampleSize * DefectCountInSample.Length); this.CenterLine = pbar * SampleSize; this.ConstControlLimits = true; this.UCL = new DoubleVector(DefectCountInSample.Length, this.CenterLine + Stds * StatsFunctions.Sqrt( SampleSize * pbar * (1 - pbar) )); this.LCL = new DoubleVector(DefectCountInSample.Length, this.CenterLine - Stds * StatsFunctions.Sqrt( SampleSize * pbar * (1 - pbar) )); for (int i = 0; i < this.LCL.Length; i++) { if (this.LCL[i] < 0) this.LCL[i] = 0; } this.Statistic = DefectCountInSample; this.TimeStart = TimeStart; this.TimeSampleInterval = TimeInterval; this.TimeLabel = TimeAxisLabel; this.DefectLabel = StatisticsLabel; this.ChartTitle = ChartTitle; } else { throw new ArgumentException("In Stats_np, the number of standard deviations must be either 1, 2, or 3"); } }
/// <summary> /// Adds a step line series to the chart /// </summary> /// <param name="chart"></param> /// <param name="name"></param> /// <param name="vector"></param> /// <param name="xstart"></param> /// <param name="xincrement"></param> void AddStepLineSeries(NChart chart, string name, DoubleVector vector, double xstart, double xincrement) { NStepLineSeries stepline = new NStepLineSeries(); chart.Series.Add(stepline); // Name the line stepline.Name = name; // Tell the series to regard the X values stepline.UseXValues = true; // No data labels stepline.DataLabelStyle.Visible = false; // Set the line color stepline.BorderStyle = new NStrokeStyle(1.0f, Color.Gray, LinePattern.Dash); // Fill X values for (int i = 0; i < vector.Length; i++) { stepline.XValues.Add(xstart + xincrement * i); } // Fill Y values stepline.Values.AddRange(vector.DataBlock.Data); }
public override void method(ref double[] vpre, DoubleVector vpost) { Assert(vpre[0], 1.0); vpre[0] = 2.0; Assert(vpost.Count, 2); vpost.Add(1.0); }
/// <summary> /// Creates statistics for the c-chart /// </summary> /// <param name="defects">Count of defect / nonconformity per-sample period</param> /// <param name="Stds">Number of standard deviations, either 1, 2, or 3 to use for control limits</param> /// <param name="ChartTitle">Title of chart.</param> /// <param name="TimeStart">The start time of the data.</param> /// <param name="TimeInterval">Time interval between each sample group.</param> /// <param name="TimeAxisLabel">Horizontal axis label.</param> /// <param name="StatisticsLabel">Vertical axis label.</param> public Stats_c(DoubleVector Defects, int Stds, String ChartTitle, Double TimeStart, Double TimeInterval, String TimeAxisLabel, String StatisticsLabel) { if (Stds == 1 || Stds == 2 || Stds == 3) { this.CenterLine = StatsFunctions.Mean(Defects); this.ConstControlLimits = true; this.UCL = new DoubleVector(Defects.Length, this.CenterLine + Stds * Math.Sqrt(this.CenterLine)); if(this.CenterLine - Stds * Math.Sqrt(this.CenterLine) > 0) this.LCL = new DoubleVector(Defects.Length, this.CenterLine - Stds * Math.Sqrt(this.CenterLine)); else this.LCL = new DoubleVector(Defects.Length, 0); this.Statistic = Defects; this.TimeStart = TimeStart; this.TimeSampleInterval = TimeInterval; this.TimeLabel = TimeAxisLabel; this.DefectLabel = StatisticsLabel; this.ChartTitle = ChartTitle; } else { throw new ArgumentException("In stats_c, the number of standard deviations must be either 1, 2, or 3"); } }
/// <summary> /// returns a DoubleMatrix with the given band structure planarised in the transverse direction /// </summary> public static Band_Data Expand_BandStructure(DoubleVector structure, int ny) { DoubleMatrix result = new DoubleMatrix(ny, structure.Length); for (int i = 0; i < ny; i++) for (int j = 0; j < structure.Length; j++) result[i, j] = structure[j]; return new Band_Data(result); }
/// <summary> /// returns a DoubleMatrix with the given band structure planarised in the growth direction /// </summary> public static Band_Data Expand_BandStructure(DoubleVector structure, int nx, int ny) { DoubleMatrix[] result = new DoubleMatrix[structure.Length]; for (int i = 0; i < structure.Length; i++) { result[i] = new DoubleMatrix(nx, ny); for (int j = 0; j < nx; j++) for (int k = 0; k < ny; k++) result[i][j, k] = structure[i]; } return new Band_Data(result); }
static void Main(string[] args) { Console.Write("**************** INFORMATION ***************" + "\n"); Console.Write("This example was auto-generated by the language-agnostic dev/scripts/example_generator.py script written by Ian Bell" + "\n"); Console.Write("CoolProp version:" + " " + CoolProp.get_global_param_string("version") + "\n"); Console.Write("CoolProp gitrevision:" + " " + CoolProp.get_global_param_string("gitrevision") + "\n"); Console.Write("CoolProp Fluids:" + " " + CoolProp.get_global_param_string("FluidsList") + "\n"); // See http://www.coolprop.org/coolprop/HighLevelAPI.html#table-of-string-inputs-to-propssi-function for a list of inputs to high-level interface; Console.Write("*********** HIGH LEVEL INTERFACE *****************" + "\n"); Console.Write("Critical temperature of water:" + " " + CoolProp.Props1SI("Water", "Tcrit") + " " + "K" + "\n"); Console.Write("Boiling temperature of water at 101325 Pa:" + " " + CoolProp.PropsSI("T", "P", 101325, "Q", 0, "Water") + " " + "K" + "\n"); Console.Write("Phase of water at 101325 Pa and 300 K:" + " " + CoolProp.PhaseSI("P", 101325, "Q", 0, "Water") + "\n"); Console.Write("c_p of water at 101325 Pa and 300 K:" + " " + CoolProp.PropsSI("C", "P", 101325, "T", 300, "Water") + " " + "J/kg/K" + "\n"); Console.Write("c_p of water (using derivatives) at 101325 Pa and 300 K:" + " " + CoolProp.PropsSI("d(H)/d(T)|P", "P", 101325, "T", 300, "Water") + " " + "J/kg/K" + "\n"); Console.Write("*********** HUMID AIR PROPERTIES *****************" + "\n"); Console.Write("Humidity ratio of 50% rel. hum. air at 300 K, 101325 Pa:" + " " + CoolProp.HAPropsSI("W", "T", 300, "P", 101325, "R", 0.5) + " " + "kg_w/kg_da" + "\n"); Console.Write("Relative humidity from last calculation:" + " " + CoolProp.HAPropsSI("R", "T", 300, "P", 101325, "W", CoolProp.HAPropsSI("W", "T", 300, "P", 101325, "R", 0.5)) + " " + "(fractional)" + "\n"); Console.Write("*********** INCOMPRESSIBLE FLUID AND BRINES *****************" + "\n"); Console.Write("Density of 50% (mass) ethylene glycol/water at 300 K, 101325 Pa:" + " " + CoolProp.PropsSI("D", "T", 300, "P", 101325, "INCOMP::MEG-50%") + " " + "kg/m^3" + "\n"); Console.Write("Viscosity of Therminol D12 at 350 K, 101325 Pa:" + " " + CoolProp.PropsSI("V", "T", 350, "P", 101325, "INCOMP::TD12") + " " + "Pa-s" + "\n"); // If you don't have REFPROP installed, disable the following lines; Console.Write("*********** REFPROP *****************" + "\n"); Console.Write("Critical temperature of water:" + " " + CoolProp.Props1SI("REFPROP::Water", "Tcrit") + " " + "K" + "\n"); Console.Write("Boiling temperature of water at 101325 Pa:" + " " + CoolProp.PropsSI("T", "P", 101325, "Q", 0, "REFPROP::Water") + " " + "K" + "\n"); Console.Write("c_p of water at 101325 Pa and 300 K:" + " " + CoolProp.PropsSI("C", "P", 101325, "T", 300, "REFPROP::Water") + " " + "J/kg/K" + "\n"); Console.Write("*********** TABULAR BACKENDS *****************" + "\n"); AbstractState TAB = AbstractState.factory("BICUBIC&HEOS", "R245fa"); TAB.update(input_pairs.PT_INPUTS, 101325, 300); Console.Write("Mass density of refrigerant R245fa at 300 K, 101325 Pa:" + " " + TAB.rhomass() + " " + "kg/m^3" + "\n"); Console.Write("*********** SATURATION DERIVATIVES (LOW-LEVEL INTERFACE) ***************" + "\n"); AbstractState AS_SAT = AbstractState.factory("HEOS", "R245fa"); AS_SAT.update(input_pairs.PQ_INPUTS, 101325, 0); Console.Write("First saturation derivative:" + " " + AS_SAT.first_saturation_deriv(parameters.iP, parameters.iT) + " " + "Pa/K" + "\n"); Console.Write("*********** LOW-LEVEL INTERFACE *****************" + "\n"); AbstractState AS = AbstractState.factory("HEOS", "Water&Ethanol"); DoubleVector z = new DoubleVector(new double[]{0.5, 0.5}); AS.set_mole_fractions(z); AS.update(input_pairs.PQ_INPUTS, 101325, 1); Console.Write("Normal boiling point temperature of water and ethanol:" + " " + AS.T() + " " + "K" + "\n"); // If you don't have REFPROP installed, disable the following block; Console.Write("*********** LOW-LEVEL INTERFACE (REFPROP) *****************" + "\n"); AbstractState AS2 = AbstractState.factory("REFPROP", "Methane&Ethane"); DoubleVector z2 = new DoubleVector(new double[]{0.2, 0.8}); AS2.set_mole_fractions(z2); AS2.update(input_pairs.QT_INPUTS, 1, 120); Console.Write("Vapor molar density:" + " " + AS2.keyed_output(parameters.iDmolar) + " " + "mol/m^3" + "\n"); }
/// <summary> /// Example c-Chart /// </summary> private void nButtonCChart_Click(object sender, EventArgs e) { // c-Chart sample data // This data-set was copied from the 'pcmanufact' data set packaged with the R qcc package by Luca Scrucca // // Example Data Description // A personal computer manufacturer counts the number of nonconformities per unit on the final // assembly line. He collects data on 20 samples of 5 computers each. DoubleVector defects = new DoubleVector(10, 12, 8, 14, 10, 16, 11, 7, 10, 15, 9, 5, 7, 11, 12, 6, 8, 10, 7, 5); IAttributeChartStats stats_c = new Stats_c(defects, 3, "c-Chart pcmanufact dataset"); // build the Nevron c-Chart visualization this.nQualityControlChart.AutoRefresh = true; this.nQualityControlChart.Clear(); AttributeChart cChart = new AttributeChart(stats_c, this.nQualityControlChart); // Update description in UI this.nRichDescription.Text = "The c-Chart, or Count Chart, is an attribute control chart for monitoring the total number of nonconformities per subgroup over time. The size of each measured subgroup must be constant."; }
/// <summary> /// Creates statistics for the p-chart. /// </summary> /// <param name="DefectCountInSample">Count of failed samples per-sample.</param> /// <param name="SampleSizes">Size of each sample</param> /// <param name="Stds">Number of standard deviations, either 1, 2, or 3 to use for control limits</param> /// <param name="ChartTitle">Title of chart.</param> /// <param name="TimeStart">The start time of the data.</param> /// <param name="TimeInterval">Time interval between each sample group.</param> /// <param name="TimeAxisLabel">Horizontal axis label.</param> /// <param name="StatisticsLabel">Vertical axis label.</param> public Stats_p(DoubleVector DefectCountInSample, DoubleVector SampleSizes, Double Stds, String ChartTitle, Double TimeStart, Double TimeInterval, String TimeAxisLabel, String StatisticsLabel) { if (Stds == 1 || Stds == 2 || Stds == 3) { if (DefectCountInSample.Length == SampleSizes.Length) { this.CenterLine = StatsFunctions.Sum(DefectCountInSample) / StatsFunctions.Sum(SampleSizes); this.ConstControlLimits = false; this.UCL = this.CenterLine + Stds * StatsFunctions.Sqrt( (new DoubleVector(SampleSizes.Length, this.CenterLine)) * (new DoubleVector(SampleSizes.Length, 1.0 - this.CenterLine)) ) / StatsFunctions.Sqrt(SampleSizes); this.LCL = this.CenterLine - Stds * StatsFunctions.Sqrt( (new DoubleVector(SampleSizes.Length, this.CenterLine)) * (new DoubleVector(SampleSizes.Length, 1.0 - this.CenterLine)) ) / StatsFunctions.Sqrt(SampleSizes); for (int i = 0; i < this.LCL.Length; i++) { if (this.LCL[i] < 0) this.LCL[i] = 0; } this.Statistic = DefectCountInSample / SampleSizes; this.TimeStart = TimeStart; this.TimeSampleInterval = TimeInterval; this.TimeLabel = TimeAxisLabel; this.DefectLabel = StatisticsLabel; this.ChartTitle = ChartTitle; } else { throw new ArgumentException("In Stats_p, the defect count and sample size vectors much have the same length"); } } else { throw new ArgumentException("In Stats_p, the number of standard deviations must be either 1, 2, or 3"); } }
/// <summary> /// Create a new neural network. /// </summary> /// <param name="inputs">The number of inputs that this network will accept.</param> /// <param name="hiddenNeurons">The number of hidden neurons in this network.</param> /// <param name="outputNeurons">The number of outputs to expect from this network.</param> /// <param name="learningRate">The rate to train this network.</param> public SimpleNeuralNetwork(int inputs, int hiddenNeurons, int outputNeurons, double learningRate) { random = new Random(); inputsCount = inputs; hiddenCount = hiddenNeurons; outputCount = outputNeurons; // The weights weights_IH = new double[inputsCount, hiddenCount]; weights_HO = new double[hiddenCount, outputCount]; InitializeWeightsRandomly(); // The neuron activations neurons_H = new double[hiddenCount]; neurons_O = new DoubleVector(outputCount); // The error arrays error_H = new double[hiddenCount]; error_O = new double[outputCount]; this.learningRate = learningRate; }
public DoubleVector times() { DoubleVector ret = new DoubleVector(NQuantLibcPINVOKE.PiecewiseFlatForward_times(swigCPtr), false); if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public DoubleVector forwards() { DoubleVector ret = new DoubleVector(NQuantLibcPINVOKE.ForwardCurve_forwards(swigCPtr), false); if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public static SWIGTYPE_p_std__vectorT_std__vectorT_double_t_t PropsSImulti(SWIGTYPE_p_std__vectorT_std__string_t Outputs, string Name1, DoubleVector Prop1, string Name2, DoubleVector Prop2, string backend, SWIGTYPE_p_std__vectorT_std__string_t fluids, DoubleVector fractions) { SWIGTYPE_p_std__vectorT_std__vectorT_double_t_t ret = new SWIGTYPE_p_std__vectorT_std__vectorT_double_t_t(CoolPropPINVOKE.PropsSImulti(SWIGTYPE_p_std__vectorT_std__string_t.getCPtr(Outputs), Name1, DoubleVector.getCPtr(Prop1), Name2, DoubleVector.getCPtr(Prop2), backend, SWIGTYPE_p_std__vectorT_std__string_t.getCPtr(fluids), DoubleVector.getCPtr(fractions)), true); if (CoolPropPINVOKE.SWIGPendingException.Pending) throw CoolPropPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public static Leg FixedRateLeg(Schedule schedule, DayCounter dayCount, DoubleVector nominals, DoubleVector couponRates) { Leg ret = new Leg(NQuantLibcPINVOKE.FixedRateLeg__SWIG_2(Schedule.getCPtr(schedule), DayCounter.getCPtr(dayCount), DoubleVector.getCPtr(nominals), DoubleVector.getCPtr(couponRates)), true); if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public YoYInflationCap(Leg leg, DoubleVector capRates) : this(NQuantLibcPINVOKE.new_YoYInflationCap(Leg.getCPtr(leg), DoubleVector.getCPtr(capRates)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
public double Min() { if (dim == 1) return vec.Min(); else if (dim == 2) return mat.Min(); else if (dim == 3) { DoubleVector mat_min = new DoubleVector(vol.Length); for (int i = 0; i < vol.Length; i++) mat_min[i] = vol[i].Min(); return mat_min.Min(); } else throw new NotImplementedException(); }
public LogLinearZeroCurve(DateVector dates, DoubleVector yields, DayCounter dayCounter, Calendar calendar, LogLinear i, Compounding compounding, Frequency frequency) : this(NQuantLibcPINVOKE.new_LogLinearZeroCurve__SWIG_0(DateVector.getCPtr(dates), DoubleVector.getCPtr(yields), DayCounter.getCPtr(dayCounter), Calendar.getCPtr(calendar), LogLinear.getCPtr(i), (int)compounding, (int)frequency), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
public abstract bool Check(DoubleVector solution);
public override bool Check(DoubleVector solution) { return(true); }
const double Oor2Pi = 0.398942280401433; // 1/sqrt(2.pi) /// <summary> /// Numerical integration of the lognormal, i.e. /// I = \int_L^U pd(S) dS func(S) /// where pd(S) is the measure exp(-(ln(S/S0)+vol^2*t/2)^2/(2*vol^2*t))/(S*vol*sqrt(2*pi*t)) /// which applies to a random walk of volatility vol after time t such that /// S = S0. /// Uses Simpson's rule evaluation, after a strategic change of variables. /// </summary> /// <param name="nSteps">Max no. of ordinates; if zero or negative no limit;</param> /// <param name="fn">The function of S to be evaluated</param> /// <param name="l">The lower limit (minimum 0)</param> /// <param name="u">The upper limit: -ve value means infinity</param> /// <param name="q">volatility * sqrt(t)</param> /// <param name="s0">The expectation value of the underlying at time t</param> /// <param name="parameters">The parameter Vector of the multivariate function: the first parameter elements is the asset price S.</param> /// <returns>A vector array of results: value, /// delta = {\partial I \over \partial S_0}, /// gamma = {\partial^2 I \over \partial S_0^2}, /// vega = {\partial I \over \partial q}, /// nSteps = The actual number used is returned here.</returns> public static double[] LogNormalIntegration(long nSteps, QRMultivariateRealFunction fn, double l, double u, double q, double s0, DoubleVector parameters) { double lb, ub, s, s1, s2, sm1 = 0d, sm2 = 0d; double v, w, y; double yy; long nMax = nSteps, nUsed; var result = new double[5]; if (s0 <= 0 || q <= 0) { throw new Exception("Invalid LogNormInt parameters"); } var q2 = q * q; var lnS1 = Math.Log(s0) - .5 * q2; /* Change limits to new variables ... */ if (l > 0) { v = (Math.Log(l) - lnS1) / q; lb = (Math.Sqrt(.25 + v * v) - .5) / v; } else { lb = -1; } if (u < 0) { ub = 1; } else if (u == 0) { ub = -1; } else { v = (Math.Log(u) - lnS1) / q; ub = (Math.Sqrt(.25 + v * v) - .5) / v; } if (ub < lb) { v = ub; ub = lb; lb = v; } else if (ub == lb) { return(result); } if (lb > -LniMax) { v = q * lb / (1 - lb * lb) + lnS1; var xx = Math.Exp(v); parameters[0] = xx; yy = fn(parameters); s = Math.Exp(-.5 * Math.Pow(lb / (1 - lb * lb), 2.0)) * (1 + lb * lb) / Math.Pow(1 - lb * lb, 2.0) * yy; s1 = s * v; s2 = s1 * v; } else { s = s1 = s2 = 0; } if (ub < LniMax) { v = q * ub / (1 - ub * ub) + lnS1; var xx = Math.Exp(v); parameters[0] = xx; yy = fn(parameters); w = Math.Exp(-.5 * Math.Pow(ub / (1 - ub * ub), 2.0)) * (1 + ub * ub) / Math.Pow(1 - ub * ub, 2.0) * yy; s += w; w *= v; s1 += w; s2 += w * v; } var h = ub - lb; var h2 = h / 2; s *= h2; s1 *= h2; s2 *= h2; double sm = 0; for (nUsed = 2; 2 * nUsed - 1 <= nMax || nMax <= 0; nUsed += nUsed - 1) { var os = s; var os1 = s1; var os2 = s2; var osm = sm; double sum; double sum1; double sum2; double z; for (z = lb + h / 2, sum = sum1 = sum2 = 0; z < ub; z += h) { if (z < -LniMax || z > LniMax) { continue; } y = 1 / (1 - z * z); v = z * y; w = v * v; var p = q * v + lnS1; var xx = Math.Exp(p); parameters[0] = xx; yy = fn(parameters); v = Math.Exp(-.5 * w) * (y * y + w) * yy; sum += v; v *= p; sum1 += v; sum2 += v * p; } h /= 2; s = s / 2 + h * sum; /* include midpoints under trapezoid rule */ s1 = s1 / 2 + h * sum1; s2 = s2 / 2 + h * sum2; sm = (4 * s - os) / 3; /* convert to Simpson's rule */ sm1 = (4 * s1 - os1) / 3; sm2 = (4 * s2 - os2) / 3; if (Math.Abs(sm - osm) < 1e-9 + Eps * Math.Abs(osm) && nUsed >= 33) { break; } } sm *= Oor2Pi; sm1 *= Oor2Pi; sm2 *= Oor2Pi; w = lnS1 / q2; v = ((w + 1) * lnS1 - 1) * sm - (1 + 2 * w) * sm1 + sm2 / q2; y = s0 * q2; result[0] = sm; result[1] = (sm1 - lnS1 * sm) / y; result[2] = v / (s0 * y); result[3] = v / q; result[4] = nSteps; return(result); }
public static Leg CmsZeroLeg(DoubleVector nominals, Schedule schedule, SwapIndex index, DayCounter paymentDayCounter, BusinessDayConvention paymentConvention, UnsignedIntVector fixingDays, DoubleVector gearings) { Leg ret = new Leg(NQuantLibcPINVOKE.CmsZeroLeg__SWIG_3(DoubleVector.getCPtr(nominals), Schedule.getCPtr(schedule), SwapIndex.getCPtr(index), DayCounter.getCPtr(paymentDayCounter), (int)paymentConvention, UnsignedIntVector.getCPtr(fixingDays), DoubleVector.getCPtr(gearings)), true); if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public HazardRateCurve(DateVector dates, DoubleVector hazardRates, DayCounter dayCounter) : this(NQuantLibcPINVOKE.new_HazardRateCurve__SWIG_2(DateVector.getCPtr(dates), DoubleVector.getCPtr(hazardRates), DayCounter.getCPtr(dayCounter)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
public HazardRateCurve(DateVector dates, DoubleVector hazardRates, DayCounter dayCounter, Calendar calendar, BackwardFlat i) : this(NQuantLibcPINVOKE.new_HazardRateCurve__SWIG_0(DateVector.getCPtr(dates), DoubleVector.getCPtr(hazardRates), DayCounter.getCPtr(dayCounter), Calendar.getCPtr(calendar), BackwardFlat.getCPtr(i)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
public LogLinearZeroCurve(DateVector dates, DoubleVector yields, DayCounter dayCounter, Calendar calendar) : this(NQuantLibcPINVOKE.new_LogLinearZeroCurve__SWIG_3(DateVector.getCPtr(dates), DoubleVector.getCPtr(yields), DayCounter.getCPtr(dayCounter), Calendar.getCPtr(calendar)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
public DiscountCurve(DateVector dates, DoubleVector discounts, DayCounter dayCounter) : this(NQuantLibcPINVOKE.new_DiscountCurve__SWIG_2(DateVector.getCPtr(dates), DoubleVector.getCPtr(discounts), DayCounter.getCPtr(dayCounter)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); }
public MarkovFunctionalSettings(uint yGridPoints, double yStdDevs, uint gaussHermitePoints, double digitalGap, double marketRateAccuracy, double lowerRateBound, double upperRateBound, int adjustments, DoubleVector smileMoneyCheckpoints) : this(NQuantLibcPINVOKE.new_MarkovFunctionalSettings__SWIG_1(yGridPoints, yStdDevs, gaussHermitePoints, digitalGap, marketRateAccuracy, lowerRateBound, upperRateBound, adjustments, DoubleVector.getCPtr(smileMoneyCheckpoints)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
public Band_Data DeepenThisCopy() { Band_Data tmp_result = null; if (dim == 1) { DoubleVector result = new DoubleVector(Length); for (int i = 0; i < Length; i++) result[i] = this[i]; tmp_result = new Band_Data(result); } else if (dim == 2) { DoubleMatrix result = new DoubleMatrix(mat.Rows, mat.Cols); for (int i = 0; i < mat.Rows; i++) for (int j = 0; j < mat.Cols; j++) result[i, j] = mat[i, j]; tmp_result = new Band_Data(result); } else if (dim == 3) { int nx = vol[0].Rows; int ny = vol[0].Cols; int nz = vol.Length; Band_Data result = new Band_Data(nx, ny, nz, 0.0); for (int k = 0; k < nz; k++) for (int i = 0; i < nx; i++) for (int j = 0; j < ny; j++) result.vol[k][i, j] = this.vol[k][i, j]; tmp_result = result; } else throw new NotImplementedException(); if (this.Laplacian != null) tmp_result.Laplacian = this.Laplacian.DeepenThisCopy(); return tmp_result; }
public CPIBond(uint settlementDays, double faceAmount, bool growthOnly, double baseCPI, Period observationLag, ZeroInflationIndex cpiIndex, CPI.InterpolationType observationInterpolation, Schedule schedule, DoubleVector coupons, DayCounter accrualDayCounter) : this(NQuantLibcPINVOKE.new_CPIBond__SWIG_7(settlementDays, faceAmount, growthOnly, baseCPI, Period.getCPtr(observationLag), ZeroInflationIndex.getCPtr(cpiIndex), (int)observationInterpolation, Schedule.getCPtr(schedule), DoubleVector.getCPtr(coupons), DayCounter.getCPtr(accrualDayCounter)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
public Band_Data(int nz, double val) { this.vec = new DoubleVector(nz, val); dim = 1; }
/// <summary> /// Base class for two-dimensional graphs. /// </summary> /// <param name="X">X-axis</param> /// <param name="Y">Y-axis</param> /// <param name="Painter">Painter of graph.</param> /// <param name="ShowZeroX">If the y-axis (x=0) should always be shown.</param> /// <param name="ShowZeroY">If the x-axis (y=0) should always be shown.</param> /// <param name="Node">Node creating the graph.</param> /// <param name="Parameters">Graph-specific parameters.</param> public Graph2D(IVector X, IVector Y, IPainter2D Painter, bool ShowZeroX, bool ShowZeroY, ScriptNode Node, params object[] Parameters) : base() { if (X is Interval XI) { X = new DoubleVector(XI.GetArray()); } if (Y is Interval YI) { Y = new DoubleVector(YI.GetArray()); } int i, c = X.Dimension; bool HasNull = false; IElement ex, ey; IElement Zero; if (c != Y.Dimension) { throw new ScriptException("X and Y series must be equally large."); } for (i = 0; i < c; i++) { ex = X.GetElement(i); ey = Y.GetElement(i); if (ex.AssociatedObjectValue is null || ey.AssociatedObjectValue is null) { HasNull = true; break; } } //this.showZeroX = ShowZeroX; //this.showZeroY = ShowZeroY; this.minX = Min.CalcMin(X, Node); this.maxX = Max.CalcMax(X, Node); if (ShowZeroX && c > 0 && this.minX.AssociatedSet is IAbelianGroup AG) { Zero = AG.AdditiveIdentity; this.minX = Min.CalcMin(new ObjectVector(this.minX, Zero), null); this.maxX = Max.CalcMax(new ObjectVector(this.maxX, Zero), null); } this.minY = Min.CalcMin(Y, Node); this.maxY = Max.CalcMax(Y, Node); if (ShowZeroY && c > 0 && this.minY.AssociatedSet is IAbelianGroup AG2) { Zero = AG2.AdditiveIdentity; this.minY = Min.CalcMin(new ObjectVector(this.minY, Zero), null); this.maxY = Max.CalcMax(new ObjectVector(this.maxY, Zero), null); } if (HasNull) { LinkedList <IElement> X2 = new LinkedList <IElement>(); LinkedList <IElement> Y2 = new LinkedList <IElement>(); this.axisTypeX = null; this.axisTypeY = null; for (i = 0; i < c; i++) { ex = X.GetElement(i); ey = Y.GetElement(i); if (ex.AssociatedObjectValue is null || ey.AssociatedObjectValue is null) { if (X2.First != null) { this.AddSegment(X, Y, X2, Y2, Node, Painter, Parameters); X2 = new LinkedList <IElement>(); Y2 = new LinkedList <IElement>(); } } else { X2.AddLast(ex); Y2.AddLast(ey); } }
public CmsRateBond(uint settlementDays, double faceAmount, Schedule schedule, SwapIndex index, DayCounter paymentDayCounter, BusinessDayConvention paymentConvention, uint fixingDays, DoubleVector gearings, DoubleVector spreads, DoubleVector caps, DoubleVector floors) : this(NQuantLibcPINVOKE.new_CmsRateBond__SWIG_3(settlementDays, faceAmount, Schedule.getCPtr(schedule), SwapIndex.getCPtr(index), DayCounter.getCPtr(paymentDayCounter), (int)paymentConvention, fixingDays, DoubleVector.getCPtr(gearings), DoubleVector.getCPtr(spreads), DoubleVector.getCPtr(caps), DoubleVector.getCPtr(floors)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
public static Leg FixedRateLeg(Schedule schedule, DayCounter dayCount, DoubleVector nominals, DoubleVector couponRates, BusinessDayConvention paymentAdjustment, DayCounter firstPeriodDayCount) { Leg ret = new Leg(NQuantLibcPINVOKE.FixedRateLeg__SWIG_0(Schedule.getCPtr(schedule), DayCounter.getCPtr(dayCount), DoubleVector.getCPtr(nominals), DoubleVector.getCPtr(couponRates), (int)paymentAdjustment, DayCounter.getCPtr(firstPeriodDayCount)), true); if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public static Leg IborLeg(DoubleVector nominals, Schedule schedule, IborIndex index, DayCounter paymentDayCounter, BusinessDayConvention paymentConvention, UnsignedIntVector fixingDays, DoubleVector gearings, DoubleVector spreads, DoubleVector caps, DoubleVector floors, bool isInArrears) { Leg ret = new Leg(NQuantLibcPINVOKE.IborLeg__SWIG_0(DoubleVector.getCPtr(nominals), Schedule.getCPtr(schedule), IborIndex.getCPtr(index), DayCounter.getCPtr(paymentDayCounter), (int)paymentConvention, UnsignedIntVector.getCPtr(fixingDays), DoubleVector.getCPtr(gearings), DoubleVector.getCPtr(spreads), DoubleVector.getCPtr(caps), DoubleVector.getCPtr(floors), isInArrears), true); if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public Cap(Leg leg, DoubleVector capRates) : this(NQuantLibcPINVOKE.new_Cap(Leg.getCPtr(leg), DoubleVector.getCPtr(capRates)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); }
/// <summary> /// Gets the price. /// </summary> /// <returns></returns> public double[,] GetPriceAndGreeks() { int n = _resetAmounts.Length; List <double> tList = new List <double>(); List <double> volList = new List <double>(); for (int i = 0; i < n; i++) { if (_resetDays[i] > 0) { tList.Add(Convert.ToDouble(_resetDays[i]) / daybasis); volList.Add(_volsToResets[i]); } } IVector t = new DoubleVector(tList.ToArray()); SparseVector times = new SparseVector(t); // Vols double[,] v = new double[n, 1]; int n1 = volList.Count; for (int idx = 0; idx < n1; idx++) { v[idx, 0] = volList[idx]; } //Matrix vols = new Matrix(v); double[] variances = CalcForwardVariance(times.Data, volList.ToArray()); double[] sigmas = Sqrt(variances); DoubleVector _vf = new DoubleVector(variances); SparseVector vf = new SparseVector(_vf, _vf.Length); //Drift double[] rates = GetForwardRates(times.Data); double[] yields = GetForwardYields(times.Data); int nrates = times.Length; double[] _drifts = new double[nrates]; double[] _logdrifts = new double[nrates]; //IVector driftsVector = new DoubleVector(_drifts); //SparseVector drifts = new SparseVector(driftsVector, driftsVector.Length); for (int idx = 0; idx < nrates; idx++) { _drifts[idx] = rates[idx] - yields[idx]; _logdrifts[idx] = _drifts[idx] - _vf[idx] * 0.5; } DoubleVector ld = new DoubleVector(_logdrifts); SparseVector logdrifts = new SparseVector(ld, ld.Length); // Discount double df = Math.Exp(-ForwardRate(0, _timeToExpiry) * _timeToExpiry); // 6 identical paths, price, delta, gamma, vega, theta, rho PathGenerator pathGen = new SinglePathGenerator(Rng(_seed), logdrifts, vf, times); MultiVarPathPricer pathPr = new CliquetPathPricer(_payoffFunc, df, _useAntithetic, _spot, _strike, _floor, _cap, _nobsin, _nobsout, _resetDays, _resetAmounts, rates, yields, sigmas); //PathPricer deltaPr = PathFactory.GetPath("Delta", df, true, _spot, _strike, _floor, _cap, _resetDays, _resetAmounts, sigmas, _nobsin, _nobsout); List <RiskStatistics> accumulatorList = new List <RiskStatistics>(); for (int i = 0; i < 6; i++) { accumulatorList.Add(new RiskStatistics()); } // Price path MonteCarloModel mcm = new MonteCarloModel(pathGen, pathPr, accumulatorList); mcm.AddMultiVarSamples(_numSimulations); double price = accumulatorList[0].Mean; double delta = accumulatorList[1].Mean; double gamma = accumulatorList[2].Mean; double vega = accumulatorList[3].Mean; double theta = accumulatorList[4].Mean; double rho = accumulatorList[5].Mean; double[,] res = new[, ] { { price, accumulatorList[0].ErrorEstimate }, { delta, accumulatorList[1].ErrorEstimate }, { gamma, accumulatorList[2].ErrorEstimate }, { vega, accumulatorList[3].ErrorEstimate }, { theta, accumulatorList[4].ErrorEstimate }, { rho, accumulatorList[5].ErrorEstimate } }; return(res); }
public MultiplicativePriceSeasonalityPtr(Date seasonalityBaseDate, Frequency frequency, DoubleVector seasonalityFactors) : this(NQuantLibcPINVOKE.new_MultiplicativePriceSeasonalityPtr(Date.getCPtr(seasonalityBaseDate), (int)frequency, DoubleVector.getCPtr(seasonalityFactors)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
public YoYInflationCollar(Leg leg, DoubleVector capRates, DoubleVector floorRates) : this(NQuantLibcPINVOKE.new_YoYInflationCollar(Leg.getCPtr(leg), DoubleVector.getCPtr(capRates), DoubleVector.getCPtr(floorRates)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); }
public MultiplicativePriceSeasonalityPtr(Date seasonalityBaseDate, Frequency frequency, DoubleVector seasonalityFactors) : this(NQuantLibcPINVOKE.new_MultiplicativePriceSeasonalityPtr(Date.getCPtr(seasonalityBaseDate), (int)frequency, DoubleVector.getCPtr(seasonalityFactors)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); }
public Polynomial Division(Polynomial DividedPolynome, Polynomial DividerPolynome) { Polynomial FractionPolynome = new Polynomial(); string coefs = ""; List<double> DividedPolynomeCoeffs = DividedPolynome.Coeff.ToList(); List<double> DividerPolynomeCoeffs = DividerPolynome.Coeff.ToList(); int FractionPolynomeDegree = DividedPolynome.Degree - DividerPolynome.Degree; Polynomial NewDividerPolynome = new Polynomial(); Polynomial RestPolynome = new Polynomial(); int j = 0; List<double> FractionPolynomeCoeffs = new List<double>(); do { for (int k = 0; k < FractionPolynomeDegree; k++) { coefs += "0 "; } FractionPolynomeCoeffs.Insert(0, DividedPolynomeCoeffs[DividedPolynomeCoeffs.Count - 1] / DividerPolynomeCoeffs[DividerPolynomeCoeffs.Count - 1]); coefs += (DividedPolynomeCoeffs[DividedPolynomeCoeffs.Count - 1] / DividerPolynomeCoeffs[DividerPolynomeCoeffs.Count - 1]).ToString() + " "; FractionPolynome = new Polynomial(new DoubleVector(coefs)); NewDividerPolynome = Polynomial.Multiply(FractionPolynome, DividerPolynome); RestPolynome = Polynomial.Subtract(DividedPolynome, NewDividerPolynome); DividedPolynome = RestPolynome; DividedPolynomeCoeffs = DividedPolynome.Coeff.ToList(); FractionPolynomeDegree--; coefs = String.Empty; j++; } while ((RestPolynome.Degree != 0)); FractionPolynomeCoeffs.Insert(0, DividedPolynomeCoeffs[DividedPolynomeCoeffs.Count - 1] / DividerPolynomeCoeffs[DividerPolynomeCoeffs.Count - 1]); string FractionPolynomeCoefficients = String.Empty; foreach (var coef in FractionPolynomeCoeffs) { FractionPolynomeCoefficients += Convert.ToString(coef) + " "; } DoubleVector FractionPolynomeVector = new DoubleVector(FractionPolynomeCoefficients); FractionPolynome = new Polynomial(FractionPolynomeVector); return FractionPolynome; }
public void calibrateVolatilitiesIterative(CalibrationHelperVector helpers, OptimizationMethod method, EndCriteria endCriteria, Constraint constraint, DoubleVector weights) { NQuantLibcPINVOKE.Gsr_calibrateVolatilitiesIterative__SWIG_0(swigCPtr, CalibrationHelperVector.getCPtr(helpers), OptimizationMethod.getCPtr(method), EndCriteria.getCPtr(endCriteria), Constraint.getCPtr(constraint), DoubleVector.getCPtr(weights)); if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
public DoubleVector times() { DoubleVector ret = new DoubleVector(NQuantLibcPINVOKE.SwaptionHelper_times(swigCPtr), true); if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); return ret; }
private static void CheckRobotSight(Robot rob1, Robot rob2, bool botRadiiFixed) { var ab = rob2.Position - rob1.Position; var edgeToEdgeDistance = ab.Magnitude() - rob1.GetRadius(botRadiiFixed) - rob2.GetRadius(botRadiiFixed); const int sightDistance = 1440; if (edgeToEdgeDistance > sightDistance) { return; // Bot too far away to see } // ac and ad are to either end of the bots, while ab is to the center var ac = ab.Unit(); var ad = new DoubleVector(ac.Y, -ac.X); ad *= rob2.GetRadius(botRadiiFixed); ad += ab; ac = new DoubleVector(-ac.Y, ac.X); ac *= rob2.GetRadius(botRadiiFixed); ac += ab; var theta = Physics.NormaliseAngle(Math.Atan2(ad.Y, ad.X) + rob1.Aim, false); var beta = Physics.NormaliseAngle(Math.Atan2(ac.Y, ac.X) + rob1.Aim, false); for (var a = 0; a < 9; a++) { if (edgeToEdgeDistance > sightDistance) { continue; } var eyeAim = Physics.NormaliseAngle(Math.PI / 18 * (4 - a), false); var eyeAimLeft = eyeAim + Math.PI / 36; var eyeAimRight = eyeAim - Math.PI / 36; if (!(eyeAimLeft >= theta && theta >= eyeAimRight || eyeAimLeft >= beta && beta >= eyeAimRight || theta >= eyeAimLeft && eyeAimRight >= beta || beta >= eyeAimLeft && eyeAimRight >= theta)) { continue; } double eyeValue; if (edgeToEdgeDistance <= 0) { // bots overlap eyeValue = 32000; } else { var percentDist = (edgeToEdgeDistance + 10) / sightDistance; eyeValue = 1 / (percentDist * percentDist); eyeValue = Math.Min(eyeValue, 32000); } // Check to see if it is closer than other bots we may have seen if (!(rob1.Memory[MemoryAddresses.EyeStart + 1 + a] < eyeValue)) { continue; } // It is closer than other bots we may have seen. // Check to see if this eye has the focus if (a == Math.Abs(rob1.Memory[MemoryAddresses.FOCUSEYE] + 4) % 9) { // This eye does have the focus // Set the EYEF value and also lastopp so the lookoccur list will get populated later rob1.LastSeenObject = rob2; rob1.Memory[MemoryAddresses.EYEF] = (int)eyeValue; } // Set the distance for the eye rob1.Memory[MemoryAddresses.EyeStart + 1 + a] = (int)eyeValue; } }
public CmsRateBond(uint settlementDays, double faceAmount, Schedule schedule, SwapIndex index, DayCounter paymentDayCounter, BusinessDayConvention paymentConvention, uint fixingDays, DoubleVector gearings, DoubleVector spreads, DoubleVector caps, DoubleVector floors) : this(NQuantLibcPINVOKE.new_CmsRateBond__SWIG_3(settlementDays, faceAmount, Schedule.getCPtr(schedule), SwapIndex.getCPtr(index), DayCounter.getCPtr(paymentDayCounter), (int)paymentConvention, fixingDays, DoubleVector.getCPtr(gearings), DoubleVector.getCPtr(spreads), DoubleVector.getCPtr(caps), DoubleVector.getCPtr(floors)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); }
public TimeGrid(DoubleVector times, uint steps) : this(NQuantLibcPINVOKE.new_TimeGrid__SWIG_3(DoubleVector.getCPtr(times), steps), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
public ForwardCurve(DateVector dates, DoubleVector forwards, DayCounter dayCounter, Calendar calendar) : this(NQuantLibcPINVOKE.new_ForwardCurve__SWIG_1(DateVector.getCPtr(dates), DoubleVector.getCPtr(forwards), DayCounter.getCPtr(dayCounter), Calendar.getCPtr(calendar)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); }
public DiscountCurve(DateVector dates, DoubleVector discounts, DayCounter dayCounter, Calendar calendar) : this(NQuantLibcPINVOKE.new_DiscountCurve__SWIG_1(DateVector.getCPtr(dates), DoubleVector.getCPtr(discounts), DayCounter.getCPtr(dayCounter), Calendar.getCPtr(calendar)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
public DefaultDensityCurve(DateVector dates, DoubleVector densities, DayCounter dayCounter) : this(NQuantLibcPINVOKE.new_DefaultDensityCurve__SWIG_2(DateVector.getCPtr(dates), DoubleVector.getCPtr(densities), DayCounter.getCPtr(dayCounter)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
public void calibrate(CalibrationHelperVector arg0, OptimizationMethod arg1, EndCriteria arg2, Constraint constraint, DoubleVector weights) { NQuantLibcPINVOKE.CalibratedModel_calibrate__SWIG_0(swigCPtr, CalibrationHelperVector.getCPtr(arg0), OptimizationMethod.getCPtr(arg1), EndCriteria.getCPtr(arg2), Constraint.getCPtr(constraint), DoubleVector.getCPtr(weights)); if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
public static string extract_fractions(string fluid_string, DoubleVector fractions) { string ret = CoolPropPINVOKE.extract_fractions(fluid_string, DoubleVector.getCPtr(fractions)); if (CoolPropPINVOKE.SWIGPendingException.Pending) throw CoolPropPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public BackwardFlatZeroCurve(DateVector dates, DoubleVector yields, DayCounter dayCounter, Calendar calendar, BackwardFlat i, Compounding compounding) : this(NQuantLibcPINVOKE.new_BackwardFlatZeroCurve__SWIG_1(DateVector.getCPtr(dates), DoubleVector.getCPtr(yields), DayCounter.getCPtr(dayCounter), Calendar.getCPtr(calendar), BackwardFlat.getCPtr(i), (int)compounding), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
public DiscountCurve(DateVector dates, DoubleVector discounts, DayCounter dayCounter, Calendar calendar, LogLinear i) : this(NQuantLibcPINVOKE.new_DiscountCurve__SWIG_0(DateVector.getCPtr(dates), DoubleVector.getCPtr(discounts), DayCounter.getCPtr(dayCounter), Calendar.getCPtr(calendar), LogLinear.getCPtr(i)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); }
public BackwardFlatZeroCurve(DateVector dates, DoubleVector yields, DayCounter dayCounter) : this(NQuantLibcPINVOKE.new_BackwardFlatZeroCurve__SWIG_4(DateVector.getCPtr(dates), DoubleVector.getCPtr(yields), DayCounter.getCPtr(dayCounter)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
public DoubleVector discounts() { DoubleVector ret = new DoubleVector(NQuantLibcPINVOKE.DiscountCurve_discounts(swigCPtr), false); if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public NonstandardSwap(VanillaSwap.Type type, DoubleVector fixedNominal, DoubleVector floatingNominal, Schedule fixedSchedule, DoubleVector fixedRate, DayCounter fixedDayCount, Schedule floatSchedule, IborIndex index, DoubleVector gearing, DoubleVector spread, DayCounter floatDayCount, bool intermediateCapitalExchange, bool finalCapitalExchange, BusinessDayConvention paymentConvention) : this(NQuantLibcPINVOKE.new_NonstandardSwap__SWIG_0((int)type, DoubleVector.getCPtr(fixedNominal), DoubleVector.getCPtr(floatingNominal), Schedule.getCPtr(fixedSchedule), DoubleVector.getCPtr(fixedRate), DayCounter.getCPtr(fixedDayCount), Schedule.getCPtr(floatSchedule), IborIndex.getCPtr(index), DoubleVector.getCPtr(gearing), DoubleVector.getCPtr(spread), DayCounter.getCPtr(floatDayCount), intermediateCapitalExchange, finalCapitalExchange, (int)paymentConvention), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
public double InfinityNorm() { if (dim == 1) return vec.InfinityNorm(); else if (dim == 2) { DoubleVector mat_absmax = new DoubleVector(mat.Rows); for (int i = 0; i < mat.Rows; i++) mat_absmax[i] = mat.Row(i).InfinityNorm(); return mat_absmax.InfinityNorm(); } else if (dim == 3) { DoubleVector vol_absmax = new DoubleVector(vol.Length); for (int i = 0; i < vol.Length; i++) vol_absmax[i] = vol[i].InfinityNorm(); return vol_absmax.InfinityNorm(); } else throw new NotImplementedException(); }
public NonstandardSwap(VanillaSwap.Type type, DoubleVector fixedNominal, DoubleVector floatingNominal, Schedule fixedSchedule, DoubleVector fixedRate, DayCounter fixedDayCount, Schedule floatSchedule, IborIndex index, DoubleVector gearing, DoubleVector spread, DayCounter floatDayCount) : this(NQuantLibcPINVOKE.new_NonstandardSwap__SWIG_3((int)type, DoubleVector.getCPtr(fixedNominal), DoubleVector.getCPtr(floatingNominal), Schedule.getCPtr(fixedSchedule), DoubleVector.getCPtr(fixedRate), DayCounter.getCPtr(fixedDayCount), Schedule.getCPtr(floatSchedule), IborIndex.getCPtr(index), DoubleVector.getCPtr(gearing), DoubleVector.getCPtr(spread), DayCounter.getCPtr(floatDayCount)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
public Band_Data(DoubleVector vec) { this.vec = vec; dim = 1; }
public CubicBSplinesFitting(DoubleVector knotVector) : this(NQuantLibcPINVOKE.new_CubicBSplinesFitting__SWIG_1(DoubleVector.getCPtr(knotVector)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
private string GetOutputCharacter(DoubleVector v) { // There is one output for each possible character the CAPTCHA can contain. // The index of the output with the highest value corresponds to a character in the character set. return charsSet[v.GetIndexOfLargestElement()]; }
public BlackVarianceCurve(Date referenceDate, DateVector dates, DoubleVector volatilities, DayCounter dayCounter) : this(NQuantLibcPINVOKE.new_BlackVarianceCurve__SWIG_1(Date.getCPtr(referenceDate), DateVector.getCPtr(dates), DoubleVector.getCPtr(volatilities), DayCounter.getCPtr(dayCounter)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }