[cig-commits] r6076 - in long/3D/Gale/trunk/src/StGermain: . Base/Automation/src

walter at geodynamics.org walter at geodynamics.org
Fri Feb 23 10:00:57 PST 2007


Author: walter
Date: 2007-02-23 10:00:56 -0800 (Fri, 23 Feb 2007)
New Revision: 6076

Modified:
   long/3D/Gale/trunk/src/StGermain/
   long/3D/Gale/trunk/src/StGermain/Base/Automation/src/VariableCondition.c
   long/3D/Gale/trunk/src/StGermain/Base/Automation/src/VariableCondition.h
Log:
 r3327 at earth (orig r3990):  LukeHodkinson | 2007-02-01 16:06:27 -0800
 When running problems with millions of elements the
 'apply to index' routine of the VariableCondition class
 was behaving with an order N^3 time. Added a mapping
 to reduce to near linear.
 



Property changes on: long/3D/Gale/trunk/src/StGermain
___________________________________________________________________
Name: svk:merge
   - 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:3196
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/branches/decomp3d/StGermain:3987
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3899
   + 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:3196
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/branches/decomp3d/StGermain:3990
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3899

Modified: long/3D/Gale/trunk/src/StGermain/Base/Automation/src/VariableCondition.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/Automation/src/VariableCondition.c	2007-02-23 18:00:54 UTC (rev 6075)
+++ long/3D/Gale/trunk/src/StGermain/Base/Automation/src/VariableCondition.c	2007-02-23 18:00:56 UTC (rev 6076)
@@ -126,6 +126,7 @@
 	self->vcTbl = NULL;
 	self->valueCount = 0;
 	self->valueTbl = NULL;
+	self->mapping = NULL;
 }
 
 
@@ -395,6 +396,11 @@
 	self->valueTbl = Memory_Alloc_Array( VariableCondition_Value, self->valueCount, "VC->valueTbl" );
 	for (val_I = 0; val_I < self->valueCount; val_I++)
 		self->valueTbl[val_I] = self->_getValue(self, val_I);
+
+	/* Build mapping. */
+	self->mapping = UIntMap_New();
+	for( i = 0; i < self->indexCount; i++ )
+		UIntMap_Insert( self->mapping, self->indexTbl[i], i );
 }
 
 void _VariableCondition_Initialise( void* variableCondition, void* data ) {
@@ -454,13 +460,9 @@
 	ConditionFunction*		cf;
 	Index				index, i;
 	Stream*				errorStr = Journal_Register( Error_Type, self->type );
-	
+
 	/* Ensure that the index provided (localIndex) has a condition attached to it */
-	for (index = 0; index < self->indexCount; index++)
-		if (self->indexTbl[index] == localIndex)
-			break;
-	if (index == self->indexCount)
-		return;
+	insist( UIntMap_Map( self->mapping, localIndex, &index ) );
 	
 	/* For each variable that has a condition at this index */
 	for (i = 0; i < self->vcVarCountTbl[index]; i++)

Modified: long/3D/Gale/trunk/src/StGermain/Base/Automation/src/VariableCondition.h
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/Automation/src/VariableCondition.h	2007-02-23 18:00:54 UTC (rev 6075)
+++ long/3D/Gale/trunk/src/StGermain/Base/Automation/src/VariableCondition.h	2007-02-23 18:00:56 UTC (rev 6076)
@@ -123,6 +123,8 @@
 		/** Array of values which are available to apply (which index/var pairs they apply to is determined
 		by VariableCondition::vcTbl). */ \
 		VariableCondition_Value*			valueTbl; \
+									\
+		UIntMap*		mapping;
 	
 	/** Abstract class for specifying (1 or more) conditions that apply to (1 or more) variables in an array - 
 	see VariableCondition.h for details */



More information about the cig-commits mailing list