bool Covariance::ConstructRHS(Rmatrix data, Integer start) { bool retval = false; if (data.IsSized() == false) throw GmatBaseException("Input covariance matrix is not properly " "initialized"); Integer length = data.GetNumRows(); if (data.GetNumColumns() != length) throw GmatBaseException("Input covariance matrix is not square"); if (start + length > dimension) throw GmatBaseException("Input covariance matrix is will not fit in " "the allocated covariance matrix"); for (Integer i = 0; i < length; ++i) for (Integer j = i; j < length; ++j) if (i == j) theCovariance(i+start, j+start) = data(i, j); else { // Symmetrize as we go theCovariance(i+start, j+start) = theCovariance(j+start, i+start) = (data(i, j) + data(j, i)) / 2.0; } return retval; }
bool Covariance::FillMatrix(const Rmatrix& rhs, bool overrideAndFill) { bool retval = true; // Check sizes of the matrices if (!overrideAndFill && (dimension != rhs.GetNumRows())) throw GmatBaseException("Covariance assignment dimensions do not match"); if (rhs.GetNumRows() != rhs.GetNumColumns()) throw GmatBaseException("Input covariance matrix is not square"); // Fill in the matrix info if (dimension != rhs.GetNumRows()) { // Must be in override and fill mode; names, indices, sizes & owners are // all invalid; clear & set as unknown elementNames.clear(); elementIndices.clear(); elementSizes.clear(); elementOwners.clear(); elementNames.push_back("GenericCovariance"); elementIndices.push_back(-1); // set dimension to the input size dimension = rhs.GetNumRows(); elementSizes.push_back(dimension); elementOwners.push_back(NULL); } theCovariance = rhs; return retval; }
Real Covariance::operator()(const Integer r, const Integer c) const { if ((r < 0 ) || (r >= dimension)) throw GmatBaseException("Covariance row index out of bounds"); if ((c < 0 ) || (c >= dimension)) throw GmatBaseException("Covariance column index out of bounds"); return theCovariance(r,c); }
// Reference object accessor methods //------------------------------------------------------------------------------ // GmatBase* GetRefObject(const Gmat::ObjectType type, const wxString &name) //------------------------------------------------------------------------------ GmatBase* CallFunction::GetRefObject(const Gmat::ObjectType type, const wxString &name) { switch (type) { case Gmat::PARAMETER: for (int i=0; i<mNumInputParams; i++) { if (mInputNames[i] == name) return mInputList[i]; } for (int i=0; i<mNumOutputParams; i++) { if (mOutputNames[i] == name) return mOutputList[i]; } throw GmatBaseException(wxT("ReportFile::GetRefObject() the object name: ") + name + wxT("not found\n")); case Gmat::FUNCTION: return mFunction; case Gmat::COMMAND: return callcmds; default: break; } // Not handled here -- invoke the next higher GetRefObject call return GmatCommand::GetRefObject(type, name); }
//--------------------------------------------------------------------------- // bool SetString(const wxString &toValue) //--------------------------------------------------------------------------- bool ObjectPropertyWrapper::SetString(const wxString &toValue) { #ifdef DEBUG_OBJ_PROP_SET_STRING MessageInterface::ShowMessage(wxT("Entering OBWrapper::SetString with toValue = %s\n"), toValue.c_str()); MessageInterface::ShowMessage(wxT(" and data type = %d\n"), (Integer) GetDataType()); MessageInterface::ShowMessage (wxT(" object = <%p><%s>'%s'\n"), object, object->GetTypeName().c_str(), object->GetName().c_str()); #endif Gmat::ParameterType propType = GetDataType(); if (propType == Gmat::STRING_TYPE || propType == Gmat::ENUMERATION_TYPE || propType == Gmat::FILENAME_TYPE || propType == Gmat::STRINGARRAY_TYPE || propType == Gmat::OBJECT_TYPE) // Added OBJECT_TYPE to handle wxT("DefaultFM.Drag = None;") return object->SetStringParameter(propID, toValue); else if (propType == Gmat::BOOLEANARRAY_TYPE) { BooleanArray boolArray = GmatStringUtil::ToBooleanArray(toValue); return object->SetBooleanArrayParameter(propID, boolArray); } else if (propType == Gmat::UNSIGNED_INTARRAY_TYPE) return object->SetStringParameter(propID, toValue); else if (propType == Gmat::RVECTOR_TYPE) // added to handle Rvectors with brackets return object->SetStringParameter(propID, toValue); else throw GmatBaseException (wxT("SetString() method not valid for wrapper of non-String type.\n")); }
//--------------------------------------------------------------------------- // wxString EvaluateOnOff() const //--------------------------------------------------------------------------- wxString ObjectPropertyWrapper::EvaluateOnOff() const { Gmat::ParameterType propType = GetDataType(); if (propType == Gmat::ON_OFF_TYPE) return object->GetOnOffParameter(propID); else throw GmatBaseException (wxT("EvaluateOnOff() method not valid for wrapper of non-OnOff type.\n")); }
//--------------------------------------------------------------------------- // bool SetOnOff(const wxString &toValue) //--------------------------------------------------------------------------- bool ObjectPropertyWrapper::SetOnOff(const wxString &toValue) { Gmat::ParameterType propType = GetDataType(); if (propType == Gmat::ON_OFF_TYPE) return object->SetOnOffParameter(propID, toValue); else throw GmatBaseException (wxT("SetOnOff() method not valid for wrapper of non-OnOff type.\n")); }
//--------------------------------------------------------------------------- // bool SetBoolean(const bool toValue) //--------------------------------------------------------------------------- bool ObjectPropertyWrapper::SetBoolean(const bool toValue) { Gmat::ParameterType propType = GetDataType(); if (propType == Gmat::BOOLEAN_TYPE) return object->SetBooleanParameter(propID, toValue); else throw GmatBaseException (wxT("SetBoolean() method not valid for wrapper of non-Boolean type.\n")); }
//--------------------------------------------------------------------------- // Integer EvaluateInteger() const //--------------------------------------------------------------------------- Integer ObjectPropertyWrapper::EvaluateInteger() const { Gmat::ParameterType propType = GetDataType(); if (propType == Gmat::INTEGER_TYPE) return object->GetIntegerParameter(propID); else throw GmatBaseException (wxT("EvaluateInteger() method not valid for wrapper of non-Integer type.\n")); }
//--------------------------------------------------------------------------- // bool EvaluateBoolean() const //--------------------------------------------------------------------------- bool ObjectPropertyWrapper::EvaluateBoolean() const { Gmat::ParameterType propType = GetDataType(); if (propType == Gmat::BOOLEAN_TYPE) return object->GetBooleanParameter(propID); else throw GmatBaseException ("EvaluateBoolean() method not valid for wrapper of non-Boolean type.\n"); }
//------------------------------------------------------------------------------ bool IAUFile::GetIAUData(Real ind, Real* iau_data, Integer dim, Integer order) { // Verify the feasibility of interpolation: if ((independence == NULL)||(pointsCount == 0)) { throw GmatBaseException("No data point is used for interpolation.\n"); } else { if((ind < independence[0])||(ind > independence[pointsCount-1])) { throw GmatBaseException("The value of an independent variable is out of range.\n"); } if(order >= pointsCount) { throw GmatBaseException("Number of data points is not enough for interpolation.\n"); } } // Specify beginning index and ending index in order to run interpolation: Real stepsize = 1.0; Integer midpoint = (ind-independence[0])/stepsize; Integer beginIndex = (0 > (midpoint-order/2))? 0:(midpoint-order/2); Integer endIndex = ((pointsCount-1) < (beginIndex+order))? (pointsCount-1):(beginIndex+order); beginIndex = (0 > (endIndex-order))? 0:(endIndex-order); // Run interpolation: // create an interpolator: LagrangeInterpolator* interpolator = new LagrangeInterpolator("", dim, order); // add data points in order to run interpolator: for (Integer i= beginIndex; i <= endIndex; ++i) { interpolator->AddPoint(independence[i], dependences[i]); } // run interpolator and get the result of dependent variables: interpolator->SetForceInterpolation(true); bool returnval = interpolator->Interpolate(ind, iau_data); delete interpolator; return returnval; }
//--------------------------------------------------------------------------- // wxString EvaluateString() const //--------------------------------------------------------------------------- wxString ObjectPropertyWrapper::EvaluateString() const { Gmat::ParameterType propType = GetDataType(); if (propType == Gmat::STRING_TYPE || propType == Gmat::ON_OFF_TYPE || propType == Gmat::ENUMERATION_TYPE || propType == Gmat::FILENAME_TYPE) return object->GetStringParameter(propID); else throw GmatBaseException (wxT("ObjectPropertyWrapper::EvaluateString() method not valid for ") wxT("wrapper of non-String type.\n")); }
//--------------------------------------------------------------------------- // bool SetInteger(const Integer toValue) //--------------------------------------------------------------------------- bool ObjectPropertyWrapper::SetInteger(const Integer toValue) { Gmat::ParameterType propType = GetDataType(); if (propType == Gmat::INTEGER_TYPE) { Integer retval = object->SetIntegerParameter(propID, toValue); return (retval == 0 ? false : true); // return true; } else throw GmatBaseException (wxT("SetInteger() method not valid for wrapper of non-Integer type.\n")); }
bool Covariance::ConstructRHS(Rvector diagonal, Integer start) { bool retval = false; if (diagonal.IsSized() == false) throw GmatBaseException("Diagonal covariance vector is not properly " "initialized"); Integer length = diagonal.GetSize(); if (start + length > dimension) throw GmatBaseException("Diagonal covariance vector is will not fit in " "the allocated covariance matrix"); length += start; for (Integer i = start; i < length; ++i) for (Integer j = start; j < length; ++j) if (i == j) theCovariance(i, j) = diagonal(i - start); else theCovariance(i, j) = 0.0; return retval; }
//------------------------------------------------------------------------------ bool BurnReal::Initialize() { try { InitializeRefObjects(); } catch(BaseException &e) { throw GmatBaseException ("BurnReal::Initialize() Fail to initialize Parameter:" + this->GetTypeName() + "\n" + e.GetFullMessage()); } return true; }
//------------------------------------------------------------------------------ // bool Initialize() //------------------------------------------------------------------------------ bool OrbitRmat66::Initialize() { try { InitializeRefObjects(); } catch(BaseException &e) { throw GmatBaseException (wxT("OrbitRmat66::Initialize() Fail to initialize Parameter:") + this->GetTypeName() + wxT("\n") + e.GetFullMessage()); } return true; }
//------------------------------------------------------------------------------ // bool Initialize() //------------------------------------------------------------------------------ bool BallisticMassReal::Initialize() { try { InitializeRefObjects(); // NOTE - as of 2012.08.16, InitializeRefObejcts // does not throw an exception } catch(BaseException &e) { throw GmatBaseException ("BallisticMassReal::Initialize() failed to initialize Parameter:" + this->GetTypeName() + "\n" + e.GetFullMessage()); } return true; }
void Covariance::AddCovarianceElement(const std::string &name, GmatBase* owner) { Integer parmID = owner->GetParameterID(name); Integer covSize = owner->HasParameterCovariances(parmID); #ifdef DEBUG_CONSTRUCTION MessageInterface::ShowMessage("Adding covariance element %s with id %d" "to object named %s\n", name.c_str(), owner->GetParameterID(name), owner->GetName().c_str()); #endif if (covSize > 0) { // Check to see if element already exists for this object; if not, add it Integer index = -1; for (UnsignedInt i = 0; i < elementNames.size(); ++i) { if (name == elementNames[i]) { if (elementOwners[i] == owner) { index = i; break; } } } if (index == -1) { elementNames.push_back(name); elementIndices.push_back(parmID); elementSizes.push_back(covSize); elementOwners.push_back(owner); dimension += covSize; } } else throw GmatBaseException("Covariance handling for " + name + " is not implemented"); #ifdef DEBUG_CONSTRUCTION MessageInterface::ShowMessage("Covariance dimension is now %d\n", dimension); #endif }
//--------------------------------------------------------------------------- Real ObjectPropertyWrapper::EvaluateReal() const { if (object == NULL) throw ParameterException( "Cannot return value of ObjectProperty - object pointer is NULL\n"); Real itsValue; try { Gmat::ParameterType propType = GetDataType(); if (propType == Gmat::INTEGER_TYPE) { itsValue = (Real)(object->GetIntegerParameter(propID)); } else if (propType == Gmat::REAL_TYPE) { itsValue = object->GetRealParameter(propID); } else { throw GmatBaseException ("EvaluateReal() method not valid for wrapper of non-Integer or non-Real type.\n"); } #ifdef DEBUG_OPW MessageInterface::ShowMessage( "In ObjPropWrapper::EvaluateReal, value = %.12f\n", itsValue); #endif } catch (BaseException &be) { //std::stringstream errmsg; //errmsg << be.GetFullMessage(); // << std::endl; //throw ParameterException(errmsg.str()); // Just rethrow here since ref object is not a Parameter object which // is confusing when Parameter exception: is shown (LOJ: 2014.04.17) throw; } return itsValue; }
//------------------------------------------------------------------------------ bool ObjectPropertyWrapper::SetObject(GmatBase *obj) { #ifdef DEBUG_OPW MessageInterface::ShowMessage (wxT("ObjectPropertyWrapper::SetObject() obj=<%p><%s>'%s'\n object=<%p><%s>'%s'\n"), obj, obj ? obj->GetTypeName().c_str() : wxT("NULL"), obj ? obj->GetName().c_str() : wxT("NULL"), object, object ? object->GetTypeName().c_str() : wxT("NULL"), object ? object->GetName().c_str() : wxT("NULL")); #endif if (obj == NULL) { throw ParameterException (wxT("Cannot set undefined object to object property \"") + GetDescription() + wxT("\"")); } if (object == NULL) { throw ParameterException (wxT("The object is not set \"") + GetDescription() + wxT("\"")); } Gmat::ParameterType propType = GetDataType(); if (propType == Gmat::OBJECT_TYPE || propType == Gmat::OBJECTARRAY_TYPE) { if (object->SetStringParameter(propID, obj->GetName())) return object->SetRefObject(obj, obj->GetType(), obj->GetName()); } else throw GmatBaseException (wxT("ObjectPropertyWrapper::SetObject() method not valid for wrapper of non-Object type.\n")); return true; }
//------------------------------------------------------------------------------ // void SaveData() //------------------------------------------------------------------------------ void VaryPanel::SaveData() { #ifdef DEBUG_VARYPANEL_SAVE MessageInterface::ShowMessage("VaryPanel::SaveData() entered\n"); #endif canClose = true; std::string strInitVal, strPert, strLower, strUpper, strMaxStep; std::string strAddSf, strMultSf; //----------------------------------------------------------------- // check input values: Number, Variable, Array element, Parameter //----------------------------------------------------------------- std::string expRange = "Real Number, Variable, Array element, Plottable Parameter"; ObjectTypeArray objTypes; objTypes.push_back(Gmat::UNKNOWN_OBJECT); // Any plottable Parameters allowed, so use UNKNOWN_OBJECT if (mInitialTextCtrl->IsModified()) { strInitVal = mInitialTextCtrl->GetValue().c_str(); CheckVariable(strInitVal, objTypes, "InitialValue", expRange, true); } if (mPertTextCtrl->IsModified()) { strPert = mPertTextCtrl->GetValue().c_str(); CheckVariable(strPert, objTypes, "Perturbation", expRange, true); } if (mLowerValueTextCtrl->IsModified()) { strLower = mLowerValueTextCtrl->GetValue().c_str(); CheckVariable(strLower, objTypes, "Lower", expRange, true); } if (mUpperValueTextCtrl->IsModified()) { strUpper = mUpperValueTextCtrl->GetValue().c_str(); CheckVariable(strUpper.c_str(), objTypes, "Upper", expRange, true); } if (mMaxStepTextCtrl->IsModified()) { strMaxStep = mMaxStepTextCtrl->GetValue().c_str(); CheckVariable(strMaxStep.c_str(), objTypes, "MaxStep", expRange, true); } if (mAdditiveTextCtrl->IsModified()) { strAddSf = mAdditiveTextCtrl->GetValue().c_str(); CheckVariable(strAddSf.c_str(), objTypes, "AdditiveScaleFactor", expRange, true); } if (mMultiplicativeTextCtrl->IsModified()) { strMultSf = mMultiplicativeTextCtrl->GetValue().c_str(); CheckVariable(strMultSf.c_str(), objTypes, "MultiplicativeScaleFactor", expRange, true); } if (!canClose) return; //----------------------------------------------------------------- // save values to base, base code should do the range checking //----------------------------------------------------------------- #ifdef DEBUG_VARYPANEL_SAVE MessageInterface::ShowMessage(" solverName=%s, variableName=%s\n", solverName.c_str(), variableName.c_str()); #endif Solver *solver = (Solver*)theGuiInterpreter->GetConfiguredObject(solverName); if (solver == NULL) throw GmatBaseException("Cannot find the solver: " + solverName); bool validateCommand = false; try { bool changed = false; if (solverChanged) { #ifdef DEBUG_VARYPANEL_SAVE MessageInterface::ShowMessage (" Solver changed, solver=<%p>'%s'\n", solver, solver->GetName().c_str()); #endif mVaryCommand->SetStringParameter("SolverName", solverName); mVaryCommand->SetRefObject(solver, Gmat::SOLVER, solverName); solverChanged = false; changed = true; } if (variableChanged) { #ifdef DEBUG_VARYPANEL_SAVE MessageInterface::ShowMessage (" Variable changed, variableName='%s'\n", variableName.c_str()); #endif validateCommand = true; mVaryCommand->SetStringParameter("Variable", variableName); solver->SetStringParameter("Variables", variableName); variableChanged = false; changed = true; } if (mInitialTextCtrl->IsModified()) { validateCommand = true; mVaryCommand->SetStringParameter("InitialValue", strInitVal.c_str()); mInitialTextCtrl->DiscardEdits(); changed = true; } if (mPertTextCtrl->IsModified()) { validateCommand = true; mVaryCommand->SetStringParameter("Perturbation", strPert.c_str()); mPertTextCtrl->DiscardEdits(); changed = true; } if (mLowerValueTextCtrl->IsModified()) { validateCommand = true; mVaryCommand->SetStringParameter("Lower", strLower.c_str()); mLowerValueTextCtrl->DiscardEdits(); changed = true; } if (mUpperValueTextCtrl->IsModified()) { validateCommand = true; mVaryCommand->SetStringParameter("Upper", strUpper.c_str()); mUpperValueTextCtrl->DiscardEdits(); changed = true; } if (mMaxStepTextCtrl->IsModified()) { validateCommand = true; mVaryCommand->SetStringParameter("MaxStep", strMaxStep.c_str()); mMaxStepTextCtrl->DiscardEdits(); changed = true; } if (mAdditiveTextCtrl->IsModified()) { validateCommand = true; mVaryCommand->SetStringParameter("AdditiveScaleFactor", strAddSf.c_str()); mAdditiveTextCtrl->DiscardEdits(); changed = true; } if (mMultiplicativeTextCtrl->IsModified()) { validateCommand = true; mVaryCommand->SetStringParameter("MultiplicativeScaleFactor", strMultSf.c_str()); mMultiplicativeTextCtrl->DiscardEdits(); changed = true; } if (changed) mVaryCommand->SetRefObject(solver, Gmat::SOLVER, solverName); // avoid unnecessary validation since it clears all wrappers and recreates them if (validateCommand) { #ifdef DEBUG_VARYPANEL_SAVE MessageInterface::ShowMessage(" Calling ValidateCommand()\n"); #endif if (!theGuiInterpreter->ValidateCommand(mVaryCommand)) canClose = false; } } catch (BaseException &e) { MessageInterface::PopupMessage(Gmat::ERROR_, e.GetFullMessage()); canClose = false; } #ifdef DEBUG_VARYPANEL_SAVE MessageInterface::ShowMessage("VaryPanel::SaveData() leaving\n"); #endif }
//------------------------------------------------------------------------------ // void OnHorizonReferenceComboBoxChange() //------------------------------------------------------------------------------ void GroundStationPanel::OnHorizonReferenceComboBoxChange(wxCommandEvent &event) { std::string horizon = horizonReferenceComboBox->GetValue().c_str(); std::string inputString; Real location1, location2, location3; if (horizon != currentHorizonReference) { std::string bodyName = centralBodyComboBox->GetValue().c_str(); // get a pointer to the celestial body CelestialBody *body = ss->GetBody(bodyName); if (!body) { std::string errmsg = "Cannot find body "; errmsg += bodyName + " needed for GroundStation panel update.\n"; throw GmatBaseException(errmsg); } Real meanRadius = body->GetRealParameter(body->GetParameterID("EquatorialRadius")); Real flattening = body->GetRealParameter(body->GetParameterID("Flattening")); // Convert location values to the appropriate values // Location 1 (Latitude) inputString = location1TextCtrl->GetValue(); CheckReal(location1, inputString, localGroundStation->GetStringParameter(BodyFixedPoint::LOCATION_LABEL_1), "Real Number"); // Location 2 (Longitude) inputString = location2TextCtrl->GetValue(); if (currentStateType != "Cartesian") CheckReal(location2, inputString, localGroundStation->GetStringParameter(BodyFixedPoint::LOCATION_LABEL_2), "Real Number >= 0.0", false, true, true, true); else CheckReal(location2, inputString, localGroundStation->GetStringParameter(BodyFixedPoint::LOCATION_LABEL_2), "Real Number"); // Location 3 (Altitude) inputString = location3TextCtrl->GetValue(); CheckReal(location3, inputString, localGroundStation->GetStringParameter(BodyFixedPoint::LOCATION_LABEL_3), "Real Number"); Rvector3 locInCurrent(location1, location2, location3); if (currentStateType == "Spherical") // latitude and longitude need to be passed in as radians { locInCurrent[0] *= GmatMathConstants::RAD_PER_DEG; locInCurrent[1] *= GmatMathConstants::RAD_PER_DEG; } //MessageInterface::ShowMessage(" ... Spherical to new horizon ... loc = %12.10f %12.10f %12.10f\n", // locInCurrent[0], locInCurrent[1], locInCurrent[2]); // ************************* Rvector3 locInNew = BodyFixedStateConverterUtil::Convert(locInCurrent, currentStateType, currentHorizonReference, currentStateType, horizon, flattening, meanRadius); //MessageInterface::ShowMessage(" ... result = %12.10f %12.10f %12.10f\n", // locInNew[0], locInNew[1], locInNew[2]); // ************************* location1 = locInNew[0]; location2 = locInNew[1]; location3 = locInNew[2]; if (currentStateType == "Spherical") // need to display DEGREES for latitude and longitude { location1 *= GmatMathConstants::DEG_PER_RAD; location2 *= GmatMathConstants::DEG_PER_RAD; } localGroundStation->SetStringParameter(BodyFixedPoint::HORIZON_REFERENCE, horizon); localGroundStation->SetRealParameter(BodyFixedPoint::LOCATION_1, location1); localGroundStation->SetRealParameter(BodyFixedPoint::LOCATION_2, location2); localGroundStation->SetRealParameter(BodyFixedPoint::LOCATION_3, location3); location1TextCtrl->SetValue(ToWxString(location1)); location2TextCtrl->SetValue(ToWxString(location2)); location3TextCtrl->SetValue(ToWxString(location3)); currentHorizonReference = horizon; } UpdateControls(); EnableUpdate(true); }
//------------------------------------------------------------------------------ void IAUFile::Initialize() { if (isInitialized) return; // Allocate buffer to store IAU2000/2006 data: AllocateArrays(); // Use FileManager::FindPath() for new file path implementation (LOJ: 2014.07.01) // Open IAU2000/2006 data file: // FileManager* fm = FileManager::Instance(); // std::string path = fm->GetPathname(FileManager::IAUSOFA_FILE); // std::string name = fm->GetFilename(FileManager::IAUSOFA_FILE); // iauFileName = path+name; // FILE* fpt = fopen(iauFileName.c_str(), "r"); FileManager *fm = FileManager::Instance(); iauFileName = fm->GetFilename(FileManager::IAUSOFA_FILE); iauFileNameFullPath = fm->FindPath(iauFileName, FileManager::IAUSOFA_FILE, true, true, true); // Check full path file if (iauFileNameFullPath == "") throw GmatBaseException("The IAU file '" + iauFileName + "' does not exist\n"); FILE* fpt = fopen(iauFileNameFullPath.c_str(), "r"); if (fpt == NULL) throw GmatBaseException("Error: GMAT cann't open '" + iauFileName + "' file!!!\n"); // Read IAU2000/2006 data from data file and store to buffer: Real t; Real XYs[3]; int c; Integer i; for (i= 0; (c = fscanf(fpt, "%lf %lf %lf %lf\n",&t,&XYs[0],&XYs[1],&XYs[2])) != EOF; ++i) { // expend the buffer size when it has no room to contain data: if (i >= tableSz) { // create a new buffer with a larger size: Integer new_size = tableSz*2; Real* ind = new Real[new_size]; Real** dep = new Real*[new_size]; // copy contain in the current buffer to the new buffer: memcpy(ind, independence, tableSz*sizeof(Real)); memcpy(dep, dependences, tableSz*sizeof(Real*)); for (Integer k=tableSz; k < new_size; ++k) dep[k] = NULL; // delete the current buffer and use the new buffer as the current buffer: delete independence; delete dependences; independence = ind; dependences = dep; tableSz = new_size; } // store data to buffer: independence[i] = t; if (dependences[i] == NULL) dependences[i] = new Real[dimension]; for (Integer j = 0; j < dimension; ++j) dependences[i][j] = XYs[j]; } fclose(fpt); pointsCount = i; // why "this->"? }