コード例 #1
0
ファイル: MathElement.cpp プロジェクト: rockstorm101/GMAT
//------------------------------------------------------------------------------
// 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");
   }
}