swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Swarm-Support] Lisp serialization for multidimensional arrays


From: Patricia Randall
Subject: [Swarm-Support] Lisp serialization for multidimensional arrays
Date: Mon, 28 Aug 2006 14:39:57 -0400

Hi! I started working on a Swarm simulation about a month ago at work and I have found the archives very helpful for most of my problems. However, I cannot find an example for lisp serialization for a malloced c multidimensional array. The example in the Defobj documentation for a one-dimensional array works fine, but I can't figure out how to extend it more than one dimension.  I have tried the following code where TestArray is a multidimensional array that has been malloced. It has NumRows rows and NumCols columns.

- (void)lispOutDeep: stream
{
  int i;
  unsigned int *ColArray;

  ColArray = (unsigned int *)malloc(NumRows*sizeof (unsigned int));
  for (i=0; i<NumRows; i++)
    {
      ColArray[i] = NumCols;
    }

  [stream catStartMakeInstance: "TestSwarm"];  
  [super lispStoreIntegerArray: TestArray Keyword: "TestArray" 
      Rank: NumRows Dims: ColArray Stream: stream];
  [stream catEndMakeInstance];
}

But the file has more data than it should; i.e. if I have 4 rows and 2 columns, than I have 8 vectors each with 2 elements while I think I should only have 4 vectors each with 2 elements. Thank you in advance for any help or insight you can offer.

Patricia Randall
Operations Research Analyst
RCI


reply via email to

[Prev in Thread] Current Thread [Next in Thread]