public virtual void UpdateProfile() { double[] parameters = null; double[] eparameters = null; MakeParameters(ref eparameters, true); InfoStruct = new BoxModelSettings(); SetInitStruct(ref InfoStruct, null); NativeMethods.RhoGenerate(InfoStruct, eparameters, eparameters.Length, _ElectronDensityArray, _BoxElectronDensityArray); if (_ReflectivityMap != null) { MakeParameters(ref parameters, false); NativeMethods.FastReflGenerate(InfoStruct, parameters, parameters.Length, _ReflectivityMap); } InfoStruct.Dispose(); if (Update != null) { Update(this, null); } }
public override string DataFit() { BackupArrays(); double[] parameters = null; int arrayconst; MakeParameters(ref parameters, true); m_dCovarArray = new double[parameters.Length]; InfoStruct = new BoxModelSettings(); SetInitStruct(ref InfoStruct, null); NativeMethods.Rhofit(InfoStruct, parameters, m_dCovarArray, parameters.Length, _fitinfo); InfoStruct.Dispose(); SubRoughTB = parameters[0]; ZOffsetTB = parameters[1]; if (HoldsigmaCB) { arrayconst = 2; } else { arrayconst = 3; } //Update paramters for (int i = 0; i < BoxCountTB; i++) { LengthArray[i] = parameters[arrayconst * i + 2]; if (!m_bUseSLD) { RhoArray[i] = parameters[arrayconst * i + 3]; } else { RhoArray[i] = parameters[arrayconst * i + 3] * SubphaseSLDTB; } if (HoldsigmaCB) { SigmaArray[i] = parameters[0]; } else { SigmaArray[i] = parameters[3 * i + 4]; } } //Display the fit UpdateProfile(); return(MakeChiSquare()); }
public override string DataFit() { BackupArrays(); double[] parameters = null; MakeParameters(ref parameters, false); m_dCovarArray = new double[parameters.Length]; InfoStruct = new BoxModelSettings(); SetInitStruct(ref InfoStruct, null); NativeMethods.FastReflfit(InfoStruct, parameters, m_dCovarArray, parameters.Length, _fitinfo); InfoStruct.Dispose(); UpdatefromParameterArray(parameters); UpdateFit(parameters); return(MakeChiSquare()); }
public override string StochFit(double[] parampercs, int iterations) { double[] parameters = null; string chosenchisquare = string.Empty; MakeParameters(ref parameters, false); double[] ParamArray = new double[1000 * parameters.Length]; double[] ChiSquareArray = new double[1000]; double[] CovarArray = new double[1000 * parameters.Length]; double[] locinfo = new double[9 * 1000]; int Size = 0; InfoStruct = new BoxModelSettings(); SetInitStruct(ref InfoStruct, parampercs); InfoStruct.Iterations = iterations; NativeMethods.ConstrainedStochFit(InfoStruct, parameters, CovarArray, parameters.Length, locinfo, ParamArray, ChiSquareArray, ref Size); //Not ideal, will always back up regardless of whether the new model is accepted or not BackupArrays(); if (ModelChooser != null) { if (ModelChooser(ParamArray, ChiSquareArray, CovarArray, locinfo, Size, parameters.Length, InfoStruct)) { } } UpdateProfile(); InfoStruct.Dispose(); return(ChiSquare.ToString("##.### E-0")); }