@@ -1026,7 +1026,7 @@ def geometric_product_basis_blades(self, blade12):
10261026 base1 = self .blade_to_base_rep (blade1 )
10271027 base2 = self .blade_to_base_rep (blade2 )
10281028 base12 = expand (base1 * base2 )
1029- base12 = nc_subs (base12 , self .basic_mul_keys , self . basic_mul_values )
1029+ base12 = nc_subs (base12 , self .basic_mul_table_dict . items () )
10301030 return self .base_to_blade_rep (base12 )
10311031
10321032 def reduce_basis (self , blst ):
@@ -1290,21 +1290,38 @@ def non_orthogonal_dot_product_basis_blades(self, blade12, mode): # blade12 = (
12901290 ############# Non-Orthogonal Tables and Dictionaries ###############
12911291
12921292 def _build_non_orthogonal_mul_table (self ):
1293- mul_table = []
1294- self .basic_mul_keys = []
1295- self .basic_mul_values = []
1296- for base1 in self .bases .flat :
1297- for base2 in self .bases .flat :
1298- key = base1 * base2
1299- value = self .non_orthogonal_bases_products ((base1 , base2 ))
1300- mul_table .append ((key , value ))
1301- self .basic_mul_keys .append (key )
1302- self .basic_mul_values .append (value )
1303- self .basic_mul_table = mul_table
1304- self .basic_mul_table_dict = OrderedDict (mul_table )
1293+ self .basic_mul_table_dict = OrderedDict (
1294+ (base1 * base2 , self .non_orthogonal_bases_products ((base1 , base2 )))
1295+ for base1 in self .bases .flat
1296+ for base2 in self .bases .flat
1297+ )
13051298
13061299 if self .debug :
1307- print ('basic_mul_table =\n ' , self .basic_mul_table )
1300+ print ('basic_mul_table =\n ' , self .basic_mul_table_dict )
1301+
1302+ @property
1303+ def basic_mul_table (self ):
1304+ # galgebra 0.5.0
1305+ warnings .warn (
1306+ "`ga.basic_mul_table` is deprecated, use `ga.basic_mul_table_dict.items()`" ,
1307+ DeprecationWarning , stacklevel = 2 )
1308+ return list (self .basic_mul_table_dict .items ())
1309+
1310+ @property
1311+ def basic_mul_keys (self ):
1312+ # galgebra 0.5.0
1313+ warnings .warn (
1314+ "`ga.basic_mul_keys` is deprecated, use `ga.basic_mul_table_dict.keys()`" ,
1315+ DeprecationWarning , stacklevel = 2 )
1316+ return list (self .basic_mul_table_dict .keys ())
1317+
1318+ @property
1319+ def basic_mul_values (self ):
1320+ # galgebra 0.5.0
1321+ warnings .warn (
1322+ "`ga.basic_mul_values` is deprecated, use `ga.basic_mul_table_dict.values()`" ,
1323+ DeprecationWarning , stacklevel = 2 )
1324+ return list (self .basic_mul_table_dict .values ())
13081325
13091326 def non_orthogonal_bases_products (self , base12 ): # base12 = (base1, base2)
13101327 # geometric product of bases for non-orthogonal basis vectors
@@ -1320,75 +1337,86 @@ def non_orthogonal_bases_products(self, base12): # base12 = (base1, base2)
13201337
13211338 def _build_base_blade_conversions (self ):
13221339
1323- blade_expansion = []
1324- blade_index = []
1340+ blade_expansion_dict = OrderedDict ()
13251341
13261342 # expand blade basis in terms of base basis
1327- for blade in self .blades .flat :
1328- index = self .indexes_to_blades_dict .inverse [blade ]
1343+ for blade , index in zip (self .blades .flat , self .indexes .flat ):
13291344 grade = len (index )
13301345 if grade <= 1 :
1331- blade_expansion .append (blade )
1332- blade_index .append (index )
1346+ blade_expansion_dict [blade ] = blade
13331347 else :
1334- a = self .indexes_to_blades_dict [(index [0 ],)]
1335- Aexpand = blade_expansion [blade_index .index (index [1 :])]
1348+ a = self .indexes_to_blades_dict [index [:1 ]]
1349+ A = self .indexes_to_blades_dict [index [1 :]]
1350+ Aexpand = blade_expansion_dict [A ]
13361351 # Formula for outer (^) product of a vector and grade-r multivector
13371352 # a^A_{r} = (a*A + (-1)^{r}*A*a)/2
13381353 # The folowing evaluation takes the most time for setup it is the due to
13391354 # the substitution required for the multiplications
13401355 a_W_A = half * (self .basic_mul (a , Aexpand ) - ((- 1 ) ** grade ) * self .basic_mul (Aexpand , a ))
1341- blade_index .append (index )
1342- blade_expansion .append (expand (a_W_A ))
1356+ blade_expansion_dict [blade ] = expand (a_W_A )
13431357
1344- self .blade_expansion = blade_expansion
1345- self .blade_expansion_dict = OrderedDict (list (zip (self .blades .flat , blade_expansion )))
1358+ self .blade_expansion_dict = blade_expansion_dict
13461359
13471360 if self .debug :
13481361 print ('blade_expansion_dict =' , self .blade_expansion_dict )
13491362
13501363 # expand base basis in terms of blade basis
13511364
1352- base_expand = []
1365+ base_expansion_dict = OrderedDict ()
13531366
13541367 for base , blade , index in zip (self .bases .flat , self .blades .flat , self .indexes .flat ):
13551368 grade = len (index )
13561369 if grade <= 1 :
1357- base_expand . append (( base , base ))
1370+ base_expansion_dict [ base ] = base
13581371 else : # back substitution of tridiagonal system
13591372 tmp = self .blade_expansion_dict [blade ]
13601373 tmp = tmp .subs (base , - blade )
1361- tmp = - tmp .subs (base_expand )
1362- base_expand . append (( base , expand (tmp )) )
1374+ tmp = - tmp .subs (base_expansion_dict )
1375+ base_expansion_dict [ base ] = expand (tmp )
13631376
1364- self .base_expand = base_expand
1365- self .base_expansion_dict = OrderedDict (base_expand )
1377+ self .base_expansion_dict = base_expansion_dict
13661378
13671379 if self .debug :
13681380 print ('base_expansion_dict =' , self .base_expansion_dict )
13691381
1382+ @property
1383+ def base_expansion (self ):
1384+ # galgebra 0.5.0
1385+ warnings .warn (
1386+ "`ga.base_expansion` is deprecated, use `ga.base_expansion_dict.items()`" ,
1387+ DeprecationWarning , stacklevel = 2 )
1388+ return list (self .base_expansion_dict .items ())
1389+
1390+ @property
1391+ def blade_expansion (self ):
1392+ # galgebra 0.5.0
1393+ warnings .warn (
1394+ "`ga.blade_expansion` is deprecated, use `ga.blade_expansion_dict.items()`" ,
1395+ DeprecationWarning , stacklevel = 2 )
1396+ return list (self .blade_expansion_dict .items ())
1397+
13701398 def base_to_blade_rep (self , A ):
13711399
13721400 if self .is_ortho :
13731401 return A
13741402 else :
13751403 # return expand(A).subs(self.base_expansion_dict)
1376- return nc_subs (expand (A ), self .base_expand )
1404+ return nc_subs (expand (A ), self .base_expansion_dict . items () )
13771405
13781406 def blade_to_base_rep (self , A ):
13791407
13801408 if self .is_ortho :
13811409 return A
13821410 else :
13831411 # return expand(A).subs(self.blade_expansion_dict)
1384- return nc_subs (expand (A ), self .blades . flat , self . blade_expansion )
1412+ return nc_subs (expand (A ), self .blade_expansion_dict . items () )
13851413
13861414 ###### Products (*,^,|,<,>) for multivector representations ########
13871415
13881416 def basic_mul (self , A , B ): # geometric product (*) of base representations
13891417 # only multiplicative operation to assume A and B are in base representation
13901418 AxB = expand (A * B )
1391- AxB = nc_subs (AxB , self .basic_mul_keys , self . basic_mul_values )
1419+ AxB = nc_subs (AxB , self .basic_mul_table_dict . items () )
13921420 return expand (AxB )
13931421
13941422 def Mul (self , A , B , mode = '*' ): # Unifies all products into one function
0 commit comments