Esempio n. 1
0
void  CAMmatrixBase::plot(const CAMmatrixBase& Ordinates) const
{
//
//  Need Conversion Check
//
	long dimension;
	long M,N;

	CAMmatrixBase A;
	const CAMmatrixBase* InputPtr;
	double* AdataPtr; double* BdataPtr;

	long j; int autoFlag;
	double x_min, x_max, y_min, y_max;

	CAMmatrixBase O;
    double* OdataPtr;
	long    Odimension;
	long    Ocount;
//
	if(Structure.isSubset() == 1)
	{
	A.initializeMinDuplicate(*this);
	dimension   = A.getDimension();
	AdataPtr    = (double*)A.getDataPointer();
	if(dimension >= 1) M = A[1].getIndexCount();
	if(dimension == 2) N = A[2].getIndexCount();
	InputPtr = &A;
	}
	else
	{
	dimension = getDimension();
	AdataPtr  = (double*)getDataPointer();
	if(dimension >= 1) M = Structure[1].getIndexCount();
	if(dimension == 2) N = Structure[2].getIndexCount();
	InputPtr = this;
	}

	if(Ordinates.Structure.isSubset() == 1)
	{
	O.initializeMinDuplicate(Ordinates);
	Odimension  = O.getDimension();
	OdataPtr    = (double*)O.getDataPointer();
	Ocount      = O[1].getIndexCount();
	}
	else
	{
	Odimension  = Ordinates.getDimension();
	OdataPtr    = (double*)Ordinates.getDataPointer();
	Ocount      = Ordinates[1].getIndexCount();
	}

	if(Odimension != 1)
	{CAMmatrixBase::ordinateError(Ordinates.Structure);}

	if(M != Ocount)
	{CAMmatrixBase::ordinateError(Ordinates.Structure);}

	switch (dimension)
	{
	case 1  :
	CAMgraphics::plot(OdataPtr,AdataPtr,M);

	break;

	case 2  :

	autoFlag = CAMgraphics::getAutoScaleFlag();
	x_min = *OdataPtr;
	x_max = *(OdataPtr +(M-1));
	y_min = InputPtr->min();
	y_max = InputPtr->max();
	CAMgraphics::axis(x_min,x_max,y_min,y_max);
	for(j = 1; j <= N; j++)
	{
	BdataPtr = AdataPtr + (j-1)*M;
	CAMgraphics::plot(OdataPtr, BdataPtr,M);
	}
	CAMgraphics::axis(autoFlag);

	break;
	default :
	CAMmatrixBase::plotDimensionError(A.Structure);
	}

}
Esempio n. 2
0
void MdamPoint::printBrief() const
{
  char * dataPointer = getDataPointer();
  Lng32 keyLen = tupp_.getAllocatedSize();

  // We don't know what the data type is, but we do know how
  // long the field is. So we will guess the data type.

  // The Generator transforms varchars to chars, so we don't
  // have to worry about varchar length fields.

  // We might have a null indicator, but we have no way of knowing
  // that here. So we will ignore that possibility. (Sorry!)

  // If the length is 2 or 4 or 8, we'll guess that it is an
  // integer and print a signed integer interpretation.

  // If the length is 7 and the first two bytes, when interpreted
  // as Big Endian, looks like a year within 100 years of 2000,
  // we'll interpret it as a TIMESTAMP(0).

  // There are other possibilities of course which can be added
  // over time but a better solution would be to change the 
  // Generator and Executor to simply give us the data type info.

  char local[1001];  // will assume our length is <= 1000
  local[0] = '\0';

  if (dataPointer)
    {
    bool allNulls = true;
    bool allFFs = true;
    bool allPrintable = true;
    size_t i = 0;
    while (i < keyLen && (allNulls || allFFs))
      {
      if (dataPointer[i] != '\0') allNulls = false;
      if (dataPointer[i] != -1) allFFs = false;
      if (!isprint(dataPointer[i])) allPrintable = false;
      i++;
      }
    if (allNulls)
      {
      strcpy(local,"*lo*");  // hopefully there won't be a legitimate value of *lo*
      }
    else if (allFFs)
      {
      strcpy(local,"*hi*");  // hopefully there won't be a legitimate value of *hi*
      }
    else if (allPrintable)
      {
      size_t lengthToMove = sizeof(local) - 1;
      if (keyLen < lengthToMove)
        lengthToMove = keyLen;
      strncpy(local,dataPointer,lengthToMove);
      local[lengthToMove] = '\0';
      }
    else  
      {
      // create a hex representation of the first 498 characters
      strcpy(local,"hex ");
      char * nextTarget = local + strlen(local);
      size_t repdChars = ((sizeof(local) - 1)/2) - 4; // -4 to allow for "hex "
      if (keyLen < repdChars)
        repdChars = keyLen;

      for (size_t i = 0; i < repdChars; i++)
        {
        unsigned char nibbles[2];
        nibbles[0] = ((unsigned char)dataPointer[i] & 
                      (unsigned char)0xf0)/16;
        nibbles[1] = (unsigned char)dataPointer[i] & (unsigned char)0x0f;
        for (size_t j = 0; j < 2; j++)
          {
          if (nibbles[j] < 10)
            *nextTarget = '0' + nibbles[j];
          else
            *nextTarget = 'a' + (nibbles[j] - 10);
          nextTarget++;
          }  // for j
        }  // for i

      *nextTarget = '\0';         
      }

    if (keyLen == 2)  // if it might be a short
      {
      // append an interpretation as a short (note that there
      // is room in local for this purpose)

      // the value is big-endian hence the weird computation
      long value = 256 * dataPointer[0] + 
                   (unsigned char)dataPointer[1];                  
      sprintf(local + strlen(local), " (short %ld)",value);
      }
    else if (keyLen == 4)  // if it might be a long
      {
      // append an interpretation as a long (note that there
      // is room in local for this purpose)

      // the value is big-endian hence the weird computation
      long value = 256 * 256 * 256 * dataPointer[0] + 
                   256 * 256 * (unsigned char)dataPointer[1] +  
                   256 * (unsigned char)dataPointer[2] + 
                   (unsigned char)dataPointer[3];           
      sprintf(local + strlen(local), " (long %ld)",value);
      }
    else if (keyLen == 8)  // if it might be a 64-bit integer
      {
      // append an interpretation as a short (note that there
      // is room in local for this purpose)

      // the value is big-endian hence the weird computation
      long long value = 256 * 256 * 256 * dataPointer[0] + 
                   256 * 256 * (unsigned char)dataPointer[1] +  
                   256 * (unsigned char)dataPointer[2] + 
                   (unsigned char)dataPointer[3]; 
      value = (long long)256 * 256 * 256 * 256 * value +   
                   256 * 256 * 256 * (unsigned char)dataPointer[4] + 
                   256 * 256 * (unsigned char)dataPointer[5] +  
                   256 * (unsigned char)dataPointer[6] + 
                   (unsigned char)dataPointer[7];        
      sprintf(local + strlen(local), " (long long %lld)",value);
      }
    else if (keyLen == 7)  // a TIMESTAMP(0) perhaps?
      {
      long year = 256 * dataPointer[0] +
                          (unsigned char)dataPointer[1];
      if ((year >= 1900) && (year <= 2100))
        {
        // looks like a TIMESTAMP(0); look further
        long month = (unsigned char)dataPointer[2];
        long day = (unsigned char)dataPointer[3];
        long hour = (unsigned char)dataPointer[4];
        long minute = (unsigned char)dataPointer[5];
        long second = (unsigned char)dataPointer[6];

        if ((month >= 1) && (month <= 12) &&
            (day >= 1) && (day <= 31) &&
            (hour >= 0) && (hour <= 23) &&
            (minute >= 0) && (minute <= 59) &&
            (second >= 0) && (second <= 59))
          {
          sprintf(local + strlen(local), 
                  " (TIMESTAMP(0) %ld-%02ld-%02ld %02ld:%02ld:%02ld)",
                  year,month,day,hour,minute,second);
          }
        }
      }
    }    
  cout << local;
  // cout << *(Lng32 *)dataPointer;
  // End test change
}
Esempio n. 3
0
 void setQuaternion(Item* target, const Quaternion& newValue)
 {
   Quaternion* data = static_cast<Quaternion*>(getDataPointer(target));
   *data = newValue;
 }
	//--------------------------------------------------------------------------------------------
	ParamData& ParamContainer::getData(long _id)
	{
		ParamData* data = getDataPointer(_id);
		GOTHOGRE_ASSERT(data != nullptr, "ParamContainer: Not found data by ID = " << _id);
		return *data;
	}