//------------------------------------------------------------------------------ // void GetMatrixOutputInfo(Integer &type, Integer &rowCount, Integer &colCount, // bool allowScalarInput) //------------------------------------------------------------------------------ void MathFunction::GetMatrixOutputInfo(Integer &type, Integer &rowCount, Integer &colCount, bool allowScalarInput) { #ifdef DEBUG_INPUT_OUTPUT MessageInterface::ShowMessage ("MathFunction::GetMatrixOutputInfo() <%p><%s> entered, allowScalarInput=%d\n" " leftNode=<%p><%s>\n rightNode=<%p><%s>\n", this, GetTypeName().c_str(), allowScalarInput, leftNode, leftNode ? leftNode->GetTypeName().c_str() : "NULL", rightNode, rightNode ? rightNode->GetTypeName().c_str() : "NULL"); #endif if (!leftNode) throw MathException(GetTypeName() + "() - Missing input arguments"); Integer type1, row1, col1; // Left node // Get the type(Real or Matrix), # rows and # columns of the left node leftNode->GetOutputInfo(type1, row1, col1); if (!allowScalarInput && type1 != Gmat::RMATRIX_TYPE) throw MathException("Left is not a matrix, so cannot do " + GetTypeName() + "()"); // output row and col is transpose of leftNode's row and col type = type1; rowCount = col1; colCount = row1; #ifdef DEBUG_INPUT_OUTPUT MessageInterface::ShowMessage ("MathFunction::GetMatrixOutputInfo() <%p><%s> returning type=%d, rowCount=%d, " "colCount=%d\n", this, GetTypeName().c_str(), type, rowCount, colCount); #endif }
//------------------------------------------------------------------------------ bool Power::ValidateInputs() { if (leftNode == NULL || rightNode == NULL) throw MathException("Power() - Missing input arguments.\n"); Integer type1, row1, col1; // left node Integer type2, row2, col2; // right node bool retval = false; // Get the type(Real or Matrix), # rows and # columns of the left node leftNode->GetOutputInfo(type1, row1, col1); // Get the type(Real or Matrix), # rows and # columns of the right node rightNode->GetOutputInfo(type2, row2, col2); if (type1 == Gmat::REAL_TYPE) { if (type2 == Gmat::REAL_TYPE || type2 == Gmat::RMATRIX_TYPE && row2 == 1 && col2 == 1) retval = true; } else if (type1 == Gmat::RMATRIX_TYPE && row1 == 1 && col1 == 1) { if (type2 == Gmat::REAL_TYPE || (type2 == Gmat::RMATRIX_TYPE && row2 == 1 && col2 == 1)) retval = true; } else throw MathException("Input is not a scalar or 1x1 matrix, so can not do Power()"); return retval; }
//------------------------------------------------------------------------------ // Real Evaluate() //------------------------------------------------------------------------------ Real MathElement::Evaluate() { #ifdef DEBUG_EVALUATE MessageInterface::ShowMessage ("MathElement::Evaluate() this='%s', refObjectName='%s', refObject=<%p>, " "elementType=%d\n", GetName().c_str(), refObjectName.c_str(), refObject, elementType); #endif // If this MathElement is function Input, just return since it is handled in // the FunctionRunner if (isFunctionInput) throw MathException("MathElement::Evaluate() Function input should " "not be handled here"); if (refObject) { #ifdef DEBUG_EVALUATE MessageInterface::ShowMessage (" refObject=<%p><%p>'%s'\n", refObject, refObject->GetTypeName().c_str(), refObject->GetName().c_str()); #endif ElementWrapper *wrapper = FindWrapper(refObjectName); if (elementType == Gmat::REAL_TYPE || elementType == Gmat::RMATRIX_TYPE) { #ifdef DEBUG_EVALUATE MessageInterface::ShowMessage (" wrapper type=%d, desc='%s'\n", wrapper->GetWrapperType(), wrapper->GetDescription().c_str()); #endif ///@note ArrayWrapper::EvaluateReal() returns 1x1 matrix as real number realValue = wrapper->EvaluateReal(); } else { throw MathException ("MathElement::Evaluate() Cannot Evaluate MathElementType of \"" + refObjectName + "\""); } #ifdef DEBUG_EVALUATE MessageInterface::ShowMessage ("MathElement::Evaluate() It's a parameter: %s realValue = %f\n", refObject->GetName().c_str(), realValue); #endif return realValue; } else { #ifdef DEBUG_EVALUATE MessageInterface::ShowMessage ("MathElement::Evaluate() It's a number: realValue = %f\n", realValue); #endif return realValue; } }
//------------------------------------------------------------------------------ bool Atan2::ValidateInputs() { if (leftNode == NULL) throw MathException("Atan2() - Missing input arguments"); if (rightNode == NULL) throw MathException("Atan2() - Not enough input arguments"); return ValidateScalarInputs(); }
//------------------------------------------------------------------------------ bool Divide::ValidateInputs() { #ifdef DEBUG_INPUT_OUTPUT MessageInterface::ShowMessage ("\nDivide::ValidateInputs() '%s' entered\n", GetName().c_str()); #endif if (leftNode == NULL) throw MathException("Divide() - Missing input arguments"); if (rightNode == NULL) throw MathException("Divide() - Not enough input arguments"); Integer type1, row1, col1; // Left node Integer type2, row2, col2; // Right node bool retval = false; // Get the type(Real or Matrix), # rows and # columns of the left node leftNode->GetOutputInfo(type1, row1, col1); // Get the type(Real or Matrix), # rows and # columns of the right node rightNode->GetOutputInfo(type2, row2, col2); #ifdef DEBUG_INPUT_OUTPUT MessageInterface::ShowMessage ("Divide::ValidateInputs() type1=%d, row1=%d, col1=%d, " "type2=%d, row2=%d, col2=%d\n", type1, row1, col1, type2, row2, col2); #endif if ((type1 == Gmat::REAL_TYPE) && (type2 == Gmat::REAL_TYPE)) retval = true; else if ((type1 == Gmat::RMATRIX_TYPE) && (type2 == Gmat::RMATRIX_TYPE)) if ((row1 == row2) && (col1 == col2)) retval = true; else if ((row1 == 1 && col1 == 1) || (row2 == 1 && col2 == 1)) retval = true; else retval = false; else retval = true; #ifdef DEBUG_INPUT_OUTPUT MessageInterface::ShowMessage ("Divide::ValidateInputs() '%s' returning %d\n", GetName().c_str(), retval); #endif return retval; }
//------------------------------------------------------------------------------ bool MathFunction::ValidateScalarInputs() { if (!leftNode) throw MathException(GetTypeName() + "() - Missing input arguments"); Integer type1, row1, col1; // Left node bool retval = false; #ifdef DEBUG_VALIDATE_INPUT MessageInterface::ShowMessage ("MathFunction::ValidateScalarInputs() <%p><%s> entered\n left=%s, %s\n", this, GetTypeName().c_str(), leftNode->GetTypeName().c_str(), leftNode->GetName().c_str()); #endif // Get the type(Real or Matrix), # rows and # columns of the left node leftNode->GetOutputInfo(type1, row1, col1); if (type1 == Gmat::REAL_TYPE) retval = true; else if (type1 == Gmat::RMATRIX_TYPE && row1 == 1 && col1 == 1) retval = true; else throw MathException("Input to " + GetTypeName() + "() is not a scalar or " "1x1 matrix, so cannot do " + GetTypeName() + "()"); if (rightNode) { leftNode->GetOutputInfo(type1, row1, col1); if (type1 == Gmat::REAL_TYPE) retval = true; else if (type1 == Gmat::RMATRIX_TYPE && row1 == 1 && col1 == 1) retval = true; else throw MathException("Input to " + GetTypeName() + "() is not a scalar or " "1x1 matrix, so cannot do " + GetTypeName() + "()"); } #ifdef DEBUG_VALIDATE_INPUT MessageInterface::ShowMessage ("MathFunction::ValidateScalarInputs() <%p><%s> returning %s, " "type=%d, row=%d, col=%d\n", this, GetTypeName().c_str(), retval ? "true" : "false", type1, row1, col1); #endif return retval; }
//------------------------------------------------------------------------------ bool MathFunction::ValidateMatrixInputs(bool allowScalarInput) { Integer type1, row1, col1; // Left node bool retval = false; #ifdef DEBUG_INPUT_OUTPUT MessageInterface::ShowMessage ("MathFunction::ValidateMatrixInputs() <%p><%s>'%s' entered, leftNode=%s, %s\n", this, GetTypeName().c_str(), GetName().c_str(), leftNode ? leftNode->GetTypeName().c_str() : "NULL", leftNode ? leftNode->GetName().c_str() : "NULL"); #endif // Get the type(Real or Matrix), # rows and # columns of the left node leftNode->GetOutputInfo(type1, row1, col1); if (type1 == Gmat::RMATRIX_TYPE) retval = true; else if (allowScalarInput && type1 == Gmat::REAL_TYPE) retval = true; else throw MathException("Input is not a matrix and scalar is not allowd, " "so cannot do " + GetTypeName() + "()"); #ifdef DEBUG_INPUT_OUTPUT MessageInterface::ShowMessage ("MathFunction::ValidateMatrixInputs() <%p><%s>'%s' returning %d\n", this, GetTypeName().c_str(), GetName().c_str(), retval); #endif return retval; }
//------------------------------------------------------------------------------ Real Norm::Evaluate() { Integer type, rowCount, colCount; leftNode->GetOutputInfo(type, rowCount, colCount); if(type == Gmat::RMATRIX_TYPE) { if (rowCount == 1) { return (leftNode->MatrixEvaluate()).GetRow(0).Norm(); } else if (colCount == 1) { return (leftNode->MatrixEvaluate()).GetColumn(0).Norm(); } else // Norm() function works for a vector or scalar. // Norm() for matrix may be implemented in the future upon the // user request throw MathException( "Norm::Evaluate():: Can only be done on a vector or a scalar. " "This is a matrix"); } else { // Norm of a scalar should be the absolute value of the scalar. Real result = leftNode->Evaluate(); return GmatMathUtil::Abs(result); } }
//------------------------------------------------------------------------------ bool Cosh::ValidateInputs() { if (leftNode == NULL) throw MathException(wxT("Cosh() - Missing input arguments.\n")); Integer type1, row1, col1; // Left node // Get the type(Real or Matrix), # rows and # columns of the left node if (leftNode) leftNode->GetOutputInfo(type1, row1, col1); else throw MathException(wxT("Cosh::ValidateInputs() leftNode is NULL\n")); if (type1 == Gmat::REAL_TYPE) return true; else return false; }
//------------------------------------------------------------------------------ // bool MatrixEvaluate() //------------------------------------------------------------------------------ Rmatrix MathElement::MatrixEvaluate() { #ifdef DEBUG_EVALUATE MessageInterface::ShowMessage ("MathElement::MatrixEvaluate() this='%s', refObjectName='%s', refObject=<%p>, " "elementType=%d\n", GetName().c_str(), refObjectName.c_str(), refObject, elementType); #endif // If this MathElement is function Input, just return since it is handled in // the FunctionRunner if (isFunctionInput) throw MathException("MathElement::MatrixEvaluate() Function input should " "not be handled here"); if (elementType == Gmat::RMATRIX_TYPE) { if (refObject) { #ifdef DEBUG_EVALUATE Rmatrix rmat = refObject->GetRmatrix(); MessageInterface::ShowMessage ("MathElement::MatrixEvaluate() It's an Array: %s matVal =\n%s\n", refObject->GetName().c_str(), rmat.ToString().c_str()); #endif ElementWrapper *wrapper = FindWrapper(refObjectName); return wrapper->EvaluateArray(); } else { #ifdef DEBUG_EVALUATE MessageInterface::ShowMessage ("MathElement::MatrixEvaluate() It's a Rmatrix. matVal =\n%s\n", matrix.ToString().c_str()); #endif return matrix; } } else { Real rval = Evaluate(); #ifdef DEBUG_EVALUATE MessageInterface::ShowMessage ("MathElement::MatrixEvaluate() It's a number: rval = %f\n", rval); #endif // Set matrix 1x1 and return Rmatrix rmat(1, 1, rval); return rmat; //throw MathException("MathElement::MatrixEvaluate() Invalid matrix"); } }
//------------------------------------------------------------------------------ ElementWrapper* MathElement::FindWrapper(const std::string &name) { #ifdef DEBUG_WRAPPERS MessageInterface::ShowMessage ("MathElement::FindWrapper() node='%s', name='%s', refObject=<%p>, " "elementType=%d, theWrapperMap=<%p>\n", GetName().c_str(), name.c_str(), refObject, elementType, theWrapperMap); #endif if (theWrapperMap == NULL) throw MathException("MathElement::FindWrapper() theWrapperMap is NULL"); #ifdef DEBUG_WRAPPERS std::map<std::string, ElementWrapper *>::iterator ewi; for (ewi = theWrapperMap->begin(); ewi != theWrapperMap->end(); ++ewi) MessageInterface::ShowMessage (" wrapperName='%s', wrapper=<%p>, wrapperType=%d, wrapperDesc='%s'\n", (ewi->first).c_str(), ewi->second, (ewi->second)->GetWrapperType(), (ewi->second)->GetDescription().c_str()); #endif if (theWrapperMap->find(name) == theWrapperMap->end()) throw MathException("MathElement::FindWrapper() Cannot find \"" + name + "\" from theWrapperMap"); ElementWrapper *wrapper = (*theWrapperMap)[name]; if (wrapper == NULL) throw MathException ("MathElement::FindWrapper() The ElementWrapper of \"" + name + "\" is NULL"); #ifdef DEBUG_WRAPPERS MessageInterface::ShowMessage ("MathElement::FindWrapper() returning wrapper <%p>\n", wrapper); #endif return wrapper; }
//------------------------------------------------------------------------------ bool Inverse::ValidateInputs() { if (leftNode == NULL) throw MathException("Inverse() - Missing input arguments.\n"); Integer type, row, col; GetOutputInfo(type, row, col); // Only Real type and Matrix are valid. Vector is not a valid input if ((type == Gmat::REAL_TYPE) || (type == Gmat::RMATRIX_TYPE && row == col)) return true; return false; }
//------------------------------------------------------------------------------ // void GetOutputInfo(Integer &type, Integer &rowCount, Integer &colCount) //------------------------------------------------------------------------------ void Tanh::GetOutputInfo(Integer &type, Integer &rowCount, Integer &colCount) { Integer type1, row1, col1; // Left node // Get the type(Real or Matrix), # rows and # columns of the left node leftNode->GetOutputInfo(type1, row1, col1); if (type1 != Gmat::REAL_TYPE) throw MathException("Left is not scalar, so cannot do Tanh().\n"); else { type = type1; rowCount = row1; colCount = col1; } }
EXPORT_C TReal32 __truncdfsf2(TReal64 a1) // // Convert a double to a float // Raises an exception if conversion results in an error // { TRealX x1=a1; TInt ret; TReal32 trg; if ((ret=x1.GetTReal(trg))!=KErrNone) MathException(ret); return(trg); }
GLDEF_C TReal64 __subdf3(TReal64 a1,TReal64 a2) // // Subtract two doubles // { TRealX x1=a1; TRealX x2=a2; TRealX res; TReal64 trg; x1.Sub(res,x2); TInt ret=res.GetTReal(trg); if (ret!=KErrNone) MathException(ret); return(trg); }
EXPORT_C TReal32 __subsf3(TReal32 a1,TReal32 a2) // // Subtract two floats // { TRealX x1=a1; TRealX x2=a2; TRealX res; TReal32 trg; x1.Sub(res,x2); // need not check error because no underflow and others will not be lost in conversion TInt ret=res.GetTReal(trg); if (ret!=KErrNone) MathException(ret); return(trg); }
EXPORT_C TReal64 __adddf3(TReal64 a1,TReal64 a2) // // Add two doubles // { TRealX x1=a1; TRealX x2=a2; TRealX res; TReal64 trg; x1.Add(res,x2); // need not check error because no underflow and others will not be lost in conversion TInt ret=res.GetTReal(trg); if (ret!=KErrNone) MathException(ret); return(trg); }
EXPORT_C TReal64 __divdf3(TReal64 a1,TReal64 a2) // // Divide two doubles // { TRealX x1=a1; TRealX x2=a2; TRealX res; TReal64 trg; TInt ret=x1.Div(res,x2); if (ret==KErrNone) // must check this because if underflow, error is lost in conversion ret=res.GetTReal(trg); if (ret!=KErrNone) MathException(ret); return((TReal64)res); }
GLDEF_C TReal64 __divdf3(TReal64 a1,TReal64 a2) // // Divide two doubles // { TRealX x1=a1; TRealX x2=a2; TRealX res; TReal64 trg; TInt ret=x1.Div(res,x2); if (ret==KErrNone) ret=res.GetTReal(trg); if (ret!=KErrNone) MathException(ret); return((TReal64)res); }
EXPORT_C TReal32 __mulsf3(TReal32 a1,TReal32 a2) // // Multiply two floats // { TRealX x1=a1; TRealX x2=a2; TRealX res; TReal32 trg; TInt ret=x1.Mult(res,x2); if (ret==KErrNone) // must check this because if underflow, error is lost in conversion ret=res.GetTReal(trg); if (ret!=KErrNone) MathException(ret); return((TReal32)res); }
//------------------------------------------------------------------------------ // void GetOutputInfo(Integer &type, Integer &rowCount, Integer &colCount) //------------------------------------------------------------------------------ void Power::GetOutputInfo(Integer &type, Integer &rowCount, Integer &colCount) { GetScalarOutputInfo(type, rowCount, colCount); #if 0 Integer type1, row1, col1; // Left node Integer type2, row2, col2; // Right node bool retval = false; // Get the type(Real or Matrix), # rows and # columns of the left node leftNode->GetOutputInfo(type1, row1, col1); // Get the type(Real or Matrix), # rows and # columns of the right node rightNode->GetOutputInfo(type2, row2, col2); if (type1 == Gmat::REAL_TYPE) { if (type2 == Gmat::REAL_TYPE || type2 == Gmat::RMATRIX_TYPE && row2 == 1 && col2 == 1) { type = type1; rowCount = row1; colCount = col1; retval = true; } } else if (type1 == Gmat::RMATRIX_TYPE && row1 == 1 && col1 == 1) { if (type2 == Gmat::REAL_TYPE || (type2 == Gmat::RMATRIX_TYPE && row2 == 1 && col2 == 1)) { type = type1; rowCount = row1; colCount = col1; retval = true; } } if (!retval) throw MathException("Input is not a scalar or 1x1 matrix, so can not do Power()"); #endif }
//------------------------------------------------------------------------------ // void GetOutputInfo(Integer &type, Integer &rowCount, Integer &colCount) //------------------------------------------------------------------------------ void Cos::GetOutputInfo(Integer &type, Integer &rowCount, Integer &colCount) { //loj: only left side is available Integer type1, row1, col1; // Left node // Integer type2, row2, col2; // Right node // Get the type(Real or Matrix), # rows and # columns of the left node leftNode->GetOutputInfo(type1, row1, col1); // // Get the type(Real or Matrix), # rows and # columns of the right node // rightNode->GetOutputInfo(type2, row2, col2); //if ((type1 != type2) || (row1 != row2) || (col1 != col2)) if (type1 != Gmat::REAL_TYPE) throw MathException(wxT("Left is not scalar, so cannot do Cos().\n")); else { type = type1; rowCount = row1; colCount = col1; } }
//------------------------------------------------------------------------------ // Real Evaluate() //------------------------------------------------------------------------------ Real MathFunction::Evaluate() { throw MathException(GetTypeName() + " cannot return Real"); }
//------------------------------------------------------------------------------ // Rmatrix MatrixEvaluate() //------------------------------------------------------------------------------ Rmatrix MathFunction::MatrixEvaluate() { throw MathException(GetTypeName() + " cannot return Matrix"); }
//------------------------------------------------------------------------------ void MathElement::SetWrapperObject(GmatBase *obj, const std::string &name) { #ifdef DEBUG_WRAPPERS MessageInterface::ShowMessage ("MathElement::SetWrapperObject() obj=<%p>, name='%s'\n", obj, name.c_str()); #endif refObject = (Parameter*) obj; refObjectType = refObject->GetTypeName().c_str(); // go through wrapperObjectNames for (UnsignedInt i=0; i<wrapperObjectNames.size(); i++) { if (name == wrapperObjectNames[i]) { #ifdef DEBUG_WRAPPERS MessageInterface::ShowMessage (" wrapperName = '%s'\n", wrapperObjectNames[i].c_str()); #endif // Handle array index Integer row, col; std::string newName; GmatStringUtil::GetArrayIndex(wrapperObjectNames[i], row, col, newName); // Check if name is the same if (newName != name) throw MathException ("MathElement::SetRefObject() Cannot find parameter name:" + name); if (refObjectType == "Array") { Array *arr = (Array*)refObject; elementType = Gmat::RMATRIX_TYPE; Integer theRowCount = arr->GetRowCount(); Integer theColCount = arr->GetColCount(); #ifdef DEBUG_WRAPPERS MessageInterface::ShowMessage ("MathElement::SetRefObject() elementType=%d, theRowCount=%d, " "theColCount=%d\n", elementType, theRowCount, theColCount); #endif if (!matrix.IsSized()) matrix.SetSize(theRowCount, theColCount); else { #ifdef DEBUG_WRAPPERS MessageInterface::ShowMessage ("MathElement::SetRefObject() matrix already sized. " "matrix.size=%d, %d\n", matrix.GetNumRows(), matrix.GetNumColumns()); #endif } matrix = arr->GetRmatrix(); // initial value #ifdef DEBUG_WRAPPERS MessageInterface::ShowMessage ("MathElement::SetRefObject() name=%s, matrix=\n%s\n", name.c_str(), matrix.ToString().c_str()); #endif } else if (refObject->GetReturnType() == Gmat::REAL_TYPE) { elementType = Gmat::REAL_TYPE; realValue = refObject->GetReal(); // initial value #ifdef DEBUG_WRAPPERS MessageInterface::ShowMessage ("MathElement::SetRefObject() name=%s, elementType=%d, " "realValue=%f\n", GetName().c_str(), elementType, realValue); #endif } } } }
//------------------------------------------------------------------------------ // bool SetChildren(MathNode *leftChild, MathNode *rightChild) //------------------------------------------------------------------------------ bool MathElement::SetChildren(MathNode *leftChild, MathNode *rightChild) { throw MathException("SetChildren() is not valid for MathElement"); }
//------------------------------------------------------------------------------ // void GetOutputInfo() //------------------------------------------------------------------------------ void MathElement::GetOutputInfo(Integer &type, Integer &rowCount, Integer &colCount) { #ifdef DEBUG_INPUT_OUTPUT MessageInterface::ShowMessage ("MathElement::GetOutputInfo() this=<%p><%s><%s>\n", this, GetTypeName().c_str(), GetName().c_str()); #endif type = elementType; rowCount = 1; colCount = 1; #ifdef DEBUG_INPUT_OUTPUT MessageInterface::ShowMessage ("MathElement::GetOutputInfo() isNumber=%d, isFunctionInput=%d, refObjectName=%s\n", isNumber, isFunctionInput, refObjectName.c_str()); #endif // if this this function input, just return if (isFunctionInput) return; if (refObjectName == "") { if (type == Gmat::RMATRIX_TYPE) { rowCount = matrix.GetNumRows(); colCount = matrix.GetNumColumns(); } } else { #ifdef DEBUG_INPUT_OUTPUT MessageInterface::ShowMessage ("MathElement::GetOutputInfo() %s is a parameter or an object, " "refObject=<%p><%s>'%s'\n", GetName().c_str(), refObject, refObject ? refObject->GetTypeName().c_str() : "NULL", refObject ? refObject->GetName().c_str() : "NULL"); #endif if (refObject) { // Check if ref object is Parameter object if (!refObject->IsOfType(Gmat::PARAMETER)) throw MathException("The math element \"" + GetName() + "\" of type \"" + refObject->GetTypeName() + "\" is invalid"); type = refObject->GetReturnType(); #ifdef DEBUG_INPUT_OUTPUT MessageInterface::ShowMessage(" object return type = %d\n", type); #endif if (type == Gmat::RMATRIX_TYPE) { // Handle array index std::string newName, rowStr, colStr; GmatStringUtil::GetArrayIndexVar(refObjectName, rowStr, colStr, newName, "()"); #ifdef DEBUG_INPUT_OUTPUT MessageInterface::ShowMessage (" rowStr='%s', colStr='%s', newName=%s\n", rowStr.c_str(), colStr.c_str(), newName.c_str()); #endif // Are we going to allow row/column slicing for future? such as: // a(:,1) -> first column vector // a(1,:) -> first row vector // a(1:2,1) -> first and second row, fisrt column vector bool wholeArray = false; if (rowStr == "-1" && colStr == "-1") wholeArray = true; // if whole array, row and colum count is actual dimension if (wholeArray) { rowCount = ((Array*)refObject)->GetRowCount(); colCount = ((Array*)refObject)->GetColCount(); } else { type = Gmat::REAL_TYPE; rowCount = 1; colCount = 1; } } #ifdef DEBUG_INPUT_OUTPUT MessageInterface::ShowMessage ("MathElement::GetOutputInfo() type=%d, row=%d, col=%d\n", type, rowCount, colCount); #endif } else { throw MathException("The output parameter: " + GetName() + " is NULL"); } } }
//------------------------------------------------------------------------------ // void GetOutputInfo(Integer &type, Integer &rowCount, Integer &colCount) //------------------------------------------------------------------------------ void Divide::GetOutputInfo(Integer &type, Integer &rowCount, Integer &colCount) { #if DEBUG_INPUT_OUTPUT MessageInterface::ShowMessage ("Divide::GetOutputInfo() entered, this=<%p><%s><%s>\n", this, GetTypeName().c_str(), GetName().c_str()); #endif Integer type1, row1, col1; // Left node Integer type2, row2, col2; // Right node // Get the type(Real or Matrix), # rows and # columns of the left node if (leftNode) leftNode->GetOutputInfo(type1, row1, col1); else throw MathException("Left node is NULL in " + GetTypeName() + "::GetOutputInfo()\n"); // Get the type(Real or Matrix), # rows and # columns of the right node if (rightNode) rightNode->GetOutputInfo(type2, row2, col2); else throw MathException("Right node is NULL in " + GetTypeName() + "::GetOutputInfo()\n"); #if DEBUG_INPUT_OUTPUT MessageInterface::ShowMessage ("Divide::GetOutputInfo() type1=%d, row1=%d, col1=%d, type2=%d, " "row2=%d, col2=%d\n", type1, row1, col1, type2, row2, col2); #endif type = type1; rowCount = row1; colCount = col1; if ((type1 == Gmat::RMATRIX_TYPE) && (type2 == Gmat::RMATRIX_TYPE)) { // Check for 1x1 if (row1 == 1 && col1 == 1) { type = type2; rowCount = row2; colCount = col2; } else if (row2 == 1 && col2 == 1) { type = type1; rowCount = row1; colCount = col1; } } else if (type2 == Gmat::RMATRIX_TYPE) { type = type2; rowCount = row2; colCount = col2; } #if DEBUG_INPUT_OUTPUT MessageInterface::ShowMessage ("Divide::GetOutputInfo() leaving, type=%d, rowCount=%d, colCount=%d\n", type, rowCount, colCount); #endif }