|
From: Mark R. D. <mdi...@la...> - 2003-05-23 16:39:33
|
I don't have cvs access for your project, can you add me? my sourceforge
username is mdiggory.
-Mark
Nick Collier wrote:
>Yes. I think this is good. Do you have CVS access? If so, go ahead and
>commit this.
>
>Nick
>
>On Fri, 2003-05-23 at 12:08, Mark R. Diggory wrote:
>
>
>>Is it really neccessary to reallocate memory everytime you use
>>DoubleArray.copyTo? This seems to be expensive to me, especially in the
>>case of Diffuse2D.
>>
>>
>> /**
>> * Copies the double[] in this DoubleMatrix to the specified DoubleMatrix.
>> */
>> public void copyMatrixTo(DoubleMatrix dm) {
>> double[] aMatrix = new double[sizeY * sizeX];
>> System.arraycopy(matrix, 0, aMatrix, 0, sizeY * sizeX);
>> dm.matrix = aMatrix;
>> }
>>
>>I think the above method could easily be written as:
>>
>> public void copyMatrixTo(DoubleMatrix dm) {
>> System.arraycopy(matrix, 0, dm.matrix , 0, sizeY * sizeX);
>> }
>>
>>without having to build a new double array. I understand that the matri
>>could be different sizes so:
>>
>> /**
>> * Copies the double[] in this DoubleMatrix to the specified DoubleMatrix.
>> */
>> public void copyMatrixTo(DoubleMatrix dm) {
>> if(matix.length != dm.matrix.length){
>> double[] aMatrix = new double[sizeY * sizeX];
>> System.arraycopy(matrix, 0, aMatrix, 0, sizeY * sizeX);
>> dm.matrix = aMatrix;
>> }else{
>> System.arraycopy(matrix, 0, dm.matrix , 0, sizeY * sizeX);
>> }
>>}
>>
>>captures that case while still providing efficient copying of
>>DoubleArrays of equal sizes by reusing allocated memory.
>>
>>what do you think?
>>Mark
>>
>>
>>
>>-------------------------------------------------------
>>This SF.net email is sponsored by: ObjectStore.
>>If flattening out C++ or Java code to make your application fit in a
>>relational database is painful, don't do it! Check out ObjectStore.
>>Now part of Progress Software. http://www.objectstore.net/sourceforge
>>_______________________________________________
>>Repast-developer mailing list
>>Rep...@li...
>>https://lists.sourceforge.net/lists/listinfo/repast-developer
>>
>>
|